Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4501006ybx; Mon, 4 Nov 2019 14:26:41 -0800 (PST) X-Google-Smtp-Source: APXvYqwRpxXbmO4DaDR8hgjNAjtQzLM3cMz1MNz7CSlrvnCSnlqu0wu5/6A2bQ2VclpILwwtenF2 X-Received: by 2002:a50:88a6:: with SMTP id d35mr32548684edd.111.1572906401391; Mon, 04 Nov 2019 14:26:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572906401; cv=none; d=google.com; s=arc-20160816; b=g5z0iFeOtgcxQw7MDDU7o/GHrv2YGH1571hKIkUEvZ9cgtq9OQX0GYtvmdRD5abY+q 3DXxqx46gGr98koobkgWCib8HiALAbwhIsZM68s3diMJ+YDRPdB0140VBAfulYffLt5k WPIxypw9odw2j7/aQZqzlxPB+lG6vVeX3MlHLCHe22R1JKcgYrOAZYzPE8MlHoYxmVjY GbWJ9/TAEb2cIfAaXX1+vtOyIq7iJ5lUmNFqS7ipAb70UMhosZFJ0zv5RKdAzd/IsmDg 2kshlyQVZbT8LbHryjX7t/f+EcF++4Z8TQvFV6Q6j62cERJLYu+mFVYg8tV/MVqD2nfm KxQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mP0y8NLm0WNYyxYlstECGqQpddWRUZnyZa7lUaKgkNs=; b=HaROogEd6HQyCPt2DCZi+4TUnLxYYcZfnDtkboibNX5ICdrhXt/CBtnTKX+QNxfxZS 7pe8w8tDcwwsXA9BcQcDVq/UfSj4aDyFuveBKSgt3DDmuOUIQq5OLVDtp0MbP2g5E3SR J6oj5FT7/qyMvFX/GyJR63n/wJgRCq6ZjMhSB0XF1frJM8WnMGjGY92A+k5VNn8O+Vtv gYAxSPhET4ogwToKbpbEPYYoY5OXwEFbLLZ/FYa+Y1BT1MJZRIg1eWIxo4sh5cscy1Uc hqOpClaW0DxhB6LkofQtuxre6eFkCMwrQXva6H6IHr7FB9hTNHB0ctJI1HgxtDOOaC9L OyxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Lz/l83yR"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si8989419edc.171.2019.11.04.14.26.18; Mon, 04 Nov 2019 14:26:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Lz/l83yR"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730992AbfKDVx3 (ORCPT + 99 others); Mon, 4 Nov 2019 16:53:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:47380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730973AbfKDVx0 (ORCPT ); Mon, 4 Nov 2019 16:53:26 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E7B7A21929; Mon, 4 Nov 2019 21:53:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904405; bh=Xcw/RNR9EXgHEbuvdCsh/HVA7ipQvPjNV0sKMexd29I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lz/l83yR/9+lReNvH76yglmndTa0zcYC1lVs5pupRPnsfu6/WKh63B8o3q7knBRCF DAqh/6QtGAzmyrQS7RYgdbppFG4d1BDW/WeVbdlTiWPHVF97Xm6nQ3coEOalIsDqi9 sshKUs7HBNjA8Azem5V+s4+KE6GK+5u+ZDyIgjUo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , ZhangXiaoxu , Anna Schumaker , Sasha Levin Subject: [PATCH 4.14 34/95] nfs: Fix nfsi->nrequests count error on nfs_inode_remove_request Date: Mon, 4 Nov 2019 22:44:32 +0100 Message-Id: <20191104212059.355168342@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212038.056365853@linuxfoundation.org> References: <20191104212038.056365853@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: ZhangXiaoxu [ Upstream commit 33ea5aaa87cdae0f9af4d6b7ee4f650a1a36fd1d ] When xfstests testing, there are some WARNING as below: WARNING: CPU: 0 PID: 6235 at fs/nfs/inode.c:122 nfs_clear_inode+0x9c/0xd8 Modules linked in: CPU: 0 PID: 6235 Comm: umount.nfs Hardware name: linux,dummy-virt (DT) pstate: 60000005 (nZCv daif -PAN -UAO) pc : nfs_clear_inode+0x9c/0xd8 lr : nfs_evict_inode+0x60/0x78 sp : fffffc000f68fc00 x29: fffffc000f68fc00 x28: fffffe00c53155c0 x27: fffffe00c5315000 x26: fffffc0009a63748 x25: fffffc000f68fd18 x24: fffffc000bfaaf40 x23: fffffc000936d3c0 x22: fffffe00c4ff5e20 x21: fffffc000bfaaf40 x20: fffffe00c4ff5d10 x19: fffffc000c056000 x18: 000000000000003c x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000040 x14: 0000000000000228 x13: fffffc000c3a2000 x12: 0000000000000045 x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000 x8 : 0000000000000000 x7 : 0000000000000000 x6 : fffffc00084b027c x5 : fffffc0009a64000 x4 : fffffe00c0e77400 x3 : fffffc000c0563a8 x2 : fffffffffffffffb x1 : 000000000000764e x0 : 0000000000000001 Call trace: nfs_clear_inode+0x9c/0xd8 nfs_evict_inode+0x60/0x78 evict+0x108/0x380 dispose_list+0x70/0xa0 evict_inodes+0x194/0x210 generic_shutdown_super+0xb0/0x220 nfs_kill_super+0x40/0x88 deactivate_locked_super+0xb4/0x120 deactivate_super+0x144/0x160 cleanup_mnt+0x98/0x148 __cleanup_mnt+0x38/0x50 task_work_run+0x114/0x160 do_notify_resume+0x2f8/0x308 work_pending+0x8/0x14 The nrequest should be increased/decreased only if PG_INODE_REF flag was setted. But in the nfs_inode_remove_request function, it maybe decrease when no PG_INODE_REF flag, this maybe lead nrequests count error. Reported-by: Hulk Robot Signed-off-by: ZhangXiaoxu Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/write.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 3c1e46f4bce32..01b9d9341b541 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -783,7 +783,6 @@ static void nfs_inode_remove_request(struct nfs_page *req) struct nfs_inode *nfsi = NFS_I(inode); struct nfs_page *head; - atomic_long_dec(&nfsi->nrequests); if (nfs_page_group_sync_on_bit(req, PG_REMOVE)) { head = req->wb_head; @@ -796,8 +795,10 @@ static void nfs_inode_remove_request(struct nfs_page *req) spin_unlock(&mapping->private_lock); } - if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags)) + if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags)) { nfs_release_request(req); + atomic_long_dec(&nfsi->nrequests); + } } static void -- 2.20.1