}
cleanup_phase = 1;
- LASSERT(S_ISDIR(dentry->d_inode->i_mode));
+ /*
+ * handling the case when remote MDS checks if dir is empty before
+ * rename. But it also does it for all entries, because inode is stored
+ * here and remote MDS does not know if rename point to dir or to reg
+ * file. So we check it here.
+ */
+ if (!S_ISDIR(dentry->d_inode->i_mode))
+ GOTO(cleanup, rc = 0);
rc = mds_init_ucred(&uc, rsd);
if (rc) {
}
push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
+ rc = mds_is_dir_empty(obd, dentry) ? 0 : -ENOTEMPTY;
+ pop_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
- rc = 0;
- if (!mds_is_dir_empty(obd, dentry))
- rc = -ENOTEMPTY;
-
+ mds_exit_ucred(&uc);
EXIT;
cleanup:
switch(cleanup_phase) {
if (rc)
ldlm_lock_decref(lockh, LCK_EX);
l_dput(dentry);
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
- mds_exit_ucred(&uc);
default:
break;
}