Whamcloud - gitweb
tune2fs: Add support for setting the default hash algorithm for htree
authorTheodore Ts'o <tytso@mit.edu>
Sat, 30 Aug 2008 01:21:19 +0000 (21:21 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 30 Aug 2008 01:21:19 +0000 (21:21 -0400)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/tune2fs.8.in
misc/tune2fs.c

index 9f8f23a..9abd898 100644 (file)
@@ -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.
index ab35a71..5d4cfc0 100644 (file)
@@ -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=<RAID per-disk chunk size in blocks>\n"
-                       "\tstripe-width=<RAID stride*data disks in blocks>\n"
+                       "\tstripe_width=<RAID stride*data disks in blocks>\n"
+                       "\thash_alg=<hash algorithm>\n"
                        "\ttest_fs\n"
                        "\t^test_fs\n"));
                free(buf);