All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [patch][xfstests-dev] aiodio_sparse2: fix up alignment for 4k logical block sized devices
@ 2011-02-11 19:08   ` Jeff Moyer
  2011-02-13 12:05     ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Moyer @ 2011-02-11 19:08 UTC (permalink / raw
  To: xfs

Hi,

When running xfstests on a 4k logical sector device, I ran into a test
failure in test 198.  The errors were all due to trying to do 512 byte
aligned I/O on a 4k logical sector device.  The attached patch tries to
auto-detect the proper block size if no alignment is specified.  If it
fails for one reason or another, it defaults to 4k alignment.  This
seems to work fine in my test rig.

Cheers,
Jeff

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

diff --git a/src/aio-dio-regress/aiodio_sparse2.c b/src/aio-dio-regress/aiodio_sparse2.c
index f1225dd..0a96479 100644
--- a/src/aio-dio-regress/aiodio_sparse2.c
+++ b/src/aio-dio-regress/aiodio_sparse2.c
@@ -19,6 +19,8 @@
 #include <limits.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h> // for BLKSSZGET
 
 #include <libaio.h>
 
@@ -274,6 +276,23 @@ void dirty_freeblocks(char *filename, int size)
 	unlink(filename2);
 }
 
+static long get_logical_block_size(char *filename)
+{
+	int fd;
+	int ret;
+	int logical_block_size;
+
+	fd = open(filename, O_RDONLY);
+	if (fd < 0)
+		return 4096;
+
+	ret = ioctl(fd, BLKSSZGET, &logical_block_size);
+	close(fd);
+	if (ret < 0)
+		return 4096;
+	return logical_block_size;
+}
+
 void usage()
 {
 	fprintf(stderr, "usage: dio_sparse [-n step] [-s filesize]"
@@ -314,7 +333,7 @@ long long scale_by_kmg(long long value, char scale)
 int main(int argc, char **argv)
 {
 	char filename[PATH_MAX];
-	long alignment = 512;
+	long alignment = 0;
 	int readsize = 65536;
 	int writesize = 65536;
 	int startoffset = 0;
@@ -376,6 +395,8 @@ int main(int argc, char **argv)
 
 	strncpy(filename, argv[argc-1], PATH_MAX);
 
+	if (alignment == 0)
+		alignment = get_logical_block_size(filename);
 	/*
 	 * Create some dirty free blocks by allocating, writing, syncing,
 	 * and then unlinking and freeing.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [patch][xfstests] 240: only run when the file system block size is larger than the disk sector size
@ 2011-02-11 20:20 ` Jeff Moyer
  2011-02-11 19:08   ` [patch][xfstests-dev] aiodio_sparse2: fix up alignment for 4k logical block sized devices Jeff Moyer
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Moyer @ 2011-02-11 20:20 UTC (permalink / raw
  To: xfs

Hi,

This test really wants to test partial file-system block I/Os.  Thus, if
the device has a 4K sector size, and the file system has a 4K block
size, there's really no point in running the test.  In the attached
patch, I check that the fs block size is larger than the device's
logical block size, which should cover a 4k device block size with a 16k
fs block size.

I verified that the patched test does not run on my 4k sector device
with a 4k file system.  I also verified that it continues to run on a
512 byte logical sector device with a 4k file system block size.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

diff --git a/240 b/240
index 0548536..563449e 100755
--- a/240
+++ b/240
@@ -7,6 +7,9 @@
 # QEMU IO to a file-backed device with misaligned partitions
 # can send this sort of IO
 #
+# This test need only be run in the case where the logical block size
+# of the device can be smaller than the file system block size.
+#
 #-----------------------------------------------------------------------
 # Copyright (c) 2010 Red Hat, Inc.  All Rights Reserved.
 #
@@ -57,8 +60,16 @@ rm -f $seq.full
 
 rm -f $TEST_DIR/aiodio_sparse
 
-# 2 threads, 4k writes, 16k filesize, stride throug file by 4k, start at 512 offset
-$here/src/aio-dio-regress/aiodio_sparse2 -i 2 -w 4k -s 16k -n 4k -o 512 "$TEST_DIR/aiodio_sparse"
+logical_block_size=`blockdev --getss $TEST_DEV`
+fs_block_size=`stat -f $TEST_DIR | grep "Block size:" | awk '{print $3}'`
+
+if [ $fs_block_size -le $logical_block_size ]; then
+	_notrun "fs block size must be larger than the device block size.  fs block size: $fs_block_size, device block size: $logical_block_size"
+fi
+
+# 2 threads, fs block sized writes, 64k filesize, stride through file by
+# fs block size, start at logical block size offset
+$here/src/aio-dio-regress/aiodio_sparse2 -i 2 -w $fs_block_size -s 64k -n $fs_block_size -o $logical_block_size "$TEST_DIR/aiodio_sparse"
 
 status=$?
 exit

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [patch][xfstests-dev] 078: xfs_repair should be run against the losetup'd device, not the image file
@ 2011-02-11 22:04 Jeff Moyer
  2011-02-11 20:20 ` [patch][xfstests] 240: only run when the file system block size is larger than the disk sector size Jeff Moyer
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Moyer @ 2011-02-11 22:04 UTC (permalink / raw
  To: xfs

Hi,

When running test 078 against a 4k logical block sized disk, it fails in
xfs_repair.  The problem is that xfs_repair is passed the loopback
filename instead of the actual loop device.  This means that it opens
the file O_DIRECT, and tries to do 512 byte aligned I/O to a 4k sector
device.  The loop device, for better or for worse, will do buffered I/O,
and thus does not suffer from the same problem.  So, the attached patch
sets up the loop device and passes that to xfs_repair.  This resolves
the issue on my test system.

Comments are more than welcome.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

diff --git a/078 b/078
index b8d9132..5cb66df 100755
--- a/078
+++ b/078
@@ -53,7 +53,7 @@ _supported_os Linux
 # Must have loop device
 _require_loop
 
-LOOP_DEV=$TEST_DIR/$seq.fs
+LOOP_IMG=$TEST_DIR/$seq.fs
 LOOP_MNT=$TEST_DIR/$seq.mnt
 
 _filter_io()
@@ -75,7 +75,7 @@ _grow_loop()
 	check=$4
 	agsize=$5
 
-	dparam="file,name=$LOOP_DEV,size=$original"
+	dparam="file,name=$LOOP_IMG,size=$original"
 	if [ -n "$agsize" ]; then
 		dparam="$dparam,agsize=$agsize"
 	fi
@@ -89,9 +89,9 @@ _grow_loop()
 		| _filter_mkfs 2>/dev/null
 
 	echo "*** extend loop file"
-	$XFS_IO_PROG -c "pwrite $new_size $bsize" $LOOP_DEV | _filter_io
+	$XFS_IO_PROG -c "pwrite $new_size $bsize" $LOOP_IMG | _filter_io
 	echo "*** mount loop filesystem"
-	mount -t xfs -o loop $LOOP_DEV $LOOP_MNT
+	mount -t xfs -o loop $LOOP_IMG $LOOP_MNT
 
 	echo "*** grow loop filesystem"
 	#xfs_growfs $LOOP_MNT 2>&1 | grep -e "^data" #| _filter_growfs 2>/dev/null
@@ -104,10 +104,13 @@ _grow_loop()
 	if [ "$check" -gt "0" ]
 	then
 		echo "*** check"
+		LOOP_DEV=`losetup -f`
+		losetup $LOOP_DEV $LOOP_IMG
 		 _check_xfs_filesystem $LOOP_DEV none none
+		losetup -d $LOOP_DEV
 	fi
 
-	rm -f $LOOP_DEV
+	rm -f $LOOP_IMG
 }
 
 # Wes' problem sizes...

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [patch][xfstests-dev] aiodio_sparse2: fix up alignment for 4k logical block sized devices
  2011-02-11 19:08   ` [patch][xfstests-dev] aiodio_sparse2: fix up alignment for 4k logical block sized devices Jeff Moyer
@ 2011-02-13 12:05     ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2011-02-13 12:05 UTC (permalink / raw
  To: Jeff Moyer; +Cc: xfs

Thanks, applied all three patches.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2011-02-13 12:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-11 22:04 [patch][xfstests-dev] 078: xfs_repair should be run against the losetup'd device, not the image file Jeff Moyer
2011-02-11 20:20 ` [patch][xfstests] 240: only run when the file system block size is larger than the disk sector size Jeff Moyer
2011-02-11 19:08   ` [patch][xfstests-dev] aiodio_sparse2: fix up alignment for 4k logical block sized devices Jeff Moyer
2011-02-13 12:05     ` Christoph Hellwig

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.