From 92eb5a339220e66e965e536bf53d63249577a93a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 22 Nov 2010 11:09:00 -0500 Subject: [PATCH] mke2fs: Set logical/physical sector size from environment for debugging If MKE2FS_DEVICE_SECTSIZE is set, then this will override the logical sector size, which is the smallest sector size that can be written atomically by the device. (Previously MKE2FS_DEVICE_SECTSIZE set the physical sector size, which was incorrect given its historical usage.) The environment variable MKE2FS_DEVICE_PHYS_SECTSIZE will set the physical sector size, which is the actual sector size used by the device in reality. The logical sector size is always less than or equal to the physical sector size; and writes smaller than the physical sector size but greather than or equal to the logical sector size will cause a read-modify-write cycle within the device firmware (or in some abstract layer lower than the Linux block I/O subsystem, at any rate). Signed-off-by: "Theodore Ts'o" --- misc/mke2fs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index fd66ff6..d59e30d 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1667,13 +1667,16 @@ got_size: _("while trying to determine physical sector size")); exit(1); } - /* Older kernels may not have physical/logical distinction */ - if (!psector_size) - psector_size = lsector_size; if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL) + lsector_size = atoi(tmp); + if ((tmp = getenv("MKE2FS_DEVICE_PHYS_SECTSIZE")) != NULL) psector_size = atoi(tmp); + /* Older kernels may not have physical/logical distinction */ + if (!psector_size) + psector_size = lsector_size; + if (blocksize <= 0) { use_bsize = get_int_from_profile(fs_types, "blocksize", 4096); -- 1.8.3.1