hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/release-management/issues/IB4E8P CVE: NA
--------------------------------
A new config BLK_BIO_ALLOC_TASK is added to control the behaviour, and the task_struct will be used later for blk-io-hierarchy to dump thread info to user.
Signed-off-by: Yu Kuai yukuai3@huawei.com --- block/Kconfig | 3 +++ block/bio.c | 11 +++++++++++ include/linux/blk_types.h | 4 ++++ 3 files changed, 18 insertions(+)
diff --git a/block/Kconfig b/block/Kconfig index 371f4f9ab298..7018fdcaa459 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -39,6 +39,9 @@ config BLOCK_LEGACY_AUTOLOAD config BLK_BIO_ALLOC_TIME bool
+config BLK_BIO_ALLOC_TASK + bool + config BLK_RQ_ALLOC_TIME bool
diff --git a/block/bio.c b/block/bio.c index 060c91e50936..c5569f8b65af 100644 --- a/block/bio.c +++ b/block/bio.c @@ -223,6 +223,13 @@ void bio_uninit(struct bio *bio) bio_integrity_free(bio);
bio_crypt_free_ctx(bio); + +#ifdef CONFIG_BLK_BIO_ALLOC_TASK + if (bio->pid) { + put_pid(bio->pid); + bio->pid = NULL; + } +#endif } EXPORT_SYMBOL(bio_uninit);
@@ -286,6 +293,10 @@ void bio_init(struct bio *bio, struct block_device *bdev, struct bio_vec *table, #ifdef CONFIG_BLK_BIO_ALLOC_TIME bio->bi_alloc_time_ns = blk_time_get_ns(); #endif + +#ifdef CONFIG_BLK_BIO_ALLOC_TASK + bio->pid = get_pid(task_pid(current)); +#endif } EXPORT_SYMBOL(bio_init);
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 1d86790dd07c..95759212836a 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -302,7 +302,11 @@ struct bio { #else KABI_RESERVE(4) #endif +#ifdef CONFIG_BLK_BIO_ALLOC_TASK + KABI_USE(5, struct pid *pid) +#else KABI_RESERVE(5) +#endif KABI_RESERVE(6) KABI_RESERVE(7) KABI_RESERVE(8)