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>
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;
struct hsm_scan_request *request;
/* Are agents full? */
struct hsm_scan_request *request;
/* Are agents full? */
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);
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 */
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++;
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
}
/* 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;
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
}
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);