Whamcloud - gitweb
LU-4069 build: cleanup from GOTO(label, -ERRNO)
[fs/lustre-release.git] / lustre / quota / qmt_pool.c
index c1f8b72..92f6d70 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>
  *                          a given ID.
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
-
 #define DEBUG_SUBSYSTEM S_LQUOTA
 
 #include <obd_class.h>
@@ -73,7 +69,7 @@ static inline void qpi_getref(struct qmt_pool_info *pool)
 }
 
 static inline void qpi_putref(const struct lu_env *env,
-                              struct qmt_pool_info *pool)
+                             struct qmt_pool_info *pool)
 {
        LASSERT(atomic_read(&pool->qpi_ref) > 0);
        if (cfs_atomic_dec_and_test(&pool->qpi_ref))
@@ -453,8 +449,10 @@ int qmt_pool_prepare(const struct lu_env *env, struct qmt_device *qmt,
                     struct dt_object *qmt_root)
 {
        struct qmt_thread_info  *qti = qmt_info(env);
+       struct lquota_glb_rec   *rec = &qti->qti_glb_rec;
        struct qmt_pool_info    *pool;
        struct dt_device        *dev = NULL;
+       dt_obj_version_t         version;
        cfs_list_t              *pos;
        int                      rc = 0, qtype;
        ENTRY;
@@ -505,6 +503,34 @@ int qmt_pool_prepare(const struct lu_env *env, struct qmt_device *qmt,
 
                        pool->qpi_glb_obj[qtype] = obj;
 
+                       version = dt_version_get(env, obj);
+                       /* set default grace time for newly created index */
+                       if (version == 0) {
+                               rec->qbr_hardlimit = 0;
+                               rec->qbr_softlimit = 0;
+                               rec->qbr_granted = 0;
+                               rec->qbr_time = pool_type == LQUOTA_RES_MD ?
+                                       MAX_IQ_TIME : MAX_DQ_TIME;
+
+                               rc = lquota_disk_write_glb(env, obj, 0, rec);
+                               if (rc) {
+                                       CERROR("%s: failed to set default "
+                                              "grace time for %s type (%d)\n",
+                                              qmt->qmt_svname,
+                                              QTYPE_NAME(qtype), rc);
+                                       RETURN(rc);
+                               }
+
+                               rc = lquota_disk_update_ver(env, dev, obj, 1);
+                               if (rc) {
+                                       CERROR("%s: failed to set initial "
+                                              "version for %s type (%d)\n",
+                                              qmt->qmt_svname,
+                                              QTYPE_NAME(qtype), rc);
+                                       RETURN(rc);
+                               }
+                       }
+
                        /* create quota entry site for this quota type */
                        pool->qpi_site[qtype] = lquota_site_alloc(env, pool,
                                                                  true, qtype,
@@ -654,7 +680,7 @@ struct lquota_entry *qmt_pool_lqe_lookup(const struct lu_env *env,
                 * entry since we keep a reference on ID 0 all the time */
                lqe = pool->qpi_grace_lqe[qtype];
                lqe_getref(lqe);
-               GOTO(out, 0);
+               GOTO(out, lqe);
        }
 
        /* now that we have the pool, let's look-up the quota entry in the