aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/the_nilfs.c
diff options
context:
space:
mode:
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{