* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
if (lustre_msg_get_transno(req->rq_repmsg) != 0)
RETURN_EXIT;
+ if (tgt_is_multimodrpcs_client(req->rq_export)) {
+ struct thandle *th;
+
+ /* generate an empty transaction to get a transno
+ * and reply data */
+ th = dt_trans_create(info->mti_env, mdt->mdt_bottom);
+ if (!IS_ERR(th)) {
+ rc = dt_trans_start(info->mti_env, mdt->mdt_bottom, th);
+ dt_trans_stop(info->mti_env, mdt->mdt_bottom, th);
+ }
+ RETURN_EXIT;
+ }
+
spin_lock(&mdt->mdt_lut.lut_translock);
if (rc != 0) {
if (info->mti_transno != 0) {
RETURN(-ENOENT);
}
- if (exp_connect_rmtclient(exp)) {
- void *buf = req_capsule_server_get(info->mti_pill, &RMF_ACL);
-
- rc = mdt_pack_remote_perm(info, o, buf);
- if (rc) {
- repbody->mbo_valid &= ~OBD_MD_FLRMTPERM;
- repbody->mbo_aclsize = 0;
- } else {
- repbody->mbo_valid |= OBD_MD_FLRMTPERM;
- repbody->mbo_aclsize = sizeof(struct mdt_remote_perm);
- }
- }
#ifdef CONFIG_FS_POSIX_ACL
- else if (exp_connect_flags(exp) & OBD_CONNECT_ACL)
- rc = mdt_pack_acl2body(info, repbody, o,
- exp->exp_target_data.ted_nodemap);
+ if (exp_connect_flags(exp) & OBD_CONNECT_ACL) {
+ struct lu_nodemap *nodemap = nodemap_get_from_exp(exp);
+ if (IS_ERR(nodemap))
+ RETURN(PTR_ERR(nodemap));
+
+ rc = mdt_pack_acl2body(info, repbody, o, nodemap);
+ nodemap_putref(nodemap);
+ if (rc)
+ RETURN(rc);
+ }
#endif
/*
struct mdt_device *mdt = info->mti_mdt;
struct req_capsule *pill = info->mti_pill;
struct ptlrpc_request *req = mdt_info_req(info);
- struct tg_export_data *ted = &req->rq_export->exp_target_data;
- struct lsd_client_data *lcd = ted->ted_lcd;
struct md_attr *ma = &info->mti_attr;
struct mdt_reint_record *rr = &info->mti_rr;
__u64 flags = info->mti_spec.sp_cr_flags;
struct mdt_object *child;
struct mdt_body *repbody;
int rc;
- ENTRY;
+ __u64 opdata;
+ ENTRY;
LASSERT(pill->rc_fmt == &RQF_LDLM_INTENT_OPEN);
ldlm_rep = req_capsule_server_get(pill, &RMF_DLM_REP);
repbody = req_capsule_server_get(pill, &RMF_MDT_BODY);
ma->ma_need = MA_INODE | MA_HSM;
- ma->ma_valid = 0;
+ ma->ma_valid = 0;
- mdt_req_from_lcd(req, lcd);
- mdt_set_disposition(info, ldlm_rep, lcd->lcd_last_data);
+ opdata = mdt_req_from_lrd(req, info->mti_reply_data);
+ mdt_set_disposition(info, ldlm_rep, opdata);
CDEBUG(D_INODE, "This is reconstruct open: disp="LPX64", result=%d\n",
ldlm_rep->lock_policy_res1, req->rq_status);
struct mdt_lock_handle *lhc,
__u64 *ibits)
{
- struct md_attr *ma = &info->mti_attr;
- __u64 open_flags = info->mti_spec.sp_cr_flags;
- ldlm_mode_t lm = LCK_CR;
- bool acq_lease = !!(open_flags & MDS_OPEN_LEASE);
- bool try_layout = false;
- bool create_layout = false;
- int rc = 0;
+ struct md_attr *ma = &info->mti_attr;
+ __u64 open_flags = info->mti_spec.sp_cr_flags;
+ enum ldlm_mode lm = LCK_CR;
+ bool acq_lease = !!(open_flags & MDS_OPEN_LEASE);
+ bool try_layout = false;
+ bool create_layout = false;
+ int rc = 0;
ENTRY;
*ibits = 0;
mdt_obd_name(info->mti_mdt), PFID(fid), -EFAULT);
LU_OBJECT_DEBUG(D_WARNING, info->mti_env,
&o->mot_obj,
- "Object isn't on this server! FLD error?\n");
+ "Object isn't on this server! FLD error?");
rc = -EFAULT;
} else {
if (mdt_object_exists(o)) {
info->mti_spec.u.sp_ea.eadata == NULL)
GOTO(out, result = err_serious(-EINVAL));
+ if (create_flags & FMODE_WRITE &&
+ exp_connect_flags(req->rq_export) & OBD_CONNECT_RDONLY)
+ GOTO(out, result = -EROFS);
+
CDEBUG(D_INODE, "I am going to open "DFID"/("DNAME"->"DFID") "
"cr_flag="LPO64" mode=0%06o msg_flag=0x%x\n",
PFID(rr->rr_fid1), PNAME(&rr->rr_name),
if (!lu_name_is_valid(&rr->rr_name))
GOTO(out, result = -EPROTO);
+again:
lh = &info->mti_lh[MDT_LH_PARENT];
mdt_lock_pdo_init(lh,
(create_flags & MDS_OPEN_CREAT) ? LCK_PW : LCK_PR,
if (result != 0 && result != -ENOENT && result != -ESTALE)
GOTO(out_parent, result);
- if (result == -ENOENT || result == -ESTALE) {
- mdt_set_disposition(info, ldlm_rep, DISP_LOOKUP_NEG);
- if (result == -ESTALE) {
- /*
- * -ESTALE means the parent is a dead(unlinked) dir, so
- * it should return -ENOENT to in accordance with the
- * original mds implementaion.
- */
- GOTO(out_parent, result = -ENOENT);
- }
+ if (result == -ENOENT || result == -ESTALE) {
+ /* If the object is dead, let's check if the object
+ * is being migrated to a new object */
+ if (result == -ESTALE) {
+ struct lu_buf lmv_buf;
+
+ lmv_buf.lb_buf = info->mti_xattr_buf;
+ lmv_buf.lb_len = sizeof(info->mti_xattr_buf);
+ rc = mo_xattr_get(info->mti_env,
+ mdt_object_child(parent),
+ &lmv_buf, XATTR_NAME_LMV);
+ if (rc > 0) {
+ struct lmv_mds_md_v1 *lmv;
+
+ lmv = lmv_buf.lb_buf;
+ if (le32_to_cpu(lmv->lmv_hash_type) &
+ LMV_HASH_FLAG_MIGRATION) {
+ /* Get the new parent FID and retry */
+ mdt_object_unlock_put(info, parent,
+ lh, 1);
+ mdt_lock_handle_init(lh);
+ fid_le_to_cpu(
+ (struct lu_fid *)rr->rr_fid1,
+ &lmv->lmv_stripe_fids[1]);
+ goto again;
+ }
+ }
+ }
+
+ mdt_set_disposition(info, ldlm_rep, DISP_LOOKUP_NEG);
+ if (result == -ESTALE) {
+ /*
+ * -ESTALE means the parent is a dead(unlinked) dir, so
+ * it should return -ENOENT to in accordance with the
+ * original mds implementaion.
+ */
+ GOTO(out_parent, result = -ENOENT);
+ }
+
if (!(create_flags & MDS_OPEN_CREAT))
GOTO(out_parent, result);
if (exp_connect_flags(req->rq_export) & OBD_CONNECT_RDONLY)
if (result != 0)
GOTO(out_child, result);
}
- created = 1;
+ created = 1;
+ mdt_counter_incr(req, LPROC_MDT_MKNOD);
} else {
/*
* The object is on remote node, return its FID for remote open.
lease_broken = ldlm_is_cancel(lease);
unlock_res_and_lock(lease);
- LDLM_DEBUG(lease, DFID " lease broken? %d\n",
+ LDLM_DEBUG(lease, DFID " lease broken? %d",
PFID(mdt_object_fid(o)), lease_broken);
/* Cancel server side lease. Client side counterpart should
CERROR("%s: error closing volatile file "DFID": rc = %d\n",
mdt_obd_name(info->mti_mdt), PFID(&data->cd_fid), rc2);
LU_OBJECT_DEBUG(D_HSM, info->mti_env, &orphan->mot_obj,
- "object closed\n");
+ "object closed");
mdt_object_put(info->mti_env, orphan);
out_unlock:
return rc;
}
-static int mdt_close_swap_layouts(struct mdt_thread_info *info,
- struct mdt_object *o, struct md_attr *ma)
+int mdt_close_swap_layouts(struct mdt_thread_info *info,
+ struct mdt_object *o, struct md_attr *ma)
{
struct mdt_lock_handle *lh1 = &info->mti_lh[MDT_LH_NEW];
struct mdt_lock_handle *lh2 = &info->mti_lh[MDT_LH_OLD];
lease_broken = ldlm_is_cancel(lease);
unlock_res_and_lock(lease);
- LDLM_DEBUG(lease, DFID " lease broken? %d\n",
+ LDLM_DEBUG(lease, DFID " lease broken? %d",
PFID(mdt_object_fid(o)), lease_broken);
/* Cancel server side lease. Client side counterpart should
out_lease:
LDLM_LOCK_PUT(lease);
- ma->ma_valid = 0;
- ma->ma_need = 0;
+ if (ma != NULL) {
+ ma->ma_valid = 0;
+ ma->ma_need = 0;
+ }
return rc;
}
RETURN(rc);
}
+int mdt_close_internal(struct mdt_thread_info *info, struct ptlrpc_request *req,
+ struct mdt_body *repbody)
+{
+ struct mdt_export_data *med;
+ struct mdt_file_data *mfd;
+ struct mdt_object *o;
+ struct md_attr *ma = &info->mti_attr;
+ int ret = 0;
+ int rc = 0;
+ ENTRY;
+
+ med = &req->rq_export->exp_mdt_data;
+ spin_lock(&med->med_open_lock);
+ mfd = mdt_handle2mfd(med, &info->mti_close_handle, req_is_replay(req));
+ if (mdt_mfd_closed(mfd)) {
+ spin_unlock(&med->med_open_lock);
+ CDEBUG(D_INODE, "no handle for file close: fid = "DFID
+ ": cookie = "LPX64"\n", PFID(info->mti_rr.rr_fid1),
+ info->mti_close_handle.cookie);
+ /** not serious error since bug 3633 */
+ rc = -ESTALE;
+ } else {
+ class_handle_unhash(&mfd->mfd_handle);
+ list_del_init(&mfd->mfd_list);
+ spin_unlock(&med->med_open_lock);
+
+ /* Do not lose object before last unlink. */
+ o = mfd->mfd_object;
+ mdt_object_get(info->mti_env, o);
+ ret = mdt_mfd_close(info, mfd);
+ if (repbody != NULL)
+ rc = mdt_handle_last_unlink(info, o, ma);
+ mdt_object_put(info->mti_env, o);
+ }
+
+ RETURN(rc ? rc : ret);
+}
+
int mdt_close(struct tgt_session_info *tsi)
{
struct mdt_thread_info *info = tsi2mdt_info(tsi);
struct ptlrpc_request *req = tgt_ses_req(tsi);
- struct mdt_export_data *med;
- struct mdt_file_data *mfd;
- struct mdt_object *o;
struct md_attr *ma = &info->mti_attr;
struct mdt_body *repbody = NULL;
int rc, ret = 0;
rc = err_serious(rc);
}
- med = &req->rq_export->exp_mdt_data;
- spin_lock(&med->med_open_lock);
- mfd = mdt_handle2mfd(med, &info->mti_close_handle, req_is_replay(req));
- if (mdt_mfd_closed(mfd)) {
- spin_unlock(&med->med_open_lock);
- CDEBUG(D_INODE, "no handle for file close: fid = "DFID
- ": cookie = "LPX64"\n", PFID(info->mti_rr.rr_fid1),
- info->mti_close_handle.cookie);
- /** not serious error since bug 3633 */
- rc = -ESTALE;
- } else {
- class_handle_unhash(&mfd->mfd_handle);
- list_del_init(&mfd->mfd_list);
- spin_unlock(&med->med_open_lock);
+ rc = mdt_close_internal(info, req, repbody);
+ if (rc != -ESTALE)
+ mdt_empty_transno(info, rc);
- /* Do not lose object before last unlink. */
- o = mfd->mfd_object;
- mdt_object_get(info->mti_env, o);
- ret = mdt_mfd_close(info, mfd);
- if (repbody != NULL)
- rc = mdt_handle_last_unlink(info, o, ma);
- mdt_empty_transno(info, rc);
- mdt_object_put(info->mti_env, o);
- }
if (repbody != NULL) {
mdt_client_compatibility(info);
rc = mdt_fix_reply(info);