Received: by 10.223.185.116 with SMTP id b49csp685596wrg; Fri, 16 Feb 2018 05:39:59 -0800 (PST) X-Google-Smtp-Source: AH8x227ub2f4t/D7ecGaqRfHBGCoszbx0I7hrc4IpIUdn/FXUup2uAyLld1O2EnEiBl7WuUrZVBp X-Received: by 2002:a17:902:6985:: with SMTP id l5-v6mr6120619plk.14.1518788399220; Fri, 16 Feb 2018 05:39:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518788399; cv=none; d=google.com; s=arc-20160816; b=CtD6E3IzDkoCnNjTlMm2NqggelLi2iRVWG2uqrlEMs8MWVKi/wbiI98j3+fDmFUn5e k4GUGauaP6pKeSUoasBnl6P9hMrRRIX+v6bdqD7Yr/dYWN8mF1hr/c1z5VQBdNbugX5M IlT7aPOI/dTQokjoEgMDY+H8o79FHebJKiMWuGswDheVd7t2f+wPzXO8Rszu1YVH/l4r OQDmYyjoyEgu4fcbthtZTUUYtKM6/99E6m1lTBhrPNp1BYRRaqZBIqMOlZtYXKrM4FhT mGRi1IaENJFLRHAyJMk9cZu7i+twd8/btxeczAmsJCrLLrl3AsV/PY3hDhZ7hcS/glTs Am9Q== 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=+ytpOuzdMSWEaW4v30u2zoKUKViXb3qAuxlhWMa5jXQ=; b=YYlm23CbBMvzArn38jmQn/Hday5FyBoJmtBb//wsYmoTbwjL3BinehxXPzsGL5EVPk uqElJ4uuJGejo/60hhHjjHjbXimmti8H25+5pPC3iiXotRUtH02bbZ04w8jTb2nPipLC O88ohYux6b21YikJZKQuGnBBmk6K6oJTMTN9Tj2QkWkNSuZCpTqXxKbp43RWIeVorc8R k9eAwSl6snHexGPmizLMt925OilqYbIsY+mACYr9NLG2WEi2E2UuG/0RR4mSgrYqx938 LaIR8qKZpq29YP1nStjz2cGLwQQykLkrqT112v5LiE/MvJI9rjoQ/VG3c/eQ43ubWOrK 9u/g== 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 44-v6si3104808plb.40.2018.02.16.05.39.32; Fri, 16 Feb 2018 05:39:59 -0800 (PST) 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 S1166535AbeBOSbP (ORCPT + 99 others); Thu, 15 Feb 2018 13:31:15 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52044 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163046AbeBOPZB (ORCPT ); Thu, 15 Feb 2018 10:25:01 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1633F102A; Thu, 15 Feb 2018 15:25:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Qu Wenruo , David Sterba Subject: [PATCH 4.4 103/108] btrfs: Handle btrfs_set_extent_delalloc failure in fixup worker Date: Thu, 15 Feb 2018 16:17:40 +0100 Message-Id: <20180215151236.655363934@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.267507937@linuxfoundation.org> References: <20180215151222.267507937@linuxfoundation.org> User-Agent: quilt/0.65 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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikolay Borisov commit f3038ee3a3f1017a1cbe9907e31fa12d366c5dcb upstream. This function was introduced by 247e743cbe6e ("Btrfs: Use async helpers to deal with pages that have been improperly dirtied") and it didn't do any error handling then. This function might very well fail in ENOMEM situation, yet it's not handled, this could lead to inconsistent state. So let's handle the failure by setting the mapping error bit. Signed-off-by: Nikolay Borisov Reviewed-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/inode.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2015,7 +2015,15 @@ again: goto out; } - btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state); + ret = btrfs_set_extent_delalloc(inode, page_start, page_end, + &cached_state); + if (ret) { + mapping_set_error(page->mapping, ret); + end_extent_writepage(page, ret, page_start, page_end); + ClearPageChecked(page); + goto out; + } + ClearPageChecked(page); set_page_dirty(page); out: