Whamcloud - gitweb
LU-2346 quota: set default grace time
[fs/lustre-release.git] / lustre / quota / qmt_pool.c
index c1f8b72..ad9e478 100644 (file)
@@ -453,8 +453,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 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;
        struct qmt_pool_info    *pool;
        struct dt_device        *dev = NULL;
+       dt_obj_version_t         version;
        cfs_list_t              *pos;
        int                      rc = 0, qtype;
        ENTRY;
        cfs_list_t              *pos;
        int                      rc = 0, qtype;
        ENTRY;
@@ -505,6 +507,34 @@ int qmt_pool_prepare(const struct lu_env *env, struct qmt_device *qmt,
 
                        pool->qpi_glb_obj[qtype] = obj;
 
 
                        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,
                        /* create quota entry site for this quota type */
                        pool->qpi_site[qtype] = lquota_site_alloc(env, pool,
                                                                  true, qtype,