Store the RAID stride value in the superblock and take advantage of it
Store the RAID stride value when a filesystem is created with a requested
RAID stride, and then use it automatically in resize2fs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index 64bc8de..6806b1f 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,10 @@
+2007-05-18 Theodore Tso <tytso@mit.edu>
+
+ * openfs.c (ext2fs_open2): Set fs->stride from the superblock's
+ s_raid_stride value.
+
+ * ext2_fs.h: Allocate space for RAID stride in the superblock.
+
2007-05-08 Eric Sandeen <sandeen@redhat.com>
* ext2_fs.h (inode_uid, inode_gid): The inode_uid() and
diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
index e13eba4..98f34fc 100644
--- a/lib/ext2fs/ext2_fs.h
+++ b/lib/ext2fs/ext2_fs.h
@@ -573,7 +573,9 @@
__u16 s_min_extra_isize; /* All inodes have at least # bytes */
__u16 s_want_extra_isize; /* New inodes should reserve # bytes */
__u32 s_flags; /* Miscellaneous flags */
- __u32 s_reserved[167]; /* Padding to the end of the block */
+ __u16 s_raid_stride; /* RAID stride */
+ __u16 s_pad; /* Padding */
+ __u32 s_reserved[166]; /* Padding to the end of the block */
};
/*
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 5050117..ea10373 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -297,6 +297,8 @@
dest += fs->blocksize;
}
+ fs->stride = fs->super->s_raid_stride;
+
*ret_fs = fs;
return 0;
cleanup:
diff --git a/misc/ChangeLog b/misc/ChangeLog
index 6cb755e..4a96f75 100644
--- a/misc/ChangeLog
+++ b/misc/ChangeLog
@@ -1,5 +1,7 @@
2007-05-18 Theodore Tso <tytso@mit.edu>
+ * mke2fs.c (main): Save the raid stride to the superblock
+
* blkid.c (main): Add -g option to blkid which will garbage
collect the cache.
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 41b09ab..0a37137 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1611,7 +1611,7 @@
test_disk(fs, &bb_list);
handle_bad_blocks(fs, bb_list);
- fs->stride = fs_stride;
+ fs->stride = fs->super->s_raid_stride = fs_stride;
retval = ext2fs_allocate_tables(fs);
if (retval) {
com_err(program_name, retval,
diff --git a/resize/ChangeLog b/resize/ChangeLog
index 866eb55..d0f0fae 100644
--- a/resize/ChangeLog
+++ b/resize/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-18 Theodore Tso <tytso@mit.edu>
+
+ * main.c (determine_fs_stride): Use the superblock s_raid_stride
+ if it is set; save the hueristically determined stride to
+ the superblock if it is not set.
+
2007-03-18 Theodore Tso <tytso@mit.edu>
* resize2fs.c (check_and_change_inodes): Check to make sure the
diff --git a/resize/main.c b/resize/main.c
index e71bbde..f9d8b84 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -101,6 +101,8 @@
unsigned int has_sb, prev_has_sb, num;
int i_stride, b_stride;
+ if (fs->stride)
+ return;
num = 0; sum = 0;
for (group = 0; group < fs->group_desc_count; group++) {
has_sb = ext2fs_bg_has_super(fs, group);
@@ -132,6 +134,9 @@
else
fs->stride = 0;
+ fs->super->s_raid_stride = fs->stride;
+ ext2fs_mark_super_dirty(fs);
+
#if 0
if (fs->stride)
printf("Using RAID stride of %d\n", fs->stride);
@@ -348,7 +353,8 @@
_("Invalid stride length"));
exit(1);
}
- fs->stride = use_stride;
+ fs->stride = fs->super->s_raid_stride = use_stride;
+ ext2fs_mark_super_dirty(fs);
} else
determine_fs_stride(fs);