Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2548625rwo; Sun, 23 Jul 2023 18:40:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlE/lH2Zlk83cwRABM+ZdIQzbz65wSIGReWPskk714bDJWxyZUda/mdRPBYcFmPZjcNmBM5o X-Received: by 2002:a17:906:3048:b0:992:4e20:bca4 with SMTP id d8-20020a170906304800b009924e20bca4mr8543404ejd.42.1690162813563; Sun, 23 Jul 2023 18:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690162813; cv=none; d=google.com; s=arc-20160816; b=NO5niWBBeKIhr7nguwy1xMHzm0ztQC8qNj/d+orgroHnsi6RhMvZnX8fsZDJmx2Goa T/KhoP/l+VsQc7CkIvpA216hr9rVjJ3GgpR4k9aQHBvBQhldSs15U7+GrR5cRSo26l3p ZVdCRNrYXRP35eut43Y2cF5ukesc9MvMA3trCmt9LrwhPUa3MpCWvBHKI4yRdaHJ7hnY HG3UVTFIkGd29peBOPhxXkxRqw1CdwVeeVsk+zFBHdyKHCdUZNAHYrkNiPczgmqtAd9y zeFOJGepX9/GK0t7NsxaIoWm/HKLqUWdMZyO8Yfhly27d29Wkw6N4MFuLycGlpMeSPuQ bsAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9qnPYdVRvgUiVqZoWT76zb1Vx3cenmGT1/ShxpO58cU=; fh=nSdIH945pkkvr0ZKxnBK9LdaUIV/6JyauvTC8JgtmEw=; b=YJrTMcCJfSN2xoOo88xy5DLNGpmg52FSpXQi5fzqDwfncNuu5UFzceyy3npQlnWOcz Rjvyvpd/lP5+aQnltCrvSrHBV0wCs5Dvk07cZ/kfuXthOpCXoyU5+YQBrjVlczybGN+L VwU66Ta0zm4oM1iAPV2vo6oPMorcJOh8/Gj1YZac8bEy0H0UODzOkq0PVrRlaRWFobbu HZTlYHi/fTlZaAhSE0Q3M+9pNUSFHQKb9crCuvmK8FMwjj3xR8n/beP+ILjDcospf5Rc LynFNLfOzKV/LFg2ZPwuWOgy2CFrC5YbMY6CNTGpMzZbc9elBJooByc0vHN/9uyjlUs4 p5SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pwMXtBsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca15-20020a170906a3cf00b0096f8ec464a3si5941330ejb.323.2023.07.23.18.39.49; Sun, 23 Jul 2023 18:40:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pwMXtBsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230087AbjGXBQx (ORCPT + 99 others); Sun, 23 Jul 2023 21:16:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbjGXBQd (ORCPT ); Sun, 23 Jul 2023 21:16:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1B8D199E; Sun, 23 Jul 2023 18:16:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C150C60F0A; Mon, 24 Jul 2023 01:16:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 913ECC433C8; Mon, 24 Jul 2023 01:16:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690161366; bh=kfUbS1fDaZ38pCthUZlM1r73l+/N/HyekdZPdF5c0iI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pwMXtBsgH2nUgDz4eKkxK+BVDWoxoxm4jinE/4eoJVT4NEVmVyXKlwhTxEE9Bi3TR kS+Ce/uzhv6r1zYFex62OrztYH/d86o3Ug80ToxDz3SkvjuWXS5Q7BMJnOAsVImcl1 odP/q74Ryu+mmPeypgFtlEU1FP8U0x5XcAhYjGgpS+A5Wn6OzaX+pgt0djDClhfyvY /zRZhjn2rLEFKaHuOOTBLSxmMRxkqIb1muC9C9A5rsgyrUlwVe+ZdM3Gc7x1Fle2aY I6ACYRLEsWsq1RONoGTE77eTdBk/9ZreuBVBVogJh1ZbgWJDfiDs6Y/KUZr9mOj+uL BD6vqqwRolkcQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ye Bin , Jan Kara , Sasha Levin , jack@suse.com Subject: [PATCH AUTOSEL 6.4 27/58] quota: fix warning in dqgrab() Date: Sun, 23 Jul 2023 21:12:55 -0400 Message-Id: <20230724011338.2298062-27-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230724011338.2298062-1-sashal@kernel.org> References: <20230724011338.2298062-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.4.5 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ye Bin [ Upstream commit d6a95db3c7ad160bc16b89e36449705309b52bcb ] There's issue as follows when do fault injection: WARNING: CPU: 1 PID: 14870 at include/linux/quotaops.h:51 dquot_disable+0x13b7/0x18c0 Modules linked in: CPU: 1 PID: 14870 Comm: fsconfig Not tainted 6.3.0-next-20230505-00006-g5107a9c821af-dirty #541 RIP: 0010:dquot_disable+0x13b7/0x18c0 RSP: 0018:ffffc9000acc79e0 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff88825e41b980 RDX: 0000000000000000 RSI: ffff88825e41b980 RDI: 0000000000000002 RBP: ffff888179f68000 R08: ffffffff82087ca7 R09: 0000000000000000 R10: 0000000000000001 R11: ffffed102f3ed026 R12: ffff888179f68130 R13: ffff888179f68110 R14: dffffc0000000000 R15: ffff888179f68118 FS: 00007f450a073740(0000) GS:ffff88882fc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffe96f2efd8 CR3: 000000025c8ad000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: dquot_load_quota_sb+0xd53/0x1060 dquot_resume+0x172/0x230 ext4_reconfigure+0x1dc6/0x27b0 reconfigure_super+0x515/0xa90 __x64_sys_fsconfig+0xb19/0xd20 do_syscall_64+0x39/0xb0 entry_SYSCALL_64_after_hwframe+0x63/0xcd Above issue may happens as follows: ProcessA ProcessB ProcessC sys_fsconfig vfs_fsconfig_locked reconfigure_super ext4_remount dquot_suspend -> suspend all type quota sys_fsconfig vfs_fsconfig_locked reconfigure_super ext4_remount dquot_resume ret = dquot_load_quota_sb add_dquot_ref do_open -> open file O_RDWR vfs_open do_dentry_open get_write_access atomic_inc_unless_negative(&inode->i_writecount) ext4_file_open dquot_file_open dquot_initialize __dquot_initialize dqget atomic_inc(&dquot->dq_count); __dquot_initialize __dquot_initialize dqget if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) ext4_acquire_dquot -> Return error DQ_ACTIVE_B flag isn't set dquot_disable invalidate_dquots if (atomic_read(&dquot->dq_count)) dqgrab WARN_ON_ONCE(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) -> Trigger warning In the above scenario, 'dquot->dq_flags' has no DQ_ACTIVE_B is normal when dqgrab(). To solve above issue just replace the dqgrab() use in invalidate_dquots() with atomic_inc(&dquot->dq_count). Signed-off-by: Ye Bin Signed-off-by: Jan Kara Message-Id: <20230605140731.2427629-3-yebin10@huawei.com> Signed-off-by: Sasha Levin --- fs/quota/dquot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 6beceed34e089..e3e4f40476579 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -555,7 +555,7 @@ static void invalidate_dquots(struct super_block *sb, int type) continue; /* Wait for dquot users */ if (atomic_read(&dquot->dq_count)) { - dqgrab(dquot); + atomic_inc(&dquot->dq_count); spin_unlock(&dq_list_lock); /* * Once dqput() wakes us up, we know it's time to free -- 2.39.2