Unionfs ODF: Exports: Handle inodes which have been deleted.
authorRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 18 May 2008 08:04:29 +0000 (04:04 -0400)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 18 May 2008 08:04:29 +0000 (04:04 -0400)
Lookup the inode in the ODF, which provides a persistent store of
inode attributes, to identify bad inodes (ie inodes which have been
deleted)

Signed-off-by: Rachita Kothiyal <rachita@fsl.cs.sunysb.edu>
fs/unionfs/export.c

index 7ba349b17c0447cb7a1099fb6f4a7759c0d70c3d..8f88e19f6d12a316bd063fa5e354eca5dc4b5ed8 100644 (file)
@@ -226,30 +226,35 @@ static struct dentry *unionfs_export_iget(struct super_block *sb,
                                        unsigned long ino, __u32 generation,
                                        __u32 mode)
 {
-       struct inode *inode;
+       struct inode *inode, *odf_inode;
        struct dentry *result;
        int err = 0;
 
        if (ino == 0 || mode == 0)
                return ERR_PTR(-ESTALE);
 
+       /*
+        * Consult the ODF to check on the inode's health.  Specially
+        * useful when the client requests an inode which was deleted.
+        * Since the ODF is our persistent store, atleast for attributes,
+        * we refer to it.
+        */
+       odf_inode = iget(UNIONFS_SB(sb)->odf.path.mnt->mnt_sb, ino);
+       if (odf_inode == NULL) {
+               return ERR_PTR(-ENOMEM);
+       } else {
+               if (is_bad_inode(odf_inode) || (generation &&
+                   odf_inode->i_generation != generation)) {
+                       iput(odf_inode);
+                       return ERR_PTR(-ESTALE);
+               }
+       }
+       iput(odf_inode);
+
        inode = iget(sb, ino);
        if (inode == NULL)
                return ERR_PTR(-ENOMEM);
 
-        /* A generation of 0 means "accept any" */
-       if (is_bad_inode(inode) || (generation
-               && inode->i_generation != generation)) {
-               /* we didn't find the right inode.. */
-               printk(KERN_ERR "fh_verify: Inode %lu, Bad count: %d %d "
-                       "or version  %u %u\n", inode->i_ino, inode->i_nlink,
-                       atomic_read(&inode->i_count), inode->i_generation,
-                       generation);
-
-               iput(inode);
-               return ERR_PTR(-ESTALE);
-       }
-
        /* Now find a dentry. If possible, get a well-connected one */
        result = d_alloc_anon(inode);
        if (!result) {