[1/4] libxfs: libxfs_buf_delwri_submit should write buffers immediately
diff mbox series

Message ID 158086365123.2079905.12151913907904621987.stgit@magnolia
State Superseded
Headers show
Series
  • libxfs: actually check that writes succeeded
Related show

Commit Message

Darrick J. Wong Feb. 5, 2020, 12:47 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

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 <darrick.wong@oracle.com>
---
 libxfs/rdwr.c   |    3 ++-
 mkfs/xfs_mkfs.c |   16 ++++++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)

Comments

Allison Collins Feb. 6, 2020, 7:37 p.m. UTC | #1
On 2/4/20 5:47 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> 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 <darrick.wong@oracle.com>
Looks ok to me:
Reviewed-by: Allison Collins <allison.henderson@oracle.com>

> ---
>   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 0d9d7202..2e9f66cc 100644
> --- a/libxfs/rdwr.c
> +++ b/libxfs/rdwr.c
> @@ -1491,9 +1491,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 5a042917..1f5d2105 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -3685,6 +3685,7 @@ main(
>   	};
>   
>   	struct list_head	buffer_list;
> +	int			error;
>   
>   	platform_uuid_generate(&cli.uuid);
>   	progname = basename(argv[0]);
> @@ -3885,16 +3886,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);
>   	}
>   
>
Christoph Hellwig Feb. 17, 2020, 1:57 p.m. UTC | #2
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

But can we come up with a better name and description for
libxfs_writebufr? and libxfs_writebuf?
Darrick J. Wong Feb. 19, 2020, 5:42 a.m. UTC | #3
On Mon, Feb 17, 2020 at 05:57:11AM -0800, Christoph Hellwig wrote:
> Looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> But can we come up with a better name and description for
> libxfs_writebufr? and libxfs_writebuf?

I'll fix both of those warts in the next cleanup series, for which I'm
running one more overnight fstests run.

In the meantime, thanks for reviewing these three series!

--D

Patch
diff mbox series

diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 0d9d7202..2e9f66cc 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -1491,9 +1491,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 5a042917..1f5d2105 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3685,6 +3685,7 @@  main(
 	};
 
 	struct list_head	buffer_list;
+	int			error;
 
 	platform_uuid_generate(&cli.uuid);
 	progname = basename(argv[0]);
@@ -3885,16 +3886,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);
 	}