Whamcloud - gitweb
LU-129 Skip quotacheck on administratively disabled OSTs
authorNiu Yawei <niu@whamcloud.com>
Tue, 22 Mar 2011 08:19:15 +0000 (01:19 -0700)
committerJohann Lombardi <johann@whamcloud.com>
Thu, 14 Apr 2011 17:56:03 +0000 (10:56 -0700)
- skip quotacheck on administratively disabled OSTs.

- introduce OBD_NOTIFY_DEACTIVATE & OBD_NOTIFY_ACTIVATE event, thus lov is now aware of
  administratively enable/disable import event, and is able to udpate the 'ltd_activate'
  accordingly.

Issue: LU-129
Signed-off-by: Niu Yawei <niu@whamcloud.com>
Change-Id: Id3d2c9e1e035086e653ab500459912f7960976c8
Reviewed-on: http://review.whamcloud.com/351
Tested-by: Hudson
Reviewed-by: Lai Siyao <laisiyao@whamcloud.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
lustre/include/lustre_import.h
lustre/include/obd.h
lustre/lov/lov_obd.c
lustre/mdc/mdc_request.c
lustre/mgc/mgc_request.c
lustre/osc/osc_request.c
lustre/ptlrpc/recover.c
lustre/quota/quota_check.c
lustre/quota/quota_ctl.c
lustre/tests/conf-sanity.sh

index 2a67f87..3d69aca 100644 (file)
@@ -94,6 +94,8 @@ enum obd_import_event {
         IMP_EVENT_INVALIDATE = 0x808003,
         IMP_EVENT_ACTIVE     = 0x808004,
         IMP_EVENT_OCD        = 0x808005,
+        IMP_EVENT_DEACTIVATE = 0x808006,
+        IMP_EVENT_ACTIVATE   = 0x808007,
 };
 
 struct obd_import_conn {
index e89805d..d72459d 100644 (file)
@@ -948,7 +948,10 @@ enum obd_notify_event {
         OBD_NOTIFY_SYNC_NONBLOCK,
         OBD_NOTIFY_SYNC,
         /* Configuration event */
-        OBD_NOTIFY_CONFIG
+        OBD_NOTIFY_CONFIG,
+        /* Administratively deactivate/activate event */
+        OBD_NOTIFY_DEACTIVATE,
+        OBD_NOTIFY_ACTIVATE
 };
 
 #define CONFIG_LOG      0x1  /* finished processing config log */
index 8b2d848..3194f45 100644 (file)
@@ -190,7 +190,7 @@ static int lov_obd_unregister_lock_cancel_cb(struct obd_device *obd,
 }
 
 static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
-                              int activate);
+                              enum obd_notify_event ev);
 
 static int lov_notify(struct obd_device *obd, struct obd_device *watched,
                       enum obd_notify_event ev, void *data)
@@ -198,7 +198,8 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched,
         int rc = 0;
         ENTRY;
 
-        if (ev == OBD_NOTIFY_ACTIVE || ev == OBD_NOTIFY_INACTIVE) {
+        if (ev == OBD_NOTIFY_ACTIVE || ev == OBD_NOTIFY_INACTIVE ||
+            ev == OBD_NOTIFY_ACTIVATE || ev == OBD_NOTIFY_DEACTIVATE) {
                 LASSERT(watched);
 
                 if (strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME)) {
@@ -212,10 +213,9 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched,
                  * observer can use the OSC normally.
                  */
                 rc = lov_set_osc_active(obd, &watched->u.cli.cl_target_uuid,
-                                        ev == OBD_NOTIFY_ACTIVE);
+                                        ev);
                 if (rc < 0) {
-                        CERROR("%sactivation of %s failed: %d\n",
-                               (ev == OBD_NOTIFY_ACTIVE) ? "" : "de",
+                        CERROR("event(%d) of %s failed: %d\n", ev,
                                obd_uuid2str(&watched->u.cli.cl_target_uuid),
                                rc);
                         RETURN(rc);
@@ -534,15 +534,15 @@ out:
  *  - any above 0 is lov index
  */
 static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
-                              int activate)
+                              enum obd_notify_event ev)
 {
         struct lov_obd *lov = &obd->u.lov;
         struct lov_tgt_desc *tgt;
-        int i = 0;
+        int i = 0, activate, active;
         ENTRY;
 
-        CDEBUG(D_INFO, "Searching in lov %p for uuid %s (activate=%d)\n",
-               lov, uuid->uuid, activate);
+        CDEBUG(D_INFO, "Searching in lov %p for uuid %s event(%d)\n",
+               lov, uuid->uuid, ev);
 
         obd_getref(obd);
         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
@@ -560,18 +560,34 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
         if (i == lov->desc.ld_tgt_count)
                 GOTO(out, i = -EINVAL);
 
-        if (lov->lov_tgts[i]->ltd_active == activate) {
+        if (ev == OBD_NOTIFY_DEACTIVATE || ev == OBD_NOTIFY_ACTIVATE) {
+                activate = (ev == OBD_NOTIFY_ACTIVATE) ? 1 : 0;
+
+                if (lov->lov_tgts[i]->ltd_activate == activate) {
+                        CDEBUG(D_INFO, "OSC %s already %sactivate!\n",
+                               uuid->uuid, activate ? "" : "de");
+                } else {
+                        lov->lov_tgts[i]->ltd_activate = activate;
+                        CDEBUG(D_CONFIG, "%sactivate OSC %s\n",
+                               activate ? "" : "de", obd_uuid2str(uuid));
+                }
+                GOTO(out, i);
+        }
+
+        active = (ev == OBD_NOTIFY_ACTIVE) ? 1 : 0;
+
+        if (lov->lov_tgts[i]->ltd_active == active) {
                 CDEBUG(D_INFO, "OSC %s already %sactive!\n", uuid->uuid,
-                       activate ? "" : "in");
+                       active ? "" : "in");
                 GOTO(out, i);
         }
 
         CDEBUG(D_CONFIG, "Marking OSC %s %sactive\n", obd_uuid2str(uuid),
-               activate ? "" : "in");
+               active ? "" : "in");
 
-        lov->lov_tgts[i]->ltd_active = activate;
+        lov->lov_tgts[i]->ltd_active = active;
 
-        if (activate) {
+        if (active) {
                 lov->desc.ld_active_tgt_count++;
                 lov->lov_tgts[i]->ltd_exp->exp_obd->obd_inactive = 0;
         } else {
index 486d3ca..7593050 100644 (file)
@@ -1360,7 +1360,9 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
         case IMP_EVENT_OCD:
                 ptlrpc_import_setasync(imp, obd->obd_namespace->ns_max_unused);
                 break;
-
+        case IMP_EVENT_DEACTIVATE:
+        case IMP_EVENT_ACTIVATE:
+                break;
         default:
                 CERROR("Unknown import event %x\n", event);
                 LBUG();
index faafe97..58ba237 100644 (file)
@@ -923,6 +923,9 @@ static int mgc_import_event(struct obd_device *obd,
                 break;
         case IMP_EVENT_OCD:
                 break;
+        case IMP_EVENT_DEACTIVATE:
+        case IMP_EVENT_ACTIVATE:
+                break;
         default:
                 CERROR("Unknown import event %#x\n", event);
                 LBUG();
index 5e957c2..70c13c1 100644 (file)
@@ -4446,6 +4446,14 @@ static int osc_import_event(struct obd_device *obd,
                 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL);
                 break;
         }
+        case IMP_EVENT_DEACTIVATE: {
+                rc = obd_notify_observer(obd, obd, OBD_NOTIFY_DEACTIVATE, NULL);
+                break;
+        }
+        case IMP_EVENT_ACTIVATE: {
+                rc = obd_notify_observer(obd, obd, OBD_NOTIFY_ACTIVATE, NULL);
+                break;
+        }
         default:
                 CERROR("Unknown import event %d\n", event);
                 LBUG();
index ec962a0..51e7c5d 100644 (file)
@@ -247,6 +247,8 @@ int ptlrpc_set_import_active(struct obd_import *imp, int active)
                 imp->imp_deactive = 1;
                 spin_unlock(&imp->imp_lock);
 
+                obd_import_event(imp->imp_obd, imp, IMP_EVENT_DEACTIVATE);
+
                 ptlrpc_invalidate_import(imp);
         }
 
@@ -279,6 +281,7 @@ int ptlrpc_recover_import(struct obd_import *imp, char *new_uuid)
         spin_lock(&imp->imp_lock);
         imp->imp_deactive = 0;
         spin_unlock(&imp->imp_lock);
+        obd_import_event(imp->imp_obd, imp, IMP_EVENT_ACTIVATE);
 
         rc = ptlrpc_recover_import_no_retry(imp, new_uuid);
 
index f384edd..9e9b05c 100644 (file)
@@ -252,6 +252,12 @@ int lov_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl)
                 if (!lov->lov_tgts[i])
                         continue;
 
+                /* Skip quota check on the administratively disabled OSTs. */
+                if (!lov->lov_tgts[i]->ltd_activate) {
+                        CWARN("lov idx %d was administratively disabled\n", i);
+                        continue;
+                }
+
                 if (!lov->lov_tgts[i]->ltd_active) {
                         CERROR("lov idx %d inactive\n", i);
                         rc = -EIO;
@@ -262,7 +268,7 @@ int lov_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl)
         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                 int err;
 
-                if (!lov->lov_tgts[i])
+                if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_activate)
                         continue;
 
                 err = obd_quotacheck(lov->lov_tgts[i]->ltd_exp, oqctl);
index 84a649d..8d412c4 100644 (file)
@@ -462,8 +462,14 @@ int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
                 struct ptlrpc_request *req;
                 struct obd_quotactl *oqc;
 
-                if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active) {
-                        if (oqctl->qc_cmd == Q_GETOQUOTA) {
+                if (!lov->lov_tgts[i])
+                        continue;
+
+                if (!lov->lov_tgts[i]->ltd_active) {
+                        /* Skip Q_GETOQUOTA on administratively disabled OSTs.
+                         */
+                        if (oqctl->qc_cmd == Q_GETOQUOTA &&
+                            lov->lov_tgts[i]->ltd_activate) {
                                 CERROR("ost %d is inactive\n", i);
                                 rc = -EIO;
                         } else {
index 1c97e58..d2c8f14 100644 (file)
@@ -1061,6 +1061,9 @@ test_29() {
            echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
        done
 
+        # quotacheck should not fail immediately after deactivate
+       [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
+
         # test new client starts deactivated
        umount_client $MOUNT || return 200
        mount_client $MOUNT
@@ -1072,6 +1075,9 @@ test_29() {
            echo "New client success: got $RESULT"
        fi
 
+        # quotacheck should not fail after umount/mount operation
+       [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
+
        # make sure it reactivates
        set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6