mkfs: handle 4k sector devices more cleanly
PATCH 1/1 mkfs: handle 4k sector devices more cleanly
Trying to mkfs a 4k sector device today fails w/o manually specifying sector size:
# modprobe scsi_debug sector_size=4096 dev_size_mb=32 # mkfs.xfs -f /dev/sdc mkfs.xfs: warning - cannot set blocksize on block device /dev/sdc: Invalid argument Warning: the data subvolume sector size 512 is less than the sector size reported by the device (4096). ... <fail>
add sectorsize to the device topology info, and use that if present.
Also check that explicitly requested sector sizes are not smaller than the hardware size. This already fails today, but with the more cryptic "cannot set blocksize" ioctl error above.
---
libxfs/linux.c +2 -2
@@ -112,9 +112,9 @@ platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fataif (major (device) !=RAMDISK_MAJOR ) {if ((error =ioctl (fd,BLKBSZSET , &blocksize)) <0 ) {fprintf (stderr,_ ("%s: %s - cannot set blocksize " -"on block device %s: %s\n" ), +"%d on block device %s: %s\n" ), progname, fatal ?"error" :"warning" , - path,strerror (errno)); + blocksize, path,strerror (errno)); } }return error;
mkfs/xfs_mkfs.c +23 -8
@@ -33,6 +33,7 @@ struct fs_topology {int dsunit;/* stripe unit - data subvolume */ int dswidth;/* stripe width - data subvolume */ int rtswidth;/* stripe width - rt subvolume */ +int sectorsize;int sectoralign; };
@@ -320,7 +321,7 @@ out_free_probe:return ret; } -static void blkid_get_topology (const char *device,int *sunit,int *swidth) +static void blkid_get_topology (const char *device,int *sunit,int *swidth,int *sectorsize) {blkid_topology tp;blkid_probe pr;
@@ -348,7 +349,9 @@ static void blkid_get_topology(const char *device, int *sunit, int *swidth) val =blkid_topology_get_optimal_io_size (tp) >>9 ;if (val >1 ) *swidth = val; - + val =blkid_probe_get_sectorsize (pr); +if (val >1 ) + *sectorsize = val;if (blkid_topology_get_alignment_offset (tp) !=0 ) { fprintf(stderr, _("warning: device is not properly aligned %s\n"),
@@ -370,13 +373,13 @@ static void get_topology(libxfs_init_t *xi, struct fs_topology *ft)if (!xi->disfile) {const char *dfile = xi->volname ? xi->volname : xi->dname; -blkid_get_topology (dfile, &ft->dsunit, &ft->dswidth); +blkid_get_topology (dfile, &ft->dsunit, &ft->dswidth, &ft->sectorsize); }if (xi->rtname && !xi->risfile) {int dummy; -blkid_get_topology (xi->rtname, &dummy, &ft->rtswidth); +blkid_get_topology (xi->rtname, &dummy, &ft->rtswidth, &dummy); } }#else /* ENABLE_BLKID */
@@ -1543,8 +1546,15 @@ main(memset (&ft,0 ,sizeof (ft));get_topology (&xi, &ft); -if (ft.sectoralign) { - sectorsize = blocksize; +/* +* MD wants sector size set == block size to avoid switching. +* Otherwise, if not specfied via command, use device sectorsize +*/ +if (ft.sectoralign || !ssflag) { +if (ft.sectoralign) + sectorsize = blocksize; +else + sectorsize = ft.sectorsize; sectorlog =libxfs_highbit32 (sectorsize);if (loginternal) { lsectorsize = sectorsize;
@@ -1556,6 +1566,11 @@ main(fprintf (stderr,_ ("illegal sector size %d\n" ), sectorsize);usage (); } +if (sectorsize < ft.sectorsize) { +fprintf (stderr,_ ("illegal sector size %d; hw sector is %d\n" ), + sectorsize, ft.sectorsize); +usage (); + }if (lsectorsize <XFS_MIN_SECTORSIZE || lsectorsize >XFS_MAX_SECTORSIZE || lsectorsize > blocksize) {fprintf (stderr,_ ("illegal log sector size %d\n" ), lsectorsize);
@@ -1749,10 +1764,10 @@ main(calc_stripe_factors (dsu, dsw, sectorsize, lsu, lsectorsize, &dsunit, &dswidth, &lsunit); -if (slflag || ssflag) +if (slflag || ssflag || ft.setorsize) xi.setblksize = sectorsize;else - xi.setblksize =1 ; + xi.setblksize =1 ;/* Use default sector size */ /* * Initialize. This will open the log and rt devices as well.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 24 lines · Eric Sandeen
Trying to mkfs a 4k sector device today fails w/o manually specifying sector size:
# modprobe scsi_debug sector_size=4096 dev_size_mb=32 # mkfs.xfs -f /dev/sdc mkfs.xfs: warning - cannot set blocksize on block device /dev/sdc: Invalid argument Warning: the data subvolume sector size 512 is less than the sector size reported by the device (4096). ... <fail>add sectorsize to the device topology info, and use that if present.
Also check that explicitly requested sector sizes are not smaller than the hardware size. This already fails today, but with the more cryptic "cannot set blocksize" ioctl error above.
Signed-off-by Eric Sandeen <[email protected]>---
libxfs/linux.c +0
-0
libxfs/linux.c platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fata · line 117
Quoted 8 lines
libxfs/linux.c +2
-2@@ -112,9 +112,9 @@ platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fataif (major (device) !=RAMDISK_MAJOR ) {if ((error =ioctl (fd,BLKBSZSET , &blocksize)) <0 ) {fprintf (stderr,_ ("%s: %s - cannot set blocksize " -"on block device %s: %s\n" ), +"%d on block device %s: %s\n" ), progname, fatal ?"error" :"warning" , - path,strerror (errno)); + blocksize, path,strerror (errno));
Defintively a more useful error message than before, thanks.
libxfs/linux.c static void blkid_get_topology(const char *device, int *sunit, int *swidth) · line 354
Quoted 13 lines
libxfs/linux.c +1
-1-static void blkid_get_topology (const char *device,int *sunit,int *swidth) +static void blkid_get_topology (const char *device,int *sunit,int *swidth,int *sectorsize) {blkid_topology tp;libxfs/linux.c +3
-1blkid_probe pr;@@ -348,7 +349,9 @@ static void blkid_get_topology(const char *device, int *sunit, int *swidth) val =blkid_topology_get_optimal_io_size (tp) >>9 ;if (val >1 ) *swidth = val; - + val =blkid_probe_get_sectorsize (pr); +if (val >1 ) + *sectorsize = val;
I don't think the val > 1 check here makes any sense.
libxfs/linux.c static void blkid_get_topology(const char *device, int *sunit, int *swidth) · line 355
Quoted 1 line
libxfs/linux.c +1
-0+blkid_get_topology (dfile, &ft->dsunit, &ft->dswidth, &ft->sectorsize);
The lines is growing a bit too long here..
Also I think you should add the sector size retrival by using the ioctl directly for the non-blkid case to make sure the code doesn't have too many corner cases.
libxfs/linux.c static void blkid_get_topology(const char *device, int *sunit, int *swidth)
Quoted 11 lines
libxfs/linux.c +9
-2-if (ft.sectoralign) { - sectorsize = blocksize; +/* +* MD wants sector size set == block size to avoid switching. +* Otherwise, if not specfied via command, use device sectorsize +*/ +if (ft.sectoralign || !ssflag) { +if (ft.sectoralign) + sectorsize = blocksize; +else + sectorsize = ft.sectorsize;
The code looks good, but I don't think the comment helps understanding what's going on. And I might get a bit pendantic here, but changing it to
if (!ssflag || ft.sectoralign)
might make the intent a bit more clear.
libxfs/linux.c
Quoted 5 lines
libxfs/linux.c +5
-0+if (sectorsize < ft.sectorsize) { +fprintf (stderr,_ ("illegal sector size %d; hw sector is %d\n" ), + sectorsize, ft.sectorsize); +usage (); + }
Looks good.
libxfs/linux.c main( · line 1767
Quoted 9 lines
libxfs/linux.c +1
-1if (lsectorsize <XFS_MIN_SECTORSIZE || lsectorsize >XFS_MAX_SECTORSIZE || lsectorsize > blocksize) {fprintf (stderr,_ ("illegal log sector size %d\n" ), lsectorsize);@@ -1749,10 +1764,10 @@ main(calc_stripe_factors (dsu, dsw, sectorsize, lsu, lsectorsize, &dsunit, &dswidth, &lsunit); -if (slflag || ssflag) +if (slflag || ssflag || ft.setorsize)
There's a c missing here, this wouldn't even compile :)
It will also be always true for blkid builds which is at least a bit confusing. If you also updated the libdisk case as suggested above we could also get rid of the xi.setblksize = 1 special case totally and always pass the proper block size to libxfs_init and libxfs_device_open (and make libxfs_device_open static in libxfs/init.c while we're at it :))
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 36 lines · Christoph Hellwig
Quoted 24 lines · Eric Sandeen
Trying to mkfs a 4k sector device today fails w/o manually specifying sector size:
# modprobe scsi_debug sector_size=4096 dev_size_mb=32 # mkfs.xfs -f /dev/sdc mkfs.xfs: warning - cannot set blocksize on block device /dev/sdc: Invalid argument Warning: the data subvolume sector size 512 is less than the sector size reported by the device (4096). ... <fail>add sectorsize to the device topology info, and use that if present.
Also check that explicitly requested sector sizes are not smaller than the hardware size. This already fails today, but with the more cryptic "cannot set blocksize" ioctl error above.
Signed-off-by Eric Sandeen <[email protected]>---
libxfs/linux.c +0
-0libxfs/linux.c platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fata · line 117
Quoted 8 lines
libxfs/linux.c +2
-2@@ -112,9 +112,9 @@ platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fataif (major (device) !=RAMDISK_MAJOR ) {if ((error =ioctl (fd,BLKBSZSET , &blocksize)) <0 ) {fprintf (stderr,_ ("%s: %s - cannot set blocksize " -"on block device %s: %s\n" ), +"%d on block device %s: %s\n" ), progname, fatal ?"error" :"warning" , - path,strerror (errno)); + blocksize, path,strerror (errno));Defintively a more useful error message than before, thanks.
Quoted 15 lines
libxfs/linux.c static void blkid_get_topology(const char *device, int *sunit, int *swidth) · line 354
Quoted 13 lines
libxfs/linux.c +1
-1-static void blkid_get_topology (const char *device,int *sunit,int *swidth) +static void blkid_get_topology (const char *device,int *sunit,int *swidth,int *sectorsize) {blkid_topology tp;libxfs/linux.c +3
-1blkid_probe pr;@@ -348,7 +349,9 @@ static void blkid_get_topology(const char *device, int *sunit, int *swidth) val =blkid_topology_get_optimal_io_size (tp) >>9 ;if (val >1 ) *swidth = val; - + val =blkid_probe_get_sectorsize (pr); +if (val >1 ) + *sectorsize = val;I don't think the val > 1 check here makes any sense.
TBH it was a cut and paste from above, sigh.
I guess I don't know why the other one uses "1" either:
unsigned long blkid_topology_get_optimal_io_size(blkid_topology tp)
{
return tp ? tp->optimal_io_size : 0;
}anyway for this one it can be an unconditional assignment I guess.
Quoted 3 lines
libxfs/linux.c static void blkid_get_topology(const char *device, int *sunit, int *swidth) · line 355
Quoted 1 line
libxfs/linux.c +1
-0+blkid_get_topology (dfile, &ft->dsunit, &ft->dswidth, &ft->sectorsize);The lines is growing a bit too long here..
yeah ....
Quoted 4 lines
Also I think you should add the sector size retrival by using the ioctl directly for the non-blkid case to make sure the code doesn't have too many corner cases.
Ok. The problem is platform_get_blocksize or whatnot would want both an fd and a path, and we've not opened anything yet :(
blkid was so handy :)
Quoted 16 lines
libxfs/linux.c static void blkid_get_topology(const char *device, int *sunit, int *swidth)
Quoted 11 lines
libxfs/linux.c +9
-2-if (ft.sectoralign) { - sectorsize = blocksize; +/* +* MD wants sector size set == block size to avoid switching. +* Otherwise, if not specfied via command, use device sectorsize +*/ +if (ft.sectoralign || !ssflag) { +if (ft.sectoralign) + sectorsize = blocksize; +else + sectorsize = ft.sectorsize;The code looks good, but I don't think the comment helps understanding what's going on. And I might get a bit pendantic here, but changing it to
Quoted 3 lines
if (!ssflag || ft.sectoralign)might make the intent a bit more clear.
ok. I can drop the comment, doesn't bother me.
Quoted 16 lines
libxfs/linux.c
Quoted 6 lines
libxfs/linux.c +5
-0+if (sectorsize < ft.sectorsize) { +fprintf (stderr,_ ("illegal sector size %d; hw sector is %d\n" ), + sectorsize, ft.sectorsize); +usage (); + }Looks good.
Quoted 7 lines
libxfs/linux.c +0
-0if (lsectorsize <XFS_MIN_SECTORSIZE || lsectorsize >XFS_MAX_SECTORSIZE || lsectorsize > blocksize) {fprintf (stderr,_ ("illegal log sector size %d\n" ), lsectorsize);@@ -1749,10 +1764,10 @@ main(calc_stripe_factors (dsu, dsw, sectorsize, lsu, lsectorsize, &dsunit, &dswidth, &lsunit);
Quoted 4 lines
libxfs/linux.c main( · line 1767
Quoted 2 lines
libxfs/linux.c +1
-1-if (slflag || ssflag) +if (slflag || ssflag || ft.setorsize)There's a c missing here, this wouldn't even compile :)
boooo for last-minute edits, sorry.
Quoted 6 lines
It will also be always true for blkid builds which is at least a bit confusing. If you also updated the libdisk case as suggested above we could also get rid of the xi.setblksize = 1 special case totally and always pass the proper block size to
libxfs_initandlibxfs_device_open(and makelibxfs_device_openstatic inlibxfs/init.cwhile we're at it :))
hm all good ideas, though need to think about how to do things cleanly with platform_find_blah.
We already have:
voidplatform_findsizes(char *path, int fd, long long *sz, int *bsz)
which would make it easy, but grumble, we don't have an fd yet!
I guess maybe I could make that function cope with a dummy fd, and do the open/close itself....
Thanks,
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 1/1 mkfs: handle 4k sector devices more cleanly
In reply to Eric SandeenTrying to mkfs a 4k sector device today fails w/o manually specifying sector size:
# modprobe scsi_debug sector_size=4096 dev_size_mb=32 # mkfs.xfs -f /dev/sdc mkfs.xfs: warning - cannot set blocksize on block device /dev/sdc: Invalid argument Warning: the data subvolume sector size 512 is less than the sector size reported by the device (4096). ... <fail>
add sectorsize to the device topology info, and use that if present.
Also check that explicitly requested sector sizes are not smaller than the hardware size. This already fails today, but with the more cryptic "cannot set blocksize" ioctl error above.
---
libxfs/linux.c +2 -2
@@ -112,9 +112,9 @@ platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fataif (major (device) !=RAMDISK_MAJOR ) {if ((error =ioctl (fd,BLKBSZSET , &blocksize)) <0 ) {fprintf (stderr,_ ("%s: %s - cannot set blocksize " -"on block device %s: %s\n" ), +"%d on block device %s: %s\n" ), progname, fatal ?"error" :"warning" , - path,strerror (errno)); + blocksize, path,strerror (errno)); } }return error;
mkfs/xfs_mkfs.c +35 -7
104 lines not on this page · raw message
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 1 line · Eric Sandeen
+extern void
platform_findsizes(char *path, int fd, long long *sz, int *bsz);
Can you move the prototype from libxfs/init.h to include/libxfs.h instead of adding it to the .c file?
Review
Quoted 9 lines
(quoted diff) +9
-0+ /* + * MD wants sector size set == block size to avoid switching. + * Otherwise, if not specfied via command, use device sectorsize + */ + if (ft.sectoralign || !ssflag) { + if (ft.sectoralign) + sectorsize = blocksize; + else + sectorsize = ft.sectorsize;
This still confuses the heck out of me. What do you think about the incremental patch at the end of the mail?
Review
Quoted 4 lines
(quoted diff) +0
-2if (slflag || ssflag) xi.setblksize = sectorsize; - else - xi.setblksize = 1;
So for the defaul case we now never set the sector size in the libxfs init. This seems safe to me, but why did we do it before? Could a previous user have left it set to a wrong value?
Maye we should just do the xi.setblksize = sectorsize unconditionally?
mkfs/xfs_mkfs.c +19 -8
@@ -1561,21 +1561,32 @@ main(memset (&ft,0 ,sizeof (ft));get_topology (&xi, &ft); -/* -* MD wants sector size set == block size to avoid switching. -* Otherwise, if not specfied via command, use device sectorsize -*/ +if (ft.sectoralign) { +/* +* Older Linux software RAID versions want the sector size +* to match the block size to avoid switching I/O sizes. +* For the legacy libdisk case we thus set the sector size to +* match the block size. For systems using libblkid we assume +* that the kernel is recent enough to not require this and +* ft.sectoralign will never be set. +*/ + sectorsize = blocksize; + }else if (!ssflag) { +/* +* Unless specified manually on the command line use the +* advertised sector size of the device. +*/ + sectorsize = ft.sectorsize; + } +if (ft.sectoralign || !ssflag) { -if (ft.sectoralign) - sectorsize = blocksize; -else - sectorsize = ft.sectorsize; sectorlog =libxfs_highbit32 (sectorsize);if (loginternal) { lsectorsize = sectorsize; lsectorlog = sectorlog; } } +if (sectorsize <XFS_MIN_SECTORSIZE || sectorsize >XFS_MAX_SECTORSIZE || sectorsize > blocksize) {fprintf (stderr,_ ("illegal sector size %d\n" ), sectorsize);
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 5 lines · Christoph Hellwig
Quoted 1 line · Eric Sandeen
+extern void
platform_findsizes(char *path, int fd, long long *sz, int *bsz);Can you move the prototype from
libxfs/init.htoinclude/libxfs.hinstead of adding it to the .c file?
sure, heh, you know - I knew that was a bad idea ;)
Quoted 4 lines
Quoted 4 lines
mkfs/xfs_mkfs.c +4
-0+/* +* MD wants sector size set == block size to avoid switching. +* Otherwise, if not specfied via command, use device sectorsize +*/
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ if (ft.sectoralign || !ssflag) { + if (ft.sectoralign) + sectorsize = blocksize; + else + sectorsize = ft.sectorsize;This still confuses the heck out of me. What do you think about the incremental patch at the end of the mail?
yeah, that seems good.
Quoted 10 lines
Review
Quoted 4 lines
(quoted diff) +0
-2if (slflag || ssflag) xi.setblksize = sectorsize; - else - xi.setblksize = 1;So for the defaul case we now never set the sector size in the libxfs init. This seems safe to me, but why did we do it before? Could a previous user have left it set to a wrong value?
Maye we should just do the xi.setblksize = sectorsize unconditionally?
ugh this stuff is messy.
let me see what sectorsize's default is...
If we take out the "1 is special" stuff I should probably chase it through all the code.
Ok, will give this one more crack :)
Thanks,
-Eric
Quoted 37 lines
Index:
xfsprogs-dev/mkfs/xfs_mkfs.c
===================================================================mkfs/xfs_mkfs.c +18
-8@@ -1561,21 +1561,32 @@ main(memset (&ft,0 ,sizeof (ft));get_topology (&xi, &ft); -/* -* MD wants sector size set == block size to avoid switching. -* Otherwise, if not specfied via command, use device sectorsize -*/ +if (ft.sectoralign) { +/* +* Older Linux software RAID versions want the sector size +* to match the block size to avoid switching I/O sizes. +* For the legacy libdisk case we thus set the sector size to +* match the block size. For systems using libblkid we assume +* that the kernel is recent enough to not require this and +* ft.sectoralign will never be set. +*/ + sectorsize = blocksize; + }else if (!ssflag) { +/* +* Unless specified manually on the command line use the +* advertised sector size of the device. +*/ + sectorsize = ft.sectorsize; + } +if (ft.sectoralign || !ssflag) { -if (ft.sectoralign) - sectorsize = blocksize; -else - sectorsize = ft.sectorsize;
mkfs/xfs_mkfs.c main( · line 1592
Quoted 10 lines
mkfs/xfs_mkfs.c +1
-0sectorlog =libxfs_highbit32 (sectorsize);if (loginternal) { lsectorsize = sectorsize; lsectorlog = sectorlog; } } +if (sectorsize <XFS_MIN_SECTORSIZE || sectorsize >XFS_MAX_SECTORSIZE || sectorsize > blocksize) {fprintf (stderr,_ ("illegal sector size %d\n" ), sectorsize);
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 5 lines · Christoph Hellwig
Quoted 1 line · Eric Sandeen
+extern void
platform_findsizes(char *path, int fd, long long *sz, int *bsz);Can you move the prototype from
libxfs/init.htoinclude/libxfs.hinstead of adding it to the .c file?
actually it seems a little out of place in libxfs/init.h; that probably works but there are no other platform_* functions there...
Should this be more like an xfs_findsizes in libxfs, which calls platform_findsizes internally just for consistency? *shrug*
Quoted 13 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+ /* + * MD wants sector size set == block size to avoid switching. + * Otherwise, if not specfied via command, use device sectorsize + */ + if (ft.sectoralign || !ssflag) { + if (ft.sectoralign) + sectorsize = blocksize; + else + sectorsize = ft.sectorsize;This still confuses the heck out of me. What do you think about the incremental patch at the end of the mail?
Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +0
-2if (slflag || ssflag) xi.setblksize = sectorsize; - else - xi.setblksize = 1;So for the defaul case we now never set the sector size in the libxfs init. This seems safe to me, but why did we do it before? Could a previous user have left it set to a wrong value?
ok so I read this wrong on my previous reply I guess.
The only way this is used is: it's sent to libxfs_init and then from there only to libxfs_open which does:
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);
}
}so "1" seems to have the special meaning of "use XFS_MIN_SECTORSIZE"
Hm, ok but in my patch setblksize is 0, so it's not getting set. I suppose this -might- mess up other utils ...
Quoted 1 line
Maye we should just do the xi.setblksize = sectorsize unconditionally?
I think that's best. It's already defaulted to XFS_MIN_SECTORSIZE
so should be no functional change if it doesn't get otherwise set - although I think it -does- get set in all cases now - either from ft.sectoralign/blocksize, from the explicit -s setting, or the ft.sectorsize by default.
What do you think about removing the "1" magic if so? At that point I think nothing relies on it.
Thanks,
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 4 lines · Eric Sandeen
Quoted 3 lines · Christoph Hellwig
Quoted 1 line · Eric Sandeen
+extern void
platform_findsizes(char *path, int fd, long long *sz, int *bsz);
Quoted 8 lines
Quoted 2 lines
Can you move the prototype from
libxfs/init.htoinclude/libxfs.hinstead of adding it to the .c file?actually it seems a little out of place in
libxfs/init.h; that probably works but there are no other platform_* functions there...Should this be more like an
xfs_findsizesin libxfs, which callsplatform_findsizesinternally just for consistency? *shrug*
I'd just move the header around to keep it simple for now.
Quoted 14 lines
The only way this is used is: it's sent to
libxfs_initand then from there only tolibxfs_openwhich does: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); } }
Quoted 4 lines
so "1" seems to have the special meaning of "use
XFS_MIN_SECTORSIZE"Hm, ok but in my patch setblksize is 0, so it's not getting set. I suppose this -might- mess up other utils ...
Yes, now we do not set any size, while previously we always set XFS_MIN_SECTORSIZE. I don't think this actually changes anything - the kernel doesn't make use of this blocksize information outside of filesystems, and we already reset it on mount.
Quoted 9 lines
Quoted 1 line
Maye we should just do the xi.setblksize = sectorsize unconditionally?
I think that's best. It's already defaulted to
XFS_MIN_SECTORSIZE
so should be no functional change if it doesn't get otherwise set - although I think it -does- get set in all cases now - either from ft.sectoralign/blocksize, from the explicit -s setting, or the ft.sectorsize by default.What do you think about removing the "1" magic if so? At that point I think nothing relies on it.
repair uses it in a weird way.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 1/1 mkfs: handle 4k sector devices more cleanly
In reply to Eric SandeenTrying to mkfs a 4k sector device today fails w/o manually specifying sector size:
# modprobe scsi_debug sector_size=4096 dev_size_mb=32 # mkfs.xfs -f /dev/sdc mkfs.xfs: warning - cannot set blocksize on block device /dev/sdc: Invalid argument Warning: the data subvolume sector size 512 is less than the sector size reported by the device (4096). ... <fail>
add sectorsize to the device topology info, and use that if present.
Also check that explicitly requested sector sizes are not smaller than the hardware size. This already fails today, but with the more cryptic "cannot set blocksize" ioctl error above.
With a few more suggested comments & cleanups from Christoph.
---
include/libxfs.h +1 -0
@@ -115,6 +115,7 @@ extern void libxfs_device_zero (dev_t, xfs_daddr_t, uint);extern void libxfs_device_close (dev_t );extern int libxfs_device_alignment (void );extern void libxfs_report (FILE *); +extern void platform_findsizes (char *path,int fd,long long *sz,int *bsz);/* check or write log footer: specify device, log size in blocks & uuid */ typedef xfs_caddr_t (libxfs_get_block_t )(xfs_caddr_t ,int ,void *);
libxfs/init.h +0 -1
@@ -24,7 +24,6 @@ extern int platform_check_ismounted (char *path, char *block, struct stat64 *sptr, int verbose);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 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);
libxfs/linux.c +2 -2
@@ -112,9 +112,9 @@ platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fataif (major (device) !=RAMDISK_MAJOR ) {if ((error =ioctl (fd,BLKBSZSET , &blocksize)) <0 ) {fprintf (stderr,_ ("%s: %s - cannot set blocksize " -"on block device %s: %s\n" ), +"%d on block device %s: %s\n" ), progname, fatal ?"error" :"warning" , - path,strerror (errno)); + blocksize, path,strerror (errno)); } }return error;
mkfs/xfs_mkfs.c +45 -7
120 lines not on this page · raw message
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Looks good,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs