From 96c6a3acd377698cb99ffd9925bec9b20ca4f6f9 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 18 May 2007 22:06:53 -0400 Subject: [PATCH] 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" --- lib/ext2fs/ChangeLog | 7 +++++++ lib/ext2fs/ext2_fs.h | 4 +++- lib/ext2fs/openfs.c | 2 ++ misc/ChangeLog | 2 ++ misc/mke2fs.c | 2 +- resize/ChangeLog | 6 ++++++ resize/main.c | 8 +++++++- 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 64bc8deef..6806b1f02 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,10 @@ +2007-05-18 Theodore Tso + + * 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 * 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 e13eba4a1..98f34fc82 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -573,7 +573,9 @@ struct ext2_super_block { __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 505011750..ea1037304 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -297,6 +297,8 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, 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 6cb755eaf..4a96f75b0 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,5 +1,7 @@ 2007-05-18 Theodore Tso + * 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 41b09ab6a..0a3713799 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1611,7 +1611,7 @@ int main (int argc, char *argv[]) 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 866eb5565..d0f0fae6a 100644 --- a/resize/ChangeLog +++ b/resize/ChangeLog @@ -1,3 +1,9 @@ +2007-05-18 Theodore Tso + + * 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 * resize2fs.c (check_and_change_inodes): Check to make sure the diff --git a/resize/main.c b/resize/main.c index e71bbde0c..f9d8b8483 100644 --- a/resize/main.c +++ b/resize/main.c @@ -101,6 +101,8 @@ static void determine_fs_stride(ext2_filsys fs) 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 @@ static void determine_fs_stride(ext2_filsys fs) 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 @@ int main (int argc, char ** argv) _("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); -- 2.47.2