Whamcloud - gitweb
LU-13165 mdt: MSG_RESENT can be improperly cleared.
[fs/lustre-release.git] / lustre / mdt / mdt_handler.c
index 9213c45..3b6918b 100644 (file)
@@ -1735,11 +1735,14 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                }
 
                rc = mdt_getattr_internal(info, child, 0);
-               if (unlikely(rc != 0))
+               if (unlikely(rc != 0)) {
                        mdt_object_unlock(info, child, lhc, 1);
+                       RETURN(rc);
+               }
 
-               mdt_pack_secctx_in_reply(info, child);
-
+               rc = mdt_pack_secctx_in_reply(info, child);
+               if (unlikely(rc))
+                       mdt_object_unlock(info, child, lhc, 1);
                RETURN(rc);
        }
 
@@ -1854,7 +1857,7 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                mdt_lock_reg_init(lhc, LCK_PR);
 
                if (!(child_bits & MDS_INODELOCK_UPDATE) &&
-                     mdt_object_exists(child) && !mdt_object_remote(child)) {
+                   !mdt_object_remote(child)) {
                        struct md_attr *ma = &info->mti_attr;
 
                        ma->ma_valid = 0;
@@ -1868,12 +1871,12 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                         * lock and this might save us RPC on later STAT. For
                         * directories, it also let negative dentry cache start
                         * working for this dir. */
-                        if (ma->ma_valid & MA_INODE &&
-                            ma->ma_attr.la_valid & LA_CTIME &&
-                            info->mti_mdt->mdt_namespace->ns_ctime_age_limit +
-                               ma->ma_attr.la_ctime < ktime_get_real_seconds())
-                                child_bits |= MDS_INODELOCK_UPDATE;
-                }
+                       if (ma->ma_valid & MA_INODE &&
+                           ma->ma_attr.la_valid & LA_CTIME &&
+                           info->mti_mdt->mdt_namespace->ns_ctime_age_limit +
+                           ma->ma_attr.la_ctime < ktime_get_real_seconds())
+                               child_bits |= MDS_INODELOCK_UPDATE;
+               }
 
                /* layout lock must be granted in a best-effort way
                 * for IT operations */
@@ -1915,7 +1918,11 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                GOTO(out_child, rc);
        }
 
-       mdt_pack_secctx_in_reply(info, child);
+       rc = mdt_pack_secctx_in_reply(info, child);
+       if (unlikely(rc)) {
+               mdt_object_unlock(info, child, lhc, 1);
+               GOTO(out_child, rc);
+       }
 
        lock = ldlm_handle2lock(&lhc->mlh_reg_lh);
        if (lock) {
@@ -1927,8 +1934,7 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                         PLDLMRES(lock->l_resource),
                         PFID(mdt_object_fid(child)));
 
-               if (mdt_object_exists(child) &&
-                   S_ISREG(lu_object_attr(&child->mot_obj)) &&
+               if (S_ISREG(lu_object_attr(&child->mot_obj)) &&
                    !mdt_object_remote(child) && child != parent) {
                        mdt_object_put(info->mti_env, child);
                        rc = mdt_pack_size2body(info, child_fid,
@@ -3372,8 +3378,9 @@ mdt_object_lock_internal(struct mdt_thread_info *info, struct mdt_object *o,
                 * object anyway XXX*/
                if (lh->mlh_type == MDT_PDO_LOCK &&
                    lh->mlh_pdo_hash != 0) {
-                       CDEBUG(D_INFO, "%s: "DFID" convert PDO lock to"
-                              "EX lock.\n", mdt_obd_name(info->mti_mdt),
+                       CDEBUG(D_INFO,
+                              "%s: "DFID" convert PDO lock to EX lock.\n",
+                              mdt_obd_name(info->mti_mdt),
                               PFID(mdt_object_fid(o)));
                        lh->mlh_pdo_hash = 0;
                        lh->mlh_rreg_mode = LCK_EX;
@@ -3936,7 +3943,7 @@ void mdt_intent_fixup_resent(struct mdt_thread_info *info,
         * If the xid matches, then we know this is a resent request, and allow
         * it. (It's probably an OPEN, for which we don't send a lock.
         */
-       if (req_can_reconstruct(req, NULL) == 1)
+       if (req_can_reconstruct(req, NULL) != 0)
                return;
 
         /*
@@ -6070,7 +6077,7 @@ static int mdt_ctxt_add_dirty_flag(struct lu_env *env,
 
 static int mdt_export_cleanup(struct obd_export *exp)
 {
-       struct list_head         closing_list;
+       LIST_HEAD(closing_list);
        struct mdt_export_data  *med = &exp->exp_mdt_data;
        struct obd_device       *obd = exp->exp_obd;
        struct mdt_device       *mdt;
@@ -6080,7 +6087,6 @@ static int mdt_export_cleanup(struct obd_export *exp)
        int rc = 0;
        ENTRY;
 
-       INIT_LIST_HEAD(&closing_list);
        spin_lock(&med->med_open_lock);
        while (!list_empty(&med->med_open_head)) {
                struct list_head *tmp = med->med_open_head.next;
@@ -6938,7 +6944,7 @@ static int mdt_obd_postrecov(struct obd_device *obd)
         return rc;
 }
 
-static struct obd_ops mdt_obd_device_ops = {
+static const struct obd_ops mdt_obd_device_ops = {
         .o_owner          = THIS_MODULE,
         .o_set_info_async = mdt_obd_set_info_async,
         .o_connect        = mdt_obd_connect,