Whamcloud - gitweb
LU-3711 mdt: default archive id is tunable 73/7373/2
authorjcl <jacques-charles.lafoucriere@cea.fr>
Sat, 17 Aug 2013 16:37:39 +0000 (18:37 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 4 Sep 2013 04:37:49 +0000 (04:37 +0000)
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 <jacques-charles.lafoucriere@cea.fr>
Change-Id: I0d59c37e7bc9a552d1787cf85d03328989ba9b19
Reviewed-on: http://review.whamcloud.com/7373
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Tested-by: Malcolm Cowe <malcolm.j.cowe@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_coordinator.c
lustre/mdt/mdt_hsm_cdt_client.c
lustre/mdt/mdt_internal.h
lustre/tests/sanity-hsm.sh

index 5c07bf0..deb26db 100644 (file)
@@ -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 },
index 8264070..8047c87 100644 (file)
@@ -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) {
index 86805bc..4e7db2a 100644 (file)
@@ -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
index 7807177..c83e44e 100644 (file)
@@ -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"