Whamcloud - gitweb
LU-12477 llite: remove unused ll_teardown_mmaps()
[fs/lustre-release.git] / lustre / mdt / mdt_hsm_cdt_client.c
index 705e98e..12ec150 100644 (file)
@@ -111,32 +111,30 @@ static int hsm_find_compatible(const struct lu_env *env, struct mdt_device *mdt,
                               struct hsm_action_list *hal)
 {
        struct hsm_action_item *hai;
-       int rc, i, ok_cnt;
+       int rc = 0, i;
+       bool check = false;
        ENTRY;
 
-       ok_cnt = 0;
        hai = hai_first(hal);
        for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
                /* We only support ARCHIVE, RESTORE, REMOVE and CANCEL here. */
                if (hai->hai_action == HSMA_NONE)
                        RETURN(-EINVAL);
 
-               /* in a cancel request hai_cookie may be set by caller to
-                * show the request to be canceled
-                * if not we need to search by FID
+               /* In a cancel request hai_cookie may be set by caller to show
+                * the request to be canceled. If there is at least one cancel
+                * request that does not have a cookie set we need to search by
+                * FID; we can skip checking in all other cases
                 */
-               if (hai->hai_action == HSMA_CANCEL && hai->hai_cookie != 0)
-                       ok_cnt++;
-               else
-                       hai->hai_cookie = 0;
+               if (hai->hai_action == HSMA_CANCEL && hai->hai_cookie == 0) {
+                       check = true;
+                       break;
+               }
        }
 
-       /* if all requests are cancel with cookie, no need to find compatible */
-       if (ok_cnt == hal->hal_count)
-               RETURN(0);
-
-       rc = cdt_llog_process(env, mdt, hsm_find_compatible_cb, hal, 0, 0,
-                             READ);
+       if (check)
+               rc = cdt_llog_process(env, mdt, hsm_find_compatible_cb, hal, 0,
+                                             0, READ);
 
        RETURN(rc);
 }
@@ -241,7 +239,7 @@ hsm_action_permission(struct mdt_thread_info *mti,
        if (hsma != HSMA_RESTORE && mdt_rdonly(mti->mti_exp))
                RETURN(-EROFS);
 
-       if (md_capable(uc, CFS_CAP_SYS_ADMIN))
+       if (md_capable(uc, CAP_SYS_ADMIN))
                RETURN(0);
 
        ma->ma_need = MA_INODE;
@@ -315,7 +313,7 @@ static int mdt_hsm_register_hal(struct mdt_thread_info *mti,
                        /* In case of REMOVE and CANCEL a Lustre file
                         * is not mandatory, but restrict this
                         * exception to admins. */
-                       if (md_capable(mdt_ucred(mti), CFS_CAP_SYS_ADMIN) &&
+                       if (md_capable(mdt_ucred(mti), CAP_SYS_ADMIN) &&
                            (hai->hai_action == HSMA_REMOVE ||
                             hai->hai_action == HSMA_CANCEL))
                                goto record;