summaryrefslogtreecommitdiff
path: root/fs/nilfs2/the_nilfs.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-08-14 16:44:51 +0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-23 04:24:35 +0400
commitfd52202930b7e8db48bee5a6fc6b1f438e822a23 (patch)
tree1ecb7ce60634b5575dd463417447555ef9f1576a /fs/nilfs2/the_nilfs.c
parentb7c0634204993d7c6678c852e4bd118426599111 (diff)
downloadlinux-fd52202930b7e8db48bee5a6fc6b1f438e822a23.tar.xz
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/the_nilfs.c')
-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,
int nilfs_checkpoint_is_mounted(struct the_nilfs *nilfs, __u64 cno,
int snapshot_mount)
{
- struct nilfs_sb_info *sbi;
- int ret = 0;
+ struct nilfs_root *root;
+ int ret;
- down_read(&nilfs->ns_super_sem);
- if (cno == 0 || cno > nilfs->ns_cno)
- goto out_unlock;
+ if (cno < 0 || cno > nilfs->ns_cno)
+ return false;
- 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))
- ret++;
+ return true; /* protect recent checkpoints */
- out_unlock:
- up_read(&nilfs->ns_super_sem);
+ ret = false;
+ root = nilfs_lookup_root(nilfs, cno);
+ if (root) {
+ ret = true;
+ nilfs_put_root(root);
+ }
return ret;
}