From: jcl Date: Sat, 17 Aug 2013 16:37:39 +0000 (+0200) Subject: LU-3711 mdt: default archive id is tunable X-Git-Tag: 2.4.93~73 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=325ce4b25e94fc0fbf4441487713fae53637f40e LU-3711 mdt: default archive id is tunable Add a /proc entry to specify default archive id. The default is used when no archive id or 0 archive id are specified from the command line. Signed-off-by: JC Lafoucriere Change-Id: I0d59c37e7bc9a552d1787cf85d03328989ba9b19 Reviewed-on: http://review.whamcloud.com/7373 Tested-by: Hudson Tested-by: Maloo Tested-by: Malcolm Cowe Reviewed-by: Jinshan Xiong Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index 5c07bf0..deb26db 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -929,6 +929,7 @@ int mdt_hsm_cdt_start(struct mdt_device *mdt) cdt->cdt_delay = 60; cdt->cdt_timeout = 3600; cdt->cdt_max_request = 3; + cdt->cdt_archive_id = 1; atomic_set(&cdt->cdt_request_count, 0); /* to avoid deadlock when start is made through /proc @@ -1897,6 +1898,7 @@ GENERATE_PROC_METHOD(cdt_loop_period) GENERATE_PROC_METHOD(cdt_delay) GENERATE_PROC_METHOD(cdt_timeout) GENERATE_PROC_METHOD(cdt_max_request) +GENERATE_PROC_METHOD(cdt_archive_id) /* * procfs write method for MDT/hsm_control @@ -1982,6 +1984,9 @@ static struct lprocfs_vars lprocfs_mdt_hsm_vars[] = { { "agents", NULL, NULL, NULL, &mdt_hsm_agent_fops, 0 }, { "agent_actions", NULL, NULL, NULL, &mdt_agent_actions_fops, 0444 }, + { "archive_id", lprocfs_rd_hsm_cdt_archive_id, + lprocfs_wr_hsm_cdt_archive_id, + NULL, NULL, 0 }, { "grace_delay", lprocfs_rd_hsm_cdt_delay, lprocfs_wr_hsm_cdt_delay, NULL, NULL, 0 }, diff --git a/lustre/mdt/mdt_hsm_cdt_client.c b/lustre/mdt/mdt_hsm_cdt_client.c index 8264070..8047c87 100644 --- a/lustre/mdt/mdt_hsm_cdt_client.c +++ b/lustre/mdt/mdt_hsm_cdt_client.c @@ -351,6 +351,7 @@ int mdt_hsm_add_actions(struct mdt_thread_info *mti, /* for cancel archive number is taken from canceled request * for other request, we take from lma if not specified, + * or we use the default if none found in lma * this works also for archive because the default value is 0 * /!\ there is a side effect: in case of restore on multiple * files which are in different backend, the initial compound @@ -358,8 +359,12 @@ int mdt_hsm_add_actions(struct mdt_thread_info *mti, * warranty an agent can serve any combinaison of archive * backend */ - if (hai->hai_action != HSMA_CANCEL && archive_id == 0) - archive_id = mh.mh_arch_id; + if (hai->hai_action != HSMA_CANCEL && archive_id == 0) { + if (mh.mh_arch_id != 0) + archive_id = mh.mh_arch_id; + else + archive_id = cdt->cdt_archive_id; + } /* if restore, take an exclusive lock on layout */ if (hai->hai_action == HSMA_RESTORE) { diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 86805bc..4e7db2a 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -125,6 +125,8 @@ struct coordinator { cfs_time_t cdt_loop_period; /**< llog scan period */ cfs_time_t cdt_delay; /**< request grace delay */ cfs_time_t cdt_timeout; /**< request timeout */ + __u32 cdt_archive_id; /** archive id used when + * none are specified */ __u64 cdt_max_request; /**< max count of started * requests */ atomic_t cdt_request_count; /**< current count of diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index 7807177..c83e44e 100644 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -751,6 +751,25 @@ test_10c() { } run_test 10c "Check forbidden archive" +test_10d() { + # test needs a running copytool + copytool_setup + + mkdir -p $DIR/$tdir + local f=$DIR/$tdir/$tfile + local fid=$(copy_file /etc/hosts $f) + $LFS hsm_archive $f || error "cannot archive $f" + wait_request_state $fid ARCHIVE SUCCEED + + local ar=$(get_hsm_archive_id $f) + local dflt=$(get_hsm_param archive_id) + [[ $ar == $dflt ]] || + error "archived file is not on default archive: $ar != $dflt" + + copytool_cleanup +} +run_test 10d "Archive a file on the default archive id" + test_11() { mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile @@ -2069,7 +2088,7 @@ test_90() { } run_test 90 "Archive/restore a file list" -double_verify_reset_ham_param() { +double_verify_reset_hsm_param() { local p=$1 echo "Testing $HSM_PARAM.$p" local val=$(get_hsm_param $p) @@ -2092,10 +2111,11 @@ double_verify_reset_ham_param() { } test_100() { - double_verify_reset_ham_param loop_period - double_verify_reset_ham_param grace_delay - double_verify_reset_ham_param request_timeout - double_verify_reset_ham_param max_requests + double_verify_reset_hsm_param loop_period + double_verify_reset_hsm_param grace_delay + double_verify_reset_hsm_param request_timeout + double_verify_reset_hsm_param max_requests + double_verify_reset_hsm_param archive_id } run_test 100 "Set coordinator /proc tunables"