From: Johann Lombardi Date: Wed, 21 Nov 2012 09:56:46 +0000 (+0100) Subject: LU-2361 quota: allow upgraded fs to start w/o spc accounting X-Git-Tag: 2.3.59~45 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=6ecab5f514a1307c833967741003bca02dd533ff LU-2361 quota: allow upgraded fs to start w/o spc accounting All filesystems upgraded to 2.4 should run tunefs.lustre --quota to have functional space accounting. If not done, we still allow the filesystem to be started, but print an error on the console if the administrator tries to enable quota. Signed-off-by: Johann Lombardi Change-Id: I98ff2cf5e5c381353b219679b935bc0584b033cc Reviewed-on: http://review.whamcloud.com/4642 Tested-by: Hudson Reviewed-by: Niu Yawei Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/quota/lproc_quota.c b/lustre/quota/lproc_quota.c index 038abf6..62215f9 100644 --- a/lustre/quota/lproc_quota.c +++ b/lustre/quota/lproc_quota.c @@ -272,8 +272,13 @@ static int lprocfs_quota_seq_open(struct inode *inode, struct file *file) /* Initialize the common environment to be used in the seq operations */ rc = lu_env_init(&lqp->lqp_env, LCT_LOCAL); if (rc) { + char *obd_name = "quota"; + + if (lqp->lqp_obj != NULL) + obd_name = lqp->lqp_obj->do_lu.lo_dev->ld_obd->obd_name; + CERROR("%s: error initializing procfs quota env: rc = %d\n", - lqp->lqp_obj->do_lu.lo_dev->ld_obd->obd_name, rc); + obd_name, rc); goto out_lqp; } diff --git a/lustre/quota/qsd_config.c b/lustre/quota/qsd_config.c index 6738e4b..32b785f 100644 --- a/lustre/quota/qsd_config.c +++ b/lustre/quota/qsd_config.c @@ -191,6 +191,16 @@ int qsd_process_config(struct lustre_cfg *lcfg) read_unlock(&qsd->qsd_lock); if (skip) continue; + if (qsd->qsd_acct_failed) { + LCONSOLE_ERROR("%s: can't enable quota " + "enforcement since space " + "accounting isn't functional. " + "Please run tunefs.lustre " + "--quota on an unmounted " + "filesystem if not done already" + "\n", qsd->qsd_svname); + continue; + } for (type = USRQUOTA; type < MAXQUOTAS; type++) { qqi = qsd->qsd_type_array[type]; diff --git a/lustre/quota/qsd_internal.h b/lustre/quota/qsd_internal.h index 30f4c51..79908f2 100644 --- a/lustre/quota/qsd_internal.h +++ b/lustre/quota/qsd_internal.h @@ -112,7 +112,9 @@ struct qsd_instance { qsd_prepared:1, /* qsd_prepare() successfully * called */ qsd_exp_valid:1,/* qsd_exp is now valid */ - qsd_stopping:1; /* qsd_instance is stopping */ + qsd_stopping:1, /* qsd_instance is stopping */ + qsd_acct_failed:1; /* failed to set up acct + * for one quota type */ }; /* diff --git a/lustre/quota/qsd_lib.c b/lustre/quota/qsd_lib.c index ec9ffea..dc4fdae 100644 --- a/lustre/quota/qsd_lib.c +++ b/lustre/quota/qsd_lib.c @@ -104,16 +104,26 @@ static int lprocfs_qsd_rd_state(char *page, char **start, off_t off, qsd->qsd_is_md ? "md" : "dt", enabled, qsd->qsd_exp_valid ? "setup" : "not setup yet"); - if (qsd->qsd_prepared) + if (qsd->qsd_prepared) { + memset(enabled, 0, sizeof(enabled)); + if (qsd->qsd_type_array[USRQUOTA]->qqi_acct_obj != NULL) + strcat(enabled, "u"); + if (qsd->qsd_type_array[GRPQUOTA]->qqi_acct_obj != NULL) + strcat(enabled, "g"); + if (strlen(enabled) == 0) + strcat(enabled, "none"); rc += snprintf(page + rc, count - rc, + "space acct: %s\n" "user uptodate: glb[%d],slv[%d],reint[%d]\n" "group uptodate: glb[%d],slv[%d],reint[%d]\n", + enabled, qsd->qsd_type_array[USRQUOTA]->qqi_glb_uptodate, qsd->qsd_type_array[USRQUOTA]->qqi_slv_uptodate, qsd->qsd_type_array[USRQUOTA]->qqi_reint, qsd->qsd_type_array[GRPQUOTA]->qqi_glb_uptodate, qsd->qsd_type_array[GRPQUOTA]->qqi_slv_uptodate, qsd->qsd_type_array[GRPQUOTA]->qqi_reint); + } return rc; } @@ -357,12 +367,14 @@ static int qsd_qtype_init(const struct lu_env *env, struct qsd_instance *qsd, /* open accounting object */ LASSERT(qqi->qqi_acct_obj == NULL); qqi->qqi_acct_obj = acct_obj_lookup(env, qsd->qsd_dev, qtype); - if (qqi->qqi_acct_obj == NULL) { - LCONSOLE_ERROR("%s: No %s space accounting support. Please use " - "tunefs.lustre --quota option to enable quota " - "accounting.\n", - qsd->qsd_svname, QTYPE_NAME(qtype)); - GOTO(out, rc = -ENOENT); + if (IS_ERR(qqi->qqi_acct_obj)) { + LCONSOLE_WARN("%s: No %s space accounting support. Please " + "consider running tunefs.lustre --quota on an " + "unmounted filesystem to enable quota accounting." + "\n", qsd->qsd_svname, + QTYPE_NAME(qtype)); + qqi->qqi_acct_obj = NULL; + qsd->qsd_acct_failed = true; } /* open global index copy */ @@ -675,6 +687,15 @@ int qsd_prepare(const struct lu_env *env, struct qsd_instance *qsd) for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) { struct qsd_qtype_info *qqi = qsd->qsd_type_array[qtype]; + if (qsd_type_enabled(qsd, qtype) && qsd->qsd_acct_failed) { + LCONSOLE_ERROR("%s: can't enable quota enforcement " + "since space accounting isn't functional" + ". Please run tunefs.lustre --quota on " + "an unmounted filesystem if not done " + "already\n", qsd->qsd_svname); + break; + } + rc = qsd_start_reint_thread(qqi); if (rc) { CERROR("%s: failed to start reint thread for type %s " @@ -733,7 +754,7 @@ int qsd_start(const struct lu_env *env, struct qsd_instance *qsd) write_lock(&qsd->qsd_lock); if (!qsd->qsd_prepared) { - CERROR("%s: can't start qsd instance since it was properly " + CERROR("%s: can't start qsd instance since it wasn't properly " "initialized\n", qsd->qsd_svname); rc = -EFAULT; } else if (qsd->qsd_started) { diff --git a/lustre/quota/qsd_reint.c b/lustre/quota/qsd_reint.c index adac87f..eefc3c1 100644 --- a/lustre/quota/qsd_reint.c +++ b/lustre/quota/qsd_reint.c @@ -636,6 +636,10 @@ int qsd_start_reint_thread(struct qsd_qtype_info *qqi) if (!qsd_type_enabled(qqi->qqi_qsd, qqi->qqi_qtype)) RETURN(0); + if (qqi->qqi_qsd->qsd_acct_failed) + /* no space accounting support, can't enable enforcement */ + RETURN(0); + /* check if the reintegration has already started or finished */ write_lock(&qsd->qsd_lock); diff --git a/lustre/quota/qsd_writeback.c b/lustre/quota/qsd_writeback.c index 3d7bc2a..871a14e 100644 --- a/lustre/quota/qsd_writeback.c +++ b/lustre/quota/qsd_writeback.c @@ -373,6 +373,13 @@ static bool qsd_job_pending(struct qsd_instance *qsd, cfs_list_t *upd, job_pending = true; } + if (qsd->qsd_acct_failed) { + /* don't bother kicking off reintegration if space accounting + * failed to be enabled */ + write_unlock(&qsd->qsd_lock); + return job_pending; + } + for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) { struct qsd_qtype_info *qqi = qsd->qsd_type_array[qtype];