If a block device has bio integrity enabled, rw_page will bypass the
integrity payload, which is undesirable. Skip rw_page if this is the
case.

Currently brd and zram provide rw_page, and the proposed 'nd' drivers
will too.

Signed-off-by: Vishal Verma <vishal.l.ve...@linux.intel.com>
Suggested-by: Matthew Wilcox <matthew.r.wil...@intel.com>
Cc: Jens Axboe <ax...@fb.com>
Cc: Martin K. Petersen <martin.peter...@oracle.com>
Acked-by: Dan Williams <dan.j.willi...@intel.com>
---

Applies to v4.1-rc2

 fs/block_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index c7e4163..054ef1b 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -376,7 +376,7 @@ int bdev_read_page(struct block_device *bdev, sector_t 
sector,
                        struct page *page)
 {
        const struct block_device_operations *ops = bdev->bd_disk->fops;
-       if (!ops->rw_page)
+       if (!ops->rw_page || bdev_get_integrity(bdev))
                return -EOPNOTSUPP;
        return ops->rw_page(bdev, sector + get_start_sect(bdev), page, READ);
 }
@@ -407,7 +407,7 @@ int bdev_write_page(struct block_device *bdev, sector_t 
sector,
        int result;
        int rw = (wbc->sync_mode == WB_SYNC_ALL) ? WRITE_SYNC : WRITE;
        const struct block_device_operations *ops = bdev->bd_disk->fops;
-       if (!ops->rw_page)
+       if (!ops->rw_page || bdev_get_integrity(bdev))
                return -EOPNOTSUPP;
        set_page_writeback(page);
        result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, rw);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to