* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#include <lprocfs_status.h>
#include "lmv_internal.h"
-int lmv_intent_remote(struct obd_export *exp, void *lmm,
- int lmmsize, struct lookup_intent *it,
- int flags, struct ptlrpc_request **reqp,
- ldlm_blocking_callback cb_blocking,
- __u64 extra_lock_flags)
+static int lmv_intent_remote(struct obd_export *exp, void *lmm,
+ int lmmsize, struct lookup_intent *it,
+ const struct lu_fid *parent_fid, int flags,
+ struct ptlrpc_request **reqp,
+ ldlm_blocking_callback cb_blocking,
+ __u64 extra_lock_flags)
{
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
GOTO(out, rc = -ENOMEM);
op_data->op_fid1 = body->fid1;
- op_data->op_bias = MDS_CROSS_REF;
+ /* Sent the parent FID to the remote MDT */
+ if (parent_fid != NULL) {
+ /* The parent fid is only for remote open to
+ * check whether the open is from OBF,
+ * see mdt_cross_open */
+ LASSERT(it->it_op & IT_OPEN);
+ op_data->op_fid2 = *parent_fid;
+ /* Add object FID to op_fid3, in case it needs to check stale
+ * (M_CHECK_STALE), see mdc_finish_intent_lock */
+ op_data->op_fid3 = body->fid1;
+ }
+ op_data->op_bias = MDS_CROSS_REF;
CDEBUG(D_INODE, "REMOTE_INTENT with fid="DFID" -> mds #%d\n",
PFID(&body->fid1), tgt->ltd_idx);
if (rc)
GOTO(out_free_op_data, rc);
- /*
- * LLite needs LOOKUP lock to track dentry revocation in order to
- * maintain dcache consistency. Thus drop UPDATE lock here and put
- * LOOKUP in request.
- */
- if (it->d.lustre.it_lock_mode != 0) {
- ldlm_lock_decref((void *)&it->d.lustre.it_lock_handle,
- it->d.lustre.it_lock_mode);
- it->d.lustre.it_lock_mode = 0;
- }
- it->d.lustre.it_lock_handle = plock.cookie;
- it->d.lustre.it_lock_mode = pmode;
-
- EXIT;
+ /*
+ * LLite needs LOOKUP lock to track dentry revocation in order to
+ * maintain dcache consistency. Thus drop UPDATE|PERM lock here
+ * and put LOOKUP in request.
+ */
+ if (it->d.lustre.it_lock_mode != 0) {
+ it->d.lustre.it_remote_lock_handle =
+ it->d.lustre.it_lock_handle;
+ it->d.lustre.it_remote_lock_mode = it->d.lustre.it_lock_mode;
+ }
+
+ it->d.lustre.it_lock_handle = plock.cookie;
+ it->d.lustre.it_lock_mode = pmode;
+
+ EXIT;
out_free_op_data:
- OBD_FREE_PTR(op_data);
+ OBD_FREE_PTR(op_data);
out:
- if (rc && pmode)
- ldlm_lock_decref(&plock, pmode);
+ if (rc && pmode)
+ ldlm_lock_decref(&plock, pmode);
- ptlrpc_req_finished(*reqp);
- *reqp = req;
- return rc;
+ ptlrpc_req_finished(*reqp);
+ *reqp = req;
+ return rc;
}
/*
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));
- if (it->it_op & IT_CREAT) {
+ /* If it is ready to open the file by FID, do not need
+ * allocate FID at all, otherwise it will confuse MDT */
+ if ((it->it_op & IT_CREAT) &&
+ !(it->it_flags & MDS_OPEN_BY_FID)) {
/*
* For open with IT_CREATE and for IT_CREATE cases allocate new
* fid and setup FLD for it.
* Okay, MDS has returned success. Probably name has been resolved in
* remote inode.
*/
- rc = lmv_intent_remote(exp, lmm, lmmsize, it, flags, reqp,
- cb_blocking, extra_lock_flags);
+ rc = lmv_intent_remote(exp, lmm, lmmsize, it, &op_data->op_fid1, flags,
+ reqp, cb_blocking, extra_lock_flags);
if (rc != 0) {
LASSERT(rc < 0);
/*
if (likely(!(body->valid & OBD_MD_MDS)))
RETURN(0);
- rc = lmv_intent_remote(exp, lmm, lmmsize, it, flags, reqp,
+ rc = lmv_intent_remote(exp, lmm, lmmsize, it, NULL, flags, reqp,
cb_blocking, extra_lock_flags);
RETURN(rc);