Received: by 10.192.165.156 with SMTP id m28csp1136207imm; Wed, 11 Apr 2018 13:06:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/4ITq1fVWPAXiWhqPHKcsFp8fr73telRHARYHPJspRfHUYUbf91QEKpnoRPHLpqmrPRXin X-Received: by 10.99.151.74 with SMTP id d10mr4352170pgo.171.1523477206499; Wed, 11 Apr 2018 13:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523477206; cv=none; d=google.com; s=arc-20160816; b=sNG0Lcqg/Y0nkqWQCuZSU498PpIls7kjNUSd33j8EqG/I3o3d0gM5t+3ygFvItXgd1 cg2guYd1lPNMvt2AU3MeSzx19LycSev9/bzw1lzxpBoAn6XjB0Jzhr69xr7VZ/2zW9hq fwzEDd5q6C09Q9gotEOxnl+/hKsC6nGrnB3x3c0YpNUfIfuFsNo717sxCYd8vMd48dC3 YTYC5F0ZZQuz8AFdokkKwTILOzoQY5ETXOOjcQ9Y7wigcdNBmiOREjndvU9Ompckiff0 MwKBNQLJrL0yDgIaRzYHc+9mdjSkmItJD8b7X5cbp5KEEX90y7Aamiv2bRbCWbmZ6UlR bGCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Lhkpoewnm15dX6rH0dDTRkiMPH+u5KXc/mXVk7niodI=; b=piSS7qA2AG5Oh8/uBfy0gesZQF9BNbaR1kOj1/R6ut1Z8ZYmSuS07hvPhPNg0G4zK9 KvaNxcfDUcV1hJ3F8y/EG+P/CzHJAaZQs8Xvpr9k46Eij+X4jR7OJzx/CK4V552facoo fvW+Q5gXBjlAM8hKrAh+aqwLqvAdIV42+Ep36ruD7vK2jcgEvFi/cqPMpQChHYiEK7CH 9cP9NuU3y4Sf/JPToMNIfUwu5KTRNr3uWHV3kcYb39WikgnpFTIuu6NiG1AnopvAdtAH ImqOTsWINsr/aspAuVSybDecaDPspPmDRxVjvu8Zevu61N/l26lhZlKh4MXWoWMCzQTA 9MTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7-v6si1727159plq.187.2018.04.11.13.06.09; Wed, 11 Apr 2018 13:06:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756669AbeDKUBz (ORCPT + 99 others); Wed, 11 Apr 2018 16:01:55 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35764 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933866AbeDKS4V (ORCPT ); Wed, 11 Apr 2018 14:56:21 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D6EB5C03; Wed, 11 Apr 2018 18:56:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konstantin Khlebnikov , Theodore Tso , Sasha Levin Subject: [PATCH 4.9 086/310] ext4: handle the rest of ext4_mb_load_buddy() ENOMEM errors Date: Wed, 11 Apr 2018 20:33:45 +0200 Message-Id: <20180411183625.973364202@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konstantin Khlebnikov [ Upstream commit 9651e6b2e20648d04d5e1fe6479a3056047e8781 ] I've got another report about breaking ext4 by ENOMEM error returned from ext4_mb_load_buddy() caused by memory shortage in memory cgroup. This time inside ext4_discard_preallocations(). This patch replaces ext4_error() with ext4_warning() where errors returned from ext4_mb_load_buddy() are not fatal and handled by caller: * ext4_mb_discard_group_preallocations() - called before generating ENOSPC, we'll try to discard other group or return ENOSPC into user-space. * ext4_trim_all_free() - just stop trimming and return ENOMEM from ioctl. Some callers cannot handle errors, thus __GFP_NOFAIL is used for them: * ext4_discard_preallocations() * ext4_mb_discard_lg_preallocations() Fixes: adb7ef600cc9 ("ext4: use __GFP_NOFAIL in ext4_free_blocks()") Signed-off-by: Konstantin Khlebnikov Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/ext4/mballoc.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3877,7 +3877,8 @@ ext4_mb_discard_group_preallocations(str err = ext4_mb_load_buddy(sb, group, &e4b); if (err) { - ext4_error(sb, "Error loading buddy information for %u", group); + ext4_warning(sb, "Error %d loading buddy information for %u", + err, group); put_bh(bitmap_bh); return 0; } @@ -4034,10 +4035,11 @@ repeat: BUG_ON(pa->pa_type != MB_INODE_PA); group = ext4_get_group_number(sb, pa->pa_pstart); - err = ext4_mb_load_buddy(sb, group, &e4b); + err = ext4_mb_load_buddy_gfp(sb, group, &e4b, + GFP_NOFS|__GFP_NOFAIL); if (err) { - ext4_error(sb, "Error loading buddy information for %u", - group); + ext4_error(sb, "Error %d loading buddy information for %u", + err, group); continue; } @@ -4293,11 +4295,14 @@ ext4_mb_discard_lg_preallocations(struct spin_unlock(&lg->lg_prealloc_lock); list_for_each_entry_safe(pa, tmp, &discard_list, u.pa_tmp_list) { + int err; group = ext4_get_group_number(sb, pa->pa_pstart); - if (ext4_mb_load_buddy(sb, group, &e4b)) { - ext4_error(sb, "Error loading buddy information for %u", - group); + err = ext4_mb_load_buddy_gfp(sb, group, &e4b, + GFP_NOFS|__GFP_NOFAIL); + if (err) { + ext4_error(sb, "Error %d loading buddy information for %u", + err, group); continue; } ext4_lock_group(sb, group); @@ -5117,8 +5122,8 @@ ext4_trim_all_free(struct super_block *s ret = ext4_mb_load_buddy(sb, group, &e4b); if (ret) { - ext4_error(sb, "Error in loading buddy " - "information for %u", group); + ext4_warning(sb, "Error %d loading buddy information for %u", + ret, group); return ret; } bitmap = e4b.bd_bitmap;