From 1599b470fb881313c1d44594f05d578c43825312 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 22 Nov 2010 10:50:42 -0500 Subject: [PATCH] mke2fs: Fill in min_io and opt_io with physical sector size If the device does not have an explicitly specified minimum io_size or optimal io_size, and the physical sector size is greater than the block size, then use the physical sector size as a better-than-nothing hint. This should help for SSD's that have a physical sector size of 8k or 16k (which are reportedly will be coming soon). Signed-off-by: "Theodore Ts'o" --- misc/mke2fs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index a11dd8c..fd66ff6 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1084,8 +1084,9 @@ static const char *default_files[] = { "", 0 }; * Sets the geometry of a device (stripe/stride), and returns the * device's alignment offset, if any, or a negative error. */ -static int ext2fs_get_device_geometry(const char *file, - struct ext2_super_block *fs_param) +static int get_device_geometry(const char *file, + struct ext2_super_block *fs_param, + int psector_size) { int rc = -1; int blocksize; @@ -1110,6 +1111,12 @@ static int ext2fs_get_device_geometry(const char *file, min_io = blkid_topology_get_minimum_io_size(tp); opt_io = blkid_topology_get_optimal_io_size(tp); blocksize = EXT2_BLOCK_SIZE(fs_param); + if ((min_io == 0) && (psector_size > blocksize)) + min_io = psector_size; + if ((opt_io == 0) && min_io) + opt_io = min_io; + if ((opt_io == 0) && (psector_size > blocksize)) + opt_io = psector_size; fs_param->s_raid_stride = min_io / blocksize; fs_param->s_raid_stripe_width = opt_io / blocksize; @@ -1707,7 +1714,7 @@ got_size: int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE); #ifdef HAVE_BLKID_PROBE_GET_TOPOLOGY - retval = ext2fs_get_device_geometry(device_name, &fs_param); + retval = get_device_geometry(device_name, &fs_param, psector_size); if (retval < 0) { fprintf(stderr, _("warning: Unable to get device geometry for %s\n"), -- 1.8.3.1