|
@@ -192,3 +192,81 @@ static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
|
|
{
|
|
{
|
|
return blkg ? blkg->pd[pol->plid] : NULL;
|
|
return blkg ? blkg->pd[pol->plid] : NULL;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * pdata_to_blkg - get blkg associated with policy private data
|
|
|
|
+ * @pd: policy private data of interest
|
|
|
|
+ *
|
|
|
|
+ * @pd is policy private data. Determine the blkg it's associated with.
|
|
|
|
+ */
|
|
|
|
+static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd)
|
|
|
|
+{
|
|
|
|
+ return pd ? pd->blkg : NULL;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * blkg_path - format cgroup path of blkg
|
|
|
|
+ * @blkg: blkg of interest
|
|
|
|
+ * @buf: target buffer
|
|
|
|
+ * @buflen: target buffer length
|
|
|
|
+ *
|
|
|
|
+ * Format the path of the cgroup of @blkg into @buf.
|
|
|
|
+ */
|
|
|
|
+static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen)
|
|
|
|
+{
|
|
|
|
+ int ret;
|
|
|
|
+
|
|
|
|
+ rcu_read_lock();
|
|
|
|
+ ret = cgroup_path(blkg->blkcg->css.cgroup, buf, buflen);
|
|
|
|
+ rcu_read_unlock();
|
|
|
|
+ if (ret)
|
|
|
|
+ strncpy(buf, "<unavailable>", buflen);
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * blkg_get - get a blkg reference
|
|
|
|
+ * @blkg: blkg to get
|
|
|
|
+ *
|
|
|
|
+ * The caller should be holding queue_lock and an existing reference.
|
|
|
|
+ */
|
|
|
|
+static inline void blkg_get(struct blkcg_gq *blkg)
|
|
|
|
+{
|
|
|
|
+ lockdep_assert_held(blkg->q->queue_lock);
|
|
|
|
+ WARN_ON_ONCE(!blkg->refcnt);
|
|
|
|
+ blkg->refcnt++;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void __blkg_release(struct blkcg_gq *blkg);
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * blkg_put - put a blkg reference
|
|
|
|
+ * @blkg: blkg to put
|
|
|
|
+ *
|
|
|
|
+ * The caller should be holding queue_lock.
|
|
|
|
+ */
|
|
|
|
+static inline void blkg_put(struct blkcg_gq *blkg)
|
|
|
|
+{
|
|
|
|
+ lockdep_assert_held(blkg->q->queue_lock);
|
|
|
|
+ WARN_ON_ONCE(blkg->refcnt <= 0);
|
|
|
|
+ if (!--blkg->refcnt)
|
|
|
|
+ __blkg_release(blkg);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * blk_get_rl - get request_list to use
|
|
|
|
+ * @q: request_queue of interest
|
|
|
|
+ * @bio: bio which will be attached to the allocated request (may be %NULL)
|
|
|
|
+ *
|
|
|
|
+ * The caller wants to allocate a request from @q to use for @bio. Find
|
|
|
|
+ * the request_list to use and obtain a reference on it. Should be called
|
|
|
|
+ * under queue_lock. This function is guaranteed to return non-%NULL
|
|
|
|
+ * request_list.
|
|
|
|
+ */
|
|
|
|
+static inline struct request_list *blk_get_rl(struct request_queue *q,
|
|
|
|
+ struct bio *bio)
|
|
|
|
+{
|
|
|
|
+ struct blkcg *blkcg;
|
|
|
|
+ struct blkcg_gq *blkg;
|
|
|
|
+
|
|
|
|
+ rcu_read_lock();
|