@@ -22,6 +22,8 @@
#include <linux/sort.h>
#include <linux/rbtree.h>
+#include "dm-thin.h"
+
#define DM_MSG_PREFIX "thin"
/*
@@ -2629,6 +2631,9 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio)
struct dm_bio_prison_cell *virt_cell, *data_cell;
struct dm_cell_key key;
+ if (keep_pool_bio_blkcg(tc->pool))
+ thin_keep_bio_blkcg(bio);
+
thin_hook_bio(tc, bio);
if (tc->requeue_mode) {
new file mode 100644
@@ -0,0 +1,17 @@
+#ifndef DM_THIN_H
+#define DM_THIN_H
+
+#include <linux/bio.h>
+
+#ifdef CONFIG_BLK_CGROUP
+static inline void thin_keep_bio_blkcg(struct bio *bio)
+{
+ if (!bio->bi_css)
+ bio_associate_current(bio);
+}
+#else
+static inline void thin_keep_bio_blkcg(struct bio *bio) {}
+#endif /* CONFIG_BLK_CGROUP */
+
+#endif
+
If keep_bio_blkcg is enabled, assign the io_context and the blkcg of current task to bio before processing the bio. Signed-off-by: Hou Tao <houtao1@huawei.com> --- drivers/md/dm-thin.c | 5 +++++ drivers/md/dm-thin.h | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 drivers/md/dm-thin.h