aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2011-03-08 21:05:07 -0500
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2011-03-08 21:05:07 -0500
commit3b2ce58b0f3c1633750529713be0e467282abd78 (patch)
tree48c0111adadf00e67933fb5d9883296754fca6ce /fs/nilfs2
parentbe667377a8b8cd73e1b923f33fb5be4034aa4bfa (diff)
nilfs2: move mount options to nilfs object
This moves mount_opt local variable to nilfs object from nilfs_sb_info struct. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/sb.h16
-rw-r--r--fs/nilfs2/segment.c9
-rw-r--r--fs/nilfs2/super.c56
-rw-r--r--fs/nilfs2/the_nilfs.c4
-rw-r--r--fs/nilfs2/the_nilfs.h18
5 files changed, 54 insertions, 49 deletions
diff --git a/fs/nilfs2/sb.h b/fs/nilfs2/sb.h
index 7a17715f215f..d7346c949c81 100644
--- a/fs/nilfs2/sb.h
+++ b/fs/nilfs2/sb.h
@@ -34,8 +34,6 @@ struct nilfs_sc_info;
34 * NILFS super-block data in memory 34 * NILFS super-block data in memory
35 */ 35 */
36struct nilfs_sb_info { 36struct nilfs_sb_info {
37 /* Mount options */
38 unsigned long s_mount_opt;
39 uid_t s_resuid; 37 uid_t s_resuid;
40 gid_t s_resgid; 38 gid_t s_resgid;
41 39
@@ -68,18 +66,4 @@ static inline struct nilfs_sc_info *NILFS_SC(struct nilfs_sb_info *sbi)
68 return sbi->s_sc_info; 66 return sbi->s_sc_info;
69} 67}
70 68
71/*
72 * Bit operations for the mount option
73 */
74#define nilfs_clear_opt(sbi, opt) \
75 do { (sbi)->s_mount_opt &= ~NILFS_MOUNT_##opt; } while (0)
76#define nilfs_set_opt(sbi, opt) \
77 do { (sbi)->s_mount_opt |= NILFS_MOUNT_##opt; } while (0)
78#define nilfs_test_opt(sbi, opt) ((sbi)->s_mount_opt & NILFS_MOUNT_##opt)
79#define nilfs_write_opt(sbi, mask, opt) \
80 do { (sbi)->s_mount_opt = \
81 (((sbi)->s_mount_opt & ~NILFS_MOUNT_##mask) | \
82 NILFS_MOUNT_##opt); \
83 } while (0)
84
85#endif /* _NILFS_SB */ 69#endif /* _NILFS_SB */
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 2de9f636792a..851bcd3890c8 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -2298,6 +2298,7 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
2298 loff_t start, loff_t end) 2298 loff_t start, loff_t end)
2299{ 2299{
2300 struct nilfs_sb_info *sbi = NILFS_SB(sb); 2300 struct nilfs_sb_info *sbi = NILFS_SB(sb);
2301 struct the_nilfs *nilfs = sbi->s_nilfs;
2301 struct nilfs_sc_info *sci = NILFS_SC(sbi); 2302 struct nilfs_sc_info *sci = NILFS_SC(sbi);
2302 struct nilfs_inode_info *ii; 2303 struct nilfs_inode_info *ii;
2303 struct nilfs_transaction_info ti; 2304 struct nilfs_transaction_info ti;
@@ -2310,9 +2311,9 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
2310 2311
2311 ii = NILFS_I(inode); 2312 ii = NILFS_I(inode);
2312 if (test_bit(NILFS_I_INODE_DIRTY, &ii->i_state) || 2313 if (test_bit(NILFS_I_INODE_DIRTY, &ii->i_state) ||
2313 nilfs_test_opt(sbi, STRICT_ORDER) || 2314 nilfs_test_opt(nilfs, STRICT_ORDER) ||
2314 test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) || 2315 test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) ||
2315 nilfs_discontinued(sbi->s_nilfs)) { 2316 nilfs_discontinued(nilfs)) {
2316 nilfs_transaction_unlock(sbi); 2317 nilfs_transaction_unlock(sbi);
2317 err = nilfs_segctor_sync(sci); 2318 err = nilfs_segctor_sync(sci);
2318 return err; 2319 return err;
@@ -2480,14 +2481,14 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
2480 set_current_state(TASK_INTERRUPTIBLE); 2481 set_current_state(TASK_INTERRUPTIBLE);
2481 schedule_timeout(sci->sc_interval); 2482 schedule_timeout(sci->sc_interval);
2482 } 2483 }
2483 if (nilfs_test_opt(sbi, DISCARD)) { 2484 if (nilfs_test_opt(nilfs, DISCARD)) {
2484 int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs, 2485 int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs,
2485 sci->sc_nfreesegs); 2486 sci->sc_nfreesegs);
2486 if (ret) { 2487 if (ret) {
2487 printk(KERN_WARNING 2488 printk(KERN_WARNING
2488 "NILFS warning: error %d on discard request, " 2489 "NILFS warning: error %d on discard request, "
2489 "turning discards off for the device\n", ret); 2490 "turning discards off for the device\n", ret);
2490 nilfs_clear_opt(sbi, DISCARD); 2491 nilfs_clear_opt(nilfs, DISCARD);
2491 } 2492 }
2492 } 2493 }
2493 2494
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 1673b3d99842..0576cb21d699 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -109,7 +109,7 @@ static void nilfs_set_error(struct nilfs_sb_info *sbi)
109void nilfs_error(struct super_block *sb, const char *function, 109void nilfs_error(struct super_block *sb, const char *function,
110 const char *fmt, ...) 110 const char *fmt, ...)
111{ 111{
112 struct nilfs_sb_info *sbi = NILFS_SB(sb); 112 struct the_nilfs *nilfs = sbi->s_nilfs;
113 struct va_format vaf; 113 struct va_format vaf;
114 va_list args; 114 va_list args;
115 115
@@ -126,13 +126,13 @@ void nilfs_error(struct super_block *sb, const char *function,
126 if (!(sb->s_flags & MS_RDONLY)) { 126 if (!(sb->s_flags & MS_RDONLY)) {
127 nilfs_set_error(sbi); 127 nilfs_set_error(sbi);
128 128
129 if (nilfs_test_opt(sbi, ERRORS_RO)) { 129 if (nilfs_test_opt(nilfs, ERRORS_RO)) {
130 printk(KERN_CRIT "Remounting filesystem read-only\n"); 130 printk(KERN_CRIT "Remounting filesystem read-only\n");
131 sb->s_flags |= MS_RDONLY; 131 sb->s_flags |= MS_RDONLY;
132 } 132 }
133 } 133 }
134 134
135 if (nilfs_test_opt(sbi, ERRORS_PANIC)) 135 if (nilfs_test_opt(nilfs, ERRORS_PANIC))
136 panic("NILFS (device %s): panic forced after error\n", 136 panic("NILFS (device %s): panic forced after error\n",
137 sb->s_id); 137 sb->s_id);
138} 138}
@@ -196,7 +196,7 @@ static int nilfs_sync_super(struct nilfs_sb_info *sbi, int flag)
196 196
197 retry: 197 retry:
198 set_buffer_dirty(nilfs->ns_sbh[0]); 198 set_buffer_dirty(nilfs->ns_sbh[0]);
199 if (nilfs_test_opt(sbi, BARRIER)) { 199 if (nilfs_test_opt(nilfs, BARRIER)) {
200 err = __sync_dirty_buffer(nilfs->ns_sbh[0], 200 err = __sync_dirty_buffer(nilfs->ns_sbh[0],
201 WRITE_SYNC | WRITE_FLUSH_FUA); 201 WRITE_SYNC | WRITE_FLUSH_FUA);
202 } else { 202 } else {
@@ -530,22 +530,22 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf)
530static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs) 530static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
531{ 531{
532 struct super_block *sb = vfs->mnt_sb; 532 struct super_block *sb = vfs->mnt_sb;
533 struct nilfs_sb_info *sbi = NILFS_SB(sb); 533 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
534 struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root; 534 struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root;
535 535
536 if (!nilfs_test_opt(sbi, BARRIER)) 536 if (!nilfs_test_opt(nilfs, BARRIER))
537 seq_puts(seq, ",nobarrier"); 537 seq_puts(seq, ",nobarrier");
538 if (root->cno != NILFS_CPTREE_CURRENT_CNO) 538 if (root->cno != NILFS_CPTREE_CURRENT_CNO)
539 seq_printf(seq, ",cp=%llu", (unsigned long long)root->cno); 539 seq_printf(seq, ",cp=%llu", (unsigned long long)root->cno);
540 if (nilfs_test_opt(sbi, ERRORS_PANIC)) 540 if (nilfs_test_opt(nilfs, ERRORS_PANIC))
541 seq_puts(seq, ",errors=panic"); 541 seq_puts(seq, ",errors=panic");
542 if (nilfs_test_opt(sbi, ERRORS_CONT)) 542 if (nilfs_test_opt(nilfs, ERRORS_CONT))
543 seq_puts(seq, ",errors=continue"); 543 seq_puts(seq, ",errors=continue");
544 if (nilfs_test_opt(sbi, STRICT_ORDER)) 544 if (nilfs_test_opt(nilfs, STRICT_ORDER))
545 seq_puts(seq, ",order=strict"); 545 seq_puts(seq, ",order=strict");
546 if (nilfs_test_opt(sbi, NORECOVERY)) 546 if (nilfs_test_opt(nilfs, NORECOVERY))
547 seq_puts(seq, ",norecovery"); 547 seq_puts(seq, ",norecovery");
548 if (nilfs_test_opt(sbi, DISCARD)) 548 if (nilfs_test_opt(nilfs, DISCARD))
549 seq_puts(seq, ",discard"); 549 seq_puts(seq, ",discard");
550 550
551 return 0; 551 return 0;
@@ -594,7 +594,7 @@ static match_table_t tokens = {
594 594
595static int parse_options(char *options, struct super_block *sb, int is_remount) 595static int parse_options(char *options, struct super_block *sb, int is_remount)
596{ 596{
597 struct nilfs_sb_info *sbi = NILFS_SB(sb); 597 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
598 char *p; 598 char *p;
599 substring_t args[MAX_OPT_ARGS]; 599 substring_t args[MAX_OPT_ARGS];
600 600
@@ -609,29 +609,29 @@ static int parse_options(char *options, struct super_block *sb, int is_remount)
609 token = match_token(p, tokens, args); 609 token = match_token(p, tokens, args);
610 switch (token) { 610 switch (token) {
611 case Opt_barrier: 611 case Opt_barrier:
612 nilfs_set_opt(sbi, BARRIER); 612 nilfs_set_opt(nilfs, BARRIER);
613 break; 613 break;
614 case Opt_nobarrier: 614 case Opt_nobarrier:
615 nilfs_clear_opt(sbi, BARRIER); 615 nilfs_clear_opt(nilfs, BARRIER);
616 break; 616 break;
617 case Opt_order: 617 case Opt_order:
618 if (strcmp(args[0].from, "relaxed") == 0) 618 if (strcmp(args[0].from, "relaxed") == 0)
619 /* Ordered data semantics */ 619 /* Ordered data semantics */
620 nilfs_clear_opt(sbi, STRICT_ORDER); 620 nilfs_clear_opt(nilfs, STRICT_ORDER);
621 else if (strcmp(args[0].from, "strict") == 0) 621 else if (strcmp(args[0].from, "strict") == 0)
622 /* Strict in-order semantics */ 622 /* Strict in-order semantics */
623 nilfs_set_opt(sbi, STRICT_ORDER); 623 nilfs_set_opt(nilfs, STRICT_ORDER);
624 else 624 else
625 return 0; 625 return 0;
626 break; 626 break;
627 case Opt_err_panic: 627 case Opt_err_panic:
628 nilfs_write_opt(sbi, ERROR_MODE, ERRORS_PANIC); 628 nilfs_write_opt(nilfs, ERROR_MODE, ERRORS_PANIC);
629 break; 629 break;
630 case Opt_err_ro: 630 case Opt_err_ro:
631 nilfs_write_opt(sbi, ERROR_MODE, ERRORS_RO); 631 nilfs_write_opt(nilfs, ERROR_MODE, ERRORS_RO);
632 break; 632 break;
633 case Opt_err_cont: 633 case Opt_err_cont:
634 nilfs_write_opt(sbi, ERROR_MODE, ERRORS_CONT); 634 nilfs_write_opt(nilfs, ERROR_MODE, ERRORS_CONT);
635 break; 635 break;
636 case Opt_snapshot: 636 case Opt_snapshot:
637 if (is_remount) { 637 if (is_remount) {
@@ -642,13 +642,13 @@ static int parse_options(char *options, struct super_block *sb, int is_remount)
642 } 642 }
643 break; 643 break;
644 case Opt_norecovery: 644 case Opt_norecovery:
645 nilfs_set_opt(sbi, NORECOVERY); 645 nilfs_set_opt(nilfs, NORECOVERY);
646 break; 646 break;
647 case Opt_discard: 647 case Opt_discard:
648 nilfs_set_opt(sbi, DISCARD); 648 nilfs_set_opt(nilfs, DISCARD);
649 break; 649 break;
650 case Opt_nodiscard: 650 case Opt_nodiscard:
651 nilfs_clear_opt(sbi, DISCARD); 651 nilfs_clear_opt(nilfs, DISCARD);
652 break; 652 break;
653 default: 653 default:
654 printk(KERN_ERR 654 printk(KERN_ERR
@@ -660,10 +660,12 @@ static int parse_options(char *options, struct super_block *sb, int is_remount)
660} 660}
661 661
662static inline void 662static inline void
663nilfs_set_default_options(struct nilfs_sb_info *sbi, 663nilfs_set_default_options(struct super_block *sb,
664 struct nilfs_super_block *sbp) 664 struct nilfs_super_block *sbp)
665{ 665{
666 sbi->s_mount_opt = 666 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
667
668 nilfs->ns_mount_opt =
667 NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER; 669 NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER;
668} 670}
669 671
@@ -736,7 +738,7 @@ int nilfs_store_magic_and_option(struct super_block *sb,
736 sb->s_flags |= MS_NOATIME; 738 sb->s_flags |= MS_NOATIME;
737#endif 739#endif
738 740
739 nilfs_set_default_options(sbi, sbp); 741 nilfs_set_default_options(sb, sbp);
740 742
741 sbi->s_resuid = le16_to_cpu(sbp->s_def_resuid); 743 sbi->s_resuid = le16_to_cpu(sbp->s_def_resuid);
742 sbi->s_resgid = le16_to_cpu(sbp->s_def_resgid); 744 sbi->s_resgid = le16_to_cpu(sbp->s_def_resgid);
@@ -1023,7 +1025,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
1023 int err; 1025 int err;
1024 1026
1025 old_sb_flags = sb->s_flags; 1027 old_sb_flags = sb->s_flags;
1026 old_mount_opt = sbi->s_mount_opt; 1028 old_mount_opt = nilfs->ns_mount_opt;
1027 1029
1028 if (!parse_options(data, sb, 1)) { 1030 if (!parse_options(data, sb, 1)) {
1029 err = -EINVAL; 1031 err = -EINVAL;
@@ -1092,7 +1094,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
1092 1094
1093 restore_opts: 1095 restore_opts:
1094 sb->s_flags = old_sb_flags; 1096 sb->s_flags = old_sb_flags;
1095 sbi->s_mount_opt = old_mount_opt; 1097 nilfs->ns_mount_opt = old_mount_opt;
1096 return err; 1098 return err;
1097} 1099}
1098 1100
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 9098909d5cef..d3775336a16c 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -283,7 +283,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
283 if (s_flags & MS_RDONLY) { 283 if (s_flags & MS_RDONLY) {
284 __u64 features; 284 __u64 features;
285 285
286 if (nilfs_test_opt(sbi, NORECOVERY)) { 286 if (nilfs_test_opt(nilfs, NORECOVERY)) {
287 printk(KERN_INFO "NILFS: norecovery option specified. " 287 printk(KERN_INFO "NILFS: norecovery option specified. "
288 "skipping roll-forward recovery\n"); 288 "skipping roll-forward recovery\n");
289 goto skip_recovery; 289 goto skip_recovery;
@@ -305,7 +305,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
305 goto failed_unload; 305 goto failed_unload;
306 } 306 }
307 sbi->s_super->s_flags &= ~MS_RDONLY; 307 sbi->s_super->s_flags &= ~MS_RDONLY;
308 } else if (nilfs_test_opt(sbi, NORECOVERY)) { 308 } else if (nilfs_test_opt(nilfs, NORECOVERY)) {
309 printk(KERN_ERR "NILFS: recovery cancelled because norecovery " 309 printk(KERN_ERR "NILFS: recovery cancelled because norecovery "
310 "option was specified for a read/write mount\n"); 310 "option was specified for a read/write mount\n");
311 err = -EINVAL; 311 err = -EINVAL;
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index fd85e4c05c6b..438278041d80 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -72,6 +72,7 @@ enum {
72 * @ns_cptree: rb-tree of all mounted checkpoints (nilfs_root) 72 * @ns_cptree: rb-tree of all mounted checkpoints (nilfs_root)
73 * @ns_cptree_lock: lock protecting @ns_cptree 73 * @ns_cptree_lock: lock protecting @ns_cptree
74 * @ns_gc_inodes: dummy inodes to keep live blocks 74 * @ns_gc_inodes: dummy inodes to keep live blocks
75 * @ns_mount_opt: mount options
75 * @ns_blocksize_bits: bit length of block size 76 * @ns_blocksize_bits: bit length of block size
76 * @ns_blocksize: block size 77 * @ns_blocksize: block size
77 * @ns_nsegments: number of segments in filesystem 78 * @ns_nsegments: number of segments in filesystem
@@ -148,6 +149,9 @@ struct the_nilfs {
148 /* GC inode list */ 149 /* GC inode list */
149 struct list_head ns_gc_inodes; 150 struct list_head ns_gc_inodes;
150 151
152 /* Mount options */
153 unsigned long ns_mount_opt;
154
151 /* Disk layout information (static) */ 155 /* Disk layout information (static) */
152 unsigned int ns_blocksize_bits; 156 unsigned int ns_blocksize_bits;
153 unsigned int ns_blocksize; 157 unsigned int ns_blocksize;
@@ -180,6 +184,20 @@ THE_NILFS_FNS(DISCONTINUED, discontinued)
180THE_NILFS_FNS(GC_RUNNING, gc_running) 184THE_NILFS_FNS(GC_RUNNING, gc_running)
181THE_NILFS_FNS(SB_DIRTY, sb_dirty) 185THE_NILFS_FNS(SB_DIRTY, sb_dirty)
182 186
187/*
188 * Mount option operations
189 */
190#define nilfs_clear_opt(nilfs, opt) \
191 do { (nilfs)->ns_mount_opt &= ~NILFS_MOUNT_##opt; } while (0)
192#define nilfs_set_opt(nilfs, opt) \
193 do { (nilfs)->ns_mount_opt |= NILFS_MOUNT_##opt; } while (0)
194#define nilfs_test_opt(nilfs, opt) ((nilfs)->ns_mount_opt & NILFS_MOUNT_##opt)
195#define nilfs_write_opt(nilfs, mask, opt) \
196 do { (nilfs)->ns_mount_opt = \
197 (((nilfs)->ns_mount_opt & ~NILFS_MOUNT_##mask) | \
198 NILFS_MOUNT_##opt); \
199 } while (0)
200
183/** 201/**
184 * struct nilfs_root - nilfs root object 202 * struct nilfs_root - nilfs root object
185 * @cno: checkpoint number 203 * @cno: checkpoint number