From: Bart Samwel Add support for value 0 to the commit option of reiserfs. Means "restore to the default value". For the maximum commit age, this default value is normally read from the journal; this patch adds an extra variable to cache the default value for the maximum commit age. --- 25-akpm/fs/reiserfs/journal.c | 1 + 25-akpm/fs/reiserfs/super.c | 16 ++++++++++------ 25-akpm/include/linux/reiserfs_fs_sb.h | 2 ++ 3 files changed, 13 insertions(+), 6 deletions(-) diff -puN fs/reiserfs/journal.c~reiserfs-commit-default fs/reiserfs/journal.c --- 25/fs/reiserfs/journal.c~reiserfs-commit-default 2004-03-31 23:14:20.256178464 -0800 +++ 25-akpm/fs/reiserfs/journal.c 2004-03-31 23:14:20.266176944 -0800 @@ -2308,6 +2308,7 @@ int journal_init(struct super_block *p_s SB_JOURNAL_MAX_TRANS_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_DEFAULT_MAX_COMMIT_AGE(p_s_sb) = SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb); SB_JOURNAL_MAX_TRANS_AGE(p_s_sb) = JOURNAL_MAX_TRANS_AGE; } diff -puN fs/reiserfs/super.c~reiserfs-commit-default fs/reiserfs/super.c --- 25/fs/reiserfs/super.c~reiserfs-commit-default 2004-03-31 23:14:20.258178160 -0800 +++ 25-akpm/fs/reiserfs/super.c 2004-03-31 23:14:20.267176792 -0800 @@ -709,13 +709,11 @@ static int reiserfs_parse_options (struc char *p = 0; int val = simple_strtoul (arg, &p, 0); /* commit=NNN (time in seconds) */ - if ( *p != '\0' || val == 0) { + if ( *p != '\0' || val < 0) { printk ("reiserfs_parse_options: bad value %s\n", arg); return 0; } - if ( val > 0 ) { - *commit_max_age = val; - } + *commit_max_age = val; } if ( c == 'w' ) { @@ -821,8 +819,14 @@ static int reiserfs_remount (struct supe 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; - SB_JOURNAL_MAX_TRANS_AGE(s) = commit_max_age; + SB_JOURNAL_MAX_COMMIT_AGE(s) = commit_max_age; + SB_JOURNAL_MAX_TRANS_AGE(s) = commit_max_age; + } + else + { + /* 0 means restore defaults. */ + SB_JOURNAL_MAX_COMMIT_AGE(s) = SB_JOURNAL_DEFAULT_MAX_COMMIT_AGE(s); + SB_JOURNAL_MAX_TRANS_AGE(s) = JOURNAL_MAX_TRANS_AGE; } if(blocks) { diff -puN include/linux/reiserfs_fs_sb.h~reiserfs-commit-default include/linux/reiserfs_fs_sb.h --- 25/include/linux/reiserfs_fs_sb.h~reiserfs-commit-default 2004-03-31 23:14:20.259178008 -0800 +++ 25-akpm/include/linux/reiserfs_fs_sb.h 2004-03-31 23:14:20.268176640 -0800 @@ -208,6 +208,7 @@ struct reiserfs_journal { unsigned int s_journal_trans_max ; /* max number of blocks in a transaction. */ unsigned int s_journal_max_batch ; /* max number of blocks to batch into a trans */ unsigned int s_journal_max_commit_age ; /* in seconds, how old can an async commit be */ + unsigned int s_journal_default_max_commit_age ; /* the default for the max commit age */ unsigned int s_journal_max_trans_age ; /* in seconds, how old can a transaction be */ struct reiserfs_journal_cnode *j_cnode_free_list ; @@ -481,6 +482,7 @@ int reiserfs_resize(struct super_block * #define SB_JOURNAL_TRANS_MAX(s) (SB_JOURNAL(s)->s_journal_trans_max) #define SB_JOURNAL_MAX_BATCH(s) (SB_JOURNAL(s)->s_journal_max_batch) #define SB_JOURNAL_MAX_COMMIT_AGE(s) (SB_JOURNAL(s)->s_journal_max_commit_age) +#define SB_JOURNAL_DEFAULT_MAX_COMMIT_AGE(s) (SB_JOURNAL(s)->s_journal_default_max_commit_age) #define SB_JOURNAL_MAX_TRANS_AGE(s) (SB_JOURNAL(s)->s_journal_max_trans_age) /* A safe version of the "bdevname", which returns the "s_id" field of _