Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2656766pxa; Mon, 17 Aug 2020 15:42:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSL7mz2LgTDNO6u8ARqwUbVXLiprv9lwwJ+KAt7kjSi5Zrh+Zxk2tntdnIhqRdSjRTUM/M X-Received: by 2002:a17:906:3cc:: with SMTP id c12mr16725718eja.222.1597704131181; Mon, 17 Aug 2020 15:42:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704131; cv=none; d=google.com; s=arc-20160816; b=n6NROVWJeZ31xjeRJjB2RTQ9/cxOK+MfxcDy4FJ2cwnx45Jg4XsIQ1eS0KtzugA2Ju 3MXqp3zSt9N3gtnXkCaUkPTus226AHXYktlS7sdL+/DgNU6ipIPeE41Tnc+d9pPWxG8o k+vNPogjCgJmdn5eUa5v6acWm/4ly34Wbjlc9kHtdhPkqAZB0BiSGi+tvelfPWRwYtLv ctKcudeoQjo1aHHoCF3SnTJ6F4alAoEC9RDtYuZEuwWMMRubUfzSWxljo/a/yfi5ogMP RQWcIBS5sQuSlJ878pRGnFvnmBT2FoUhMnSvLPEZ4Z7edUbf0hBssokQ5LT/Ye5vNp1g rTww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uDQEN7ibMsvxJEHhes30B0/hZ1O43CctW7fn6eTj5e4=; b=RZ2adFyGFPT3CjghbmhtXx6/9c5gF6MmJrTM4tkaN6VgSFoOlMFktcS1qlKIPo/Ltf DKGJ/rCGD2x+e/5UEZbAl6Hiqqh4tl8Fw8Unc/pWyGnImBD7FCZNKCIamgRH0LOtezn1 +4xbIX9JI8lL1lzMHRew7ah4DKg+MRBa9CCYpnwwkIlf97SbonMZU/WhbknNaFWM+YtA bdQuPEXPGqq+/sMW+bnfm+KtkmJpvhMllEwaEQd9xztMrAJz5bu6DwZ2xL086HWjIill EX2Q60ZwZvtm3eZ/0UWmVyCkRnK3w0vV6TzW5hJb974rKrBi5mfPOR069QFgSb4r3wn3 JvkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EEz5+yrd; 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=fail (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 y5si11063683eje.702.2020.08.17.15.41.47; Mon, 17 Aug 2020 15:42:11 -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=@kernel.org header.s=default header.b=EEz5+yrd; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390198AbgHQSTF (ORCPT + 99 others); Mon, 17 Aug 2020 14:19:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:53176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388368AbgHQQFf (ORCPT ); Mon, 17 Aug 2020 12:05:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3FE032063A; Mon, 17 Aug 2020 16:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680331; bh=4DXY1vXP3gHlxRm6MrXusWr04+KdDQZB2L/sqduC1dQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EEz5+yrd4yver8zUmMt0BTLX2xQrTERPDxCoOJmHAPGdo2gZ2JOIfAf4d9imBQvki NChdor07T2n/h2kCyeercD1GK+TJdoiwPFV8722S0ydyreLzXFpFBHLCRNxRQF0jRf rZ0KdqhW/xSFa3LlHjadwkU7tdw7rWMaXDxO9fmA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Brian Foster , Dave Chinner , Sasha Levin Subject: [PATCH 5.4 127/270] xfs: dont eat an EIO/ENOSPC writeback error when scrubbing data fork Date: Mon, 17 Aug 2020 17:15:28 +0200 Message-Id: <20200817143802.108023009@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Darrick J. Wong [ Upstream commit eb0efe5063bb10bcb653e4f8e92a74719c03a347 ] The data fork scrubber calls filemap_write_and_wait to flush dirty pages and delalloc reservations out to disk prior to checking the data fork's extent mappings. Unfortunately, this means that scrub can consume the EIO/ENOSPC errors that would otherwise have stayed around in the address space until (we hope) the writer application calls fsync to persist data and collect errors. The end result is that programs that wrote to a file might never see the error code and proceed as if nothing were wrong. xfs_scrub is not in a position to notify file writers about the writeback failure, and it's only here to check metadata, not file contents. Therefore, if writeback fails, we should stuff the error code back into the address space so that an fsync by the writer application can pick that up. Fixes: 99d9d8d05da2 ("xfs: scrub inode block mappings") Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Dave Chinner Signed-off-by: Sasha Levin --- fs/xfs/scrub/bmap.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c index fa6ea6407992a..392fb4df5c127 100644 --- a/fs/xfs/scrub/bmap.c +++ b/fs/xfs/scrub/bmap.c @@ -45,9 +45,27 @@ xchk_setup_inode_bmap( */ if (S_ISREG(VFS_I(sc->ip)->i_mode) && sc->sm->sm_type == XFS_SCRUB_TYPE_BMBTD) { + struct address_space *mapping = VFS_I(sc->ip)->i_mapping; + inode_dio_wait(VFS_I(sc->ip)); - error = filemap_write_and_wait(VFS_I(sc->ip)->i_mapping); - if (error) + + /* + * Try to flush all incore state to disk before we examine the + * space mappings for the data fork. Leave accumulated errors + * in the mapping for the writer threads to consume. + * + * On ENOSPC or EIO writeback errors, we continue into the + * extent mapping checks because write failures do not + * necessarily imply anything about the correctness of the file + * metadata. The metadata and the file data could be on + * completely separate devices; a media failure might only + * affect a subset of the disk, etc. We can handle delalloc + * extents in the scrubber, so leaving them in memory is fine. + */ + error = filemap_fdatawrite(mapping); + if (!error) + error = filemap_fdatawait_keep_errors(mapping); + if (error && (error != -ENOSPC && error != -EIO)) goto out; } -- 2.25.1