Whamcloud - gitweb
LU-12930 various: use schedule_timeout_*interruptible
[fs/lustre-release.git] / lustre / quota / qsd_config.c
index 06e566e..ed3415e 100644 (file)
 #define DEBUG_SUBSYSTEM S_LQUOTA
 
 #include <obd_class.h>
-#include <lustre_param.h>
+#include <uapi/linux/lustre/lustre_param.h>
 
 #include "qsd_internal.h"
 
-static struct list_head qfs_list = LIST_HEAD_INIT(qfs_list);
+static LIST_HEAD(qfs_list);
 /* protect the qfs_list */
 static DEFINE_SPINLOCK(qfs_list_lock);
 
@@ -119,35 +119,13 @@ out:
        RETURN(qfs);
 }
 
-/*
- * Quota configuration handlers in charge of processing all per-filesystem quota
- * parameters set via conf_param.
- *
- * \param lcfg - quota configuration log to be processed
- */
-int qsd_process_config(struct lustre_cfg *lcfg)
+int qsd_config(char *valstr, char *fsname, int pool)
 {
-       struct qsd_fsinfo       *qfs;
-       char                    *fsname = lustre_cfg_string(lcfg, 0);
-       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,
-              cfgstr);
-
-       if (class_match_param(cfgstr, PARAM_QUOTA, &keystr) != 0)
-               RETURN(-EINVAL);
-
-       if (!class_match_param(keystr, QUOTA_METAPOOL_NAME, &valstr))
-               pool = LQUOTA_RES_MD;
-       else if (!class_match_param(keystr, QUOTA_DATAPOOL_NAME, &valstr))
-               pool = LQUOTA_RES_DT;
-       else
-               RETURN(-EINVAL);
+       struct qsd_fsinfo *qfs;
+       int rc, enabled = 0, old_enabled = 0;
+       bool reint = false;
 
+       ENTRY;
        qfs = qsd_get_fsinfo(fsname, 0);
        if (qfs == NULL) {
                CERROR("failed to find quota filesystem information for %s\n",
@@ -159,6 +137,8 @@ int qsd_process_config(struct lustre_cfg *lcfg)
                enabled |= 1 << USRQUOTA;
        if (strchr(valstr, 'g'))
                enabled |= 1 << GRPQUOTA;
+       if (strchr(valstr, 'p'))
+               enabled |= 1 << PRJQUOTA;
 
        mutex_lock(&qfs->qfs_mutex);
        if (qfs->qfs_enabled[pool - LQUOTA_FIRST_RES] == enabled)
@@ -168,6 +148,7 @@ int qsd_process_config(struct lustre_cfg *lcfg)
        if ((qfs->qfs_enabled[pool - LQUOTA_FIRST_RES] & enabled) != enabled)
                reint = true;
 
+       old_enabled = qfs->qfs_enabled[pool - LQUOTA_FIRST_RES];
        qfs->qfs_enabled[pool - LQUOTA_FIRST_RES] = enabled;
 
        /* trigger reintegration for all qsd */
@@ -187,19 +168,25 @@ 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 < LL_MAXQUOTAS; type++) {
                                qqi = qsd->qsd_type_array[type];
+                               /* only trigger reintegration if this
+                                * type of quota is not enabled before */
+                               if ((old_enabled & 1 << type) ||
+                                   !(enabled & 1 << type))
+                                       continue;
+
+                               if (qqi->qqi_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;
+                               }
                                qsd_start_reint_thread(qqi);
                        }
                }
@@ -209,3 +196,33 @@ out:
        qsd_put_fsinfo(qfs);
        RETURN(0);
 }
+
+/*
+ * Quota configuration handlers in charge of processing all per-filesystem quota
+ * parameters set via conf_param.
+ *
+ * \param lcfg - quota configuration log to be processed
+ */
+int qsd_process_config(struct lustre_cfg *lcfg)
+{
+       char *fsname = lustre_cfg_string(lcfg, 0);
+       char *cfgstr = lustre_cfg_string(lcfg, 1);
+       char *keystr, *valstr;
+       int pool;
+
+       ENTRY;
+       CDEBUG(D_QUOTA, "processing quota parameter: fs:%s cfgstr:%s\n", fsname,
+              cfgstr);
+
+       if (class_match_param(cfgstr, PARAM_QUOTA, &keystr) != 0)
+               RETURN(-EINVAL);
+
+       if (!class_match_param(keystr, QUOTA_METAPOOL_NAME, &valstr))
+               pool = LQUOTA_RES_MD;
+       else if (!class_match_param(keystr, QUOTA_DATAPOOL_NAME, &valstr))
+               pool = LQUOTA_RES_DT;
+       else
+               RETURN(-EINVAL);
+
+       return qsd_config(valstr, fsname, pool);
+}