From d73b61f996a28411ebac4ace9d45d5fee9acb364 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Sun, 1 Mar 2020 12:33:38 -0500 Subject: [PATCH] libxfs: libxfs_buf_delwri_submit should write buffers immediately The whole point of libxfs_buf_delwri_submit is to submit a bunch of buffers for write and wait for the response. Unfortunately, while it does mark the buffers dirty, it doesn't actually flush them and lets the cache mru flusher do it. This is inconsistent with the kernel API, which actually writes the buffers and returns any IO errors. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- libxfs/rdwr.c | 3 ++- mkfs/xfs_mkfs.c | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index e2d9d7904..92281d586 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -1498,9 +1498,10 @@ xfs_buf_delwri_submit( list_for_each_entry_safe(bp, n, buffer_list, b_list) { list_del_init(&bp->b_list); - error2 = libxfs_writebuf(bp, 0); + error2 = libxfs_writebufr(bp); if (!error) error = error2; + libxfs_putbuf(bp); } return error; diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index d3b36756a..e303519a1 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3640,6 +3640,7 @@ main( }; struct list_head buffer_list; + int error; platform_uuid_generate(&cli.uuid); progname = basename(argv[0]); @@ -3840,16 +3841,19 @@ main( if (agno % 16) continue; - if (libxfs_buf_delwri_submit(&buffer_list)) { - fprintf(stderr, _("%s: writing AG headers failed\n"), - progname); + error = -libxfs_buf_delwri_submit(&buffer_list); + if (error) { + fprintf(stderr, + _("%s: writing AG headers failed, err=%d\n"), + progname, error); exit(1); } } - if (libxfs_buf_delwri_submit(&buffer_list)) { - fprintf(stderr, _("%s: writing AG headers failed\n"), - progname); + error = -libxfs_buf_delwri_submit(&buffer_list); + if (error) { + fprintf(stderr, _("%s: writing AG headers failed, err=%d\n"), + progname, error); exit(1); } -- 2.49.0