From patchwork Fri Sep 1 08:59:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naohiro Aota X-Patchwork-Id: 9933773 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 DDAAD6016C for ; Fri, 1 Sep 2017 09:00:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF8FA271CB for ; Fri, 1 Sep 2017 09:00:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4441285E5; Fri, 1 Sep 2017 09:00:14 +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 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 28F58271CB for ; Fri, 1 Sep 2017 09:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751800AbdIAJAM (ORCPT ); Fri, 1 Sep 2017 05:00:12 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:56113 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751547AbdIAJAJ (ORCPT ); Fri, 1 Sep 2017 05:00:09 -0400 X-IronPort-AV: E=Sophos;i="5.41,457,1498492800"; d="scan'208";a="149643961" Received: from mail-bl2nam02lp0080.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([207.46.163.80]) by ob1.hgst.iphmx.com with ESMTP; 01 Sep 2017 16:59:22 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ApckADnrbj5RjKlnfDYe4B38y3Q4+tp64Y+hfOJngwM=; b=NUIJAemWEJvDT5CWxclo9rG1ynEYIjktidT6ovhqU3qqZWvShBIz2Dz9tAcwDFsejwpbriab3+wMFfeHScPI1eSZdemso2SDshWvO5wkYyuvd6EFCaakkjBSp8pGU++OoH29NLgAMSbBJYDIfOXtGpJywPrb35dFOqGqCfRqKPU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Naohiro.Aota@wdc.com; Received: from naota.dhcp.fujisawa.hgst.com (199.255.47.10) by BN6PR04MB0661.namprd04.prod.outlook.com (10.172.197.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Fri, 1 Sep 2017 08:59:20 +0000 Subject: [PATCH 2/2] btrfs: finish ordered extent cleaning if no progress is found From: Naohiro Aota To: linux-btrfs@vger.kernel.org Cc: fdmanana@suse.com, clm@fb.com, dsterba@suse.com, jbacik@fb.com, quwenruo.btrfs@gmx.com Date: Fri, 01 Sep 2017 17:59:07 +0900 Message-ID: <150425634736.4737.8343712690392096633.stgit@naota.dhcp.fujisawa.hgst.com> In-Reply-To: <150425632766.4737.133868215044509089.stgit@naota.dhcp.fujisawa.hgst.com> References: <150425632766.4737.133868215044509089.stgit@naota.dhcp.fujisawa.hgst.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [199.255.47.10] X-ClientProxiedBy: KAXPR01CA0016.jpnprd01.prod.outlook.com (10.171.236.154) To BN6PR04MB0661.namprd04.prod.outlook.com (10.172.197.150) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 157d0251-8b04-4383-75a0-08d4f117bcad X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BN6PR04MB0661; X-Microsoft-Exchange-Diagnostics: 1; BN6PR04MB0661; 3:1+bXiTo1ftnG/XyXGI0UOb/GnzAC8daB4F9jR1NI8IThUDer7er3op3hVktoUjGLY2aQze3xgwuC8qyNiwEYBOzZaxBhjFghc8Le7DRtQzqME7tiIzwlEMkG/9/YWKjvaSEJdWYf8zJc/XW1nak1V+FO8rt8NxygrD7OGdFBPGjiBkqUp15A9RFLtIQxmaOzfKWJdj+rDmRAsxeC6usgIOLTxmjcShSmznww2b7Q1zlnAhPBgdKMvMv3KfnZn4ME; 25:yDyzx1iWjxj3mpyALvJ8o3rpY8+gDmLTV43YPv9J1H1u3liUMSWqrEr83q6hkBU8e5P5Ypbxie8pzqXDL71xufqVesy32pbBbm62fg2/C3wGvbd4+umNj5qS+3Z5GvG7lOHZ2BxrfSGbc6N7hqJxMwOyC94CsRSzxXkHNWO97joV0zIoe4RPBawwlUebEVU40QFhTy24SSmqedwRDsuAeIIc6RJCI5clxAubYXdVKOvGgOaNVGZmvp73+PGtktWAL/hwthE5gzcqfIFOKhELiJpxzX0zEtwiFNLWEJXANzxgKqJwv0mDm8B3ey1HQv8VKj6gyPcmddln4Y+3gl97yg==; 31:+X5sQiO1+N1BglWi+0azL+wuQ3mKn5/zWXjpsVUwCaewMqjJRAfN2fHA2RUrtrfV2FRYYuK9G1SCRykVP177rp0TtcE3pnft7GxP7lJYmDKjpwL2j11ZjZp/WjxxOTng7pcJN1Ld+mnasygWt9JNUbsg5F8hoCOs8aMXJBhk8rPWMmtWfIzncTdcbPRgvNFWBrNKz/WVuU6TgrguYH4DZZuFQBT09e5KqQHuqCdPumg= X-MS-TrafficTypeDiagnostic: BN6PR04MB0661: WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; BN6PR04MB0661; 20:HKSHvrFyi0w/zLm8tv2aOLaBF3C/9ceAzm8RJeEt5XH5Tm2E8hufYJ+ej8qe27G9PaA/HBjYzPDtL6poguJpto5nP1JunZv4MxHavHA6Wuhx5ntPViRS0vMUwk9kvSzFeIIgWhS3kFrdmMsKmHjp8j4PDzTZ/D9KkzXFxLNqAey6NC8YGX8efTwcw/0ix5/Rd0d5/mCi0gbbmG9QWFD0iupRA/M5fzUIxDp7ILgVqA9ET3zPa16lkFweOWVcP6XrI1S6mQw2pHX4WQgKlWH5gWTiO4bEy0Ftcz4MXAZg8D4FzjIyfYxa2fruZtskEQPOxsAXjXaRcD3ryeGg1y9KG2QatNiOFbDrA1VMzH3jlZ3y4SRUaW2znHJqyEoyguLL9Xs0+n/wRXrt50hmSs4ba3vAfCxC+AzkffAu4qldIke4h4WZjIAzQvAJc7LAsbm/vlErul29/dNsTl0Sg1UCVYo6VSb+biUQbOvaYynPeKiA7A2UC6zwOMu4QJrXeSiH; 4:Uu5FIgR2KjJMTEQ03+3RHIo14TckMSZpmXvV9j6wfXag/ywc4wkYbK8k7QRT102unqCmrPIulsfSPrwyxpoMX2LNWM8YxIc07JezpbpgEsfLkzm2bgJy1Y6LJaCwsDb0LDnvPHAEjsSXETsA/WAC1Hup92J0oNpkh83/nG6HyhDzWIvyLDx0JHM0pNDg3jKVyFR72O50+f2c4o/rIq+DYpapCdEDMmzUzq0NVtYlSRKXoUROQF9kXAnNwpDnYHw61nV2AE/HSRgQO7a0CLKyOXlNqpZTZ3V7fGGk2CWtSDY= X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123558100)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR04MB0661; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR04MB0661; X-Forefront-PRVS: 0417A3FFD2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(189002)(199003)(55016002)(42186005)(6666003)(50466002)(86362001)(6116002)(2361001)(2950100002)(6916009)(2351001)(3846002)(8666007)(575784001)(105586002)(106356001)(2906002)(230700001)(68736007)(83506001)(4326008)(9686003)(4001350100001)(97736004)(53936002)(8936002)(103116003)(6506006)(101416001)(7736002)(5660300001)(47776003)(110136004)(66066001)(305945005)(25786009)(50986999)(189998001)(54356999)(76176999)(478600001)(8676002)(81166006)(81156014)(33646002)(72206003)(23676002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN6PR04MB0661; H:naota.dhcp.fujisawa.hgst.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: wdc.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjA0TUIwNjYxOzIzOk1ONU9VU05MRWpCWHloYVhXVElDQzNybFph?= =?utf-8?B?RHhBdmdlc0w0UEJWYjAvdk9ac1lEUXcxUEZyMWQxZFNxa2pDWDlpUWpHRnVX?= =?utf-8?B?Slk5c21VUTBmazI3RGRrNHhUMmZoVkZLckY4eEFPT2FGWEo4VEd1UUZyTjMw?= =?utf-8?B?OGkwTVNUMW93UkNya3EvL2hzdzluWWROSWJZM0R0bDc0WGkzejNTcFR4RVF0?= =?utf-8?B?Tyt2cVhEN0tjSFN4OGxmaDhFeDVWN3YwOXdvTTFrZ1M0anA0aEVpUl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ftvuMdxwTHAmVsg3dOqnaERcR5g4xMwsaU2t0Qjw/ZzzvnzZlknpnD+/UOwfGEnOliBcCv+IyypAmEux99FfKdyXouoHecLv34AN8PvY=; 7:3qWHrYDtuCD7Xjv5IHXuTV5volmeNnhKHiwZYIzcew7lK0wDD6rSKKu+apus+1hdHO3SHZTFiwi2lPP2kvMuGthXapy7YSc2DpM063ooNQe/jKqtlG+X9pOXRMqVFICrSRqUKl2mSlaVhOsE97j+qGA4py9lZs5By9dx3QHZyGFqF/n4m1UY7auXUDsEFJr2xPlmQphiLvp44epsBI63IuJ3nvxvv3wb79YNlQ3dJ44= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR04MB0661; 20:Ptvw6VoWO+PZrGpOHBzaTdMMrp5GaoV1QlWF84aEWw4ZHD6oEEnYAtJ1E7hFOOFRcur8CVL5GvaN3nrGSuU9YINY0bHUIipR3r8dbqTuJPedcTEiTilSL9iG3q5Wwb4dXX7/bnGq7yXqnKKV501O7lyOnPtnh9BlHYXCyIzS9f4= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2017 08:59:20.5139 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR04MB0661 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 __endio_write_update_ordered() repeats the search until it reaches the end of the specified range. This works well with direct IO path, because before the function is called, it's ensured that there are ordered extents filling whole the range. It's not the case, however, when it's called from run_delalloc_range(): it is possible to have error in the midle of the loop in e.g. run_delalloc_nocow(), so that there exisits the range not covered by any ordered extents. By cleaning such "uncomplete" range, __endio_write_update_ordered() stucks at offset where there're no ordered extents. Since the ordered extents are created from head to tail, we can stop the search if there are no offset progress. Signed-off-by: Naohiro Aota Fixes: 524272607e88 ("btrfs: Handle delalloc error correctly to avoid ordered extent hang") Cc: # 4.12 Reviewed-by: Josef Bacik --- fs/btrfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ae4c0a1bef38..fd5934121b4b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8309,6 +8309,7 @@ static void __endio_write_update_ordered(struct inode *inode, btrfs_work_func_t func; u64 ordered_offset = offset; u64 ordered_bytes = bytes; + u64 last_offset; int ret; if (btrfs_is_free_space_inode(BTRFS_I(inode))) { @@ -8320,6 +8321,7 @@ static void __endio_write_update_ordered(struct inode *inode, } again: + last_offset = ordered_offset; ret = btrfs_dec_test_first_ordered_pending(inode, &ordered, &ordered_offset, ordered_bytes, @@ -8330,6 +8332,8 @@ static void __endio_write_update_ordered(struct inode *inode, btrfs_init_work(&ordered->work, func, finish_ordered_fn, NULL, NULL); btrfs_queue_work(wq, &ordered->work); out_test: + if (ordered_offset == last_offset) + return; /* * our bio might span multiple ordered extents. If we haven't * completed the accounting for the whole dio, go back and try again