Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3975269ybz; Mon, 20 Apr 2020 13:02:59 -0700 (PDT) X-Google-Smtp-Source: APiQypK5UFtYYr5UoX8W2ISoi5l/v2K5lMrNXOjqa9yOQ7l0JlBAlpFhk5r7QXr2welH3HqOEO7z X-Received: by 2002:a17:906:bb07:: with SMTP id jz7mr7877372ejb.317.1587412979696; Mon, 20 Apr 2020 13:02:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587412979; cv=none; d=google.com; s=arc-20160816; b=U6fVzr3C353QdgDVMHsVy3Z057zgluP+UbolJ7vfRuT24XNEioToQwHk9Xg6947wLv 0FQUk0Q0tTkCw/8G7aGGgMLZVx22QEhseuvNUHti15KPtuRi9DX07HSCFun5o/LuIXZE Am7nD5qAOlyniQOcW/UUZfeiqiMqoggraMAoTXO/HzNDwwkS+JfLtYyZMAA04h4+4wAx nTQmca/0ngSWpQDOD7Urfhu+V77p0nh1yqHjHI6PaQylI0Q6FfxzP/vW1iSSdf7vBNi8 YY3oBlSKRGcJblNmCUnC1OR0dIw0GsKL+ws7yf7cE4JeMPTv1u/mdDPV1gjpNegyWHse J0pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature; bh=39ikxJL/ikRE9a7l20noBIeqccFXOBkwxddlrq7TrQw=; b=AHxIuLY7VPN2VfsgjOjaAQGLA8zDumYP5wlkrfgth7rWEU66VV7VDgp/PV9CXQWh0J aNQHUg8Ph5lI3jArM+Irn9Ll7HDA1VUlLlpt9MKRdDQcOr65np5A6/Sal6zHeDvedq97 dxAtKY/OI8rFlT8KmL5Oxdgm538edKuwS8e5BI7cI9d7BB0+7Kb1ZeUbhjJ26VLjzmkd VuCt4utOuSB4swyde0u65Yr+bgm5pwZhg/XU8k6ZJHKYaBu7rUw0qnb/0CvuEXRUgjvx GuNM93hFKwuy3vevai+cNQmAliOmmtIbPQqy3bJN59+DNPWs2KxXpmsFAM/sdN1YCxnC HVYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bmi31Yk+; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u21si144914ejz.518.2020.04.20.13.02.27; Mon, 20 Apr 2020 13:02:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bmi31Yk+; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726099AbgDTUC0 (ORCPT + 99 others); Mon, 20 Apr 2020 16:02:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:55699 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725918AbgDTUC0 (ORCPT ); Mon, 20 Apr 2020 16:02:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587412945; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=39ikxJL/ikRE9a7l20noBIeqccFXOBkwxddlrq7TrQw=; b=Bmi31Yk+KY2GaC2JdgjB3G2Dr1Ib9CksWxkcIpsy5iijhIJG3gjEXYSDRYVUTxgIUNVZWI YumIakIikWo9zKHLhNmmZHUG+Vyk1advHJIVJ0B9OkiqsbSFLIOtwL1fb1GO8zEzUEL2SS gFUJgPPK2Ez4TE/5m6mxFnTL+J5SfX8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-ubeMa61nOAOymAQYbdhdgQ-1; Mon, 20 Apr 2020 16:02:22 -0400 X-MC-Unique: ubeMa61nOAOymAQYbdhdgQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EEE291005510; Mon, 20 Apr 2020 20:02:21 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CEF5910013A1; Mon, 20 Apr 2020 20:02:21 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 03KK2L8G022268; Mon, 20 Apr 2020 16:02:21 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 03KK2Lrl022264; Mon, 20 Apr 2020 16:02:21 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Mon, 20 Apr 2020 16:02:21 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Jan Kara cc: linux-ext4@vger.kernel.org Subject: [PATCH] ext2: fix missing percpu_counter_inc Message-ID: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org sbi->s_freeinodes_counter is only decreased by the ext2 code, it is never increased. This patch fixes it. Note that sbi->s_freeinodes_counter is only used in the algorithm that tries to find the group for new allocations, so this bug is not easily visible (the only visibility is that the group finding algorithm selects inoptinal result). Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org --- fs/ext2/ialloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Index: linux-2.6/fs/ext2/ialloc.c =================================================================== --- linux-2.6.orig/fs/ext2/ialloc.c 2019-09-20 14:39:07.951999000 +0200 +++ linux-2.6/fs/ext2/ialloc.c 2020-04-20 21:33:26.389999000 +0200 @@ -80,6 +80,7 @@ static void ext2_release_inode(struct su if (dir) le16_add_cpu(&desc->bg_used_dirs_count, -1); spin_unlock(sb_bgl_lock(EXT2_SB(sb), group)); + percpu_counter_inc(&EXT2_SB(sb)->s_freeinodes_counter); if (dir) percpu_counter_dec(&EXT2_SB(sb)->s_dirs_counter); mark_buffer_dirty(bh); @@ -528,7 +529,7 @@ got: goto fail; } - percpu_counter_add(&sbi->s_freeinodes_counter, -1); + percpu_counter_dec(&sbi->s_freeinodes_counter); if (S_ISDIR(mode)) percpu_counter_inc(&sbi->s_dirs_counter);