aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-08-14 08:44:51 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:35 -0400
commitfd52202930b7e8db48bee5a6fc6b1f438e822a23 (patch)
tree1ecb7ce60634b5575dd463417447555ef9f1576a /fs/nilfs2
parentb7c0634204993d7c6678c852e4bd118426599111 (diff)
nilfs2: use checkpoint tree for mount check of snapshots
This rewrites nilfs_checkpoint_is_mounted() function so that it decides whether a checkpoint is mounted by whether the corresponding root object is found in checkpoint tree. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/the_nilfs.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index f1d599273d9e..89c78562d0e9 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -954,26 +954,20 @@ struct nilfs_sb_info *nilfs_find_sbinfo(struct the_nilfs *nilfs,
954int nilfs_checkpoint_is_mounted(struct the_nilfs *nilfs, __u64 cno, 954int nilfs_checkpoint_is_mounted(struct the_nilfs *nilfs, __u64 cno,
955 int snapshot_mount) 955 int snapshot_mount)
956{ 956{
957 struct nilfs_sb_info *sbi; 957 struct nilfs_root *root;
958 int ret = 0; 958 int ret;
959 959
960 down_read(&nilfs->ns_super_sem); 960 if (cno < 0 || cno > nilfs->ns_cno)
961 if (cno == 0 || cno > nilfs->ns_cno) 961 return false;
962 goto out_unlock;
963 962
964 list_for_each_entry(sbi, &nilfs->ns_supers, s_list) {
965 if (sbi->s_snapshot_cno == cno &&
966 (!snapshot_mount || nilfs_test_opt(sbi, SNAPSHOT))) {
967 /* exclude read-only mounts */
968 ret++;
969 break;
970 }
971 }
972 /* for protecting recent checkpoints */
973 if (cno >= nilfs_last_cno(nilfs)) 963 if (cno >= nilfs_last_cno(nilfs))
974 ret++; 964 return true; /* protect recent checkpoints */
975 965
976 out_unlock: 966 ret = false;
977 up_read(&nilfs->ns_super_sem); 967 root = nilfs_lookup_root(nilfs, cno);
968 if (root) {
969 ret = true;
970 nilfs_put_root(root);
971 }
978 return ret; 972 return ret;
979} 973}