Whamcloud - gitweb
LU-5396 lod: (and mdt, mgs) make some symbols static
[fs/lustre-release.git] / lustre / mdt / mdt_recovery.c
index f3e6884..b06022b 100644 (file)
@@ -27,7 +27,7 @@
  * 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/
@@ -72,7 +72,7 @@ const struct lu_buf *mdt_buf_const(const struct lu_env *env,
 }
 
 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);
 }
@@ -116,7 +116,7 @@ int mdt_fs_setup(const struct lu_env *env, struct mdt_device *mdt,
        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);
 
@@ -139,16 +139,16 @@ void mdt_fs_cleanup(const struct lu_env *env, struct mdt_device *mdt)
 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;
@@ -162,7 +162,7 @@ static void mdt_steal_ack_locks(struct ptlrpc_request *req)
                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",
@@ -189,8 +189,8 @@ static void mdt_steal_ack_locks(struct ptlrpc_request *req)
 /**
  * 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];
@@ -200,8 +200,7 @@ void mdt_vbr_reconstruct(struct ptlrpc_request *req,
         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);
@@ -234,6 +233,26 @@ void mdt_reconstruct_generic(struct mdt_thread_info *mti,
         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)
 {
@@ -266,7 +285,9 @@ static void mdt_reconstruct_create(struct mdt_thread_info *mti,
         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 */
@@ -310,7 +331,10 @@ static void mdt_reconstruct_setattr(struct mdt_thread_info *mti,
 
         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)) {
@@ -320,7 +344,7 @@ static void mdt_reconstruct_setattr(struct mdt_thread_info *mti,
                 repbody = req_capsule_server_get(mti->mti_pill, &RMF_MDT_BODY);
                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;
                }