From patchwork Fri Sep 1 08:58:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naohiro Aota X-Patchwork-Id: 9933771 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 8720C6016C for ; Fri, 1 Sep 2017 08:59:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 780CA285E5 for ; Fri, 1 Sep 2017 08:59:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A5C1285E8; Fri, 1 Sep 2017 08:59:57 +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 CCF8A285E5 for ; Fri, 1 Sep 2017 08:59:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751752AbdIAI7x (ORCPT ); Fri, 1 Sep 2017 04:59:53 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:50362 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751742AbdIAI7u (ORCPT ); Fri, 1 Sep 2017 04:59:50 -0400 X-IronPort-AV: E=Sophos;i="5.41,457,1498492800"; d="scan'208";a="47111668" Received: from mail-bl2nam02lp0085.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([207.46.163.85]) by ob1.hgst.iphmx.com with ESMTP; 01 Sep 2017 16:59:05 +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=MuvIzT6j0WkWY7j/Yhge6+cgHLNX83vx3/5wOrWe6UM=; b=eIpac2xS9EDWfs9Xax2JD4V9sda6xPzS1KuflZjwiA88yyjrafVWdEqbWkIS8yirbIzKpU7oXN0hzuk/KI56OtIXaQnSPKs4zZzJwWiYhsF2frtBTgp2vCfcLHiy0SGR9eZBhLY4sShjqhuhd20TclmypGc7r6lXdtou04Op5lI= 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 CY4PR04MB0664.namprd04.prod.outlook.com (10.172.136.149) 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:00 +0000 Subject: [PATCH 1/2] btrfs: clear ordered flag on cleaning up ordered extents 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:58:47 +0900 Message-ID: <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: OS2PR01CA0113.jpnprd01.prod.outlook.com (10.174.152.159) To CY4PR04MB0664.namprd04.prod.outlook.com (10.172.136.149) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a6e9d6e5-39fc-4f06-70ff-08d4f117b0ce X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CY4PR04MB0664; X-Microsoft-Exchange-Diagnostics: 1; CY4PR04MB0664; 3:TsigmdQL2CbeGLWXoiYRLBMhSUwtNdro6gtlS0KUd+3IkVnB4mfW2uZHUIZdiaR8hKwDpc+w+G9Tzi8R8xMP9rkDfD75Zdg1M+QTVYxpe5Bg34Bccsn70Ja0e6QUUnMiH32tCfhCPd9UnK3bRejpY5NBVBZ8u2l8x86YfExk1PZ5D38pOKXv5YpfysFC9Q9gvTsSskYWjr7Af5KcexWmvj/kcmUzw3lqqZCKi+N7pk9i12C+/CH3EgekwJO8eF3t; 25:Nas1OnoB6mDXrBNDUvTiFgKnZM9rJkl2sAYb6SaU9lGLUiSLz79v8mrNUqWCOqF6X3cLtow4cuQ50e5Sf0XZOqNH/pHze32yD4+J20k2PWyeye3gFf4xvT6j8NSHXQ16I4+V6eqUhlsF/9aFFCAraq7SYU/kICmAFNRbMnWQObGm+rK29XPhtO1LsbHJm5bOvS9YeUOMv4qRlkYhizcaWO698h4ajX0q6qrk5X7YU9T5Zq2PKlZFJwJJByu9mp0370XkmFBWGAJEu8+JfiKmT/pEmntDgnltiLpvLJ0X4c6TMVyKt3CtbqlEbV0BgY0LZXJZwwDfCQzn2aaHWikRcg==; 31:XI+uDulNOhYvcF83V7e745E0B5RXiL1Gqfmw24rzY2QqzBlC3eY9RYEGyUaR/b3CkNrSyOZSg07S0qQoPWORpraYNd/AqvWyFcCSC6Z5IOYZdew8eQhsXlmjlO3JLgwVpO99rbq7d85CwmQxo8eG2D+J+WsNkMQILzReVI8oTyfI7gw+CPSMimo9b/RRcNnaFKIYgQ6Aely+EJaaQM7lnE/scjiouCh5mBm49nA/CXY= X-MS-TrafficTypeDiagnostic: CY4PR04MB0664: WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; CY4PR04MB0664; 20:aeAoF5l23vjBQCaaM3zHWEmqSQ05pl+BBHDO26UzamI18F6OyEfKulsZz5mpjjbt/Ur2EqtBXApGFIQuct8X3pP4PcarDHH1NvZAAH0XzR/+kZ/4hFgqQckOZq2te6J+6M1u4PREX2hH9AymiPnzPbn1DmamoPWRkkCqalWHXWOXMBy52c5adTmojEatLppPMWXDXZOhhokB4iqe23GkrvTEOseXVxQIqlPPGVJJwfpgoWcDOHED8Tbe1Qjm221hUsXThHNCOq1V1vQdHBWjR0MJdph9WnX8c0Fnvr79Hw9+H+igAP6smTFqVRJkOwkkDFFmSNjpoPr+9ucum0ihzf/c0SmxVf+1I6cUfQ1qDhxt1HxkDWx2+w+kmHyjDvx1yGu2WGtHXVDH1ZrviCtLDIXq8yGjZZLcckYIuXcFUh304rSIBLy7OsFA2tsngqlCqaYIRsmm0j86t928Owj8ppz6MwN6ZZe4OCU37MGfBbsAtSKLz9BLIOjCJr7aLqPR; 4:Le6kks1yWFgya/KRlnfiiI6cvy3OmSTdSpCMkjh+lyb63k3H8JdK6LZ3ZPPaJkZ9lIZx2Wyv/C5pOARmJJN7iLfawiyScB1pz2wdnsv1hmXavdJy8abP1wxAyi0jFvZFrBVhTG/WGXdjRMxE6HWkApye714fzwqMRKasZJfY5WqOgu8If3+q0flq6RfJ6DirmvbObFWzeVpfWq8kzUVmi78+GU+49bVSkTtMIbLAoPeBmuKHn6wWRC9vHok4K5RrDqv6WmC6+bs6ZvACurEIk8LcjfbWsYTRAxqX6f1ozXM= 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)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR04MB0664; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR04MB0664; X-Forefront-PRVS: 0417A3FFD2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(199003)(189002)(54356999)(478600001)(81156014)(83506001)(66066001)(23676002)(72206003)(9686003)(68736007)(110136004)(53936002)(50986999)(81166006)(305945005)(189998001)(7736002)(8936002)(4001350100001)(230700001)(8676002)(47776003)(3846002)(101416001)(2906002)(50466002)(6116002)(6916009)(6666003)(97736004)(25786009)(575784001)(86362001)(55016002)(106356001)(33646002)(6506006)(105586002)(8666007)(4326008)(5660300001)(103116003)(2361001)(2351001)(42186005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR04MB0664; H:naota.dhcp.fujisawa.hgst.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: wdc.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjA0TUIwNjY0OzIzOndWSWdRQW8vak55UFBQMnlzSFBDeHRMLzRt?= =?utf-8?B?RFlyMG1wOExOUUhLRTExYUx3WE15RnB0MzUyV1lOS1ZSZWQwOWRPNU8yTFNj?= =?utf-8?B?NzN3TjdpVTJ0RDJQb2VhSUNLTFNFbXhRS1RDZ2FEQXNMM0dCUEJrVXFKRGdu?= =?utf-8?B?bVdmdW9EMVVpWTY0aDc4c0NEZVljSTlGUkFYVWcrWWMzbTJnb2h5RVRuajdX?= =?utf-8?B?dkRjVU5EM2ZucFZMQUVvTjBkcGQ2M0FpRURlbWVrcSs0d0svL09JaWpYQjVv?= =?utf-8?B?MXpVU2FOa2pWYWJpWGlmY3QvdStwSTNuaGZ1TWw1ejI3RzBiVUlkUnMwanFI?= =?utf-8?B?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JClINeT3flB4lQmvr2DdpJqgg4BW04lGkP5s5tbcf2KoNq49V2CR1XoM7kcrvDaVwudGRUf16bQNz4SONcY9f/0LzpOuYCMrLzlcqkgdGfmMuGTIz1tVYADCdiHaeoC+2vBDT/gMNQ1sRKbe8gJdNCmoX/NCN4BTgFFE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR04MB0664; 20:DI+a9DRn1bMl1kOHRv8SiSliZ/VjIqObJtUr/IoxB1LMoxpeDhlzMhHuW4ye2KkcXLNSypTpCqV4IdzoRSqc/GmG/JBWiZIrKAs5lxwl+db5N8VMxyUUd02vIh7czVq7XDQLfvXrEHmWDU32PeDJHUnYh2UJqbUZ0f43ihDd8mg= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2017 08:59:00.6131 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR04MB0664 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 commit 524272607e88 ("btrfs: Handle delalloc error correctly to avoid ordered extent hang") introduced btrfs_cleanup_ordered_extents() to cleanup submitted ordered extents. However, it does not clear the ordered bit (Private2) of coresponding pages. Thus, the following BUG occurs from free_pages_check_bad() (on btrfs/125 with nospace_cache). BUG: Bad page state in process btrfs pfn:3fa787 page:ffffdf2acfe9e1c0 count:0 mapcount:0 mapping: (null) index:0xd flags: 0x8000000000002008(uptodate|private_2) raw: 8000000000002008 0000000000000000 000000000000000d 00000000ffffffff raw: ffffdf2acf5c1b20 ffffb443802238b0 0000000000000000 0000000000000000 page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set bad because of flags: 0x2000(private_2) This patch clear the flag as same as other places calling btrfs_dec_test_ordered_pending() for every page in the specified range. Signed-off-by: Naohiro Aota Fixes: 524272607e88 ("btrfs: Handle delalloc error correctly to avoid ordered extent hang") Cc: # 4.12 Reviewed-by: Qu Wenruo Reviewed-by: Josef Bacik --- fs/btrfs/inode.c | 12 ++++++++++++ 1 file changed, 12 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 24bcd5cd9cf2..ae4c0a1bef38 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -135,6 +135,18 @@ static inline void btrfs_cleanup_ordered_extents(struct inode *inode, const u64 offset, const u64 bytes) { + unsigned long index = offset >> PAGE_SHIFT; + unsigned long end_index = (offset + bytes - 1) >> PAGE_SHIFT; + struct page *page; + + while (index <= end_index) { + page = find_get_page(inode->i_mapping, index); + index++; + if (!page) + continue; + ClearPagePrivate2(page); + put_page(page); + } return __endio_write_update_ordered(inode, offset + PAGE_SIZE, bytes - PAGE_SIZE, false); }