Whamcloud - gitweb
LU-2361 quota: allow upgraded fs to start w/o spc accounting
[fs/lustre-release.git] / lustre / quota / qsd_config.c
index 26c06bb..32b785f 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012 Intel, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  * Use is subject to license terms.
  *
  * Author: Johann Lombardi <johann.lombardi@intel.com>
@@ -53,7 +53,7 @@ void qsd_put_fsinfo(struct qsd_fsinfo *qfs)
        ENTRY;
        LASSERT(qfs != NULL);
 
-       cfs_spin_lock(&qfs_list_lock);
+       spin_lock(&qfs_list_lock);
        LASSERT(qfs->qfs_ref > 0);
        qfs->qfs_ref--;
        if (qfs->qfs_ref == 0) {
@@ -61,7 +61,7 @@ void qsd_put_fsinfo(struct qsd_fsinfo *qfs)
                cfs_list_del(&qfs->qfs_link);
                OBD_FREE_PTR(qfs);
        }
-       cfs_spin_unlock(&qfs_list_lock);
+       spin_unlock(&qfs_list_lock);
        EXIT;
 }
 
@@ -92,14 +92,14 @@ struct qsd_fsinfo *qsd_get_fsinfo(char *name, bool create)
                if (new == NULL)
                        RETURN(NULL);
 
-               cfs_sema_init(&new->qfs_sem, 1);
+               sema_init(&new->qfs_sem, 1);
                CFS_INIT_LIST_HEAD(&new->qfs_qsd_list);
                strcpy(new->qfs_name, name);
                new->qfs_ref = 1;
        }
 
        /* search in the fsinfo list */
-       cfs_spin_lock(&qfs_list_lock);
+       spin_lock(&qfs_list_lock);
        cfs_list_for_each_entry(qfs, &qfs_list, qfs_link) {
                if (!strcmp(qfs->qfs_name, name)) {
                        qfs->qfs_ref++;
@@ -116,7 +116,7 @@ struct qsd_fsinfo *qsd_get_fsinfo(char *name, bool create)
                new = NULL;
        }
 out:
-       cfs_spin_unlock(&qfs_list_lock);
+       spin_unlock(&qfs_list_lock);
 
        if (new)
                OBD_FREE_PTR(new);
@@ -136,6 +136,7 @@ int qsd_process_config(struct lustre_cfg *lcfg)
        char                    *cfgstr = lustre_cfg_string(lcfg, 1);
        char                    *keystr, *valstr;
        int                      rc, pool, enabled = 0;
+       bool                     reint = false;
        ENTRY;
 
        CDEBUG(D_QUOTA, "processing quota parameter: fs:%s cfgstr:%s\n", fsname,
@@ -153,7 +154,7 @@ int qsd_process_config(struct lustre_cfg *lcfg)
 
        qfs = qsd_get_fsinfo(fsname, 0);
        if (qfs == NULL) {
-               CERROR("Fail to find quota filesystem information for %s\n",
+               CERROR("failed to find quota filesystem information for %s\n",
                       fsname);
                RETURN(-ENOENT);
        }
@@ -163,12 +164,52 @@ int qsd_process_config(struct lustre_cfg *lcfg)
        if (strchr(valstr, 'g'))
                enabled |= 1 << GRPQUOTA;
 
+       down(&qfs->qfs_sem);
        if (qfs->qfs_enabled[pool - LQUOTA_FIRST_RES] == enabled)
                /* no change required */
                GOTO(out, rc = 0);
 
+       if ((qfs->qfs_enabled[pool - LQUOTA_FIRST_RES] & enabled) != enabled)
+               reint = true;
+
        qfs->qfs_enabled[pool - LQUOTA_FIRST_RES] = enabled;
+
+       /* trigger reintegration for all qsd */
+       if (reint) {
+               struct qsd_instance     *qsd;
+               struct qsd_qtype_info   *qqi;
+
+               cfs_list_for_each_entry(qsd, &qfs->qfs_qsd_list, qsd_link) {
+                       bool    skip = false;
+                       int     type;
+
+                       /* start reintegration only if qsd_prepare() was
+                        * successfully called */
+                       read_lock(&qsd->qsd_lock);
+                       if (!qsd->qsd_prepared)
+                               skip = true;
+                       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];
+                               qsd_start_reint_thread(qqi);
+                       }
+               }
+       }
 out:
+       up(&qfs->qfs_sem);
        qsd_put_fsinfo(qfs);
        RETURN(0);
 }