Whamcloud - gitweb
LU-15055 lod: run qmt_pool_* only from the MDT0000 config
[fs/lustre-release.git] / lustre / quota / qmt_pool.c
index 7bb1ee3..dcfb7c7 100644 (file)
@@ -79,12 +79,14 @@ static int qpi_state_seq_show(struct seq_file *m, void *data)
        int                      type;
 
        LASSERT(pool != NULL);
+       if (unlikely(!test_bit(QPI_FLAG_STATE_INITED, &pool->qpi_flags)))
+               return -ENOENT;
 
        seq_printf(m, "pool:\n"
                   "    id: %u\n"
                   "    type: %s\n"
-                  "    ref: %d\n"
-                  "    least qunit: %lu\n",
+                  "    refcount: %d\n"
+                  "    least_qunit: %lu\n",
                   0,
                   RES_NAME(pool->qpi_rtype),
                   atomic_read(&pool->qpi_ref),
@@ -92,8 +94,8 @@ static int qpi_state_seq_show(struct seq_file *m, void *data)
 
        for (type = 0; type < LL_MAXQUOTAS; type++)
                seq_printf(m, "    %s:\n"
-                          "        #slv: %d\n"
-                          "        #lqe: %d\n",
+                          "        quota_servers: %d\n"
+                          "        quota_entries: %d\n",
                           qtype_name(type),
                           qpi_slv_nr(pool, type),
                    atomic_read(&pool->qpi_site[type]->lqs_hash->hs_count));
@@ -106,6 +108,8 @@ static int qpi_soft_least_qunit_seq_show(struct seq_file *m, void *data)
 {
        struct qmt_pool_info    *pool = m->private;
        LASSERT(pool != NULL);
+       if (unlikely(!test_bit(QPI_FLAG_STATE_INITED, &pool->qpi_flags)))
+               return -ENOENT;
 
        seq_printf(m, "%lu\n", pool->qpi_soft_least_qunit);
        return 0;
@@ -121,6 +125,8 @@ qpi_soft_least_qunit_seq_write(struct file *file, const char __user *buffer,
        int rc;
 
        LASSERT(pool != NULL);
+       if (unlikely(!test_bit(QPI_FLAG_STATE_INITED, &pool->qpi_flags)))
+               return -ENOENT;
 
        /* Not tuneable for inode limit */
        if (pool->qpi_rtype != LQUOTA_RES_DT)
@@ -177,6 +183,7 @@ static int qmt_pool_alloc(const struct lu_env *env, struct qmt_device *qmt,
        init_rwsem(&pool->qpi_recalc_sem);
 
        pool->qpi_rtype = pool_type;
+       pool->qpi_flags = 0;
 
        /* initialize refcount to 1, hash table will then grab an additional
         * reference */
@@ -459,6 +466,8 @@ void qmt_pool_fini(const struct lu_env *env, struct qmt_device *qmt)
 
        /* parse list of pool and destroy each element */
        list_for_each_entry_safe(pool, tmp, &qmt->qmt_pool_list, qpi_linkage) {
+               /* stop all recalc threads - it may hold qpi reference */
+               qmt_stop_pool_recalc(pool);
                /* release extra reference taken in qmt_pool_alloc */
                qpi_putref(env, pool);
        }
@@ -670,6 +679,7 @@ int qmt_pool_prepare(const struct lu_env *env, struct qmt_device *qmt,
                                      qmt->qmt_svname, PFID(&qti->qti_fid), rc);
 #endif
                }
+               set_bit(QPI_FLAG_STATE_INITED, &pool->qpi_flags);
                if (name)
                        break;
        }
@@ -1171,6 +1181,7 @@ static int qmt_pool_recalc(void *args)
                while (obd->obd_process_conf)
                        schedule_timeout_uninterruptible(cfs_time_seconds(1));
 
+       OBD_FAIL_TIMEOUT(OBD_FAIL_QUOTA_RECALC, cfs_fail_val);
        sem = qmt_sarr_rwsem(pool);
        LASSERT(sem);
        down_read(sem);
@@ -1356,6 +1367,9 @@ static int qmt_pool_add_rem(struct obd_device *obd, char *poolname,
        int                      rc, idx;
        ENTRY;
 
+       if (qmt->qmt_stopping)
+               RETURN(0);
+
        if (strnlen(poolname, LOV_MAXPOOLNAME + 1) > LOV_MAXPOOLNAME)
                RETURN(-ENAMETOOLONG);
 
@@ -1383,9 +1397,10 @@ static int qmt_pool_add_rem(struct obd_device *obd, char *poolname,
        rc = add ? qmt_sarr_pool_add(qpi, idx, 32) :
                   qmt_sarr_pool_rem(qpi, idx);
        if (rc) {
-               CERROR("%s: can't %s %s pool %s: rc = %d\n",
-                      add ? "add to" : "remove", obd->obd_name,
-                      slavename, poolname, rc);
+               /* message is checked in sanity-quota test_1b */
+               CERROR("%s: can't %s %s pool '%s': rc = %d\n",
+                      obd->obd_name, add ? "add to" : "remove", slavename,
+                      poolname, rc);
                GOTO(out_putref, rc);
        }
        qmt_pool_slv_nr_change(&env, qpi, idx, add);