sched: scheduler-driven cpu frequency selection
[firefly-linux-kernel-4.4.55.git] / include / linux / iocontext.h
index 1a30180630343dabd49aa886fc7621964912afdf..df38db2ef45bbf50def2b9de1970225c8a76c6de 100644 (file)
@@ -6,11 +6,7 @@
 #include <linux/workqueue.h>
 
 enum {
-       ICQ_IOPRIO_CHANGED      = 1 << 0,
-       ICQ_CGROUP_CHANGED      = 1 << 1,
        ICQ_EXITED              = 1 << 2,
-
-       ICQ_CHANGED_MASK        = ICQ_IOPRIO_CHANGED | ICQ_CGROUP_CHANGED,
 };
 
 /*
@@ -100,6 +96,7 @@ struct io_cq {
  */
 struct io_context {
        atomic_long_t refcount;
+       atomic_t active_ref;
        atomic_t nr_tasks;
 
        /* all the fields below are protected by this lock */
@@ -120,29 +117,37 @@ struct io_context {
        struct work_struct release_work;
 };
 
-static inline struct io_context *ioc_task_link(struct io_context *ioc)
+/**
+ * get_io_context_active - get active reference on ioc
+ * @ioc: ioc of interest
+ *
+ * Only iocs with active reference can issue new IOs.  This function
+ * acquires an active reference on @ioc.  The caller must already have an
+ * active reference on @ioc.
+ */
+static inline void get_io_context_active(struct io_context *ioc)
 {
-       /*
-        * if ref count is zero, don't allow sharing (ioc is going away, it's
-        * a race).
-        */
-       if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) {
-               atomic_inc(&ioc->nr_tasks);
-               return ioc;
-       }
+       WARN_ON_ONCE(atomic_long_read(&ioc->refcount) <= 0);
+       WARN_ON_ONCE(atomic_read(&ioc->active_ref) <= 0);
+       atomic_long_inc(&ioc->refcount);
+       atomic_inc(&ioc->active_ref);
+}
+
+static inline void ioc_task_link(struct io_context *ioc)
+{
+       get_io_context_active(ioc);
 
-       return NULL;
+       WARN_ON_ONCE(atomic_read(&ioc->nr_tasks) <= 0);
+       atomic_inc(&ioc->nr_tasks);
 }
 
 struct task_struct;
 #ifdef CONFIG_BLOCK
 void put_io_context(struct io_context *ioc);
+void put_io_context_active(struct io_context *ioc);
 void exit_io_context(struct task_struct *task);
 struct io_context *get_task_io_context(struct task_struct *task,
                                       gfp_t gfp_flags, int node);
-void ioc_ioprio_changed(struct io_context *ioc, int ioprio);
-void ioc_cgroup_changed(struct io_context *ioc);
-unsigned int icq_get_changed(struct io_cq *icq);
 #else
 struct io_context;
 static inline void put_io_context(struct io_context *ioc) { }