Whamcloud - gitweb
LU-7988 hsm: only browse entries of hsd.request when needed 81/19581/15
authorFrank Zago <fzago@cray.com>
Thu, 7 Apr 2016 16:59:52 +0000 (12:59 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 11 Aug 2016 05:50:38 +0000 (05:50 +0000)
In the coordinator callback, only the entries in hsd.request from 0 to
hsd.request_cnt-1 are used. So use that property instead of walking
the whole array. Consequently, the next entry available in hsd.request
is always at the hsd.request_cnt position, so use it instead of trying
to find an empty slot.

There is no need to reset hsd.request since hsd.request is already
reset in a for loop above. This saves a memset of 16 bytes per
request, each time the arbitor runs.

Test-Parameters: trivial testlist=sanity-hsm
Signed-off-by: frank zago <fzago@cray.com>
Change-Id: I2be0fe5ce918ded028bb260ef345a859b2cc41d4
Reviewed-on: http://review.whamcloud.com/19581
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Vinayak <vinayakswami.hariharmath@seagate.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_coordinator.c

index b8319fd..5f5c20a 100644 (file)
@@ -177,7 +177,7 @@ static int mdt_coordinator_cb(const struct lu_env *env,
        dump_llog_agent_req_rec("mdt_coordinator_cb(): ", larr);
        switch (larr->arr_status) {
        case ARS_WAITING: {
        dump_llog_agent_req_rec("mdt_coordinator_cb(): ", larr);
        switch (larr->arr_status) {
        case ARS_WAITING: {
-               int i, empty_slot, found;
+               int i;
                struct hsm_scan_request *request;
 
                /* Are agents full? */
                struct hsm_scan_request *request;
 
                /* Are agents full? */
@@ -185,34 +185,29 @@ static int mdt_coordinator_cb(const struct lu_env *env,
                    cdt->cdt_max_requests)
                        break;
 
                    cdt->cdt_max_requests)
                        break;
 
-               /* first search whether the request is found in the list we
-                * have built and if there is room in the request vector */
-               empty_slot = -1;
-               found = -1;
-               for (i = 0; i < hsd->max_requests &&
-                           (empty_slot == -1 || found == -1); i++) {
-                       if (hsd->request[i].hal == NULL) {
-                               empty_slot = i;
-                               continue;
-                       }
+               /* first search whether the request is found in the
+                * list we have built. */
+               request = NULL;
+               for (i = 0; i < hsd->request_cnt; i++) {
                        if (hsd->request[i].hal->hal_compound_id ==
                        if (hsd->request[i].hal->hal_compound_id ==
-                               larr->arr_compound_id) {
-                               found = i;
-                               continue;
+                           larr->arr_compound_id) {
+                               request = &hsd->request[i];
+                               break;
                        }
                }
                        }
                }
-               if (found == -1 && empty_slot == -1)
-                       /* unknown request and no more room for new request,
-                        * continue scan for to find other entries for
-                        * already found request
-                        */
-                       RETURN(0);
 
 
-               if (found == -1) {
+               if (!request) {
                        struct hsm_action_list *hal;
 
                        struct hsm_action_list *hal;
 
-                       /* request is not already known */
-                       request = &hsd->request[empty_slot];
+                       if (hsd->request_cnt == hsd->max_requests)
+                               /* Unknown request and no more room
+                                * for a new request. Continue to scan
+                                * to find other entries for already
+                                * existing requests.
+                                */
+                               RETURN(0);
+
+                       request = &hsd->request[hsd->request_cnt];
 
                        /* allocates hai vector size just needs to be large
                         * enough */
 
                        /* allocates hai vector size just needs to be large
                         * enough */
@@ -239,12 +234,9 @@ static int mdt_coordinator_cb(const struct lu_env *env,
                        request->hal_used_sz = hal_size(hal);
                        request->hal = hal;
                        hsd->request_cnt++;
                        request->hal_used_sz = hal_size(hal);
                        request->hal = hal;
                        hsd->request_cnt++;
-                       found = empty_slot;
                        hai = hai_first(hal);
                } else {
                        /* request is known */
                        hai = hai_first(hal);
                } else {
                        /* request is known */
-                       request = &hsd->request[found];
-
                        /* we check if record archive num is the same as the
                         * known request, if not we will serve it in multiple
                         * time because we do not know if the agent can serve
                        /* we check if record archive num is the same as the
                         * known request, if not we will serve it in multiple
                         * time because we do not know if the agent can serve
@@ -517,7 +509,7 @@ static int mdt_coordinator(void *data)
                }
 
                /* here hsd contains a list of requests to be started */
                }
 
                /* here hsd contains a list of requests to be started */
-               for (i = 0; i < hsd.max_requests; i++) {
+               for (i = 0; i < hsd.request_cnt; i++) {
                        struct hsm_scan_request *request = &hsd.request[i];
                        struct hsm_action_list  *hal = request->hal;
                        struct hsm_action_item  *hai;
                        struct hsm_scan_request *request = &hsd.request[i];
                        struct hsm_action_list  *hal = request->hal;
                        struct hsm_action_item  *hai;
@@ -530,9 +522,6 @@ static int mdt_coordinator(void *data)
                            cdt->cdt_max_requests)
                                break;
 
                            cdt->cdt_max_requests)
                                break;
 
-                       if (hal == NULL)
-                               continue;
-
                        rc = mdt_hsm_agent_send(mti, hal, 0);
                        /* if failure, we suppose it is temporary
                         * if the copy tool failed to do the request
                        rc = mdt_hsm_agent_send(mti, hal, 0);
                        /* if failure, we suppose it is temporary
                         * if the copy tool failed to do the request
@@ -572,20 +561,11 @@ static int mdt_coordinator(void *data)
                }
 clean_cb_alloc:
                /* free hal allocated by callback */
                }
 clean_cb_alloc:
                /* free hal allocated by callback */
-               for (i = 0; i < hsd.max_requests; i++) {
+               for (i = 0; i < hsd.request_cnt; i++) {
                        struct hsm_scan_request *request = &hsd.request[i];
 
                        struct hsm_scan_request *request = &hsd.request[i];
 
-                       if (request->hal) {
-                               OBD_FREE(request->hal, request->hal_sz);
-                               request->hal_sz = 0;
-                               request->hal = NULL;
-                               hsd.request_cnt--;
-                       }
+                       OBD_FREE(request->hal, request->hal_sz);
                }
                }
-               LASSERT(hsd.request_cnt == 0);
-
-               /* reset callback data */
-               memset(hsd.request, 0, request_sz);
        }
        EXIT;
 out:
        }
        EXIT;
 out: