From: Theodore Ts'o Date: Tue, 28 Jan 2014 17:58:56 +0000 (-0500) Subject: tune2fs, mke2fs: add the ability to control the location of the journal X-Git-Tag: v1.42.10~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b818205feb60f7a7bec5e325462294f586735215;p=thirdparty%2Fe2fsprogs.git tune2fs, mke2fs: add the ability to control the location of the journal Signed-off-by: "Theodore Ts'o" --- diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in index 67ddbf8a8..ae74bce42 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -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 diff --git a/misc/mke2fs.c b/misc/mke2fs.c index acc603d37..dd77a00a4 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -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")); diff --git a/misc/mke2fs.conf.5.in b/misc/mke2fs.conf.5.in index 0625d0ef6..758cdf497 100644 --- a/misc/mke2fs.conf.5.in +++ b/misc/mke2fs.conf.5.in @@ -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. diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in index da21080a8..94557076c 100644 --- a/misc/tune2fs.8.in +++ b/misc/tune2fs.8.in @@ -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 diff --git a/misc/tune2fs.c b/misc/tune2fs.c index b8cd347eb..64a76f1e4 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -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", diff --git a/misc/util.c b/misc/util.c index 40c8858c2..92ab79f05 100644 --- a/misc/util.c +++ b/misc/util.c @@ -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=\n" - "\tdevice=\n\n" + "\tdevice=\n" + "\tlocation=\n\n" "The journal size must be between " "1024 and 10240000 filesystem blocks.\n\n"), stderr); free(buf); diff --git a/misc/util.h b/misc/util.h index f872c38c4..11604d013 100644 --- a/misc/util.h +++ b/misc/util.h @@ -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);