From: Niu Yawei Date: Fri, 1 Apr 2011 02:14:33 +0000 (-0700) Subject: LU-129 Skip quotacheck on administratively disabled OSTs X-Git-Tag: 2.0.60.0~25 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=9ab78a5bec154492c70f780706d9eaebeaaa5e54 LU-129 Skip quotacheck on administratively disabled OSTs - 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 Change-Id: I6af7dc09226d610bb1d481609a0a0ae09a05410e Reviewed-on: http://review.whamcloud.com/387 Tested-by: Hudson Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_import.h b/lustre/include/lustre_import.h index e956755..339a232 100644 --- a/lustre/include/lustre_import.h +++ b/lustre/include/lustre_import.h @@ -124,6 +124,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, }; /** diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 1a8d508..61d0874 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -904,7 +904,10 @@ enum obd_notify_event { /* 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 */ diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 5d3aca4..943e577 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -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, - 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); @@ -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, - int activate) + enum obd_notify_event ev) { struct lov_obd *lov = &obd->u.lov; struct lov_tgt_desc *tgt; - int index; + int index, 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 (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 (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 { - 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); @@ -442,7 +459,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) { 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. */ - rc = lov_set_osc_active(obd, uuid, ev == OBD_NOTIFY_ACTIVE); + rc = lov_set_osc_active(obd, uuid, 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(uuid), rc); RETURN(rc); } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index e3eae10..2848c10 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -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_DEACTIVATE: + case IMP_EVENT_ACTIVATE: + break; default: CERROR("Unknown import event %x\n", event); LBUG(); diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 8f4c568..a12a4e1 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -1059,6 +1059,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(); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 4cee4e8..9c483c6 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -4372,6 +4372,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(); diff --git a/lustre/ptlrpc/recover.c b/lustre/ptlrpc/recover.c index 17085d6..b7855d7 100644 --- a/lustre/ptlrpc/recover.c +++ b/lustre/ptlrpc/recover.c @@ -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); + obd_import_event(imp->imp_obd, imp, IMP_EVENT_DEACTIVATE); + 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); + obd_import_event(imp->imp_obd, imp, IMP_EVENT_ACTIVATE); rc = ptlrpc_recover_import_no_retry(imp, new_uuid); diff --git a/lustre/quota/quota_check.c b/lustre/quota/quota_check.c index 6732d06..413934a 100644 --- a/lustre/quota/quota_check.c +++ b/lustre/quota/quota_check.c @@ -304,6 +304,13 @@ int lov_quota_check(struct obd_device *unused, struct obd_export *exp, 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; @@ -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; - 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); diff --git a/lustre/quota/quota_ctl.c b/lustre/quota/quota_ctl.c index 3c761f4..4fd1551 100644 --- a/lustre/quota/quota_ctl.c +++ b/lustre/quota/quota_ctl.c @@ -391,8 +391,13 @@ int lov_quota_ctl(struct obd_device *unused, struct obd_export *exp, 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 { diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 14df94b..13a6bfd 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -1034,6 +1034,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 @@ -1045,6 +1048,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