Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1508017rwb; Fri, 18 Nov 2022 21:04:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf4MexcggHnjymUKl2mGxJ3CqNdjWs29i3tszekU4GYpVaTArd/eVSbZE7QAxwOwQ+g3rhZa X-Received: by 2002:a63:1b5b:0:b0:476:d692:7bb4 with SMTP id b27-20020a631b5b000000b00476d6927bb4mr9353724pgm.522.1668834274617; Fri, 18 Nov 2022 21:04:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668834274; cv=none; d=google.com; s=arc-20160816; b=fsPm5Vp+EhlcxxVSv7oB6l70gQrsLRWZNp3qmOXm7QXMS0eABLhamX4e7lS6KM/qpW JjCNtausnty36u0TadXwldDsL+ZXtY4S4zQsUFFC16LFqwRd7FLaY1JUzov7mMdPfBhG jJ0cI+WqAGK9DKvBdSqXNwzt1JKcXcY91VEGyi7YC1PCB0/eFanPucEsA/NxNC2N+qve YnPhnYTRv5fRg20clOxnkI7iWqxpRuAxAHvI82iRCSVETfYFzq1ZAdxCjFZ6aeCMLhGV D+Z/lu27i4vyGAQYizqtSzuiNSg4UzoqfBxf7YEaPZC2rb8/omPwkKzUufoTBQhAf4yC 18dg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r21-20020a170902be1500b0017f580f646fsi4940697pls.304.2022.11.18.21.04.23; Fri, 18 Nov 2022 21:04:34 -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 + 91 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 ); 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 To: , , CC: , , , , , , 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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