aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/the_nilfs.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-06-07 12:39:31 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-06-11 21:36:18 -0400
commit6dd4740662405a68bb229ac2b9e0aeaaf2188bf2 (patch)
tree36e6ae2a095613be1c36e8828ee9471e60c09de6 /fs/nilfs2/the_nilfs.c
parent3f82ff55168e92859119bf348e9e0bd6714d2fea (diff)
nilfs2: simplify remaining sget() use
This simplifies the test function passed on the remaining sget() callsite in nilfs. Instead of checking mount type (i.e. ro-mount/rw-mount/snapshot mount) in the test function passed to sget(), this patch first looks up the nilfs_sb_info struct which the given mount type matches, and then acquires the super block instance holding the nilfs_sb_info. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nilfs2/the_nilfs.c')
-rw-r--r--fs/nilfs2/the_nilfs.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 45dbf6a61744..221953bfc859 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -664,6 +664,56 @@ int nilfs_near_disk_full(struct the_nilfs *nilfs)
664 return ret; 664 return ret;
665} 665}
666 666
667/**
668 * nilfs_find_sbinfo - find existing nilfs_sb_info structure
669 * @nilfs: nilfs object
670 * @rw_mount: mount type (non-zero value for read/write mount)
671 * @cno: checkpoint number (zero for read-only mount)
672 *
673 * nilfs_find_sbinfo() returns the nilfs_sb_info structure which
674 * @rw_mount and @cno (in case of snapshots) matched. If no instance
675 * was found, NULL is returned. Although the super block instance can
676 * be unmounted after this function returns, the nilfs_sb_info struct
677 * is kept on memory until nilfs_put_sbinfo() is called.
678 */
679struct nilfs_sb_info *nilfs_find_sbinfo(struct the_nilfs *nilfs,
680 int rw_mount, __u64 cno)
681{
682 struct nilfs_sb_info *sbi;
683
684 down_read(&nilfs->ns_sem);
685 /*
686 * The SNAPSHOT flag and sb->s_flags are supposed to be
687 * protected with nilfs->ns_sem.
688 */
689 sbi = nilfs->ns_current;
690 if (rw_mount) {
691 if (sbi && !(sbi->s_super->s_flags & MS_RDONLY))
692 goto found; /* read/write mount */
693 else
694 goto out;
695 } else if (cno == 0) {
696 if (sbi && (sbi->s_super->s_flags & MS_RDONLY))
697 goto found; /* read-only mount */
698 else
699 goto out;
700 }
701
702 list_for_each_entry(sbi, &nilfs->ns_supers, s_list) {
703 if (nilfs_test_opt(sbi, SNAPSHOT) &&
704 sbi->s_snapshot_cno == cno)
705 goto found; /* snapshot mount */
706 }
707 out:
708 up_read(&nilfs->ns_sem);
709 return NULL;
710
711 found:
712 atomic_inc(&sbi->s_count);
713 up_read(&nilfs->ns_sem);
714 return sbi;
715}
716
667int nilfs_checkpoint_is_mounted(struct the_nilfs *nilfs, __u64 cno, 717int nilfs_checkpoint_is_mounted(struct the_nilfs *nilfs, __u64 cno,
668 int snapshot_mount) 718 int snapshot_mount)
669{ 719{