Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4837340pxj; Wed, 9 Jun 2021 03:09:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBhWk9lTTMCx+RpjA+nZ89++b042Mhy5fY/bZ7SXoBoiV/ihkJwOZowC4SPjS+Aodaa8Ge X-Received: by 2002:a17:906:988a:: with SMTP id zc10mr27341060ejb.62.1623233348806; Wed, 09 Jun 2021 03:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623233348; cv=none; d=google.com; s=arc-20160816; b=raHvwKqAoToiYAjbRvphYXVNhbPiRWvvrcYCIn8alW+h9I3VXfhtWC2bvWtVCUN4sG AeFFNt3P3S5L7u7ik4LsGQpSTmexUBL7zZzP3uySVwsvx8KU8KK3QsNqgfJgoScPQkvc ZjjzMtoitcgsuojOo5+61FJzHPka0zKxqZuqQyZF0rYWM0zBBKTcSh8/5EemhtiupiHp QsD+BnMV85u68A5zbg7g6CInGvLjq5FjxCAtuw/wQN45zHQZj0S88mYGGdqn3N6dyHIq hDklYN5Fd4rPijXvmib7Q+/qUnKGgSMgMPJCAQRULQbEkFF0jnPZ3zvpFdaOvG15t+la GhAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iG3i+TJS/eSmdvB+uiQRSL+xLpzJ6dBROaRPH6mmVn4=; b=DETLn9p/jZY52dyH3TW2tHtUjW1KNxAy9wVz1EJzCYp3LDMbJaN62937467fYOfWTH SIvj6zYp2kfP0bKOn53ki8sL7bI1eELLET051oltulzWsyAeflDz1fiXDTeD/nNN3JQ2 j2ASihistndshQLr/aKGW0x6ML9QxR3CgZxOSid/rPnnamf2a0J0aSAr2B5oVublYeZZ /RnSXXcDCr8weMWFlvEERWh0NMDcd/ooWKIsNUhV4vHPjY4mgQDmLRMCEMeGsb+a0Rht 8wFHFeB/r3MZIdAIV3jxSCKY7ZjvE6RO/P97Kq27TPPNcmunq7J142Lsd+7fPEByFXQ2 l0LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oHPBVsF7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si2179560eje.501.2021.06.09.03.08.45; Wed, 09 Jun 2021 03:09:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oHPBVsF7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235588AbhFHSwT (ORCPT + 99 others); Tue, 8 Jun 2021 14:52:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:42132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235109AbhFHSqt (ORCPT ); Tue, 8 Jun 2021 14:46:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D255A61452; Tue, 8 Jun 2021 18:37:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177459; bh=FulF1Xb9hlzLZfuiYiFX5B6zWG5zxUaEkZhB++mYu2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oHPBVsF7l47zIndvxpMPOLb92H03JBl4nywAA3gRSqTU50gLC3Lz+UHP+pTT9+t+a JnLH6zdZnRfTHDBrTwch/1icaAdVqVOIHeWa5tGMT0ObB1NtCyZBVanD1Wy6Bt2CqL S4h0dDuKwhcT6CPaq2OuHWxWGYq5GMkD9uPioOFc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef Bacik , David Sterba Subject: [PATCH 5.4 59/78] btrfs: mark ordered extent and inode with error if we fail to finish Date: Tue, 8 Jun 2021 20:27:28 +0200 Message-Id: <20210608175937.268335857@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175935.254388043@linuxfoundation.org> References: <20210608175935.254388043@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Bacik commit d61bec08b904cf171835db98168f82bc338e92e4 upstream. While doing error injection testing I saw that sometimes we'd get an abort that wouldn't stop the current transaction commit from completing. This abort was coming from finish ordered IO, but at this point in the transaction commit we should have gotten an error and stopped. It turns out the abort came from finish ordered io while trying to write out the free space cache. It occurred to me that any failure inside of finish_ordered_io isn't actually raised to the person doing the writing, so we could have any number of failures in this path and think the ordered extent completed successfully and the inode was fine. Fix this by marking the ordered extent with BTRFS_ORDERED_IOERR, and marking the mapping of the inode with mapping_set_error, so any callers that simply call fdatawait will also get the error. With this we're seeing the IO error on the free space inode when we fail to do the finish_ordered_io. CC: stable@vger.kernel.org # 4.19+ Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/inode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3359,6 +3359,18 @@ out: if (ret || truncated) { u64 start, end; + /* + * If we failed to finish this ordered extent for any reason we + * need to make sure BTRFS_ORDERED_IOERR is set on the ordered + * extent, and mark the inode with the error if it wasn't + * already set. Any error during writeback would have already + * set the mapping error, so we need to set it if we're the ones + * marking this ordered extent as failed. + */ + if (ret && !test_and_set_bit(BTRFS_ORDERED_IOERR, + &ordered_extent->flags)) + mapping_set_error(ordered_extent->inode->i_mapping, -EIO); + if (truncated) start = ordered_extent->file_offset + logical_len; else