Whamcloud - gitweb
LU-129 Skip quotacheck on administratively disabled OSTs
authorNiu Yawei <niu@whamcloud.com>
Fri, 1 Apr 2011 02:14:33 +0000 (19:14 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 20 Apr 2011 22:41:37 +0000 (15:41 -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: I6af7dc09226d610bb1d481609a0a0ae09a05410e
Reviewed-on: http://review.whamcloud.com/387
Tested-by: Hudson
Reviewed-by: Oleg Drokin <green@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 e956755..339a232 100644 (file)
@@ -124,6 +124,8 @@ enum obd_import_event {
         IMP_EVENT_INVALIDATE = 0x808003,
         IMP_EVENT_ACTIVE     = 0x808004,
         IMP_EVENT_OCD        = 0x808005,
         IMP_EVENT_INVALIDATE = 0x808003,
         IMP_EVENT_ACTIVE     = 0x808004,
         IMP_EVENT_OCD        = 0x808005,
+        IMP_EVENT_DEACTIVATE = 0x808006,
+        IMP_EVENT_ACTIVATE   = 0x808007,
 };
 
 /**
 };
 
 /**
index 1a8d508..61d0874 100644 (file)
@@ -904,7 +904,10 @@ enum obd_notify_event {
         /* Configuration event */
         OBD_NOTIFY_CONFIG,
         /* Trigger quota recovery */
         /* Configuration event */
         OBD_NOTIFY_CONFIG,
         /* Trigger quota recovery */
-        OBD_NOTIFY_QUOTA
+        OBD_NOTIFY_QUOTA,
+        /* Administratively deactivate/activate event */
+        OBD_NOTIFY_DEACTIVATE,
+        OBD_NOTIFY_ACTIVATE
 };
 
 /* bit-mask flags for config events */
 };
 
 /* bit-mask flags for config events */
index 5d3aca4..943e577 100644 (file)
@@ -121,7 +121,7 @@ static void lov_putref(struct obd_device *obd)
 }
 
 static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
 }
 
 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);
 
 static int lov_notify(struct obd_device *obd, struct obd_device *watched,
                       enum obd_notify_event ev, void *data);
 
@@ -384,15 +384,15 @@ out:
  *  any >= 0 : is log target index
  */
 static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
  *  any >= 0 : is log target 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;
 {
         struct lov_obd *lov = &obd->u.lov;
         struct lov_tgt_desc *tgt;
-        int index;
+        int index, activate, active;
         ENTRY;
 
         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 (index = 0; index < lov->desc.ld_tgt_count; index++) {
 
         obd_getref(obd);
         for (index = 0; index < lov->desc.ld_tgt_count; index++) {
@@ -410,26 +410,43 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
         if (index == lov->desc.ld_tgt_count)
                 GOTO(out, index = -EINVAL);
 
         if (index == lov->desc.ld_tgt_count)
                 GOTO(out, index = -EINVAL);
 
-        if (lov->lov_tgts[index]->ltd_active == activate) {
-                CDEBUG(D_INFO, "OSC %s already %sactive!\n", uuid->uuid,
-                       activate ? "" : "in");
-                GOTO(out, index);
-        }
+        if (ev == OBD_NOTIFY_DEACTIVATE || ev == OBD_NOTIFY_ACTIVATE) {
+                activate = (ev == OBD_NOTIFY_ACTIVATE) ? 1 : 0;
 
 
-        CDEBUG(D_CONFIG, "Marking OSC %s %sactive\n", obd_uuid2str(uuid),
-               activate ? "" : "in");
+                if (lov->lov_tgts[index]->ltd_activate == activate) {
+                        CDEBUG(D_INFO, "OSC %s already %sactivate!\n",
+                               uuid->uuid, activate ? "" : "de");
+                } else {
+                        lov->lov_tgts[index]->ltd_activate = activate;
+                        CDEBUG(D_CONFIG, "%sactivate OSC %s\n",
+                               activate ? "" : "de", obd_uuid2str(uuid));
+                }
 
 
-        lov->lov_tgts[index]->ltd_active = activate;
+        } else if (ev == OBD_NOTIFY_INACTIVE || ev == OBD_NOTIFY_ACTIVE) {
+                active = (ev == OBD_NOTIFY_ACTIVE) ? 1 : 0;
 
 
-        if (activate) {
-                lov->desc.ld_active_tgt_count++;
-                lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 0;
+                if (lov->lov_tgts[index]->ltd_active == active) {
+                        CDEBUG(D_INFO, "OSC %s already %sactive!\n",
+                               uuid->uuid, active ? "" : "in");
+                        GOTO(out, index);
+                } else {
+                        CDEBUG(D_CONFIG, "Marking OSC %s %sactive\n",
+                               obd_uuid2str(uuid), active ? "" : "in");
+                }
+
+                lov->lov_tgts[index]->ltd_active = active;
+                if (active) {
+                        lov->desc.ld_active_tgt_count++;
+                        lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 0;
+                } else {
+                        lov->desc.ld_active_tgt_count--;
+                        lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 1;
+                }
+                /* remove any old qos penalty */
+                lov->lov_tgts[index]->ltd_qos.ltq_penalty = 0;
         } else {
         } else {
-                lov->desc.ld_active_tgt_count--;
-                lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 1;
+                CERROR("Unknown event(%d) for uuid %s", ev, uuid->uuid);
         }
         }
-        /* remove any old qos penalty */
-        lov->lov_tgts[index]->ltd_qos.ltq_penalty = 0;
 
  out:
         obd_putref(obd);
 
  out:
         obd_putref(obd);
@@ -442,7 +459,8 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched,
         int rc = 0;
         ENTRY;
 
         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) {
                 struct obd_uuid *uuid;
 
                 LASSERT(watched);
                 struct obd_uuid *uuid;
 
                 LASSERT(watched);
@@ -458,10 +476,9 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched,
                 /* Set OSC as active before notifying the observer, so the
                  * observer can use the OSC normally.
                  */
                 /* Set OSC as active before notifying the observer, so the
                  * observer can use the OSC normally.
                  */
-                rc = lov_set_osc_active(obd, uuid, ev == OBD_NOTIFY_ACTIVE);
+                rc = lov_set_osc_active(obd, uuid, ev);
                 if (rc < 0) {
                 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(uuid), rc);
                         RETURN(rc);
                 }
                                obd_uuid2str(uuid), rc);
                         RETURN(rc);
                 }
index e3eae10..2848c10 100644 (file)
@@ -1843,7 +1843,9 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
         case IMP_EVENT_OCD:
                 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL);
                 break;
         case IMP_EVENT_OCD:
                 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL);
                 break;
-
+        case IMP_EVENT_DEACTIVATE:
+        case IMP_EVENT_ACTIVATE:
+                break;
         default:
                 CERROR("Unknown import event %x\n", event);
                 LBUG();
         default:
                 CERROR("Unknown import event %x\n", event);
                 LBUG();
index 8f4c568..a12a4e1 100644 (file)
@@ -1059,6 +1059,9 @@ static int mgc_import_event(struct obd_device *obd,
                 break;
         case IMP_EVENT_OCD:
                 break;
                 break;
         case IMP_EVENT_OCD:
                 break;
+        case IMP_EVENT_DEACTIVATE:
+        case IMP_EVENT_ACTIVATE:
+                break;
         default:
                 CERROR("Unknown import event %#x\n", event);
                 LBUG();
         default:
                 CERROR("Unknown import event %#x\n", event);
                 LBUG();
index 4cee4e8..9c483c6 100644 (file)
@@ -4372,6 +4372,14 @@ static int osc_import_event(struct obd_device *obd,
                 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL);
                 break;
         }
                 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();
         default:
                 CERROR("Unknown import event %d\n", event);
                 LBUG();
index 17085d6..b7855d7 100644 (file)
@@ -265,6 +265,8 @@ int ptlrpc_set_import_active(struct obd_import *imp, int active)
                 imp->imp_deactive = 1;
                 cfs_spin_unlock(&imp->imp_lock);
 
                 imp->imp_deactive = 1;
                 cfs_spin_unlock(&imp->imp_lock);
 
+                obd_import_event(imp->imp_obd, imp, IMP_EVENT_DEACTIVATE);
+
                 ptlrpc_invalidate_import(imp);
         }
 
                 ptlrpc_invalidate_import(imp);
         }
 
@@ -297,6 +299,7 @@ int ptlrpc_recover_import(struct obd_import *imp, char *new_uuid)
         cfs_spin_lock(&imp->imp_lock);
         imp->imp_deactive = 0;
         cfs_spin_unlock(&imp->imp_lock);
         cfs_spin_lock(&imp->imp_lock);
         imp->imp_deactive = 0;
         cfs_spin_unlock(&imp->imp_lock);
+        obd_import_event(imp->imp_obd, imp, IMP_EVENT_ACTIVATE);
 
         rc = ptlrpc_recover_import_no_retry(imp, new_uuid);
 
 
         rc = ptlrpc_recover_import_no_retry(imp, new_uuid);
 
index 6732d06..413934a 100644 (file)
@@ -304,6 +304,13 @@ int lov_quota_check(struct obd_device *unused, struct obd_export *exp,
                 if (!lov->lov_tgts[i])
                         continue;
 
                 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, "
+                              "skip quotacheck on it.\n", i);
+                        continue;
+                }
+
                 if (!lov->lov_tgts[i]->ltd_active) {
                         CERROR("lov idx %d inactive\n", i);
                         rc = -EIO;
                 if (!lov->lov_tgts[i]->ltd_active) {
                         CERROR("lov idx %d inactive\n", i);
                         rc = -EIO;
@@ -314,7 +321,7 @@ int lov_quota_check(struct obd_device *unused, struct obd_export *exp,
         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                 int err;
 
         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);
                         continue;
 
                 err = obd_quotacheck(lov->lov_tgts[i]->ltd_exp, oqctl);
index 3c761f4..4fd1551 100644 (file)
@@ -391,8 +391,13 @@ int lov_quota_ctl(struct obd_device *unused, struct obd_export *exp,
                 int err;
 
                 tgt = lov->lov_tgts[i];
                 int err;
 
                 tgt = lov->lov_tgts[i];
-                if (!tgt || !tgt->ltd_active || tgt->ltd_reap) {
-                        if (oqctl->qc_cmd == Q_GETOQUOTA) {
+
+                if (!tgt)
+                        continue;
+
+                if (!tgt->ltd_active || tgt->ltd_reap) {
+                        if (oqctl->qc_cmd == Q_GETOQUOTA &&
+                            lov->lov_tgts[i]->ltd_activate) {
                                 rc = -EREMOTEIO;
                                 CERROR("ost %d is inactive\n", i);
                         } else {
                                 rc = -EREMOTEIO;
                                 CERROR("ost %d is inactive\n", i);
                         } else {
index 14df94b..13a6bfd 100644 (file)
@@ -1034,6 +1034,9 @@ test_29() {
            echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
        done
 
            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
         # test new client starts deactivated
        umount_client $MOUNT || return 200
        mount_client $MOUNT
@@ -1045,6 +1048,9 @@ test_29() {
            echo "New client success: got $RESULT"
        fi
 
            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
 
        # make sure it reactivates
        set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6