From 10ff68d42d06953c35459a0d949862e6aafa19f8 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 29 Aug 2008 21:21:19 -0400 Subject: [PATCH] tune2fs: Add support for setting the default hash algorithm for htree Signed-off-by: "Theodore Ts'o" --- misc/tune2fs.8.in | 10 +++++++++- misc/tune2fs.c | 24 ++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in index 9f8f23a..9abd898 100644 --- a/misc/tune2fs.8.in +++ b/misc/tune2fs.8.in @@ -164,7 +164,7 @@ metadata like bitmaps at time to avoid placing them on a single disk, which can hurt the performanace. It may also be used by block allocator. .TP -.BI stripe-width= stripe-width +.BI stripe_width= stripe-width Configure the filesystem for a RAID array with .I stripe-width filesystem blocks per stripe. This is typically be stride-size * N, where @@ -172,6 +172,14 @@ N is the number of data disks in the RAID (e.g. RAID 5 N+1, RAID 6 N+2). This allows the block allocator to prevent read-modify-write of the parity in a RAID stripe if possible when the data is written. .TP +.BI hash_alg= hash-alg +Set the default hash algorithm used for filesystems with hashed b-tree +directories. Valid algorithms accepted are: +.IR legacy , +.IR half_md4 , +and +.IR tea . +.TP .B test_fs Set a flag in the filesystem superblock indicating that it may be mounted using experimental kernel code, such as the ext4dev filesystem. diff --git a/misc/tune2fs.c b/misc/tune2fs.c index ab35a71..5d4cfc0 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -855,7 +855,7 @@ void do_findfs(int argc, char **argv) static void parse_extended_opts(ext2_filsys fs, const char *opts) { char *buf, *token, *next, *p, *arg; - int len; + int len, hash_alg; int r_usage = 0; len = strlen(opts); @@ -915,6 +915,25 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts) continue; } stripe_width_set = 1; + } else if (strcmp(token, "hash_alg") == 0 || + strcmp(token, "hash-alg") == 0) { + if (!arg) { + r_usage++; + continue; + } + hash_alg = e2p_string2hash(arg); + if (hash_alg < 0) { + fprintf(stderr, + _("Invalid hash algorithm: %s\n"), + arg); + r_usage++; + continue; + } + fs->super->s_def_hash_version = hash_alg; + printf(_("Setting default hash algorithm " + "to %s (%d)\n"), + arg, hash_alg); + ext2fs_mark_super_dirty(fs); } else r_usage++; } @@ -925,7 +944,8 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts) "\tis set off by an equals ('=') sign.\n\n" "Valid extended options are:\n" "\tstride=\n" - "\tstripe-width=\n" + "\tstripe_width=\n" + "\thash_alg=\n" "\ttest_fs\n" "\t^test_fs\n")); free(buf); -- 1.8.3.1