Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2342375imm; Thu, 7 Jun 2018 09:04:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJCXPClnPyk1uNojf8bzvpCVTnMWRI3pb9y/wNUrTs8YJUek3r5ZdT77MIYQew7pEv+ed+h X-Received: by 2002:a17:902:5501:: with SMTP id f1-v6mr2672594pli.108.1528387470471; Thu, 07 Jun 2018 09:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528387470; cv=none; d=google.com; s=arc-20160816; b=DKuchHzPXhnamM0pLxCqE3ZGs1X8/qYCeQP1L051QFOaGEXkGV33vDtOgyNCsZOYwy C4QL8LTskb5Ow6fH4KdTKo/s15sqIVe8ZemSLOExKgMKnF945QFrhLJBgGHQKSufIGp7 HLiFe3UdRkZCZo1VJQuw16HWqsxE2d6vaUbrrYEETfrFP3BpIQ+WV4SNRgYjWzmx+hjj aHhkvmk2WYCfVs3ctR9XOht1AkKaejNVGV0HWKtY5sR9MNs84d99h1MHK5l/uj4Fy/wK lKkDVvIhucFWsvOfiynIlIGBjHgwfLa/oJYH3Zpht7lYSZiQwj0sW/N1JYDna0y5APxL +mqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=FCLhVONBSwys3DMhcAHP+DbvDDPfcqqdmO+FDzOTOYY=; b=yaCnrnKLbGLJkCJ2qts2gozYkXqUXRaDZ5IEjo4XCbmOGlDj2c/5W/DPk3fUCtl9al TdA5wBa8fcg1QmuaVtD6R2U0iLKcKmeC3hLNXdrULt4RU4p4hnAYRPJoiMvslVDTuTcC DMAMocq4GA9FH/saEuyCT+kpwnIo/zDOhNZeOaGX7aFPwG9VMoVxmT0hhWINhntq8soP SZkdPI758yc6Wa5dkY2MC8QjPyQbBc2q5BdRoyitkQxHywkPfgxEY18QmuJwcYKnSLK2 kAyxgF9jiUxtWH9Kf4zdEZguYuL9EYpwoOmQ33kf6JkLlviq5MNyv6z+EBEkQWxYVgd3 l4qw== 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 p9-v6si52148234pls.460.2018.06.07.09.04.14; Thu, 07 Jun 2018 09:04:30 -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 S935384AbeFGQAg (ORCPT + 99 others); Thu, 7 Jun 2018 12:00:36 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39341 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933047AbeFGOJH (ORCPT ); Thu, 7 Jun 2018 10:09:07 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvb7-0005Zl-Jk; Thu, 07 Jun 2018 15:09:05 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb3-0002vg-T5; Thu, 07 Jun 2018 15:09:01 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Qu Wenruo" , "Nikolay Borisov" , "David Sterba" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 159/410] btrfs: Handle btrfs_set_extent_delalloc failure in fixup worker In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 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 [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- fs/btrfs/inode.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1847,7 +1847,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: