Skip to contentSkip to conversation

LVM and XFS cannot set blocksize on block device

DISCUSSION Rene Salmon 5 participants 14 messages Sep 25, 2006 – Oct 11, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

I am trying to create an xfs file system on and LVM logical volume. the actual physical drive has blocks or sectors of 4096.

when I try to make the xfs file system on top of LVM I get this message:

helix-priv:~ # mkfs.xfs -f /dev/vg_u00/lv_u00
mkfs.xfs: warning - cannot set blocksize on block device /dev/vg_u00/lv_u00: Invalid argument
Warning: the data subvolume sector size 512 is less than the sector size reported by the device (4096).

meta-data=/dev/vg_u00/lv_u00     isize=256    agcount=32, agsize=11489280 blks
         =                       sectsz=512   attr=0
data     =                       bsize=4096   blocks=367656960, imaxpct=25
         =                       sunit=0      swidth=0 blks, unwritten=1
naming   =version 2              bsize=4096
log      =internal log           bsize=4096   blocks=32768, version=1
         =                       sectsz=512   sunit=0 blks
realtime =none                   extsz=65536  blocks=0, rtextents=0

helix-priv:~ #

any ideas?

Thanks
Rene

Signature · 10 lines
-
--
        Rene Salmon
        Tulane University
        Center for Computational Science
        http://www.ccs.tulane.edu
	[email protected]
        Tel 504-862-8393
	Tel 504-988-8552
        Fax 504-862-8392
#1 lore raw
Quoted 2 lines · Rene Salmon

Warning: the data subvolume sector size 512 is less than the sector size reported by the device (4096).

does "-s size=4096" help?

#2 lore raw

Hi,

Thanks for the reply. The "-s size=4096" helped I was able to create
the file system, then mount it and use it. I did however get a warning still about "cannot set blocksize on block device". Everything seems to be working but I am a bit worried about the warning message. Following is the message. Any ideas if it is safe to ignore this or any way to get rid of it?

helix-priv:~ # mkfs.xfs -s size=4096 -f /dev/vg_u00/lv_u00
mkfs.xfs: warning - cannot set blocksize on block device /dev/vg_u00/lv_u00: Invalid argument

meta-data=/dev/vg_u00/lv_u00     isize=256    agcount=32, agsize=11489280 blks
         =                       sectsz=4096  attr=0
data     =                       bsize=4096   blocks=367656960, imaxpct=25
         =                       sunit=0      swidth=0 blks, unwritten=1
naming   =version 2              bsize=4096
log      =internal log           bsize=4096   blocks=32768, version=2
         =                       sectsz=4096  sunit=1 blks
realtime =none                   extsz=65536  blocks=0, rtextents=0

Thanks
Rene

Quoted 6 lines · Chris Wedgwood
Quoted 2 lines · Rene Salmon

Warning: the data subvolume sector size 512 is less than the sector size reported by the device (4096).

does "-s size=4096" help?

Signature · 10 lines
-
--
        Rene Salmon
        Tulane University
        Center for Computational Science
        http://www.ccs.tulane.edu
	[email protected]
        Tel 504-862-8393
	Tel 504-988-8552
        Fax 504-862-8392
#3 lore raw
Quoted 3 lines · Rene Salmon

Thanks for the reply. The "-s size=4096" helped I was able to create the file system, then mount it and use it. I did however get a warning still about "cannot set blocksize on block device".

I don't know much about the LVM code, my guess is that ioctl(... ,BLKBSZSET, ...) is failing, strace would confirm this.

Quoted 3 lines

Everything seems to be working but I am a bit worried about the warning message. Following is the message. Any ideas if it is safe to ignore this or any way to get rid of it?

What does:

  blockdev --getbsz /dev/vg_u00/lv_u00

say?

If mkfs.xfs is trying to set a blocksize that already matches the underlying device, it woudn't be hard to silence the warning by doing a check before unconditionally setting it, though I don't know that it's worth it.

#4 lore raw
Quoted 7 lines
Quoted 3 lines

Thanks for the reply. The "-s size=4096" helped I was able to create the file system, then mount it and use it. I did however get a warning still about "cannot set blocksize on block device".

I don't know much about the LVM code, my guess is that ioctl(... ,BLKBSZSET, ...) is failing, strace would confirm this.

libxfs_device_open () seems to be working with the pre-conceived notion of assuming block devices of only 512 bytes in size.

if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK)
platform_set_blocksize(fd, path, statb.st_rdev, 512);

This eventually calls to set the blk sz to 512. Since, your volume does not support less than 4k, it returns EINVAL. I think, libxfs_init should be modified to take pass on the -s size option to this call so that it does not happen.
However, I don't see any problem despite this failure. Everything
else should work fine.

Quoted 18 lines
Quoted 3 lines

Everything seems to be working but I am a bit worried about the warning message. Following is the message. Any ideas if it is safe to ignore this or any way to get rid of it?

What does:

  blockdev --getbsz /dev/vg_u00/lv_u00

say?

If mkfs.xfs is trying to set a blocksize that already matches the underlying device, it woudn't be hard to silence the warning by doing a check before unconditionally setting it, though I don't know that it's worth it.

#5 lore raw

Hi,

Thanks for the replies. The block size of my LV is indeed 4096

helix-priv:~ # blockdev --getbsz /dev/vg_u00/lv_u00 4096

I can mount and use the xfs file system no problems. I have even tested
extending the LV and doing an xfs_grow and that seemed to work no problems. So I take it I can safely ignore the warning.

Should I report this as a bug? If so Can someone point me to the bugzilla page or something of the sorts?

Thanks
Rene

Quoted 39 lines · Shailendra Tripathi
Quoted 7 lines
Quoted 3 lines

Thanks for the reply. The "-s size=4096" helped I was able to create the file system, then mount it and use it. I did however get a warning still about "cannot set blocksize on block device".

I don't know much about the LVM code, my guess is that ioctl(... ,BLKBSZSET, ...) is failing, strace would confirm this.

libxfs_device_open () seems to be working with the pre-conceived notion of assuming block devices of only 512 bytes in size.

if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK)
platform_set_blocksize(fd, path, statb.st_rdev, 512);

This eventually calls to set the blk sz to 512. Since, your volume does not support less than 4k, it returns EINVAL. I think, libxfs_init should be modified to take pass on the -s size option to this call so that it does not happen.
However, I don't see any problem despite this failure. Everything
else should work fine.

Quoted 18 lines
Quoted 3 lines

Everything seems to be working but I am a bit worried about the warning message. Following is the message. Any ideas if it is safe to ignore this or any way to get rid of it?

What does:

  blockdev --getbsz /dev/vg_u00/lv_u00

say?

If mkfs.xfs is trying to set a blocksize that already matches the underlying device, it woudn't be hard to silence the warning by doing a check before unconditionally setting it, though I don't know that it's worth it.

Signature · 10 lines
-
--
        Rene Salmon
        Tulane University
        Center for Computational Science
        http://www.ccs.tulane.edu
	[email protected]
        Tel 504-862-8393
	Tel 504-988-8552
        Fax 504-862-8392
#6 lore raw

Hi Rene,

Quoted 2 lines · Rene Salmon

Should I report this as a bug?

Well I know it now :)
but it is good to have a record of it.

Quoted 2 lines

If so Can someone point me to the bugzilla page or something of the sorts?

http://oss.sgi.com/bugzilla/
Product: Linux XFS.

Thanks,
--Tim

#7 lore raw
In reply to Shailendra Tripathi
Quoted 4 lines · Shailendra Tripathi

libxfs_device_open () seems to be working with the pre-conceived notion of assuming block devices of only 512 bytes in size.

if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK)

Quoted 9 lines
    platform_set_blocksize(fd, path, statb.st_rdev, 512);

This eventually calls to set the blk sz to 512. Since, your volume does not support less than 4k, it returns EINVAL. I think, libxfs_init should be modified to take pass on the -s size option to this call so that it does not happen.
However, I don't see any problem despite this failure. Everything
else should work fine.

Yep, this looks to me like an oversight when the larger-sector-size support was added. Seems like if the device can't be set to a smaller sector size than X, then the tools should run as if a sector size of X had been specified?

-Eric

#8 lore raw
In reply to Shailendra Tripathi
Quoted 9 lines · Shailendra Tripathi
Quoted 7 lines
Quoted 3 lines

Thanks for the reply. The "-s size=4096" helped I was able to create the file system, then mount it and use it. I did however get a warning still about "cannot set blocksize on block device".

I don't know much about the LVM code, my guess is that ioctl(... ,BLKBSZSET, ...) is failing, strace would confirm this.

Quoted 10 lines

libxfs_device_open () seems to be working with the pre-conceived notion of assuming block devices of only 512 bytes in size.

if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK)
platform_set_blocksize(fd, path, statb.st_rdev, 512);

This eventually calls to set the blk sz to 512. Since, your volume does not support less than 4k, it returns EINVAL. I think, libxfs_init should be modified to take pass on the -s size option to this call so that it does not happen.
However, I don't see any problem despite this failure. Everything
else should work fine.

Sounds reasonable.
I'll have a look soon at passing the mkfs.xfs -s option thru to libxfs which is consistent with the existing code.

--Tim

#9 lore raw
Quoted 2 lines · Tim Shimmin

I'll have a look soon at passing the mkfs.xfs -s option thru to libxfs which is consistent with the existing code.

(following up on something mentioned off the list)

When you do this change please consider *not* making the code fallback to a different blocksize if the ioctl fails when "-s size=" is given.

The logic here is that if someone clearly wants a specific value and if that cannot be met it should error out with a suitable message, not silently do something else.

#10 lore raw
Quoted 5 lines · Chris Wedgwood
Quoted 2 lines · Tim Shimmin

I'll have a look soon at passing the mkfs.xfs -s option thru to libxfs which is consistent with the existing code.

Quoted 8 lines

(following up on something mentioned off the list)

When you do this change please consider *not* making the code fallback to a different blocksize if the ioctl fails when "-s size=" is given.

The logic here is that if someone clearly wants a specific value and if that cannot be met it should error out with a suitable message, not silently do something else.

I agree.
I prefer default behaviour to happen when we are using the defaults - so we can do fallback behaviour under the assumption the user doesn't mind.
But when we ask for something explicitly, then do it or error out. :)

I'd be tempted to reuse libxfs_init_t's setblksize to be 1 as it currently is if one wants the device blksize to be set and

Quoted 1 line

1 (really > 512 etc...) if one wants to set it to a particular value.

--Tim

#11 lore raw
In reply to Shailendra Tripathi
Quoted 9 lines · Shailendra Tripathi
Quoted 7 lines
Quoted 3 lines

Thanks for the reply. The "-s size=4096" helped I was able to create the file system, then mount it and use it. I did however get a warning still about "cannot set blocksize on block device".

I don't know much about the LVM code, my guess is that ioctl(... ,BLKBSZSET, ...) is failing, strace would confirm this.

Quoted 6 lines

libxfs_device_open () seems to be working with the pre-conceived notion of assuming block devices of only 512 bytes in size.

if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK)
platform_set_blocksize(fd, path, statb.st_rdev, 512);

This eventually calls to set the blk sz to 512. Since, your volume does not support less than 4k, it returns EINVAL. I think, libxfs_init should be modified to take pass on the -s size option to this call so that it does not happen.

I've attached a patch.
Is this the sort of thing you were after?

--Tim

Subject: Re: LVM and XFS cannot set blocksize on block device

Shailendra wrote:
libxfs_device_open () seems to be working with the pre-conceived notion of assuming block devices of only 512 bytes in size.
This eventually calls to set the blk sz to 512. Since, your volume does not support less than 4k, it returns EINVAL. I think, libxfs_init should be modified to pass on the -s size option to this call so that it does not happen.
...

libxfs/darwin.c renamed from libxfs/darwin.c.orig +2 -2
Index: xfsprogs/libxfs/darwin.c
===================================================================
@@ -51,8 +51,8 @@
 	return (writable == 0);
 }
 
-void
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize)
+int
+platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
 {
 }
 
libxfs/freebsd.c renamed from libxfs/freebsd.c.orig +2 -2
Index: xfsprogs/libxfs/freebsd.c
===================================================================
@@ -91,8 +91,8 @@
 	return 0;
 }
 
-void
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize)
+int
+platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
 {
 	return;
 }
libxfs/init.c renamed from libxfs/init.c.orig +10 -2
Index: xfsprogs/libxfs/init.c
===================================================================
@@ -116,8 +116,16 @@
 		exit(1);
 	}
 
-	if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK)
-		platform_set_blocksize(fd, path, statb.st_rdev, 512);
+	if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK) {
+		if (setblksize == 1)
+			/* use the default blocksize */
+			(void)platform_set_blocksize(fd, path, statb.st_rdev, XFS_MIN_SECTORSIZE, 0);
+		else {
+			/* given an explicit blocksize to use */
+			if (platform_set_blocksize(fd, path, statb.st_rdev, setblksize, 1))
+			    exit(1);
+		}
+	}
 
 	/*
 	 * Get the device number from the stat buf - unless
libxfs/irix.c renamed from libxfs/irix.c.orig +2 -2
Index: xfsprogs/libxfs/irix.c
===================================================================
@@ -36,8 +36,8 @@
 	return 1;
 }
 
-void
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize)
+int
+platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
 {
 	return;
 }
libxfs/linux.c renamed from libxfs/linux.c.orig +9 -5
Index: xfsprogs/libxfs/linux.c
===================================================================
@@ -102,16 +102,20 @@
 	return sts;
 }
 
-void
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize)
+int
+platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
 {
+	int error = 0;
+
 	if (major(device) != RAMDISK_MAJOR) {
-		if (ioctl(fd, BLKBSZSET, &blocksize) < 0) {
-			fprintf(stderr, _("%s: warning - cannot set blocksize "
+		if ((error = ioctl(fd, BLKBSZSET, &blocksize)) < 0) {
+			fprintf(stderr, _("%s: %s - cannot set blocksize "
 					"on block device %s: %s\n"),
-				progname, path, strerror(errno));
+				progname, fatal ? "error": "warning",
+				path, strerror(errno));
 		}
 	}
+	return error;
 }
 
 void
mkfs/xfs_mkfs.c renamed from mkfs/xfs_mkfs.c.orig +5 -1
Index: xfsprogs/mkfs/xfs_mkfs.c
===================================================================
@@ -634,7 +634,6 @@
 	bzero(&fsx, sizeof(fsx));
 
 	bzero(&xi, sizeof(xi));
-	xi.setblksize = 1;
 	xi.isdirect = LIBXFS_DIRECT;
 	xi.isreadonly = LIBXFS_EXCLUSIVELY;
 
@@ -1506,6 +1505,11 @@
 	calc_stripe_factors(dsu, dsw, sectorsize, lsu, lsectorsize,
 				&dsunit, &dswidth, &lsunit);
 
+	if (slflag || ssflag)
+	    xi.setblksize = sectorsize;
+	else
+	    xi.setblksize = 1;
+
 	/*
 	 * Initialize.  This will open the log and rt devices as well.
 	 */
libxfs/init.h renamed from libxfs/init.h.orig +1 -1
Index: xfsprogs/libxfs/init.h
===================================================================
@@ -25,7 +25,7 @@
 extern int platform_check_iswritable (char *path, char *block,
 					struct stat64 *sptr, int fatal);
 extern void platform_findsizes (char *path, int fd, long long *sz, int *bsz);
-extern void platform_set_blocksize (int fd, char *path, dev_t device, int bsz);
+extern int platform_set_blocksize (int fd, char *path, dev_t device, int bsz, int fatal);
 extern void platform_flush_device (int fd, dev_t device);
 extern char *platform_findrawpath(char *path);
 extern char *platform_findrawpath (char *path);
#12 lore raw

We are currently running SLES 10 on this box. I have called IBM and they submitted a bug report to Novell and LTC Bugzilla 28003.

Is this all we need to do to get the patch into maybe SLES 10 SP1?

thanks

Rene

Quoted 172 lines · Timothy Shimmin
Quoted 9 lines · Shailendra Tripathi
Quoted 7 lines
Quoted 3 lines

Thanks for the reply. The "-s size=4096" helped I was able to create the file system, then mount it and use it. I did however get a warning still about "cannot set blocksize on block device".

I don't know much about the LVM code, my guess is that ioctl(... ,BLKBSZSET, ...) is failing, strace would confirm this.

Quoted 6 lines

libxfs_device_open () seems to be working with the pre-conceived notion of assuming block devices of only 512 bytes in size.

if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK)
platform_set_blocksize(fd, path, statb.st_rdev, 512);

This eventually calls to set the blk sz to 512. Since, your volume does not support less than 4k, it returns EINVAL. I think, libxfs_init should be modified to take pass on the -s size option to this call so that it does not happen.

I've attached a patch.
Is this the sort of thing you were after?

--Tim

------------------------------------------------------------------------

Subject: Re: LVM and XFS cannot set blocksize on block device

Shailendra wrote:
libxfs_device_open () seems to be working with the pre-conceived notion of assuming block devices of only 512 bytes in size.
This eventually calls to set the blk sz to 512. Since, your volume does not support less than 4k, it returns EINVAL. I think, libxfs_init should be modified to pass on the -s size option to this call so that it does not happen.
...

Index: xfsprogs/libxfs/darwin.c
===================================================================

libxfs/darwin.c renamed from libxfs/darwin.c.orig +2 -2
@@ -51,8 +51,8 @@
 	return (writable == 0);
 }
 
-void
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize)
+int
+platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
 {
 }
 

Index: xfsprogs/libxfs/freebsd.c
===================================================================

libxfs/freebsd.c renamed from libxfs/freebsd.c.orig +2 -2
@@ -91,8 +91,8 @@
 	return 0;
 }
 
-void
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize)
+int
+platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
 {
 	return;
 }

Index: xfsprogs/libxfs/init.c
===================================================================

libxfs/init.c renamed from libxfs/init.c.orig +10 -2
@@ -116,8 +116,16 @@
 		exit(1);
 	}
 
-	if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK)
-		platform_set_blocksize(fd, path, statb.st_rdev, 512);
+	if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK) {
+		if (setblksize == 1)
+			/* use the default blocksize */
+			(void)platform_set_blocksize(fd, path, statb.st_rdev, XFS_MIN_SECTORSIZE, 0);
+		else {
+			/* given an explicit blocksize to use */
+			if (platform_set_blocksize(fd, path, statb.st_rdev, setblksize, 1))
+			    exit(1);
+		}
+	}
 
 	/*
 	 * Get the device number from the stat buf - unless

Index: xfsprogs/libxfs/irix.c
===================================================================

libxfs/irix.c renamed from libxfs/irix.c.orig +2 -2
@@ -36,8 +36,8 @@
 	return 1;
 }
 
-void
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize)
+int
+platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
 {
 	return;
 }

Index: xfsprogs/libxfs/linux.c
===================================================================

libxfs/linux.c renamed from libxfs/linux.c.orig +9 -5
@@ -102,16 +102,20 @@
 	return sts;
 }
 
-void
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize)
+int
+platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
 {
+	int error = 0;
+
 	if (major(device) != RAMDISK_MAJOR) {
-		if (ioctl(fd, BLKBSZSET, &blocksize) < 0) {
-			fprintf(stderr, _("%s: warning - cannot set blocksize "
+		if ((error = ioctl(fd, BLKBSZSET, &blocksize)) < 0) {
+			fprintf(stderr, _("%s: %s - cannot set blocksize "
 					"on block device %s: %s\n"),
-				progname, path, strerror(errno));
+				progname, fatal ? "error": "warning",
+				path, strerror(errno));
 		}
 	}
+	return error;
 }
 
 void

Index: xfsprogs/mkfs/xfs_mkfs.c
===================================================================

mkfs/xfs_mkfs.c renamed from mkfs/xfs_mkfs.c.orig +5 -1
@@ -634,7 +634,6 @@
 	bzero(&fsx, sizeof(fsx));
 
 	bzero(&xi, sizeof(xi));
-	xi.setblksize = 1;
 	xi.isdirect = LIBXFS_DIRECT;
 	xi.isreadonly = LIBXFS_EXCLUSIVELY;
 
@@ -1506,6 +1505,11 @@
 	calc_stripe_factors(dsu, dsw, sectorsize, lsu, lsectorsize,
 				&dsunit, &dswidth, &lsunit);
 
+	if (slflag || ssflag)
+	    xi.setblksize = sectorsize;
+	else
+	    xi.setblksize = 1;
+
 	/*
 	 * Initialize.  This will open the log and rt devices as well.
 	 */

Index: xfsprogs/libxfs/init.h
===================================================================

libxfs/init.h renamed from libxfs/init.h.orig +1 -1
@@ -25,7 +25,7 @@
 extern int platform_check_iswritable (char *path, char *block,
 					struct stat64 *sptr, int fatal);
 extern void platform_findsizes (char *path, int fd, long long *sz, int *bsz);
-extern void platform_set_blocksize (int fd, char *path, dev_t device, int bsz);
+extern int platform_set_blocksize (int fd, char *path, dev_t device, int bsz, int fatal);
 extern void platform_flush_device (int fd, dev_t device);
 extern char *platform_findrawpath(char *path);
 extern char *platform_findrawpath (char *path);
#13 lore raw

Hi Rene,

Quoted 2 lines · --On 6 October 2006 3:36:49 PM -0500 Rene Salmon <[email protected]> wrote:

We are currently running SLES 10 on this box. I have called IBM and they submitted a bug report to Novell and LTC Bugzilla 28003.

Ok.

Quoted 3 lines

Is this all we need to do to get the patch into maybe SLES 10 SP1?

We will have an xfsprogs update (which will include this fix amongst others) for sles10 sp1.

Cheers,
Tim.