Commit fd522029 authored by Ryusuke Konishi's avatar Ryusuke Konishi

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: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent b7c06342
...@@ -954,26 +954,20 @@ struct nilfs_sb_info *nilfs_find_sbinfo(struct the_nilfs *nilfs, ...@@ -954,26 +954,20 @@ struct nilfs_sb_info *nilfs_find_sbinfo(struct the_nilfs *nilfs,
int nilfs_checkpoint_is_mounted(struct the_nilfs *nilfs, __u64 cno, int nilfs_checkpoint_is_mounted(struct the_nilfs *nilfs, __u64 cno,
int snapshot_mount) int snapshot_mount)
{ {
struct nilfs_sb_info *sbi; struct nilfs_root *root;
int ret = 0; int ret;
down_read(&nilfs->ns_super_sem); if (cno < 0 || cno > nilfs->ns_cno)
if (cno == 0 || cno > nilfs->ns_cno) return false;
goto out_unlock;
list_for_each_entry(sbi, &nilfs->ns_supers, s_list) {
if (sbi->s_snapshot_cno == cno &&
(!snapshot_mount || nilfs_test_opt(sbi, SNAPSHOT))) {
/* exclude read-only mounts */
ret++;
break;
}
}
/* for protecting recent checkpoints */
if (cno >= nilfs_last_cno(nilfs)) if (cno >= nilfs_last_cno(nilfs))
ret++; return true; /* protect recent checkpoints */
out_unlock: ret = false;
up_read(&nilfs->ns_super_sem); root = nilfs_lookup_root(nilfs, cno);
if (root) {
ret = true;
nilfs_put_root(root);
}
return ret; return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment