-
-/* If we are unlinking an open file/dir (i.e. creating an orphan) then
- * we instead link the inode into the PENDING directory until it is
- * finally released. We can't simply call mds_reint_rename() or some
- * part thereof, because we don't have the inode to check for link
- * count/open status until after it is locked.
- *
- * For lock ordering, we always get the PENDING, then pending_child lock
- * last to avoid deadlocks.
- */
-
-int mds_open_unlink_rename(struct mds_update_record *rec,
- struct obd_device *obd, struct dentry *dparent,
- struct dentry *dchild, void **handle)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct inode *pending_dir = mds->mds_pending_dir->d_inode;
- struct dentry *pending_child;
- char fidname[LL_FID_NAMELEN];
- int fidlen = 0, rc;
- ENTRY;
-
- LASSERT(!mds_inode_is_orphan(dchild->d_inode));
-
- down(&pending_dir->i_sem);
- fidlen = ll_fid2str(fidname, dchild->d_inode->i_ino,
- dchild->d_inode->i_generation);
-
- CDEBUG(D_HA, "pending destroy of %dx open file %s = %s\n",
- mds_open_orphan_count(dchild->d_inode), rec->ur_name, fidname);
-
- pending_child = lookup_one_len(fidname, mds->mds_pending_dir, fidlen);
- if (IS_ERR(pending_child))
- GOTO(out_lock, rc = PTR_ERR(pending_child));
-
- if (pending_child->d_inode != NULL) {
- CERROR("re-destroying orphan file %s?\n", rec->ur_name);
- LASSERT(pending_child->d_inode == dchild->d_inode);
- GOTO(out_dput, rc = 0);
- }
-
- *handle = fsfilt_start(obd, pending_dir, FSFILT_OP_RENAME, NULL);
- if (IS_ERR(*handle))
- GOTO(out_dput, rc = PTR_ERR(*handle));
-
- lock_kernel();
- rc = vfs_rename(dparent->d_inode, dchild, pending_dir, pending_child);
- unlock_kernel();
- if (rc)
- CERROR("error renaming orphan %lu/%s to PENDING: rc = %d\n",
- dparent->d_inode->i_ino, rec->ur_name, rc);
- else
- mds_inode_set_orphan(dchild->d_inode);
-out_dput:
- dput(pending_child);
-out_lock:
- up(&pending_dir->i_sem);
- RETURN(rc);
-}
-
-static int mds_osc_destroy_orphan(struct mds_obd *mds,
- struct inode *inode,