Received: by 10.223.185.116 with SMTP id b49csp2216254wrg; Thu, 15 Feb 2018 08:14:26 -0800 (PST) X-Google-Smtp-Source: AH8x225yaGoVc5nlY86Q0dLh3RDDJnekEXutzXwcu1IJS1YJFNMB8fAr+uhoq2jrSYVNWDoGUiG1 X-Received: by 2002:a17:902:4d46:: with SMTP id o6-v6mr2957339plh.166.1518711266768; Thu, 15 Feb 2018 08:14:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518711266; cv=none; d=google.com; s=arc-20160816; b=B8UCrtudVUCMRX0eDOibVKim/ZqSPca3DGUluMQ+MIZQEBv1XlcSPkq0/lcUBX2qCe wlOOxt+r1DhrDjOMM4Qbs9aeK8Qre3GDl210nVNXVs141JeGOnMNyZzSdV5Yl6Z0P2IM 8Iawz59zPb3alXto41TEANzJCtDIksmi+dSM3kFZNpmiGPGOuB+JjAkQsJlB5c3lKUzq pZ8vlT86z7zak89P0lUlyL/JevG99goNnrhj63cTnox8Lpmn6i3JfNcqRBZEmFAGUjO1 RB32libc/4MJtB44MBROVEbplvqnKeTcDdm07KXWlXEvc6Ykvc8rISN0tOlNYiVc3ZTQ ExNw== 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=I+0/ZHKDCH/A3penlwhp5kXEuSfYDrvOQJglVeDvWMk=; b=klbUJ86LzW0RJvPdqVvVcZcUCDPHbcu+0U92zQs2FbDmiAl4j8nbx3JYo0fIuJLkbp PcZdq8VZqTsfjjD64ABUA0WvR5MpZwL3t8uM1jGJVLlBol7befZMg33VPc/NWRTj/ktO E7/XcpGsrNAIDB+8r1uCYFHtMv9yACEBtrfNuepecHvftkUho9zxDNRkSq3cVOvksIBW L9bIIfjdCgZgZbrx6x8i1zi869lplx1KgDk6HaaTZeDPjTUQtEEQZg8k3MhSWzwr+tMn HMelAozOI8CBxoyjfQdCmI3b7TuOfpqlTVaRNFj8IhKU9Bnv275ahsJ6MA8CRI/l9c4j D9iA== 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 t6si16360pgc.749.2018.02.15.08.14.10; Thu, 15 Feb 2018 08:14:26 -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 S1425604AbeBOQLg (ORCPT + 99 others); Thu, 15 Feb 2018 11:11:36 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34890 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424433AbeBOPpS (ORCPT ); Thu, 15 Feb 2018 10:45:18 -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 9432211BF; Thu, 15 Feb 2018 15:45:17 +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.15 146/202] btrfs: Handle btrfs_set_extent_delalloc failure in fixup worker Date: Thu, 15 Feb 2018 16:17:26 +0100 Message-Id: <20180215151720.664579239@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2098,8 +2098,15 @@ again: goto out; } - btrfs_set_extent_delalloc(inode, page_start, page_end, 0, &cached_state, - 0); + ret = btrfs_set_extent_delalloc(inode, page_start, page_end, 0, + &cached_state, 0); + 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); btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE);