* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011 Whamcloud, Inc.
- *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
LASSERT(o);
LASSERT(mdt_object_exists(o) >= 0);
if (mdt_object_exists(o) > 0)
- *version = mo_version_get(info->mti_env, mdt_object_child(o));
+ *version = dt_version_get(info->mti_env, mdt_obj2dt(o));
else
*version = ENOENT_VERSION;
CDEBUG(D_INODE, "FID "DFID" version is "LPX64"\n",
if (IS_ERR(parent))
RETURN(PTR_ERR(parent));
+ if (mdt_object_obf(parent))
+ GOTO(out_put_parent, rc = -EPERM);
+
rc = mdt_version_get_check_save(info, parent, 0);
if (rc)
GOTO(out_put_parent, rc);
RETURN(rc);
}
-/* In the raw-setattr case, we lock the child inode.
- * In the write-back case or if being called from open,
- * the client holds a lock already.
- * We use the ATTR_FROM_OPEN (translated into MRF_SETATTR_LOCKED by
- * mdt_setattr_unpack()) flag to tell these cases apart. */
int mdt_attr_set(struct mdt_thread_info *info, struct mdt_object *mo,
struct md_attr *ma, int flags)
{
struct mdt_lock_handle *lh;
int do_vbr = ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID|LA_FLAGS);
+ __u64 lockpart = MDS_INODELOCK_UPDATE;
int rc;
ENTRY;
lh = &info->mti_lh[MDT_LH_PARENT];
mdt_lock_reg_init(lh, LCK_PW);
- if (!(flags & MRF_SETATTR_LOCKED)) {
- __u64 lockpart = MDS_INODELOCK_UPDATE;
- if (ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID))
- lockpart |= MDS_INODELOCK_LOOKUP;
+ if (ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID))
+ lockpart |= MDS_INODELOCK_LOOKUP;
- rc = mdt_object_lock(info, mo, lh, lockpart, MDT_LOCAL_LOCK);
- if (rc != 0)
- RETURN(rc);
- }
+ rc = mdt_object_lock(info, mo, lh, lockpart, MDT_LOCAL_LOCK);
+ if (rc != 0)
+ RETURN(rc);
if (mdt_object_exists(mo) == 0)
GOTO(out_unlock, rc = -ENOENT);
/* start a log jounal handle if needed */
if (!(mdt_conn_flags(info) & OBD_CONNECT_SOM)) {
if ((ma->ma_attr.la_valid & LA_SIZE) ||
- (rr->rr_flags & MRF_SETATTR_LOCKED)) {
+ (rr->rr_flags & MRF_OPEN_TRUNC)) {
/* Check write access for the O_TRUNC case */
if (mdt_write_read(mo) < 0)
GOTO(out_put, rc = -ETXTBSY);
if (rc == 0)
mdt_counter_incr(req->rq_export, LPROC_MDT_SETATTR);
+ mdt_client_compatibility(info);
mdt_shrink_reply(info);
return rc;
}
GOTO(out, rc);
}
+ if (mdt_object_obf(mp))
+ GOTO(out_unlock_parent, rc = -EPERM);
+
rc = mdt_version_get_check_save(info, mp, 0);
if (rc)
GOTO(out_unlock_parent, rc);
/* step 2: find & lock the child */
lname = mdt_name(info->mti_env, (char *)rr->rr_name, rr->rr_namelen);
/* lookup child object along with version checking */
+ fid_zero(child_fid);
rc = mdt_lookup_version_check(info, mp, lname, child_fid, 1);
if (rc != 0)
GOTO(out_unlock_parent, rc);
if (IS_ERR(mp))
RETURN(PTR_ERR(mp));
+ if (mdt_object_obf(mp))
+ GOTO(out_unlock_parent, rc = -EPERM);
+
rc = mdt_version_get_check_save(info, mp, 0);
if (rc)
GOTO(out_unlock_parent, rc);
if (IS_ERR(msrcdir))
GOTO(out_rename_lock, rc = PTR_ERR(msrcdir));
+ if (mdt_object_obf(msrcdir))
+ GOTO(out_unlock_source, rc = -EPERM);
+
rc = mdt_version_get_check_save(info, msrcdir, 0);
if (rc)
GOTO(out_unlock_source, rc);
if (IS_ERR(mtgtdir))
GOTO(out_unlock_source, rc = PTR_ERR(mtgtdir));
+ if (mdt_object_obf(mtgtdir))
+ GOTO(out_put_target, rc = -EPERM);
+
/* check early, the real version will be saved after locking */
rc = mdt_version_get_check(info, mtgtdir, 1);
if (rc)
/* step 3: find & lock the old object. */
lname = mdt_name(info->mti_env, (char *)rr->rr_name, rr->rr_namelen);
mdt_name_copy(&slname, lname);
+ fid_zero(old_fid);
rc = mdt_lookup_version_check(info, msrcdir, &slname, old_fid, 2);
if (rc != 0)
GOTO(out_unlock_target, rc);
/* new target object may not exist now */
lname = mdt_name(info->mti_env, (char *)rr->rr_tgt, rr->rr_tgtlen);
/* lookup with version checking */
+ fid_zero(new_fid);
rc = mdt_lookup_version_check(info, mtgtdir, lname, new_fid, 3);
if (rc == 0) {
/* the new_fid should have been filled at this moment */
mdt_counter_incr(req->rq_export, LPROC_MDT_RENAME);
if (mnew)
mdt_handle_last_unlink(info, mnew, ma);
+
+ mdt_rename_counter_tally(info, info->mti_mdt, req->rq_export,
+ msrcdir, mtgtdir);
}
EXIT;