Message ID | 20221119045159.1400244-1-chenxiaosong2@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp547999wrr; Fri, 18 Nov 2022 20:08:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf7fuTLGstE7awlzBiJ1qLvkLIkRnKY/zOFHdhxgECjXFH3uKE7ystw1T5QhY7ry6urVj/lB X-Received: by 2002:a05:6402:3214:b0:459:278b:7a8b with SMTP id g20-20020a056402321400b00459278b7a8bmr8447244eda.355.1668830912326; Fri, 18 Nov 2022 20:08:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668830912; cv=none; d=google.com; s=arc-20160816; b=K1d3OZPxWycWSeFddSc3VQxPdxD5gwpg5fMqICDwN9/af0100Zzs8ykrulsNB+gNFA RRPoVyJ4os1CfKEL24dhwoQCZ61lzPy6ehEj4D7ZoiLk4TWyS/kX3Kx2Ns7tNse/DvBC SFjkIcGh6DVS1zE4WhE7j3Fx4W/QIJU0+sUr3mp550eorZSmWtSrx0vf3jVbKDusdtou z2yyRBSYw3THr4cwamWpIqvblIk7ppx2F6q0zGzXEct6Z2afXE+qmch9FoTQHlriX6zp jSBViAcJ7r4LLvGaSgN936Y69hyCn0N29zZk6RVYCgz7C+Glp81kscSUbj7Rsqb0Cwmz p8Dg== 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 :message-id:date:subject:cc:to:from; bh=3Jcs7/6L49KOfzoU88RsLhHh9qoO7ahMPjKha+7j6+E=; b=TI1zKY+Ft4kKwUsmK16XEYFe7k68MKB+Jl+Koh9nRvQauevGopIQgPI8oZ6jzAwB0J n/5RkeoP6hM2xUz7av8sp9qhVTiI0VOFiKEUzq07GuUF91FN59X7J/yf3jeu69op5hwO w/1GsBr5IRtlXyud3nBZS0sBbzjOK5mK/bSmtFyVR/iKX50TfCNiPKV7DdEHrNZA+usA 6o+IyEG749JfWz9XHzMa5Qunv6WmA9DBTZ8clxGXoT2XoqbX9Y7lFpRjJyRVgxW+WcNW jh+ddW/MyEN6sssMU/CukQfbOA1oNUjynuFHGn5CT3fDj3R99yxhQfPxIzaWiAA4TF0f NIMg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a056402254900b0045caa8bf80bsi4669772edb.307.2022.11.18.20.08.05; Fri, 18 Nov 2022 20:08:32 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232429AbiKSDuh (ORCPT <rfc822;kkmonlee@gmail.com> + 99 others); Fri, 18 Nov 2022 22:50:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233050AbiKSDtu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 18 Nov 2022 22:49:50 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98AF6C4969; Fri, 18 Nov 2022 19:47:21 -0800 (PST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NDfjB1GcJzmVw8; Sat, 19 Nov 2022 11:46:54 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 19 Nov 2022 11:47:19 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 19 Nov 2022 11:47:19 +0800 From: ChenXiaoSong <chenxiaosong2@huawei.com> To: <sfrench@samba.org>, <pc@cjr.nz>, <dhowells@redhat.com> CC: <linux-cifs@vger.kernel.org>, <samba-technical@lists.samba.org>, <linux-kernel@vger.kernel.org>, <chenxiaosong2@huawei.com>, <yi.zhang@huawei.com>, <zhangxiaoxu5@huawei.com>, <yanaijie@huawei.com> Subject: [PATCH] cifs: fix missing unlock in cifs_file_copychunk_range() Date: Sat, 19 Nov 2022 12:51:59 +0800 Message-ID: <20221119045159.1400244-1-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749896042486206711?= X-GMAIL-MSGID: =?utf-8?q?1749896042486206711?= |
Series |
cifs: fix missing unlock in cifs_file_copychunk_range()
|
|
Commit Message
ChenXiaoSong
Nov. 19, 2022, 4:51 a.m. UTC
xfstests generic/013 and generic/476 reported WARNING as follows:
WARNING: lock held when returning to user space!
6.1.0-rc5+ #4 Not tainted
------------------------------------------------
fsstress/504233 is leaving the kernel with locks still held!
2 locks held by fsstress/504233:
#0: ffff888054c38850 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at:
lock_two_nondirectories+0xcf/0xf0
#1: ffff8880b8fec750 (&sb->s_type->i_mutex_key#21/4){+.+.}-{3:3}, at:
lock_two_nondirectories+0xb7/0xf0
This will lead to deadlock and hungtask.
Fix this by releasing locks when failed to write out on a file range in
cifs_file_copychunk_range().
Fixes: 3e3761f1ec7d ("smb3: use filemap_write_and_wait_range instead of filemap_write_and_wait")
Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
---
fs/cifs/cifsfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
good catch. merged into cifs-2.6.git for-next On Fri, Nov 18, 2022 at 10:09 PM ChenXiaoSong <chenxiaosong2@huawei.com> wrote: > > xfstests generic/013 and generic/476 reported WARNING as follows: > > WARNING: lock held when returning to user space! > 6.1.0-rc5+ #4 Not tainted > ------------------------------------------------ > fsstress/504233 is leaving the kernel with locks still held! > 2 locks held by fsstress/504233: > #0: ffff888054c38850 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: > lock_two_nondirectories+0xcf/0xf0 > #1: ffff8880b8fec750 (&sb->s_type->i_mutex_key#21/4){+.+.}-{3:3}, at: > lock_two_nondirectories+0xb7/0xf0 > > This will lead to deadlock and hungtask. > > Fix this by releasing locks when failed to write out on a file range in > cifs_file_copychunk_range(). > > Fixes: 3e3761f1ec7d ("smb3: use filemap_write_and_wait_range instead of filemap_write_and_wait") > Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com> > --- > fs/cifs/cifsfs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c > index fe220686bba4..712a43161448 100644 > --- a/fs/cifs/cifsfs.c > +++ b/fs/cifs/cifsfs.c > @@ -1281,7 +1281,7 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, > rc = filemap_write_and_wait_range(src_inode->i_mapping, off, > off + len - 1); > if (rc) > - goto out; > + goto unlock; > > /* should we flush first and last page first */ > truncate_inode_pages(&target_inode->i_data, 0); > @@ -1297,6 +1297,8 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, > * that target is updated on the server > */ > CIFS_I(target_inode)->time = 0; > + > +unlock: > /* although unlocking in the reverse order from locking is not > * strictly necessary here it is a little cleaner to be consistent > */ > -- > 2.31.1 >
ChenXiaoSong <chenxiaosong2@huawei.com> writes: > xfstests generic/013 and generic/476 reported WARNING as follows: > > WARNING: lock held when returning to user space! > 6.1.0-rc5+ #4 Not tainted > ------------------------------------------------ > fsstress/504233 is leaving the kernel with locks still held! > 2 locks held by fsstress/504233: > #0: ffff888054c38850 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: > lock_two_nondirectories+0xcf/0xf0 > #1: ffff8880b8fec750 (&sb->s_type->i_mutex_key#21/4){+.+.}-{3:3}, at: > lock_two_nondirectories+0xb7/0xf0 > > This will lead to deadlock and hungtask. > > Fix this by releasing locks when failed to write out on a file range in > cifs_file_copychunk_range(). > > Fixes: 3e3761f1ec7d ("smb3: use filemap_write_and_wait_range instead of filemap_write_and_wait") > Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com> > --- > fs/cifs/cifsfs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index fe220686bba4..712a43161448 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1281,7 +1281,7 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, rc = filemap_write_and_wait_range(src_inode->i_mapping, off, off + len - 1); if (rc) - goto out; + goto unlock; /* should we flush first and last page first */ truncate_inode_pages(&target_inode->i_data, 0); @@ -1297,6 +1297,8 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, * that target is updated on the server */ CIFS_I(target_inode)->time = 0; + +unlock: /* although unlocking in the reverse order from locking is not * strictly necessary here it is a little cleaner to be consistent */