Whamcloud - gitweb
tune2fs, mke2fs: add the ability to control the location of the journal
authorTheodore Ts'o <tytso@mit.edu>
Tue, 28 Jan 2014 17:58:56 +0000 (12:58 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 30 Jan 2014 18:58:17 +0000 (13:58 -0500)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/mke2fs.8.in
misc/mke2fs.c
misc/mke2fs.conf.5.in
misc/tune2fs.8.in
misc/tune2fs.c
misc/util.c
misc/util.h

index 67ddbf8..ae74bce 100644 (file)
@@ -409,6 +409,13 @@ The size of the journal must be at least 1024 filesystem blocks
 (i.e., 1MB if using 1k blocks, 4MB if using 4k blocks, etc.)
 and may be no more than 10,240,000 filesystem blocks or half the total
 file system size (whichever is smaller)
+.TP
+.BI location =journal-location
+Specify the location of the journal.  The argument
+.I journal-location
+can either be specified as a block number, or if the number has a units
+suffix (e.g., 'M', 'G', etc.) interpret it as the offset from the
+beginning of the file system.
 @JDEV@.TP
 @JDEV@.BI device= external-journal
 @JDEV@Attach the filesystem to the journal block device located on
index acc603d..dd77a00 100644 (file)
@@ -97,6 +97,7 @@ static char   *bad_blocks_filename = NULL;
 static __u32   fs_stride;
 static int     quotatype = -1;  /* Initialize both user and group quotas by default */
 static __u64   offset;
+static blk64_t journal_location = ~0LL;
 
 static struct ext2_super_block fs_param;
 static char *fs_uuid = NULL;
@@ -2010,6 +2011,15 @@ profile_error:
                                               EXT2_MKJOURNAL_LAZYINIT : 0;
        journal_flags |= EXT2_MKJOURNAL_NO_MNT_CHECK;
 
+       if (!journal_location_string)
+               journal_location_string = get_string_from_profile(fs_types,
+                                               "journal_location", "");
+       if ((journal_location == ~0ULL) && journal_location_string &&
+           *journal_location_string)
+               journal_location = parse_num_blocks2(journal_location_string,
+                                               fs_param.s_log_block_size);
+       free(journal_location_string);
+
        /* Get options from profile */
        for (cpp = fs_types; *cpp; cpp++) {
                tmp = NULL;
@@ -2724,8 +2734,9 @@ int main (int argc, char *argv[])
                               journal_blocks);
                        fflush(stdout);
                }
-               retval = ext2fs_add_journal_inode(fs, journal_blocks,
-                                                 journal_flags);
+               retval = ext2fs_add_journal_inode2(fs, journal_blocks,
+                                                  journal_location,
+                                                  journal_flags);
                if (retval) {
                        com_err(program_name, retval, "%s",
                                _("\n\twhile trying to create journal"));
index 0625d0e..758cdf4 100644 (file)
@@ -357,6 +357,9 @@ initialization noticeably, but it requires the kernel to finish
 initializing the filesystem in the background when the filesystem is
 first mounted.
 .TP
+.I journal_location
+This relation specifies the location of the journal.
+.TP
 .I inode_ratio
 This relation specifies the default inode ratio if the user does not
 specify one on the command line.
index da21080..9455707 100644 (file)
@@ -333,6 +333,13 @@ megabytes.   The size of the journal must be at least 1024 filesystem blocks
 and may be no more than 102,400 filesystem blocks.
 There must be enough free space in the filesystem to create a journal of
 that size.
+.TP
+.BI location =journal-location
+Specify the location of the journal.  The argument
+.I journal-location
+can either be specified as a block number, or if the number has a units
+suffix (e.g., 'M', 'G', etc.) interpret it as the offset from the
+beginning of the file system.
 @JDEV@.TP
 @JDEV@.BI device= external-journal
 @JDEV@Attach the filesystem to the journal block device located on
index b8cd347..64a76f1 100644 (file)
@@ -98,6 +98,7 @@ static int usrquota, grpquota;
 
 int journal_size, journal_flags;
 char *journal_device;
+static blk64_t journal_location = ~0LL;
 
 static struct list_head blk_move_list;
 
@@ -694,8 +695,13 @@ static int add_journal(ext2_filsys fs)
                fflush(stdout);
                journal_blocks = figure_journal_size(journal_size, fs);
 
-               retval = ext2fs_add_journal_inode(fs, journal_blocks,
-                                                 journal_flags);
+               if (journal_location_string)
+                       journal_location =
+                               parse_num_blocks2(journal_location_string,
+                                                 fs->super->s_log_block_size);
+               retval = ext2fs_add_journal_inode2(fs, journal_blocks,
+                                                  journal_location,
+                                                  journal_flags);
                if (retval) {
                        fprintf(stderr, "\n");
                        com_err(program_name, retval, "%s",
index 40c8858..92ab79f 100644 (file)
@@ -34,6 +34,8 @@
 #include "blkid/blkid.h"
 #include "util.h"
 
+char *journal_location_string = NULL;
+
 #ifndef HAVE_STRCASECMP
 int strcasecmp (char *s1, char *s2)
 {
@@ -218,6 +220,12 @@ void parse_journal_opts(const char *opts)
                        journal_size = strtoul(arg, &p, 0);
                        if (*p)
                                journal_usage++;
+               } else if (!strcmp(token, "location")) {
+                       if (!arg) {
+                               journal_usage++;
+                               continue;
+                       }
+                       journal_location_string = strdup(arg);
                } else if (strcmp(token, "v1_superblock") == 0) {
                        journal_flags |= EXT2_MKJOURNAL_V1_SUPER;
                        continue;
@@ -231,7 +239,8 @@ void parse_journal_opts(const char *opts)
                        "\tis set off by an equals ('=') sign.\n\n"
                        "Valid journal options are:\n"
                        "\tsize=<journal size in megabytes>\n"
-                       "\tdevice=<journal device>\n\n"
+                       "\tdevice=<journal device>\n"
+                       "\tlocation=<journal location>\n\n"
                        "The journal size must be between "
                        "1024 and 10240000 filesystem blocks.\n\n"), stderr);
                free(buf);
index f872c38..11604d0 100644 (file)
@@ -13,6 +13,7 @@
 extern int      journal_size;
 extern int      journal_flags;
 extern char    *journal_device;
+extern char    *journal_location_string;
 
 #ifndef HAVE_STRCASECMP
 extern int strcasecmp (char *s1, char *s2);