diff mbox series

[06/11] filemap: Convert filemap_write_and_wait_range() to use errseq

Message ID 20230109051823.480289-7-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Remove AS_EIO and AS_ENOSPC | expand

Commit Message

Matthew Wilcox (Oracle) Jan. 9, 2023, 5:18 a.m. UTC
Use the errseq APIs to discover writeback errors instead of
filemap_check_errors().  This gives us more precise information
about whether this writeback generated the error.  This will no
longer clear errors, so they will be visible to other users, which
is what we want.  Take this opportunity to de-indent
filemap_write_and_wait_range().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/filemap.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

Comments

kernel test robot Jan. 17, 2023, 2:55 a.m. UTC | #1
Greeting,

FYI, we noticed xfstests.generic.475.fail due to commit (built with gcc-11):

commit: f6a6a1bcc3903e3bb50ac4d96e27c56007065646 ("[PATCH 06/11] filemap: Convert filemap_write_and_wait_range() to use errseq")
url: https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/memory-failure-Remove-comment-referencing-AS_EIO/20230109-132009
base: https://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git dev-test
patch link: https://lore.kernel.org/all/20230109051823.480289-7-willy@infradead.org/
patch subject: [PATCH 06/11] filemap: Convert filemap_write_and_wait_range() to use errseq

in testcase: xfstests
version: xfstests-x86_64-fb6575e-1_20230116
with following parameters:

	disk: 4HDD
	fs: ext4
	test: generic-group-23

test-description: xfstests is a regression test suite for xfs and other files ystems.
test-url: git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git


on test machine: 4 threads Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (Skylake) with 32G memory

caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):


If you fix the issue, kindly add following tag
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Link: https://lore.kernel.org/oe-lkp/202301171021.42644ea2-oliver.sang@intel.com


generic/475       [failed, exit status 1]- output mismatch (see /lkp/benchmarks/xfstests/results//generic/475.out.bad)
    --- tests/generic/475.out	2023-01-16 16:39:10.000000000 +0000
    +++ /lkp/benchmarks/xfstests/results//generic/475.out.bad	2023-01-17 02:04:43.317885414 +0000
    @@ -1,2 +1,6 @@
     QA output created by 475
     Silence is golden.
    +mount: /fs/scratch: can't read superblock on /dev/mapper/error-test.
    +mount failed
    +(see /lkp/benchmarks/xfstests/results//generic/475.full for details)
    +umount: /fs/scratch: not mounted.
    ...
    (Run 'diff -u /lkp/benchmarks/xfstests/tests/generic/475.out /lkp/benchmarks/xfstests/results//generic/475.out.bad'  to see the entire diff)


To reproduce:

        git clone https://github.com/intel/lkp-tests.git
        cd lkp-tests
        sudo bin/lkp install job.yaml           # job file is attached in this email
        bin/lkp split-job --compatible job.yaml # generate the yaml file for lkp run
        sudo bin/lkp run generated-yaml-file

        # if come across any failure that blocks the test,
        # please remove ~/.lkp and /lkp dir to run from a clean state.
diff mbox series

Patch

diff --git a/mm/filemap.c b/mm/filemap.c
index 48daedc224d9..c72b2e1140d7 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -659,26 +659,27 @@  EXPORT_SYMBOL_GPL(filemap_range_has_writeback);
 int filemap_write_and_wait_range(struct address_space *mapping,
 				 loff_t lstart, loff_t lend)
 {
-	int err = 0, err2;
+	int err;
+	errseq_t since;
 
 	if (lend < lstart)
 		return 0;
+	if (!mapping_needs_writeback(mapping))
+		return 0;
 
-	if (mapping_needs_writeback(mapping)) {
-		err = __filemap_fdatawrite_range(mapping, lstart, lend,
-						 WB_SYNC_ALL);
-		/*
-		 * Even if the above returned error, the pages may be
-		 * written partially (e.g. -ENOSPC), so we wait for it.
-		 * But the -EIO is special case, it may indicate the worst
-		 * thing (e.g. bug) happened, so we avoid waiting for it.
-		 */
-		if (err != -EIO)
-			__filemap_fdatawait_range(mapping, lstart, lend);
-	}
-	err2 = filemap_check_errors(mapping);
+	since = filemap_sample_wb_err(mapping);
+	err = __filemap_fdatawrite_range(mapping, lstart, lend, WB_SYNC_ALL);
+	/*
+	 * Even if the above returned an error, the pages may be written
+	 * partially (e.g. -ENOSPC), so we wait for it.  But the -EIO
+	 * is a special case, it may indicate the worst thing (e.g. bug)
+	 * happened, so we avoid waiting for it.
+	 */
+	if (err != -EIO)
+		__filemap_fdatawait_range(mapping, lstart, lend);
 	if (!err)
-		err = err2;
+		err = filemap_check_wb_err(mapping, since);
+
 	return err;
 }
 EXPORT_SYMBOL(filemap_write_and_wait_range);