Whamcloud - gitweb
LU-9679 modules: Use LIST_HEAD for declaring list_heads
[fs/lustre-release.git] / lustre / quota / qsd_config.c
index 91e1386..ed3415e 100644 (file)
 #define DEBUG_SUBSYSTEM S_LQUOTA
 
 #include <obd_class.h>
-#include <uapi/linux/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",
@@ -170,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 */
@@ -192,6 +171,12 @@ int qsd_process_config(struct lustre_cfg *lcfg)
 
                        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 "
@@ -211,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);
+}