Whamcloud - gitweb
b=6285
authoralex <alex>
Thu, 7 Jul 2005 14:23:22 +0000 (14:23 +0000)
committeralex <alex>
Thu, 7 Jul 2005 14:23:22 +0000 (14:23 +0000)
 - sometimes mds_getattr_lock() is asked to refresh attributes by fid.
   it doesn't take LOOKUP lock, thus has no protected from concurrent
   unlink. this means mds_getattr_lock() can return already unlinked
   (and being removed) inode. to avoid this we check i_nlink right
   after we got UPDATE lock and return -ENOENT if nlink is zero

lustre/mds/handler.c

index 77c4b23..e4b4681 100644 (file)
@@ -292,6 +292,20 @@ struct dentry *mds_id2locked_dentry(struct obd_device *obd, struct lustre_id *id
                 if (lockh[1].cookie)
                         ldlm_lock_decref(lockh + 1, *mode);
 #endif
+        } if (de->d_inode && de->d_inode->i_nlink == 0) {
+                /* as sometimes we lookup inode by ino/generation through
+                   iopen mechanism, it's possible to find already unlinked
+                   inode with nlink == 0. let's interpretate the case as
+                   ENOENT -bzzz */
+                CWARN("found already unlinked inode %lu/%u\n",
+                      de->d_inode->i_ino, de->d_inode->i_generation);
+                l_dput(de);
+                retval = ERR_PTR(-ENOENT);
+                ldlm_lock_decref(lockh, lock_mode);
+#ifdef S_PDIROPS
+                if (lockh[1].cookie)
+                        ldlm_lock_decref(lockh + 1, *mode);
+#endif
         }
 
         RETURN(retval);