Whamcloud - gitweb
LU-4065 mdt: Ensure accurate coordinator state 74/8074/4
authorBruno Faccini <bruno.faccini@intel.com>
Sat, 26 Oct 2013 05:59:39 +0000 (07:59 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 18 Nov 2013 12:34:49 +0000 (12:34 +0000)
Some control must be added in procfs interface to
ensure that the coordinator state will be kept accurate.

Signed-off-by: Bruno Faccini <bruno.faccini@intel.com>
Change-Id: I41e5b42ddbdbcb652c202ee01fa120126e78f3d2
Reviewed-on: http://review.whamcloud.com/8074
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
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

index b11723d..87a5f3e 100644 (file)
@@ -1984,10 +1984,24 @@ int lprocfs_wr_hsm_cdt_control(struct file *file, const char *buffer,
                        rc = mdt_hsm_cdt_start(mdt);
                }
        } else if (strncmp(buffer, CDT_STOP_CMD, strlen(CDT_STOP_CMD)) == 0) {
-               cdt->cdt_state = CDT_STOPPING;
+               if ((cdt->cdt_state == CDT_STOPPING) ||
+                   (cdt->cdt_state == CDT_STOPPED)) {
+                       CERROR("%s: Coordinator already stopped\n",
+                              mdt_obd_name(mdt));
+                       rc = -EALREADY;
+               } else {
+                       cdt->cdt_state = CDT_STOPPING;
+               }
        } else if (strncmp(buffer, CDT_DISABLE_CMD,
                           strlen(CDT_DISABLE_CMD)) == 0) {
-               cdt->cdt_state = CDT_DISABLE;
+               if ((cdt->cdt_state == CDT_STOPPING) ||
+                   (cdt->cdt_state == CDT_STOPPED)) {
+                       CERROR("%s: Coordinator is stopped\n",
+                              mdt_obd_name(mdt));
+                       rc = -EINVAL;
+               } else {
+                       cdt->cdt_state = CDT_DISABLE;
+               }
        } else if (strncmp(buffer, CDT_PURGE_CMD, strlen(CDT_PURGE_CMD)) == 0) {
                rc = hsm_cancel_all_actions(mdt);
        } else if (strncmp(buffer, CDT_HELP_CMD, strlen(CDT_HELP_CMD)) == 0) {