Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34241af7 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'for-linus' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:

 - the virtio_blk stack DMA corruption fix from Christoph, fixing and
   issue with VMAP stacks.

 - O_DIRECT blkbits calculation fix from Chandan.

 - discard regression fix from Christoph.

 - queue init error handling fixes for nbd and virtio_blk, from Omar and
   Jeff.

 - two small nvme fixes, from Christoph and Guilherme.

 - rename of blk_queue_zone_size and bdev_zone_size to _sectors instead,
   to more closely follow what we do in other places in the block layer.
   This interface is new for this series, so let's get the naming right
   before releasing a kernel with this feature. From Damien.

* 'for-linus' of git://git.kernel.dk/linux-block:
  block: don't try to discard from __blkdev_issue_zeroout
  sd: remove __data_len hack for WRITE SAME
  nvme: use blk_rq_payload_bytes
  scsi: use blk_rq_payload_bytes
  block: add blk_rq_payload_bytes
  block: Rename blk_queue_zone_size and bdev_zone_size
  nvme: apply DELAY_BEFORE_CHK_RDY quirk at probe time too
  nvme-rdma: fix nvme_rdma_queue_is_ready
  virtio_blk: fix panic in initialization error path
  nbd: blk_mq_init_queue returns an error code on failure, not NULL
  virtio_blk: avoid DMA to stack for the sense buffer
  do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned
parents f0ad1771 bef13315
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -301,13 +301,6 @@ int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
	if ((sector | nr_sects) & bs_mask)
		return -EINVAL;

	if (discard) {
		ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask,
				BLKDEV_DISCARD_ZERO, biop);
		if (ret == 0 || (ret && ret != -EOPNOTSUPP))
			goto out;
	}

	ret = __blkdev_issue_write_zeroes(bdev, sector, nr_sects, gfp_mask,
			biop);
	if (ret == 0 || (ret && ret != -EOPNOTSUPP))
@@ -370,6 +363,12 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
	struct bio *bio = NULL;
	struct blk_plug plug;

	if (discard) {
		if (!blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask,
				BLKDEV_DISCARD_ZERO))
			return 0;
	}

	blk_start_plug(&plug);
	ret = __blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask,
			&bio, discard);
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
static inline sector_t blk_zone_start(struct request_queue *q,
				      sector_t sector)
{
	sector_t zone_mask = blk_queue_zone_size(q) - 1;
	sector_t zone_mask = blk_queue_zone_sectors(q) - 1;

	return sector & ~zone_mask;
}
@@ -222,7 +222,7 @@ int blkdev_reset_zones(struct block_device *bdev,
		return -EINVAL;

	/* Check alignment (handle eventual smaller last zone) */
	zone_sectors = blk_queue_zone_size(q);
	zone_sectors = blk_queue_zone_sectors(q);
	if (sector & (zone_sectors - 1))
		return -EINVAL;

+7 −7
Original line number Diff line number Diff line
@@ -434,7 +434,7 @@ static bool part_zone_aligned(struct gendisk *disk,
			      struct block_device *bdev,
			      sector_t from, sector_t size)
{
	unsigned int zone_size = bdev_zone_size(bdev);
	unsigned int zone_sectors = bdev_zone_sectors(bdev);

	/*
	 * If this function is called, then the disk is a zoned block device
@@ -446,7 +446,7 @@ static bool part_zone_aligned(struct gendisk *disk,
	 * regular block devices (no zone operation) and their zone size will
	 * be reported as 0. Allow this case.
	 */
	if (!zone_size)
	if (!zone_sectors)
		return true;

	/*
@@ -455,24 +455,24 @@ static bool part_zone_aligned(struct gendisk *disk,
	 * use it. Check the zone size too: it should be a power of 2 number
	 * of sectors.
	 */
	if (WARN_ON_ONCE(!is_power_of_2(zone_size))) {
	if (WARN_ON_ONCE(!is_power_of_2(zone_sectors))) {
		u32 rem;

		div_u64_rem(from, zone_size, &rem);
		div_u64_rem(from, zone_sectors, &rem);
		if (rem)
			return false;
		if ((from + size) < get_capacity(disk)) {
			div_u64_rem(size, zone_size, &rem);
			div_u64_rem(size, zone_sectors, &rem);
			if (rem)
				return false;
		}

	} else {

		if (from & (zone_size - 1))
		if (from & (zone_sectors - 1))
			return false;
		if ((from + size) < get_capacity(disk) &&
		    (size & (zone_size - 1)))
		    (size & (zone_sectors - 1)))
			return false;

	}
+4 −2
Original line number Diff line number Diff line
@@ -1042,6 +1042,7 @@ static int __init nbd_init(void)
		return -ENOMEM;

	for (i = 0; i < nbds_max; i++) {
		struct request_queue *q;
		struct gendisk *disk = alloc_disk(1 << part_shift);
		if (!disk)
			goto out;
@@ -1067,12 +1068,13 @@ static int __init nbd_init(void)
		 * every gendisk to have its very own request_queue struct.
		 * These structs are big so we dynamically allocate them.
		 */
		disk->queue = blk_mq_init_queue(&nbd_dev[i].tag_set);
		if (!disk->queue) {
		q = blk_mq_init_queue(&nbd_dev[i].tag_set);
		if (IS_ERR(q)) {
			blk_mq_free_tag_set(&nbd_dev[i].tag_set);
			put_disk(disk);
			goto out;
		}
		disk->queue = q;

		/*
		 * Tell the block layer that we are not a rotational device
+5 −2
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ struct virtblk_req {
	struct virtio_blk_outhdr out_hdr;
	struct virtio_scsi_inhdr in_hdr;
	u8 status;
	u8 sense[SCSI_SENSE_BUFFERSIZE];
	struct scatterlist sg[];
};

@@ -102,7 +103,8 @@ static int __virtblk_add_req(struct virtqueue *vq,
	}

	if (type == cpu_to_virtio32(vq->vdev, VIRTIO_BLK_T_SCSI_CMD)) {
		sg_init_one(&sense, vbr->req->sense, SCSI_SENSE_BUFFERSIZE);
		memcpy(vbr->sense, vbr->req->sense, SCSI_SENSE_BUFFERSIZE);
		sg_init_one(&sense, vbr->sense, SCSI_SENSE_BUFFERSIZE);
		sgs[num_out + num_in++] = &sense;
		sg_init_one(&inhdr, &vbr->in_hdr, sizeof(vbr->in_hdr));
		sgs[num_out + num_in++] = &inhdr;
@@ -628,11 +630,12 @@ static int virtblk_probe(struct virtio_device *vdev)
	if (err)
		goto out_put_disk;

	q = vblk->disk->queue = blk_mq_init_queue(&vblk->tag_set);
	q = blk_mq_init_queue(&vblk->tag_set);
	if (IS_ERR(q)) {
		err = -ENOMEM;
		goto out_free_tags;
	}
	vblk->disk->queue = q;

	q->queuedata = vblk;

Loading