From 973759d1ff3bbcb217754bd9942fdf670dec2d96 Mon Sep 17 00:00:00 2001 From: Quentin Bouget Date: Thu, 24 Aug 2017 13:16:04 +0200 Subject: [PATCH] LU-8626 hsm: count the number of started requests of each type Add counters in the coordinator to keep track of how many started hsm requests of each type (ARCHIVE, RESTORE, REMOVE) the coordinator is managing. There is no counter for CANCEL requests as the coordinator does not keep track of them like it does for the other requests. Test-Parameters: trivial testlist=sanity-hsm Signed-off-by: Quentin Bouget Change-Id: I0c1e9881f2f6a4f005dfc3545b1b51714eb91b7b Reviewed-on: https://review.whamcloud.com/28677 Reviewed-by: Henri Doreau Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Stephan Thiell Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_coordinator.c | 3 +++ lustre/mdt/mdt_hsm_cdt_requests.c | 23 +++++++++++++++++++++++ lustre/mdt/mdt_internal.h | 8 ++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index 53abb99..ac99386 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -1072,6 +1072,9 @@ static int mdt_hsm_cdt_start(struct mdt_device *mdt) /* cdt_last_cookie is protected by cdt_llog_lock */ cdt->cdt_last_cookie = ktime_get_real_seconds(); atomic_set(&cdt->cdt_request_count, 0); + atomic_set(&cdt->cdt_archive_count, 0); + atomic_set(&cdt->cdt_restore_count, 0); + atomic_set(&cdt->cdt_remove_count, 0); cdt->cdt_user_request_mask = (1UL << HSMA_RESTORE); cdt->cdt_group_request_mask = (1UL << HSMA_RESTORE); cdt->cdt_other_request_mask = (1UL << HSMA_RESTORE); diff --git a/lustre/mdt/mdt_hsm_cdt_requests.c b/lustre/mdt/mdt_hsm_cdt_requests.c index 60872ed..29a638d 100644 --- a/lustre/mdt/mdt_hsm_cdt_requests.c +++ b/lustre/mdt/mdt_hsm_cdt_requests.c @@ -382,6 +382,17 @@ int mdt_cdt_add_request(struct coordinator *cdt, struct cdt_agent_req *car) mdt_hsm_agent_update_statistics(cdt, 0, 0, 1, &car->car_uuid); + switch (car->car_hai->hai_action) { + case HSMA_ARCHIVE: + atomic_inc(&cdt->cdt_archive_count); + break; + case HSMA_RESTORE: + atomic_inc(&cdt->cdt_restore_count); + break; + case HSMA_REMOVE: + atomic_inc(&cdt->cdt_remove_count); + break; + } atomic_inc(&cdt->cdt_request_count); RETURN(0); @@ -427,6 +438,18 @@ int mdt_cdt_remove_request(struct coordinator *cdt, __u64 cookie) list_del(&car->car_request_list); up_write(&cdt->cdt_request_lock); + switch (car->car_hai->hai_action) { + case HSMA_ARCHIVE: + atomic_dec(&cdt->cdt_archive_count); + break; + case HSMA_RESTORE: + atomic_dec(&cdt->cdt_restore_count); + break; + case HSMA_REMOVE: + atomic_dec(&cdt->cdt_remove_count); + break; + } + /* Drop reference from cdt_request_list. */ mdt_cdt_put_request(car); diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index fdc42bc..10c7123 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -156,8 +156,12 @@ struct coordinator { * specified */ __u64 cdt_max_requests; /**< max count of started * requests */ - atomic_t cdt_request_count; /**< current count of - * started requests */ + /** Current count of active requests */ + atomic_t cdt_request_count; /** total */ + atomic_t cdt_archive_count; + atomic_t cdt_restore_count; + atomic_t cdt_remove_count; + /* started requests (struct cdt_agent_req:car_cookie_hash) * indexed by cookie */ struct cfs_hash *cdt_request_cookie_hash; -- 1.8.3.1