hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/10302 --------------------------------- Reject PCI P2PDMA on dm and md when any lower device has a block integrity profile. A mixed dm table may omit that profile on its top disk, so the P2PDMA client cannot detect the CPU integrity path there. This is the 6.6 queue-flag adaptation of the integrity withhold: dm_table_supports_pci_p2pdma() checks the underlying device integrity profile, and disk_stack_limits() clears QUEUE_FLAG_PCI_P2PDMA for integrity-bearing members so md personalities do not advertise P2P. Signed-off-by: Zizhi Wo <wozizhi@huawei.com> --- block/blk-settings.c | 4 +++- drivers/md/dm-table.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index 23e3b6b0c266..f684135c3145 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -12,10 +12,11 @@ #include <linux/gcd.h> #include <linux/lcm.h> #include <linux/jiffies.h> #include <linux/gfp.h> #include <linux/dma-mapping.h> +#include <linux/blk-integrity.h> #include "blk.h" #include "blk-rq-qos.h" #include "blk-wbt.h" @@ -799,11 +800,12 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev, if (blk_stack_limits(&t->limits, &bdev_get_queue(bdev)->limits, get_start_sect(bdev) + (offset >> 9)) < 0) pr_notice("%s: Warning: Device %pg is misaligned\n", disk->disk_name, bdev); - if (!blk_queue_pci_p2pdma(bdev_get_queue(bdev))) + if (!blk_queue_pci_p2pdma(bdev_get_queue(bdev)) || + bdev_get_integrity(bdev)) blk_queue_flag_clear(QUEUE_FLAG_PCI_P2PDMA, t); disk_update_readahead(disk); } EXPORT_SYMBOL(disk_stack_limits); diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 6dfe6ec08133..2197e6da2148 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1567,11 +1567,12 @@ static bool dm_table_supports_poll(struct dm_table *t) } static int device_not_pci_p2pdma_capable(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { - return !blk_queue_pci_p2pdma(bdev_get_queue(dev->bdev)); + return !blk_queue_pci_p2pdma(bdev_get_queue(dev->bdev)) || + bdev_get_integrity(dev->bdev); } static bool dm_table_supports_pci_p2pdma(struct dm_table *t) { for (unsigned int i = 0; i < t->num_targets; i++) { -- 2.52.0