From patchwork Wed Aug 5 09:51:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 6947421 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5E4119F358 for ; Wed, 5 Aug 2015 09:52:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67F5120377 for ; Wed, 5 Aug 2015 09:52:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 080922047B for ; Wed, 5 Aug 2015 09:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752706AbbHEJwD (ORCPT ); Wed, 5 Aug 2015 05:52:03 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:33510 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752632AbbHEJv5 (ORCPT ); Wed, 5 Aug 2015 05:51:57 -0400 Received: by wijp15 with SMTP id p15so40959417wij.0; Wed, 05 Aug 2015 02:51:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n0LrPO/Lmc5yr+L3hoVsMXxWiRoBzDpV6tKCtbDraOc=; b=gE/Y9H9lzt6TQ+Z+1GR1vC2ECtDRB0OQTQWxXpSScWDeDQ5Q1la+JtTHqvANT2LEeN MnEbRa3ruPfWB/W68BbyLt1W2LTk+7ZHzurdyIRz8UnEvtrjti8ZpX6N1QnHqx8PRnnQ 1+x7qqAoePZzMQn6tc+LLH79WNNpTdSlV1wuKrHu2tov+i7PdZIfO5vusZbKPsB0/Oj9 Oq9r6uNxDisTpFCLebpodjWuetT2fNHhuWnZivJrNH9vmLMCtOt7wxNryp7M1hviTjbP Es4aMtxPpdYIOC9Cdwi368nwGmWFABV4HxDO6FBpjLXXlgEb/hdHGRN1tMgEzb5XROA1 7hXA== X-Received: by 10.194.185.146 with SMTP id fc18mr17551886wjc.46.1438768315724; Wed, 05 Aug 2015 02:51:55 -0700 (PDT) Received: from tiehlicka.suse.cz (nat1.scz.suse.com. [213.151.88.250]) by smtp.gmail.com with ESMTPSA id yu4sm3229106wjc.43.2015.08.05.02.51.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Aug 2015 02:51:55 -0700 (PDT) From: mhocko@kernel.org To: LKML Cc: , , Andrew Morton , Johannes Weiner , Tetsuo Handa , Dave Chinner , "Theodore Ts'o" , linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, Jan Kara , Michal Hocko Subject: [RFC 7/8] btrfs: Prevent from early transaction abort Date: Wed, 5 Aug 2015 11:51:23 +0200 Message-Id: <1438768284-30927-8-git-send-email-mhocko@kernel.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438768284-30927-1-git-send-email-mhocko@kernel.org> References: <1438768284-30927-1-git-send-email-mhocko@kernel.org> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Hocko Btrfs relies on GFP_NOFS allocation when commiting the transaction but since "mm: page_alloc: do not lock up GFP_NOFS allocations upon OOM" those allocations are allowed to fail which can lead to a pre-mature transaction abort: [ 55.328093] Call Trace: [ 55.328890] [] dump_stack+0x4f/0x7b [ 55.330518] [] ? console_unlock+0x334/0x363 [ 55.332738] [] __alloc_pages_nodemask+0x81d/0x8d4 [ 55.334910] [] pagecache_get_page+0x10e/0x20c [ 55.336844] [] alloc_extent_buffer+0xd0/0x350 [btrfs] [ 55.338973] [] btrfs_find_create_tree_block+0x15/0x17 [btrfs] [ 55.341329] [] btrfs_alloc_tree_block+0x18c/0x405 [btrfs] [ 55.343566] [] split_leaf+0x1e4/0x6a6 [btrfs] [ 55.345577] [] btrfs_search_slot+0x671/0x831 [btrfs] [ 55.347679] [] ? get_parent_ip+0xe/0x3e [ 55.349434] [] btrfs_insert_empty_items+0x5d/0xa8 [btrfs] [ 55.351681] [] __btrfs_run_delayed_refs+0x7a6/0xf35 [btrfs] [ 55.353979] [] btrfs_run_delayed_refs+0x6e/0x226 [btrfs] [ 55.356212] [] ? start_transaction+0x192/0x534 [btrfs] [ 55.358378] [] ? start_transaction+0x192/0x534 [btrfs] [ 55.360626] [] btrfs_commit_transaction+0x4c/0xaba [btrfs] [ 55.362894] [] ? start_transaction+0x192/0x534 [btrfs] [ 55.365221] [] btrfs_sync_file+0x29c/0x310 [btrfs] [ 55.367273] [] vfs_fsync_range+0x8f/0x9e [ 55.369047] [] vfs_fsync+0x1c/0x1e [ 55.370654] [] do_fsync+0x34/0x4e [ 55.372246] [] SyS_fsync+0x10/0x14 [ 55.373851] [] system_call_fastpath+0x12/0x6f [ 55.381070] BTRFS: error (device hdb1) in btrfs_run_delayed_refs:2821: errno=-12 Out of memory [ 55.382431] BTRFS warning (device hdb1): Skipping commit of aborted transaction. [ 55.382433] BTRFS warning (device hdb1): cleanup_transaction:1692: Aborting unused transaction(IO failure). [ 55.384280] ------------[ cut here ]------------ [ 55.384312] WARNING: CPU: 0 PID: 3010 at fs/btrfs/delayed-ref.c:438 btrfs_select_ref_head+0xd9/0xfe [btrfs]() [...] [ 55.384337] Call Trace: [ 55.384353] [] dump_stack+0x4f/0x7b [ 55.384357] [] ? down_trylock+0x2d/0x37 [ 55.384359] [] warn_slowpath_common+0xa1/0xbb [ 55.384398] [] ? btrfs_select_ref_head+0xd9/0xfe [btrfs] [ 55.384400] [] warn_slowpath_null+0x1a/0x1c [ 55.384423] [] btrfs_select_ref_head+0xd9/0xfe [btrfs] [ 55.384446] [] ? __btrfs_run_delayed_refs+0xa2/0xf35 [btrfs] [ 55.384455] [] __btrfs_run_delayed_refs+0xab/0xf35 [btrfs] [ 55.384476] [] btrfs_run_delayed_refs+0x6e/0x226 [btrfs] [ 55.384499] [] ? start_transaction+0x192/0x534 [btrfs] [ 55.384521] [] ? start_transaction+0x192/0x534 [btrfs] [ 55.384543] [] btrfs_commit_transaction+0x4c/0xaba [btrfs] [ 55.384565] [] ? start_transaction+0x192/0x534 [btrfs] [ 55.384588] [] btrfs_sync_file+0x29c/0x310 [btrfs] [ 55.384591] [] vfs_fsync_range+0x8f/0x9e [ 55.384592] [] vfs_fsync+0x1c/0x1e [ 55.384593] [] do_fsync+0x34/0x4e [ 55.384594] [] SyS_fsync+0x10/0x14 [ 55.384595] [] system_call_fastpath+0x12/0x6f [...] [ 55.384608] ---[ end trace c29799da1d4dd621 ]--- [ 55.437323] BTRFS info (device hdb1): forced readonly [ 55.438815] BTRFS info (device hdb1): delayed_refs has NO entry Fix this by reintroducing the no-fail behavior of this allocation path with the explicit __GFP_NOFAIL. Signed-off-by: Michal Hocko Reviewed-by: David Sterba --- fs/btrfs/extent_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index c374e1e71e5f..88fad7051e38 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4607,7 +4607,7 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start, { struct extent_buffer *eb = NULL; - eb = kmem_cache_zalloc(extent_buffer_cache, GFP_NOFS); + eb = kmem_cache_zalloc(extent_buffer_cache, GFP_NOFS|__GFP_NOFAIL); if (eb == NULL) return NULL; eb->start = start; @@ -4867,7 +4867,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, return NULL; for (i = 0; i < num_pages; i++, index++) { - p = find_or_create_page(mapping, index, GFP_NOFS); + p = find_or_create_page(mapping, index, GFP_NOFS|__GFP_NOFAIL); if (!p) goto free_eb;