aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/super.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-09-12 22:16:34 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:38 -0400
commit032dbb3b503a30fce732ec4c05525d0abed1f1d6 (patch)
tree462696abcf0783d50efe97a3ca2641beecc91a3e /fs/nilfs2/super.c
parentf1e89c86fdd0f5e59f6768146c86437934202033 (diff)
nilfs2: see state of root dentry for mount check of snapshots
After applied the patch that unified sb instances, root dentry of snapshots can be left in dcache even after their trees are unmounted. The orphan root dentry/inode keeps a root object, and this causes false positive of nilfs_checkpoint_is_mounted function. This resolves the issue by having nilfs_checkpoint_is_mounted test whether the root dentry is busy or not. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/super.c')
-rw-r--r--fs/nilfs2/super.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 39e7d7f8eda0..ab96d26bf7e9 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -833,6 +833,38 @@ static int nilfs_try_to_shrink_tree(struct dentry *root_dentry)
833 return nilfs_tree_was_touched(root_dentry); 833 return nilfs_tree_was_touched(root_dentry);
834} 834}
835 835
836int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno)
837{
838 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
839 struct nilfs_root *root;
840 struct inode *inode;
841 struct dentry *dentry;
842 int ret;
843
844 if (cno < 0 || cno > nilfs->ns_cno)
845 return false;
846
847 if (cno >= nilfs_last_cno(nilfs))
848 return true; /* protect recent checkpoints */
849
850 ret = false;
851 root = nilfs_lookup_root(NILFS_SB(sb)->s_nilfs, cno);
852 if (root) {
853 inode = nilfs_ilookup(sb, root, NILFS_ROOT_INO);
854 if (inode) {
855 dentry = d_find_alias(inode);
856 if (dentry) {
857 if (nilfs_tree_was_touched(dentry))
858 ret = nilfs_try_to_shrink_tree(dentry);
859 dput(dentry);
860 }
861 iput(inode);
862 }
863 nilfs_put_root(root);
864 }
865 return ret;
866}
867
836/** 868/**
837 * nilfs_fill_super() - initialize a super block instance 869 * nilfs_fill_super() - initialize a super block instance
838 * @sb: super_block 870 * @sb: super_block