OSDN Git Service

ChangeLog, util.c, util.h:
authorTheodore Ts'o <tytso@mit.edu>
Thu, 18 Jan 2001 01:47:48 +0000 (01:47 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 18 Jan 2001 01:47:48 +0000 (01:47 +0000)
  util.h, util.c (journal_default_size): New function from Andreas
   Dilger to calculate an appropriate default journal size given a
   filesystem size.
  util.c (parse_journal_opts): Allow the creation of a journal as small
   as 1MB.

misc/ChangeLog
misc/util.c
misc/util.h

index 64d04f1..1a3ffd1 100644 (file)
@@ -1,5 +1,12 @@
 2001-01-17  Theodore Ts'o  <tytso@valinux.com>
 
+       * util.h, util.c (journal_default_size): New function from Andreas
+               Dilger to calculate an appropriate default journal size
+               given a filesystem size.
+
+       * util.c (parse_journal_opts): Allow the creation of a journal as
+               small as 1MB.
+
        * dumpe2fs.c (print_journal_information): Use s_first_data_block
                to find the correct block to read the journal superblock.
 
index bf3aabd..eaf6fea 100644 (file)
@@ -164,7 +164,7 @@ void parse_journal_opts(const char *opts)
                        }
                        journal_size = strtoul(arg, &p, 0);
                journal_size_check:
-                       if (*p || (journal_size < 4 || journal_size > 100)) {
+                       if (*p || (journal_size < 1 || journal_size > 100)) {
                                fprintf(stderr,
                                _("Invalid journal size parameter - %s.\n"),
                                        arg);
@@ -191,8 +191,29 @@ void parse_journal_opts(const char *opts)
                        "\tsize=<journal size in megabytes>\n"
                        "\tdevice=<journal device>\n\n"
                        "Journal size must be between "
-                       "4 and 100 megabytes.\n\n" ));
+                       "1 and 100 megabytes.\n\n" ));
                exit(1);
        }
 }      
 
+/*
+ * Find a reasonable journal file size (in blocks) given the number of blocks
+ * in the filesystem.  For very small filesystems, it is not reasonable to
+ * have a journal that fills more than half of the filesystem.
+ */
+int journal_default_size(blk_t blocks_count)
+{
+       blk_t j_blocks;
+
+       if (blocks_count < 2048) {
+               fprintf(stderr, "Filesystem too small for a journal\n");
+               j_blocks = 0;
+       } else if (blocks_count < 32768)
+               j_blocks = 1024;
+       else if (blocks_count < 262144)
+               j_blocks = 4096;
+       else
+               j_blocks = 8192;
+
+       return j_blocks;
+}
index bf63109..61a7800 100644 (file)
@@ -21,3 +21,4 @@ extern void proceed_question(void);
 extern void check_plausibility(const char *device);
 extern void parse_journal_opts(const char *opts);
 extern void check_mount(const char *device, int force, const char *type);
+extern int journal_default_size(const blk_t blocks_count);