diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nilfs2/the_nilfs.c | 28 |
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, | |||
954 | int nilfs_checkpoint_is_mounted(struct the_nilfs *nilfs, __u64 cno, | 954 | int 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 | } |