All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] aio-dio-eof-race: handle aio pwrite errors and short reads
@ 2018-04-12  5:07 Omar Sandoval
  2018-04-12  5:07 ` [PATCH v2 2/2] common/rc: raise mixed mode threshold to 1GB Omar Sandoval
  0 siblings, 1 reply; 3+ messages in thread
From: Omar Sandoval @ 2018-04-12  5:07 UTC (permalink / raw
  To: linux-btrfs, fstests, Eryu Guan; +Cc: kernel-team

From: Omar Sandoval <osandov@fb.com>

generic/427 fails on Btrfs with a cryptic "pread: Success" message. This
is because an aio pwrite fails with ENOSPC, so the file isn't as long as
we expect it to be. Make sure we check the result of the aio writes and
also print a more explicit message for short reads (which are
technically valid but in practice shouldn't happen for this test case).
Now the test fails with a much more informative "pwrite: No space left
on device".

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 src/aio-dio-regress/aio-dio-eof-race.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/aio-dio-regress/aio-dio-eof-race.c b/src/aio-dio-regress/aio-dio-eof-race.c
index bb1890b5..04479035 100644
--- a/src/aio-dio-regress/aio-dio-eof-race.c
+++ b/src/aio-dio-regress/aio-dio-eof-race.c
@@ -154,6 +154,9 @@ int main(int argc, char *argv[])
 
 	/* Keep extending until size_MB */
 	while (eof < size_MB * 1024 * 1024) {
+		ssize_t sret;
+		int i;
+
 		memset(buf, IO_PATTERN, buf_size);
 		fstat(fd, &statbuf);
 		eof = statbuf.st_size;
@@ -186,15 +189,32 @@ int main(int argc, char *argv[])
 			return 1;
 		}
 
+		for (i = 0; i < err; i++) {
+			/*
+			 * res is unsigned for some reason, so this is the best
+			 * way to detect that it contains a negative errno.
+			 */
+			if (evs[i].res > buf_size / 4) {
+				fprintf(stderr, "pwrite: %s\n",
+					strerror(-evs[i].res));
+				return 1;
+			}
+		}
+
 		/*
 		 * And then read it back.
 		 *
 		 * Using pread to keep it simple, but AIO has the same effect.
 		 * eof is the prior eof; we just wrote buf_size more.
 		 */
-		if (pread(fd, buf, buf_size, eof) != buf_size) {
+		sret = pread(fd, buf, buf_size, eof);
+		if (sret == -1) {
 			perror("pread");
 			return 1;
+		} else if (sret != buf_size) {
+			fprintf(stderr, "short read %zd was less than %zu\n",
+				sret, buf_size);
+			return 1;
 		}
 
 		/*
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] common/rc: raise mixed mode threshold to 1GB
  2018-04-12  5:07 [PATCH v2 1/2] aio-dio-eof-race: handle aio pwrite errors and short reads Omar Sandoval
@ 2018-04-12  5:07 ` Omar Sandoval
  2018-04-12  5:53   ` Dave Chinner
  0 siblings, 1 reply; 3+ messages in thread
From: Omar Sandoval @ 2018-04-12  5:07 UTC (permalink / raw
  To: linux-btrfs, fstests, Eryu Guan; +Cc: kernel-team

From: Omar Sandoval <osandov@fb.com>

generic/427 creates a 256 MB filesystem and then writes a 200 MB file,
which fails on Btrfs if mixed mode is not enabled. Raise the threshold
to 1GB, which is where we typically recommend mixed mode.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 common/rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/rc b/common/rc
index 5dbb8fe5..dc0062de 100644
--- a/common/rc
+++ b/common/rc
@@ -999,7 +999,7 @@ _scratch_mkfs_sized()
 	;;
     btrfs)
 	local mixed_opt=
-	(( fssize <= 100 * 1024 * 1024 )) && mixed_opt='--mixed'
+	(( fssize <= 1024 * 1024 * 1024 )) && mixed_opt='--mixed'
 	$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
 	;;
     jfs)
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/2] common/rc: raise mixed mode threshold to 1GB
  2018-04-12  5:07 ` [PATCH v2 2/2] common/rc: raise mixed mode threshold to 1GB Omar Sandoval
@ 2018-04-12  5:53   ` Dave Chinner
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2018-04-12  5:53 UTC (permalink / raw
  To: Omar Sandoval; +Cc: linux-btrfs, fstests, Eryu Guan, kernel-team

On Wed, Apr 11, 2018 at 10:07:29PM -0700, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> generic/427 creates a 256 MB filesystem and then writes a 200 MB file,
> which fails on Btrfs if mixed mode is not enabled. Raise the threshold
> to 1GB, which is where we typically recommend mixed mode.
> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>
> ---
>  common/rc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/rc b/common/rc
> index 5dbb8fe5..dc0062de 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -999,7 +999,7 @@ _scratch_mkfs_sized()
>  	;;
>      btrfs)
>  	local mixed_opt=
> -	(( fssize <= 100 * 1024 * 1024 )) && mixed_opt='--mixed'
> +	(( fssize <= 1024 * 1024 * 1024 )) && mixed_opt='--mixed'
>  	$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
>  	;;
>      jfs)

Makes sense.

Reviewed-by: Dave Chinner <dchinner@redhat.com>

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-12  5:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-12  5:07 [PATCH v2 1/2] aio-dio-eof-race: handle aio pwrite errors and short reads Omar Sandoval
2018-04-12  5:07 ` [PATCH v2 2/2] common/rc: raise mixed mode threshold to 1GB Omar Sandoval
2018-04-12  5:53   ` Dave Chinner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.