Whamcloud - gitweb
LU-9312 hsm: fix error handling around mdt_hsm_get_md_hsm() 41/26741/3
authorJohn L. Hammond <john.hammond@intel.com>
Wed, 19 Apr 2017 15:42:20 +0000 (10:42 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 May 2017 03:46:02 +0000 (03:46 +0000)
Correct several spurious NULL return checks from
mdt_hsm_get_md_hsm().

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: Icfe74e87183bc5356d4c7627088b402805dcc164
Reviewed-on: https://review.whamcloud.com/26741
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: Henri Doreau <henri.doreau@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_coordinator.c
lustre/mdt/mdt_hsm_cdt_agent.c

index 804b8e2..e1f2493 100644 (file)
@@ -1290,7 +1290,7 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti,
 
                /* restore in data FID done, we swap the layouts
                 * only if restore is successful */
 
                /* restore in data FID done, we swap the layouts
                 * only if restore is successful */
-               if (pgs->hpk_errval == 0 && !IS_ERR_OR_NULL(obj)) {
+               if (pgs->hpk_errval == 0 && !IS_ERR(obj)) {
                        rc = hsm_swap_layouts(mti, obj, &car->car_hai->hai_dfid,
                                              &mh);
                        if (rc) {
                        rc = hsm_swap_layouts(mti, obj, &car->car_hai->hai_dfid,
                                              &mh);
                        if (rc) {
index c3d4182..a28a932 100644 (file)
@@ -463,86 +463,81 @@ int mdt_hsm_agent_send(struct mdt_thread_info *mti,
        fail_request = false;
        hai = hai_first(hal);
        for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
        fail_request = false;
        hai = hai_first(hal);
        for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
-               if (hai->hai_action != HSMA_CANCEL) {
-                       struct mdt_object *obj;
-                       struct md_hsm hsm;
+               struct mdt_object *obj;
+               struct md_hsm hsm;
 
 
-                       obj = mdt_hsm_get_md_hsm(mti, &hai->hai_fid, &hsm);
-                       if (!IS_ERR(obj) && obj != NULL) {
-                               mdt_object_put(mti->mti_env, obj);
-                       } else {
-                               if (hai->hai_action == HSMA_REMOVE)
-                                       continue;
-
-                               if (obj == NULL) {
-                                       fail_request = true;
-                                       rc = mdt_agent_record_update(
-                                                            mti->mti_env, mdt,
-                                                            &hai->hai_cookie,
-                                                            1, ARS_FAILED);
-                                       if (rc) {
-                                               CERROR(
-                                             "%s: mdt_agent_record_update() "
-                                             "failed, cannot update "
-                                             "status to %s for cookie "
-                                             "%#llx: rc = %d\n",
-                                             mdt_obd_name(mdt),
-                                             agent_req_status2name(ARS_FAILED),
-                                             hai->hai_cookie, rc);
-                                               GOTO(out_buf, rc);
-                                       }
-                                       continue;
-                               }
-                               GOTO(out_buf, rc = PTR_ERR(obj));
+               if (hai->hai_action == HSMA_CANCEL)
+                       continue;
+
+               obj = mdt_hsm_get_md_hsm(mti, &hai->hai_fid, &hsm);
+               if (!IS_ERR(obj)) {
+                       mdt_object_put(mti->mti_env, obj);
+               } else if (PTR_ERR(obj) == -ENOENT) {
+                       if (hai->hai_action == HSMA_REMOVE)
+                               continue;
+
+                       fail_request = true;
+                       rc = mdt_agent_record_update(mti->mti_env, mdt,
+                                                    &hai->hai_cookie,
+                                                    1, ARS_FAILED);
+                       if (rc < 0) {
+                               CERROR("%s: mdt_agent_record_update() failed, "
+                                      "cannot update status to %s for cookie "
+                                      "%#llx: rc = %d\n",
+                                      mdt_obd_name(mdt),
+                                      agent_req_status2name(ARS_FAILED),
+                                      hai->hai_cookie, rc);
+                               GOTO(out_buf, rc);
+                       }
+
+                       continue;
+               } else {
+                       GOTO(out_buf, rc = PTR_ERR(obj));
+               }
+
+               if (!mdt_hsm_is_action_compat(hai, hal->hal_archive_id,
+                                             hal->hal_flags, &hsm)) {
+                       /* incompatible request, we abort the request */
+                       /* next time coordinator will wake up, it will
+                        * make the same compound with valid only
+                        * records */
+                       fail_request = true;
+                       rc = mdt_agent_record_update(mti->mti_env, mdt,
+                                                    &hai->hai_cookie,
+                                                    1, ARS_FAILED);
+                       if (rc) {
+                               CERROR("%s: mdt_agent_record_update() failed, "
+                                      "cannot update status to %s for cookie "
+                                      "%#llx: rc = %d\n",
+                                      mdt_obd_name(mdt),
+                                      agent_req_status2name(ARS_FAILED),
+                                      hai->hai_cookie, rc);
+                               GOTO(out_buf, rc);
                        }
 
                        }
 
-                       if (!mdt_hsm_is_action_compat(hai, hal->hal_archive_id,
-                                                     hal->hal_flags, &hsm)) {
-                               /* incompatible request, we abort the request */
-                               /* next time coordinator will wake up, it will
-                                * make the same compound with valid only
-                                * records */
-                               fail_request = true;
-                               rc = mdt_agent_record_update(mti->mti_env, mdt,
-                                                            &hai->hai_cookie,
-                                                            1, ARS_FAILED);
-                               if (rc) {
-                                       CERROR("%s: mdt_agent_record_update() "
-                                             "failed, cannot update "
-                                             "status to %s for cookie "
-                                             "%#llx: rc = %d\n",
-                                             mdt_obd_name(mdt),
-                                             agent_req_status2name(ARS_FAILED),
-                                             hai->hai_cookie, rc);
-                                       GOTO(out_buf, rc);
-                               }
-
-                               /* if restore and record status updated, give
-                                * back granted layout lock */
-                               if (hai->hai_action == HSMA_RESTORE) {
-                                       struct cdt_restore_handle *crh = NULL;
-                                       struct mdt_object *obj = NULL;
-
-                                       mutex_lock(&cdt->cdt_restore_lock);
-                                       crh = mdt_hsm_restore_hdl_find(cdt,
-                                                               &hai->hai_fid);
-                                       if (crh != NULL)
-                                               list_del(&crh->crh_list);
-                                       mutex_unlock(&cdt->cdt_restore_lock);
-                                       obj = mdt_object_find(mti->mti_env,
-                                                             mti->mti_mdt,
-                                                             &hai->hai_fid);
-                                       if (!IS_ERR(obj) && crh != NULL)
-                                               mdt_object_unlock(mti, obj,
-                                                                 &crh->crh_lh,
-                                                                 1);
-                                       if (crh != NULL)
-                                               OBD_SLAB_FREE_PTR(crh,
-                                                       mdt_hsm_cdt_kmem);
-                                       if (!IS_ERR(obj))
-                                               mdt_object_put(mti->mti_env,
-                                                              obj);
-                               }
+                       /* if restore and record status updated, give
+                        * back granted layout lock */
+                       if (hai->hai_action == HSMA_RESTORE) {
+                               struct cdt_restore_handle *crh = NULL;
+                               struct mdt_object *obj = NULL;
+
+                               mutex_lock(&cdt->cdt_restore_lock);
+                               crh = mdt_hsm_restore_hdl_find(cdt,
+                                                              &hai->hai_fid);
+                               if (crh != NULL)
+                                       list_del(&crh->crh_list);
+                               mutex_unlock(&cdt->cdt_restore_lock);
+                               obj = mdt_object_find(mti->mti_env,
+                                                     mti->mti_mdt,
+                                                     &hai->hai_fid);
+                               if (!IS_ERR(obj) && crh != NULL)
+                                       mdt_object_unlock(mti, obj,
+                                                         &crh->crh_lh, 1);
+                               if (crh != NULL)
+                                       OBD_SLAB_FREE_PTR(crh,
+                                                         mdt_hsm_cdt_kmem);
+                               if (!IS_ERR(obj))
+                                       mdt_object_put(mti->mti_env, obj);
                        }
                }
        }
                        }
                }
        }