* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
}
void mdt_trans_stop(const struct lu_env *env,
- struct mdt_device *mdt, struct thandle *th)
+ struct mdt_device *mdt, struct thandle *th)
{
dt_trans_stop(env, mdt->mdt_bottom, th);
}
mdt->mdt_txn_cb.dtc_txn_commit = NULL;
mdt->mdt_txn_cb.dtc_cookie = NULL;
mdt->mdt_txn_cb.dtc_tag = LCT_MD_THREAD;
- CFS_INIT_LIST_HEAD(&mdt->mdt_txn_cb.dtc_linkage);
+ INIT_LIST_HEAD(&mdt->mdt_txn_cb.dtc_linkage);
dt_txn_callback_add(mdt->mdt_bottom, &mdt->mdt_txn_cb);
static void mdt_steal_ack_locks(struct ptlrpc_request *req)
{
struct ptlrpc_service_part *svcpt;
- struct obd_export *exp = req->rq_export;
- cfs_list_t *tmp;
- struct ptlrpc_reply_state *oldrep;
- int i;
+ struct obd_export *exp = req->rq_export;
+ struct list_head *tmp;
+ struct ptlrpc_reply_state *oldrep;
+ int i;
- /* CAVEAT EMPTOR: spinlock order */
+ /* CAVEAT EMPTOR: spinlock order */
spin_lock(&exp->exp_lock);
- cfs_list_for_each (tmp, &exp->exp_outstanding_replies) {
- oldrep = cfs_list_entry(tmp, struct ptlrpc_reply_state,
- rs_exp_list);
+ list_for_each(tmp, &exp->exp_outstanding_replies) {
+ oldrep = list_entry(tmp, struct ptlrpc_reply_state,
+ rs_exp_list);
if (oldrep->rs_xid != req->rq_xid)
continue;
svcpt = oldrep->rs_svcpt;
spin_lock(&svcpt->scp_rep_lock);
- cfs_list_del_init (&oldrep->rs_exp_list);
+ list_del_init(&oldrep->rs_exp_list);
CDEBUG(D_HA, "Stealing %d locks from rs %p x"LPD64".t"LPD64
" o%d NID %s\n",
/**
* VBR: restore versions
*/
-void mdt_vbr_reconstruct(struct ptlrpc_request *req,
- struct lsd_client_data *lcd)
+static void mdt_vbr_reconstruct(struct ptlrpc_request *req,
+ struct lsd_client_data *lcd)
{
__u64 pre_versions[4] = {0};
pre_versions[0] = lcd->lcd_pre_versions[0];
lustre_msg_set_versions(req->rq_repmsg, pre_versions);
}
-void mdt_req_from_lcd(struct ptlrpc_request *req,
- struct lsd_client_data *lcd)
+void mdt_req_from_lcd(struct ptlrpc_request *req, struct lsd_client_data *lcd)
{
DEBUG_REQ(D_HA, req, "restoring transno "LPD64"/status %d",
lcd->lcd_last_transno, lcd->lcd_last_result);
return mdt_req_from_lcd(req, ted->ted_lcd);
}
+/**
+ * Generate fake attributes for a non-existing object
+ *
+ * While the client was waiting for the reply, the original transaction
+ * got committed and corresponding rep-ack lock got released, then another
+ * client was able to destroy the object. But we still need to send some
+ * attributes back. So we fake them and set nlink=0, so the client will
+ * be able to detect a non-existing object and drop it from the cache
+ * immediately.
+ *
+ * \param[out] ma attributes to fill
+ */
+static void mdt_fake_ma(struct md_attr *ma)
+{
+ ma->ma_valid = MA_INODE;
+ memset(&ma->ma_attr, 0, sizeof(ma->ma_attr));
+ ma->ma_attr.la_valid = LA_NLINK;
+ ma->ma_attr.la_mode = S_IFREG;
+}
+
static void mdt_reconstruct_create(struct mdt_thread_info *mti,
struct mdt_lock_handle *lhc)
{
mti->mti_attr.ma_need = MA_INODE;
mti->mti_attr.ma_valid = 0;
rc = mdt_attr_get_complex(mti, child, &mti->mti_attr);
- if (rc == -EREMOTE) {
+ if (rc == -ENOENT) {
+ mdt_fake_ma(&mti->mti_attr);
+ } else if (rc == -EREMOTE) {
/* object was created on remote server */
if (!mdt_is_dne_client(exp))
/* Return -EIO for old client */
rc = -EIO;
req->rq_status = rc;
- body->valid |= OBD_MD_MDS;
+ body->mbo_valid |= OBD_MD_MDS;
}
mdt_pack_attr2body(mti, body, &mti->mti_attr.ma_attr,
mdt_object_fid(child));
mti->mti_attr.ma_need = MA_INODE;
mti->mti_attr.ma_valid = 0;
- mdt_attr_get_complex(mti, obj, &mti->mti_attr);
+
+ rc = mdt_attr_get_complex(mti, obj, &mti->mti_attr);
+ if (rc == -ENOENT)
+ mdt_fake_ma(&mti->mti_attr);
mdt_pack_attr2body(mti, body, &mti->mti_attr.ma_attr,
mdt_object_fid(obj));
if (mti->mti_ioepoch && (mti->mti_ioepoch->flags & MF_EPOCH_OPEN)) {
struct mdt_body *repbody;
repbody = req_capsule_server_get(mti->mti_pill, &RMF_MDT_BODY);
- repbody->ioepoch = obj->mot_ioepoch;
+ repbody->mbo_ioepoch = obj->mot_ioepoch;
spin_lock(&med->med_open_lock);
- cfs_list_for_each_entry(mfd, &med->med_open_head, mfd_list) {
+ list_for_each_entry(mfd, &med->med_open_head, mfd_list) {
if (mfd->mfd_xid == req->rq_xid)
break;
}
LASSERT(&mfd->mfd_list != &med->med_open_head);
spin_unlock(&med->med_open_lock);
- repbody->handle.cookie = mfd->mfd_handle.h_cookie;
+ repbody->mbo_handle.cookie = mfd->mfd_handle.h_cookie;
}
mdt_object_put(mti->mti_env, obj);