From patchwork Thu Jan 25 18:02:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 10184675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E60A60383 for ; Thu, 25 Jan 2018 19:08:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F0522893D for ; Thu, 25 Jan 2018 19:08:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43CC528946; Thu, 25 Jan 2018 19:08:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0AFC2893D for ; Thu, 25 Jan 2018 19:08:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751264AbeAYTIs (ORCPT ); Thu, 25 Jan 2018 14:08:48 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:47066 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235AbeAYTIq (ORCPT ); Thu, 25 Jan 2018 14:08:46 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0PJ7PwD060984 for ; Thu, 25 Jan 2018 19:08:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id; s=corp-2017-10-26; bh=Q/jX6tinq9sgTNHdodgH+G6bDAxrsKR/ATOM8y41BYc=; b=ixwluFtWvYwEd9Hdp+uDtFRdm0PQCvxEPvZu8EIy5hBfdTQBG/N3EhlOyO+q6Zibd2ZH yrfEHT3TCJUl5MLUmuun/YvWFQEHdzwXMPl7VAMa9bZGxkGdFSbXTQmMuvLwrv3xE6Tz suPxjPLs9TI8bl/1+CJeG4yTMZ5lzGUPsxhiYXMLJ7rTF6ilWIuDv49KqHBQ7i+oe2cs 37VlRCKm32aBebPie4gtj75uRxTPxMfQDj75RLio4ECULa6MDOGKITo3JeFB8fy9Sfyc WB/nuaiFJMVvjT2H980wvOqldGibPGO/2UslDezmJ5DiqCqan1T6XYajKjfwfRf1OCim mQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2fqkb3ghev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 25 Jan 2018 19:08:45 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w0PJ8i1b015789 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 25 Jan 2018 19:08:44 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w0PJ8iCH007069 for ; Thu, 25 Jan 2018 19:08:44 GMT Received: from dhcp-10-211-47-181.usdhcp.oraclecorp.com.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 25 Jan 2018 11:08:43 -0800 From: Liu Bo To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: fix deadlock in run_delalloc_nocow Date: Thu, 25 Jan 2018 11:02:50 -0700 Message-Id: <20180125180256.10844-3-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.9.4 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8785 signatures=668655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=5 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=541 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801250256 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP @cur_offset is not set back to what it should be (@cow_start) if btrfs_next_leaf() returns something wrong, and the range [cow_start, cur_offset) remains locked forever. cc: Signed-off-by: Liu Bo Reviewed-by: Josef Bacik --- fs/btrfs/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ac1a1ac..281a250 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1332,8 +1332,11 @@ static noinline int run_delalloc_nocow(struct inode *inode, leaf = path->nodes[0]; if (path->slots[0] >= btrfs_header_nritems(leaf)) { ret = btrfs_next_leaf(root, path); - if (ret < 0) + if (ret < 0) { + if (cow_start != (u64)-1) + cur_offset = cow_start; goto error; + } if (ret > 0) break; leaf = path->nodes[0];