]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
mke2fs: Set logical/physical sector size from environment for debugging
authorTheodore Ts'o <tytso@mit.edu>
Mon, 22 Nov 2010 16:09:00 +0000 (11:09 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 22 Nov 2010 16:09:00 +0000 (11:09 -0500)
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" <tytso@mit.edu>
misc/mke2fs.c

index fd66ff6382659c33fa1701494724c2a4569aad5b..d59e30d4723e5b67e1063de634dc8fb0613a92d9 100644 (file)
@@ -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);