-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* 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/
* Author: Yury Umanets <umka@clusterfs.com>
*/
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
#define DEBUG_SUBSYSTEM S_MDS
#include "mdt_internal.h"
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);
lname = mdt_name(info->mti_env, (char *)rr->rr_name, rr->rr_namelen);
rc = mdt_lookup_version_check(info, parent, lname,
&info->mti_tmp_fid1, 1);
- /* -ENOENT is expected here */
- if (rc != 0 && rc != -ENOENT)
- GOTO(out_put_parent, rc);
+ if (rc == 0)
+ GOTO(out_put_parent, rc = -EEXIST);
- /* save version of file name for replay, it must be ENOENT here */
- mdt_enoent_version_save(info, 1);
+ /* -ENOENT is expected here */
+ if (rc != -ENOENT)
+ GOTO(out_put_parent, rc);
+
+ /* save version of file name for replay, it must be ENOENT here */
+ mdt_enoent_version_save(info, 1);
- child = mdt_object_find(info->mti_env, mdt, rr->rr_fid2);
+ child = mdt_object_new(info->mti_env, mdt, rr->rr_fid2);
if (likely(!IS_ERR(child))) {
struct md_object *next = mdt_object_child(parent);
info->mti_spec.sp_cr_mode =
mdt_dlm_mode2mdl_mode(lh->mlh_pdo_mode);
- /*
- * Do perform lookup sanity check. We do not know if name exists
- * or not.
- */
- info->mti_spec.sp_cr_lookup = 1;
+ /*
+ * Do not perform lookup sanity check. We know that name does
+ * not exist.
+ */
+ info->mti_spec.sp_cr_lookup = 0;
info->mti_spec.sp_feat = &dt_directory_features;
rc = mdo_create(info->mti_env, next, lname,
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);
struct mdt_object *mo;
struct md_object *next;
struct mdt_body *repbody;
- int som_au, rc;
+ int som_au, rc, rc2;
ENTRY;
DEBUG_REQ(D_INODE, req, "setattr "DFID" %x", PFID(rr->rr_fid1),
/* 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);
mdt_object_put(info->mti_env, mo);
out:
if (rc == 0)
- mdt_counter_incr(req->rq_export, LPROC_MDT_SETATTR);
+ mdt_counter_incr(req, LPROC_MDT_SETATTR);
- mdt_shrink_reply(info);
+ mdt_client_compatibility(info);
+ rc2 = mdt_fix_reply(info);
+ if (rc == 0)
+ rc = rc2;
return rc;
}
rc = mdt_md_mkobj(info);
} else {
LASSERT(info->mti_rr.rr_namelen > 0);
- mdt_counter_incr(req->rq_export, LPROC_MDT_MKDIR);
+ mdt_counter_incr(req, LPROC_MDT_MKDIR);
rc = mdt_md_create(info);
}
break;
case S_IFSOCK:{
/* Special file should stay on the same node as parent. */
LASSERT(info->mti_rr.rr_namelen > 0);
- mdt_counter_incr(req->rq_export, LPROC_MDT_MKNOD);
+ mdt_counter_incr(req, LPROC_MDT_MKNOD);
rc = mdt_md_create(info);
break;
}
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 (ma->ma_valid & MA_INODE) {
switch (ma->ma_attr.la_mode & S_IFMT) {
case S_IFDIR:
- mdt_counter_incr(req->rq_export, LPROC_MDT_RMDIR);
+ mdt_counter_incr(req, LPROC_MDT_RMDIR);
break;
case S_IFREG:
case S_IFLNK:
case S_IFBLK:
case S_IFIFO:
case S_IFSOCK:
- mdt_counter_incr(req->rq_export, LPROC_MDT_UNLINK);
+ mdt_counter_incr(req, LPROC_MDT_UNLINK);
break;
default:
LASSERTF(0, "bad file type %o unlinking\n",
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);
mdt_object_child(ms), lname, ma);
if (rc == 0)
- mdt_counter_incr(req->rq_export, LPROC_MDT_LINK);
+ mdt_counter_incr(req, LPROC_MDT_LINK);
EXIT;
out_unlock_child:
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 */
/* handle last link of tgt object */
if (rc == 0) {
- mdt_counter_incr(req->rq_export, LPROC_MDT_RENAME);
+ mdt_counter_incr(req, LPROC_MDT_RENAME);
if (mnew)
mdt_handle_last_unlink(info, mnew, ma);
+
+ mdt_rename_counter_tally(info, info->mti_mdt, req,
+ msrcdir, mtgtdir);
}
EXIT;