Commit a8007b5b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] reiserfs commit_max_age mount option

From: Nikita Danilov <Nikita@Namesys.COM>

Add "commit" reiserfs mount option to override maximal transaction age. 
Usage:

mount -treiserfs -ocommit=<time-in-seconds> /device /mountpoint

Submitted by Hugang <hugang@soulinfo.com>.
parent f37b1ef8
...@@ -1967,7 +1967,7 @@ static int journal_init_dev( struct super_block *super, ...@@ -1967,7 +1967,7 @@ static int journal_init_dev( struct super_block *super,
/* /*
** must be called once on fs mount. calls journal_read for you ** must be called once on fs mount. calls journal_read for you
*/ */
int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_format) { int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_format, unsigned int commit_max_age) {
int num_cnodes = SB_ONDISK_JOURNAL_SIZE(p_s_sb) * 2 ; int num_cnodes = SB_ONDISK_JOURNAL_SIZE(p_s_sb) * 2 ;
struct buffer_head *bhjh; struct buffer_head *bhjh;
struct reiserfs_super_block * rs; struct reiserfs_super_block * rs;
...@@ -2032,7 +2032,11 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo ...@@ -2032,7 +2032,11 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo
SB_JOURNAL_TRANS_MAX(p_s_sb) = le32_to_cpu (jh->jh_journal.jp_journal_trans_max); SB_JOURNAL_TRANS_MAX(p_s_sb) = le32_to_cpu (jh->jh_journal.jp_journal_trans_max);
SB_JOURNAL_MAX_BATCH(p_s_sb) = le32_to_cpu (jh->jh_journal.jp_journal_max_batch); SB_JOURNAL_MAX_BATCH(p_s_sb) = le32_to_cpu (jh->jh_journal.jp_journal_max_batch);
if (commit_max_age != 0) {
SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb) = commit_max_age;
} else {
SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb) = le32_to_cpu (jh->jh_journal.jp_journal_max_commit_age); SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb) = le32_to_cpu (jh->jh_journal.jp_journal_max_commit_age);
}
SB_JOURNAL_MAX_TRANS_AGE(p_s_sb) = JOURNAL_MAX_TRANS_AGE; SB_JOURNAL_MAX_TRANS_AGE(p_s_sb) = JOURNAL_MAX_TRANS_AGE;
if (SB_JOURNAL_TRANS_MAX(p_s_sb)) { if (SB_JOURNAL_TRANS_MAX(p_s_sb)) {
......
...@@ -401,7 +401,7 @@ static int show_journal(struct seq_file *m, struct super_block *sb) ...@@ -401,7 +401,7 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
DJP( jp_journal_trans_max ), DJP( jp_journal_trans_max ),
DJP( jp_journal_magic ), DJP( jp_journal_magic ),
DJP( jp_journal_max_batch ), DJP( jp_journal_max_batch ),
DJP( jp_journal_max_commit_age ), SB_JOURNAL_MAX_COMMIT_AGE(sb),
DJP( jp_journal_max_trans_age ), DJP( jp_journal_max_trans_age ),
JF( j_1st_reserved_block ), JF( j_1st_reserved_block ),
......
...@@ -645,7 +645,8 @@ static int reiserfs_parse_options (struct super_block * s, char * options, /* st ...@@ -645,7 +645,8 @@ static int reiserfs_parse_options (struct super_block * s, char * options, /* st
collection of bitflags defining what collection of bitflags defining what
mount options were selected. */ mount options were selected. */
unsigned long * blocks, /* strtol-ed from NNN of resize=NNN */ unsigned long * blocks, /* strtol-ed from NNN of resize=NNN */
char ** jdev_name) char ** jdev_name,
unsigned int * commit_max_age)
{ {
int c; int c;
char * arg = NULL; char * arg = NULL;
...@@ -662,6 +663,7 @@ static int reiserfs_parse_options (struct super_block * s, char * options, /* st ...@@ -662,6 +663,7 @@ static int reiserfs_parse_options (struct super_block * s, char * options, /* st
{"resize", 'r', 0, 0, 0}, {"resize", 'r', 0, 0, 0},
{"jdev", 'j', 0, 0, 0}, {"jdev", 'j', 0, 0, 0},
{"nolargeio", 'w', 0, 0, 0}, {"nolargeio", 'w', 0, 0, 0},
{"commit", 'c', 0, 0, 0},
{NULL, 0, 0, 0, 0} {NULL, 0, 0, 0, 0}
}; };
...@@ -690,6 +692,19 @@ static int reiserfs_parse_options (struct super_block * s, char * options, /* st ...@@ -690,6 +692,19 @@ static int reiserfs_parse_options (struct super_block * s, char * options, /* st
} }
} }
if ( c == 'c' ) {
char *p = 0;
int val = simple_strtoul (arg, &p, 0);
/* commit=NNN (time in seconds) */
if ( *p != '\0' || val == 0) {
printk ("reiserfs_parse_options: bad value %s\n", arg);
return 0;
}
if ( val > 0 ) {
*commit_max_age = val;
}
}
if ( c == 'w' ) { if ( c == 'w' ) {
char *p=0; char *p=0;
int val = simple_strtoul (arg, &p, 0); int val = simple_strtoul (arg, &p, 0);
...@@ -743,10 +758,11 @@ static int reiserfs_remount (struct super_block * s, int * mount_flags, char * a ...@@ -743,10 +758,11 @@ static int reiserfs_remount (struct super_block * s, int * mount_flags, char * a
unsigned long blocks; unsigned long blocks;
unsigned long mount_options = REISERFS_SB(s)->s_mount_opt; unsigned long mount_options = REISERFS_SB(s)->s_mount_opt;
unsigned long safe_mask = 0; unsigned long safe_mask = 0;
unsigned int commit_max_age = 0;
rs = SB_DISK_SUPER_BLOCK (s); rs = SB_DISK_SUPER_BLOCK (s);
if (!reiserfs_parse_options(s, arg, &mount_options, &blocks, NULL)) if (!reiserfs_parse_options(s, arg, &mount_options, &blocks, NULL, &commit_max_age))
return -EINVAL; return -EINVAL;
handle_attrs(s); handle_attrs(s);
...@@ -764,6 +780,10 @@ static int reiserfs_remount (struct super_block * s, int * mount_flags, char * a ...@@ -764,6 +780,10 @@ static int reiserfs_remount (struct super_block * s, int * mount_flags, char * a
* the bits we're not allowed to change here */ * the bits we're not allowed to change here */
REISERFS_SB(s)->s_mount_opt = (REISERFS_SB(s)->s_mount_opt & ~safe_mask) | (mount_options & safe_mask); REISERFS_SB(s)->s_mount_opt = (REISERFS_SB(s)->s_mount_opt & ~safe_mask) | (mount_options & safe_mask);
if(commit_max_age != 0) {
SB_JOURNAL_MAX_COMMIT_AGE(s) = commit_max_age;
}
if(blocks) { if(blocks) {
int rc = reiserfs_resize(s, blocks); int rc = reiserfs_resize(s, blocks);
if (rc != 0) if (rc != 0)
...@@ -1217,6 +1237,7 @@ static int reiserfs_fill_super (struct super_block * s, void * data, int silent) ...@@ -1217,6 +1237,7 @@ static int reiserfs_fill_super (struct super_block * s, void * data, int silent)
struct reiserfs_transaction_handle th ; struct reiserfs_transaction_handle th ;
int old_format = 0; int old_format = 0;
unsigned long blocks; unsigned long blocks;
unsigned int commit_max_age = 0;
int jinit_done = 0 ; int jinit_done = 0 ;
struct reiserfs_iget_args args ; struct reiserfs_iget_args args ;
struct reiserfs_super_block * rs; struct reiserfs_super_block * rs;
...@@ -1241,7 +1262,7 @@ static int reiserfs_fill_super (struct super_block * s, void * data, int silent) ...@@ -1241,7 +1262,7 @@ static int reiserfs_fill_super (struct super_block * s, void * data, int silent)
REISERFS_SB(s)->s_alloc_options.preallocsize = 9; REISERFS_SB(s)->s_alloc_options.preallocsize = 9;
jdev_name = NULL; jdev_name = NULL;
if (reiserfs_parse_options (s, (char *) data, &(sbi->s_mount_opt), &blocks, &jdev_name) == 0) { if (reiserfs_parse_options (s, (char *) data, &(sbi->s_mount_opt), &blocks, &jdev_name, &commit_max_age) == 0) {
goto error; goto error;
} }
...@@ -1283,7 +1304,7 @@ static int reiserfs_fill_super (struct super_block * s, void * data, int silent) ...@@ -1283,7 +1304,7 @@ static int reiserfs_fill_super (struct super_block * s, void * data, int silent)
#endif #endif
// set_device_ro(s->s_dev, 1) ; // set_device_ro(s->s_dev, 1) ;
if(journal_init(s, jdev_name, old_format)) { if( journal_init(s, jdev_name, old_format, commit_max_age) ) {
SPRINTK(silent, "sh-2022: reiserfs_fill_super: unable to initialize journal space\n") ; SPRINTK(silent, "sh-2022: reiserfs_fill_super: unable to initialize journal space\n") ;
goto error ; goto error ;
} else { } else {
......
...@@ -1719,7 +1719,7 @@ void reiserfs_allow_writes(struct super_block *s) ; ...@@ -1719,7 +1719,7 @@ void reiserfs_allow_writes(struct super_block *s) ;
void reiserfs_check_lock_depth(char *caller) ; void reiserfs_check_lock_depth(char *caller) ;
void reiserfs_prepare_for_journal(struct super_block *, struct buffer_head *bh, int wait) ; void reiserfs_prepare_for_journal(struct super_block *, struct buffer_head *bh, int wait) ;
void reiserfs_restore_prepared_buffer(struct super_block *, struct buffer_head *bh) ; void reiserfs_restore_prepared_buffer(struct super_block *, struct buffer_head *bh) ;
int journal_init(struct super_block *, const char * j_dev_name, int old_format) ; int journal_init(struct super_block *, const char * j_dev_name, int old_format, unsigned int) ;
int journal_release(struct reiserfs_transaction_handle*, struct super_block *) ; int journal_release(struct reiserfs_transaction_handle*, struct super_block *) ;
int journal_release_error(struct reiserfs_transaction_handle*, struct super_block *) ; int journal_release_error(struct reiserfs_transaction_handle*, struct super_block *) ;
int journal_end(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ; int journal_end(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment