Whamcloud - gitweb
LU-15283 quota: deadlock between reint & lquota_wb
[fs/lustre-release.git] / lustre / quota / qsd_internal.h
index fb6bccd..b590b84 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  * Use is subject to license terms.
  */
 
@@ -33,6 +33,8 @@
 struct qsd_type_info;
 struct qsd_fsinfo;
 
+extern struct kmem_cache *upd_kmem;
+
 /*
  * A QSD instance implements quota enforcement support for a given OSD.
  * The instance can be created via qsd_init() and then freed with qsd_fini().
@@ -45,15 +47,12 @@ struct qsd_instance {
        /* name of service which created this qsd instance */
        char                     qsd_svname[MAX_OBD_NAME];
 
-       /* pool ID is always 0 for now */
-       int                      qsd_pool_id;
-
        /* dt_device associated with this qsd instance */
        struct dt_device        *qsd_dev;
 
        /* procfs directory where information related to the underlying slaves
         * are exported */
-       cfs_proc_dir_entry_t    *qsd_proc;
+       struct proc_dir_entry   *qsd_proc;
 
        /* export used for the connection to quota master */
        struct obd_export       *qsd_exp;
@@ -70,7 +69,7 @@ struct qsd_instance {
         *
         * This will have to be revisited if new quota types are added in the
         * future. For the time being, we can just use an array. */
-       struct qsd_qtype_info   *qsd_type_array[MAXQUOTAS];
+       struct qsd_qtype_info   *qsd_type_array[LL_MAXQUOTAS];
 
        /* per-filesystem quota information */
        struct qsd_fsinfo       *qsd_fsinfo;
@@ -85,7 +84,7 @@ struct qsd_instance {
        spinlock_t               qsd_adjust_lock;
 
        /* dedicated thread for updating slave index files. */
-       struct ptlrpc_thread     qsd_upd_thread;
+       struct task_struct      *qsd_upd_task;
 
        /* list of update tasks */
        struct list_head         qsd_upd_list;
@@ -107,14 +106,15 @@ struct qsd_instance {
         * enforced here (via procfs) */
        int                      qsd_timeout;
 
-       unsigned long            qsd_is_md:1,    /* managing quota for mdt */
-                                qsd_started:1,  /* instance is now started */
-                                qsd_prepared:1, /* qsd_prepare() successfully
+       unsigned long           qsd_is_md:1,    /* managing quota for mdt */
+                               qsd_started:1,  /* instance is now started */
+                               qsd_prepared:1, /* qsd_prepare() successfully
                                                  * called */
-                                qsd_exp_valid:1,/* qsd_exp is now valid */
-                                qsd_stopping:1, /* qsd_instance is stopping */
-                                qsd_acct_failed:1; /* failed to set up acct
-                                                    * for one quota type */
+                               qsd_exp_valid:1,/* qsd_exp is now valid */
+                               qsd_stopping:1, /* qsd_instance is stopping */
+                               qsd_updating:1, /* qsd is updating record */
+                               qsd_exclusive:1; /* upd exclusive with reint */
+
 };
 
 /*
@@ -157,7 +157,7 @@ struct qsd_qtype_info {
        struct lquota_site      *qqi_site;
 
        /* Reintegration thread */
-       struct ptlrpc_thread     qqi_reint_thread;
+       struct task_struct      *qqi_reint_task;
 
        /* statistics on operations performed by this slave */
        struct lprocfs_stats    *qqi_stats;
@@ -169,14 +169,20 @@ struct qsd_qtype_info {
 
        /* Various flags representing the current state of the slave for this
         * quota type. */
-       unsigned long            qqi_glb_uptodate:1, /* global index uptodate
+       unsigned long           qqi_glb_uptodate:1, /* global index uptodate
                                                        with master */
-                                qqi_slv_uptodate:1, /* slave index uptodate
+                               qqi_slv_uptodate:1, /* slave index uptodate
                                                        with master */
-                                qqi_reint:1;    /* in reintegration or not */
+                               qqi_reint:1,    /* in reintegration or not */
+                               qqi_acct_failed:1; /* failed to setup acct */
 
        /* A list of references to this instance, for debugging */
-       struct lu_ref            qqi_reference;
+       struct lu_ref           qqi_reference;
+
+       /* default quota setting*/
+       __u64                   qqi_default_hardlimit;
+       __u64                   qqi_default_softlimit;
+       __u64                   qqi_default_gracetime;
 };
 
 /*
@@ -260,15 +266,7 @@ extern struct lu_context_key qsd_thread_key;
 static inline
 struct qsd_thread_info *qsd_info(const struct lu_env *env)
 {
-       struct qsd_thread_info *info;
-
-       info = lu_context_key_get(&env->le_ctx, &qsd_thread_key);
-       if (info == NULL) {
-               lu_env_refill((struct lu_env *)env);
-               info = lu_context_key_get(&env->le_ctx, &qsd_thread_key);
-       }
-       LASSERT(info);
-       return info;
+       return lu_env_info(env, &qsd_thread_key);
 }
 
 /* helper function to check whether a given quota type is enabled */
@@ -277,7 +275,7 @@ static inline int qsd_type_enabled(struct qsd_instance *qsd, int type)
        int     enabled, pool;
 
        LASSERT(qsd != NULL);
-       LASSERT(type < MAXQUOTAS);
+       LASSERT(type < LL_MAXQUOTAS);
 
        if (qsd->qsd_fsinfo == NULL)
                return 0;
@@ -285,7 +283,7 @@ static inline int qsd_type_enabled(struct qsd_instance *qsd, int type)
        pool = qsd->qsd_is_md ? LQUOTA_RES_MD : LQUOTA_RES_DT;
        enabled = qsd->qsd_fsinfo->qfs_enabled[pool - LQUOTA_FIRST_RES];
 
-       return enabled & (1 << type);
+       return enabled & BIT(type);
 }
 
 /* helper function to set new qunit and compute associated qtune value */
@@ -322,7 +320,7 @@ static inline void qsd_set_edquot(struct lquota_entry *lqe, bool edquot)
 {
        lqe->lqe_edquot = edquot;
        if (edquot)
-               lqe->lqe_edquot_time = cfs_time_current_64();
+               lqe->lqe_edquot_time = ktime_get_seconds();
 }
 
 #define QSD_WB_INTERVAL        60 /* 60 seconds */
@@ -337,7 +335,7 @@ static inline int qsd_wait_timeout(struct qsd_instance *qsd)
 }
 
 /* qsd_entry.c */
-extern struct lquota_entry_operations qsd_lqe_ops;
+extern const struct lquota_entry_operations qsd_lqe_ops;
 int qsd_refresh_usage(const struct lu_env *, struct lquota_entry *);
 int qsd_update_index(const struct lu_env *, struct qsd_qtype_info *,
                     union lquota_id *, bool, __u64, void *);
@@ -349,6 +347,8 @@ int qsd_write_version(const struct lu_env *, struct qsd_qtype_info *,
 /* qsd_lock.c */
 extern struct ldlm_enqueue_info qsd_glb_einfo;
 extern struct ldlm_enqueue_info qsd_id_einfo;
+void qsd_update_default_quota(struct qsd_qtype_info *qqi, __u64 hardlimit,
+                             __u64 softlimit, __u64 gracetime);
 int qsd_id_lock_match(struct lustre_handle *, struct lustre_handle *);
 int qsd_id_lock_cancel(const struct lu_env *, struct lquota_entry *);
 
@@ -379,6 +379,7 @@ void qsd_upd_schedule(struct qsd_qtype_info *, struct lquota_entry *,
 /* qsd_config.c */
 struct qsd_fsinfo *qsd_get_fsinfo(char *, bool);
 void qsd_put_fsinfo(struct qsd_fsinfo *);
+int qsd_config(char *valstr, char *fsname, int pool);
 int qsd_process_config(struct lustre_cfg *);
 
 /* qsd_handler.c */