summaryrefslogtreecommitdiff
path: root/drivers/block/virtio_blk.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2024-01-11 13:58:04 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2024-01-11 13:58:04 -0800
commit01d550f0fcc06c7292f79a6f1453aac122d1d2c8 (patch)
tree58b58ac1cb833af0469b1942774a382633bc6cda /drivers/block/virtio_blk.c
parentd05e626603d57936314816433db8bf1d34b5a504 (diff)
parent587371ed783b046f22ba7a5e1cc9a19ae35123b4 (diff)
Merge tag 'for-6.8/block-2024-01-08' of git://git.kernel.dk/linux
Pull block updates from Jens Axboe: "Pretty quiet round this time around. This contains: - NVMe updates via Keith: - nvme fabrics spec updates (Guixin, Max) - nvme target udpates (Guixin, Evan) - nvme attribute refactoring (Daniel) - nvme-fc numa fix (Keith) - MD updates via Song: - Fix/Cleanup RCU usage from conf->disks[i].rdev (Yu Kuai) - Fix raid5 hang issue (Junxiao Bi) - Add Yu Kuai as Reviewer of the md subsystem - Remove deprecated flavors (Song Liu) - raid1 read error check support (Li Nan) - Better handle events off-by-1 case (Alex Lyakas) - Efficiency improvements for passthrough (Kundan) - Support for mapping integrity data directly (Keith) - Zoned write fix (Damien) - rnbd fixes (Kees, Santosh, Supriti) - Default to a sane discard size granularity (Christoph) - Make the default max transfer size naming less confusing (Christoph) - Remove support for deprecated host aware zoned model (Christoph) - Misc fixes (me, Li, Matthew, Min, Ming, Randy, liyouhong, Daniel, Bart, Christoph)" * tag 'for-6.8/block-2024-01-08' of git://git.kernel.dk/linux: (78 commits) block: Treat sequential write preferred zone type as invalid block: remove disk_clear_zoned sd: remove the !ZBC && blk_queue_is_zoned case in sd_read_block_characteristics drivers/block/xen-blkback/common.h: Fix spelling typo in comment blk-cgroup: fix rcu lockdep warning in blkg_lookup() blk-cgroup: don't use removal safe list iterators block: floor the discard granularity to the physical block size mtd_blkdevs: use the default discard granularity bcache: use the default discard granularity zram: use the default discard granularity null_blk: use the default discard granularity nbd: use the default discard granularity ubd: use the default discard granularity block: default the discard granularity to sector size bcache: discard_granularity should not be smaller than a sector block: remove two comments in bio_split_discard block: rename and document BLK_DEF_MAX_SECTORS loop: don't abuse BLK_DEF_MAX_SECTORS aoe: don't abuse BLK_DEF_MAX_SECTORS null_blk: don't cap max_hw_sectors to BLK_DEF_MAX_SECTORS ...
Diffstat (limited to 'drivers/block/virtio_blk.c')
-rw-r--r--drivers/block/virtio_blk.c78
1 files changed, 23 insertions, 55 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 47556d8ccc32..3b6b9abb8ce1 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -722,52 +722,15 @@ fail_report:
return ret;
}
-static void virtblk_revalidate_zones(struct virtio_blk *vblk)
-{
- u8 model;
-
- virtio_cread(vblk->vdev, struct virtio_blk_config,
- zoned.model, &model);
- switch (model) {
- default:
- dev_err(&vblk->vdev->dev, "unknown zone model %d\n", model);
- fallthrough;
- case VIRTIO_BLK_Z_NONE:
- case VIRTIO_BLK_Z_HA:
- disk_set_zoned(vblk->disk, BLK_ZONED_NONE);
- return;
- case VIRTIO_BLK_Z_HM:
- WARN_ON_ONCE(!vblk->zone_sectors);
- if (!blk_revalidate_disk_zones(vblk->disk, NULL))
- set_capacity_and_notify(vblk->disk, 0);
- }
-}
-
static int virtblk_probe_zoned_device(struct virtio_device *vdev,
struct virtio_blk *vblk,
struct request_queue *q)
{
u32 v, wg;
- u8 model;
-
- virtio_cread(vdev, struct virtio_blk_config,
- zoned.model, &model);
-
- switch (model) {
- case VIRTIO_BLK_Z_NONE:
- case VIRTIO_BLK_Z_HA:
- /* Present the host-aware device as non-zoned */
- return 0;
- case VIRTIO_BLK_Z_HM:
- break;
- default:
- dev_err(&vdev->dev, "unsupported zone model %d\n", model);
- return -EINVAL;
- }
dev_dbg(&vdev->dev, "probing host-managed zoned device\n");
- disk_set_zoned(vblk->disk, BLK_ZONED_HM);
+ disk_set_zoned(vblk->disk);
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
virtio_cread(vdev, struct virtio_blk_config,
@@ -839,23 +802,12 @@ static int virtblk_probe_zoned_device(struct virtio_device *vdev,
*/
#define virtblk_report_zones NULL
-static inline void virtblk_revalidate_zones(struct virtio_blk *vblk)
-{
-}
-
static inline int virtblk_probe_zoned_device(struct virtio_device *vdev,
struct virtio_blk *vblk, struct request_queue *q)
{
- u8 model;
-
- virtio_cread(vdev, struct virtio_blk_config, zoned.model, &model);
- if (model == VIRTIO_BLK_Z_HM) {
- dev_err(&vdev->dev,
- "virtio_blk: zoned devices are not supported");
- return -EOPNOTSUPP;
- }
-
- return 0;
+ dev_err(&vdev->dev,
+ "virtio_blk: zoned devices are not supported");
+ return -EOPNOTSUPP;
}
#endif /* CONFIG_BLK_DEV_ZONED */
@@ -1005,7 +957,6 @@ static void virtblk_config_changed_work(struct work_struct *work)
struct virtio_blk *vblk =
container_of(work, struct virtio_blk, config_work);
- virtblk_revalidate_zones(vblk);
virtblk_update_capacity(vblk, true);
}
@@ -1570,9 +1521,26 @@ static int virtblk_probe(struct virtio_device *vdev)
* placed after the virtio_device_ready() call above.
*/
if (virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED)) {
- err = virtblk_probe_zoned_device(vdev, vblk, q);
- if (err)
+ u8 model;
+
+ virtio_cread(vdev, struct virtio_blk_config, zoned.model,
+ &model);
+ switch (model) {
+ case VIRTIO_BLK_Z_NONE:
+ case VIRTIO_BLK_Z_HA:
+ /* Present the host-aware device as non-zoned */
+ break;
+ case VIRTIO_BLK_Z_HM:
+ err = virtblk_probe_zoned_device(vdev, vblk, q);
+ if (err)
+ goto out_cleanup_disk;
+ break;
+ default:
+ dev_err(&vdev->dev, "unsupported zone model %d\n",
+ model);
+ err = -EINVAL;
goto out_cleanup_disk;
+ }
}
err = device_add_disk(&vdev->dev, vblk->disk, virtblk_attr_groups);