From patchwork Wed Feb 9 08:28:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 541322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7CDCC43219 for ; Wed, 9 Feb 2022 08:28:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241273AbiBII2m (ORCPT ); Wed, 9 Feb 2022 03:28:42 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:35990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238708AbiBII2j (ORCPT ); Wed, 9 Feb 2022 03:28:39 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D17BC05CBB4; Wed, 9 Feb 2022 00:28:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=OEk2XaHb/rIimZjLxXur2nVVRIHACoTITsr2juHinrU=; b=IWwc9YcE+T5I1KZX+iZQFBfo8s KqCPMQVK2jizPUXyJzEj5gFfV2vJjVKBTqkaYzxbZ0FmcN8NyTvegdeaeG0kQG5Cmw3jDEcu+iAAN Mtdb5PFwL/3TYzxq9Xncw6uNog4v729g/7S19ffEiK6ua785n8bH1lwlEOMw+UznkTm//CaQ3vuNl htQXLe8Vmsehp6tMVwAYl6EdfWOlpivdIiP3Un+S3aIHQdK5FAHEKGMWZJtxqtQ/7M6XrXeY3ebk9 U5DfMStSECKMOWMIwFNYgq23XBgRG0tXdj6m645JXOssrtce9mvxDHVB/pjjweJUDr18JDFzyMhzu hi8lCXpA==; Received: from [2001:4bb8:188:3efc:ea2:7599:7eeb:4b5a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHiL4-00Gc81-RG; Wed, 09 Feb 2022 08:28:35 +0000 From: Christoph Hellwig To: axboe@kernel.dk, martin.petersen@oracle.com, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, target-devel@vger.kernel.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, manoj@linux.ibm.com, mrochs@linux.ibm.com, ukrishn@linux.ibm.com Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com, dm-devel@redhat.com Subject: [PATCH 1/7] cxlflash: query write_zeroes limit for zeroing Date: Wed, 9 Feb 2022 09:28:22 +0100 Message-Id: <20220209082828.2629273-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209082828.2629273-1-hch@lst.de> References: <20220209082828.2629273-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The write_same and write_zeroes limits for SCSI are effectively the same, so the current code works just fine. But we plan to remove REQ_OP_WRITE_SAME support, so switch to quering the write zeroes limit for a zeroing WRITE SAME operation. Signed-off-by: Christoph Hellwig --- drivers/scsi/cxlflash/vlun.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c index 01917b28cdb65..5c74dc7c22889 100644 --- a/drivers/scsi/cxlflash/vlun.c +++ b/drivers/scsi/cxlflash/vlun.c @@ -430,8 +430,8 @@ static int write_same16(struct scsi_device *sdev, struct device *dev = &cfg->dev->dev; const u32 s = ilog2(sdev->sector_size) - 9; const u32 to = sdev->request_queue->rq_timeout; - const u32 ws_limit = blk_queue_get_max_sectors(sdev->request_queue, - REQ_OP_WRITE_SAME) >> s; + const u32 ws_limit = + sdev->request_queue->limits.max_write_zeroes_sectors >> s; cmd_buf = kzalloc(CMD_BUFSIZE, GFP_KERNEL); scsi_cmd = kzalloc(MAX_COMMAND_SIZE, GFP_KERNEL); From patchwork Wed Feb 9 08:28:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 542346 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A133DC4332F for ; Wed, 9 Feb 2022 08:28:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240131AbiBII2p (ORCPT ); Wed, 9 Feb 2022 03:28:45 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:35848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241188AbiBII2k (ORCPT ); Wed, 9 Feb 2022 03:28:40 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE4F4C05CBBC; Wed, 9 Feb 2022 00:28:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Ju2Dc9S6K8/TuiokaA0+SwaE6V+mK2jVNZLcDBk59jY=; b=EsIUAqcH84PDq9EsQd0tO+w/Zd sYmY+SVIk14WXWS/ApvmXDPcEfSbg22elTa8GaTJJRTXGsFsoGKgs3ZnWL56rp389HXPrdDoL2Cjs xRu+oVVIESNIqYtit+QlakxdGaPFn5mmZSfa9dNOy35xJcD/o8BFq8EyIx9sAXPNDsVjkzVHZNEjK ro/6LmGNEl5E5JE77Ieqvx2w4hgL2g6Lzqbgnu3oOdfSXODesedHRZu1UuFvMZW7c9ahmpod++0jy RLstU9mmcZlvIj0wzkHHpMvGDFFsuIex/FAgocLL6LzTyFwKG5AXJ9PXocBm1n7f33xy1FQeogU4/ fLByfwAQ==; Received: from [2001:4bb8:188:3efc:ea2:7599:7eeb:4b5a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHiL8-00GcAG-EB; Wed, 09 Feb 2022 08:28:39 +0000 From: Christoph Hellwig To: axboe@kernel.dk, martin.petersen@oracle.com, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, target-devel@vger.kernel.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, manoj@linux.ibm.com, mrochs@linux.ibm.com, ukrishn@linux.ibm.com Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com, dm-devel@redhat.com Subject: [PATCH 2/7] drbd: drop REQ_OP_WRITE_SAME support Date: Wed, 9 Feb 2022 09:28:23 +0100 Message-Id: <20220209082828.2629273-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209082828.2629273-1-hch@lst.de> References: <20220209082828.2629273-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org REQ_OP_WRITE_SAME was only ever submitted by the legacy Linux zeroing code, which has switched to use REQ_OP_WRITE_ZEROES long ago. Signed-off-by: Christoph Hellwig --- drivers/block/drbd/drbd_main.c | 31 ++----------- drivers/block/drbd/drbd_nl.c | 72 +----------------------------- drivers/block/drbd/drbd_receiver.c | 47 +++---------------- drivers/block/drbd/drbd_req.c | 1 - drivers/block/drbd/drbd_worker.c | 5 --- 5 files changed, 13 insertions(+), 143 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 6f450816c4fa6..96881d5babd9e 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -912,7 +912,7 @@ assign_p_sizes_qlim(struct drbd_device *device, struct p_sizes *p, p->qlim->io_min = cpu_to_be32(queue_io_min(q)); p->qlim->io_opt = cpu_to_be32(queue_io_opt(q)); p->qlim->discard_enabled = blk_queue_discard(q); - p->qlim->write_same_capable = !!q->limits.max_write_same_sectors; + p->qlim->write_same_capable = 0; } else { q = device->rq_queue; p->qlim->physical_block_size = cpu_to_be32(queue_physical_block_size(q)); @@ -1591,9 +1591,6 @@ static int _drbd_send_bio(struct drbd_peer_device *peer_device, struct bio *bio) ? 0 : MSG_MORE); if (err) return err; - /* REQ_OP_WRITE_SAME has only one segment */ - if (bio_op(bio) == REQ_OP_WRITE_SAME) - break; } return 0; } @@ -1612,9 +1609,6 @@ static int _drbd_send_zc_bio(struct drbd_peer_device *peer_device, struct bio *b bio_iter_last(bvec, iter) ? 0 : MSG_MORE); if (err) return err; - /* REQ_OP_WRITE_SAME has only one segment */ - if (bio_op(bio) == REQ_OP_WRITE_SAME) - break; } return 0; } @@ -1646,7 +1640,6 @@ static u32 bio_flags_to_wire(struct drbd_connection *connection, return (bio->bi_opf & REQ_SYNC ? DP_RW_SYNC : 0) | (bio->bi_opf & REQ_FUA ? DP_FUA : 0) | (bio->bi_opf & REQ_PREFLUSH ? DP_FLUSH : 0) | - (bio_op(bio) == REQ_OP_WRITE_SAME ? DP_WSAME : 0) | (bio_op(bio) == REQ_OP_DISCARD ? DP_DISCARD : 0) | (bio_op(bio) == REQ_OP_WRITE_ZEROES ? ((connection->agreed_features & DRBD_FF_WZEROES) ? @@ -1665,7 +1658,6 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request * struct drbd_device *device = peer_device->device; struct drbd_socket *sock; struct p_data *p; - struct p_wsame *wsame = NULL; void *digest_out; unsigned int dp_flags = 0; int digest_size; @@ -1703,29 +1695,14 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request * err = __send_command(peer_device->connection, device->vnr, sock, cmd, sizeof(*t), NULL, 0); goto out; } - if (dp_flags & DP_WSAME) { - /* this will only work if DRBD_FF_WSAME is set AND the - * handshake agreed that all nodes and backend devices are - * WRITE_SAME capable and agree on logical_block_size */ - wsame = (struct p_wsame*)p; - digest_out = wsame + 1; - wsame->size = cpu_to_be32(req->i.size); - } else - digest_out = p + 1; + digest_out = p + 1; /* our digest is still only over the payload. * TRIM does not carry any payload. */ if (digest_size) drbd_csum_bio(peer_device->connection->integrity_tfm, req->master_bio, digest_out); - if (wsame) { - err = - __send_command(peer_device->connection, device->vnr, sock, P_WSAME, - sizeof(*wsame) + digest_size, NULL, - bio_iovec(req->master_bio).bv_len); - } else - err = - __send_command(peer_device->connection, device->vnr, sock, P_DATA, - sizeof(*p) + digest_size, NULL, req->i.size); + err = __send_command(peer_device->connection, device->vnr, sock, P_DATA, + sizeof(*p) + digest_size, NULL, req->i.size); if (!err) { /* For protocol A, we have to memcpy the payload into * socket buffers, as we may complete right away diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 44ccf8b4f4b29..02030c9c4d3b1 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -1265,71 +1265,6 @@ static void fixup_write_zeroes(struct drbd_device *device, struct request_queue q->limits.max_write_zeroes_sectors = 0; } -static void decide_on_write_same_support(struct drbd_device *device, - struct request_queue *q, - struct request_queue *b, struct o_qlim *o, - bool disable_write_same) -{ - struct drbd_peer_device *peer_device = first_peer_device(device); - struct drbd_connection *connection = peer_device->connection; - bool can_do = b ? b->limits.max_write_same_sectors : true; - - if (can_do && disable_write_same) { - can_do = false; - drbd_info(peer_device, "WRITE_SAME disabled by config\n"); - } - - if (can_do && connection->cstate >= C_CONNECTED && !(connection->agreed_features & DRBD_FF_WSAME)) { - can_do = false; - drbd_info(peer_device, "peer does not support WRITE_SAME\n"); - } - - if (o) { - /* logical block size; queue_logical_block_size(NULL) is 512 */ - unsigned int peer_lbs = be32_to_cpu(o->logical_block_size); - unsigned int me_lbs_b = queue_logical_block_size(b); - unsigned int me_lbs = queue_logical_block_size(q); - - if (me_lbs_b != me_lbs) { - drbd_warn(device, - "logical block size of local backend does not match (drbd:%u, backend:%u); was this a late attach?\n", - me_lbs, me_lbs_b); - /* rather disable write same than trigger some BUG_ON later in the scsi layer. */ - can_do = false; - } - if (me_lbs_b != peer_lbs) { - drbd_warn(peer_device, "logical block sizes do not match (me:%u, peer:%u); this may cause problems.\n", - me_lbs, peer_lbs); - if (can_do) { - drbd_dbg(peer_device, "logical block size mismatch: WRITE_SAME disabled.\n"); - can_do = false; - } - me_lbs = max(me_lbs, me_lbs_b); - /* We cannot change the logical block size of an in-use queue. - * We can only hope that access happens to be properly aligned. - * If not, the peer will likely produce an IO error, and detach. */ - if (peer_lbs > me_lbs) { - if (device->state.role != R_PRIMARY) { - blk_queue_logical_block_size(q, peer_lbs); - drbd_warn(peer_device, "logical block size set to %u\n", peer_lbs); - } else { - drbd_warn(peer_device, - "current Primary must NOT adjust logical block size (%u -> %u); hope for the best.\n", - me_lbs, peer_lbs); - } - } - } - if (can_do && !o->write_same_capable) { - /* If we introduce an open-coded write-same loop on the receiving side, - * the peer would present itself as "capable". */ - drbd_dbg(peer_device, "WRITE_SAME disabled (peer device not capable)\n"); - can_do = false; - } - } - - blk_queue_max_write_same_sectors(q, can_do ? DRBD_MAX_BBIO_SECTORS : 0); -} - static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backing_dev *bdev, unsigned int max_bio_size, struct o_qlim *o) { @@ -1339,7 +1274,6 @@ static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backi struct request_queue *b = NULL; struct disk_conf *dc; bool discard_zeroes_if_aligned = true; - bool disable_write_same = false; if (bdev) { b = bdev->backing_bdev->bd_disk->queue; @@ -1349,7 +1283,6 @@ static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backi dc = rcu_dereference(device->ldev->disk_conf); max_segments = dc->max_bio_bvecs; discard_zeroes_if_aligned = dc->discard_zeroes_if_aligned; - disable_write_same = dc->disable_write_same; rcu_read_unlock(); blk_set_stacking_limits(&q->limits); @@ -1360,7 +1293,6 @@ static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backi blk_queue_max_segments(q, max_segments ? max_segments : BLK_MAX_SEGMENTS); blk_queue_segment_boundary(q, PAGE_SIZE-1); decide_on_discard_support(device, q, b, discard_zeroes_if_aligned); - decide_on_write_same_support(device, q, b, o, disable_write_same); if (b) { blk_stack_limits(&q->limits, &b->limits, 0); @@ -1666,8 +1598,8 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info) if (write_ordering_changed(old_disk_conf, new_disk_conf)) drbd_bump_write_ordering(device->resource, NULL, WO_BDEV_FLUSH); - if (old_disk_conf->discard_zeroes_if_aligned != new_disk_conf->discard_zeroes_if_aligned - || old_disk_conf->disable_write_same != new_disk_conf->disable_write_same) + if (old_disk_conf->discard_zeroes_if_aligned != + new_disk_conf->discard_zeroes_if_aligned) drbd_reconsider_queue_parameters(device, device->ldev, NULL); drbd_md_sync(device); diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 04e3ec12d8b49..46e2ec0bd2f98 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -1604,19 +1604,7 @@ static void drbd_issue_peer_discard_or_zero_out(struct drbd_device *device, stru drbd_endio_write_sec_final(peer_req); } -static void drbd_issue_peer_wsame(struct drbd_device *device, - struct drbd_peer_request *peer_req) -{ - struct block_device *bdev = device->ldev->backing_bdev; - sector_t s = peer_req->i.sector; - sector_t nr = peer_req->i.size >> 9; - if (blkdev_issue_write_same(bdev, s, nr, GFP_NOIO, peer_req->pages)) - peer_req->flags |= EE_WAS_ERROR; - drbd_endio_write_sec_final(peer_req); -} - - -/* +/** * drbd_submit_peer_request() * @device: DRBD device. * @peer_req: peer request @@ -1651,7 +1639,7 @@ int drbd_submit_peer_request(struct drbd_device *device, * Correctness first, performance later. Next step is to code an * asynchronous variant of the same. */ - if (peer_req->flags & (EE_TRIM|EE_WRITE_SAME|EE_ZEROOUT)) { + if (peer_req->flags & (EE_TRIM | EE_ZEROOUT)) { /* wait for all pending IO completions, before we start * zeroing things out. */ conn_wait_active_ee_empty(peer_req->peer_device->connection); @@ -1668,10 +1656,7 @@ int drbd_submit_peer_request(struct drbd_device *device, spin_unlock_irq(&device->resource->req_lock); } - if (peer_req->flags & (EE_TRIM|EE_ZEROOUT)) - drbd_issue_peer_discard_or_zero_out(device, peer_req); - else /* EE_WRITE_SAME */ - drbd_issue_peer_wsame(device, peer_req); + drbd_issue_peer_discard_or_zero_out(device, peer_req); return 0; } @@ -1854,7 +1839,6 @@ read_in_block(struct drbd_peer_device *peer_device, u64 id, sector_t sector, unsigned long *data; struct p_trim *trim = (pi->cmd == P_TRIM) ? pi->data : NULL; struct p_trim *zeroes = (pi->cmd == P_ZEROES) ? pi->data : NULL; - struct p_trim *wsame = (pi->cmd == P_WSAME) ? pi->data : NULL; digest_size = 0; if (!trim && peer_device->connection->peer_integrity_tfm) { @@ -1869,7 +1853,7 @@ read_in_block(struct drbd_peer_device *peer_device, u64 id, sector_t sector, data_size -= digest_size; } - /* assume request_size == data_size, but special case trim and wsame. */ + /* assume request_size == data_size, but special case trim. */ ds = data_size; if (trim) { if (!expect(data_size == 0)) @@ -1879,23 +1863,11 @@ read_in_block(struct drbd_peer_device *peer_device, u64 id, sector_t sector, if (!expect(data_size == 0)) return NULL; ds = be32_to_cpu(zeroes->size); - } else if (wsame) { - if (data_size != queue_logical_block_size(device->rq_queue)) { - drbd_err(peer_device, "data size (%u) != drbd logical block size (%u)\n", - data_size, queue_logical_block_size(device->rq_queue)); - return NULL; - } - if (data_size != bdev_logical_block_size(device->ldev->backing_bdev)) { - drbd_err(peer_device, "data size (%u) != backend logical block size (%u)\n", - data_size, bdev_logical_block_size(device->ldev->backing_bdev)); - return NULL; - } - ds = be32_to_cpu(wsame->size); } if (!expect(IS_ALIGNED(ds, 512))) return NULL; - if (trim || wsame || zeroes) { + if (trim || zeroes) { if (!expect(ds <= (DRBD_MAX_BBIO_SECTORS << 9))) return NULL; } else if (!expect(ds <= DRBD_MAX_BIO_SIZE)) @@ -1927,8 +1899,6 @@ read_in_block(struct drbd_peer_device *peer_device, u64 id, sector_t sector, peer_req->flags |= EE_ZEROOUT; return peer_req; } - if (wsame) - peer_req->flags |= EE_WRITE_SAME; /* receive payload size bytes into page chain */ ds = data_size; @@ -2427,8 +2397,6 @@ static unsigned long wire_flags_to_bio_op(u32 dpf) return REQ_OP_WRITE_ZEROES; if (dpf & DP_DISCARD) return REQ_OP_DISCARD; - if (dpf & DP_WSAME) - return REQ_OP_WRITE_SAME; else return REQ_OP_WRITE; } @@ -2695,11 +2663,11 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info * update_peer_seq(peer_device, peer_seq); spin_lock_irq(&device->resource->req_lock); } - /* TRIM and WRITE_SAME are processed synchronously, + /* TRIM and is processed synchronously, * we wait for all pending requests, respectively wait for * active_ee to become empty in drbd_submit_peer_request(); * better not add ourselves here. */ - if ((peer_req->flags & (EE_TRIM|EE_WRITE_SAME|EE_ZEROOUT)) == 0) + if ((peer_req->flags & (EE_TRIM | EE_ZEROOUT)) == 0) list_add_tail(&peer_req->w.list, &device->active_ee); spin_unlock_irq(&device->resource->req_lock); @@ -5068,7 +5036,6 @@ static struct data_cmd drbd_cmd_handler[] = { [P_TRIM] = { 0, sizeof(struct p_trim), receive_Data }, [P_ZEROES] = { 0, sizeof(struct p_trim), receive_Data }, [P_RS_DEALLOCATED] = { 0, sizeof(struct p_block_desc), receive_rs_deallocated }, - [P_WSAME] = { 1, sizeof(struct p_wsame), receive_Data }, }; static void drbdd(struct drbd_connection *connection) diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index c00ae8619519e..d46a3c450af26 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -36,7 +36,6 @@ static struct drbd_request *drbd_req_new(struct drbd_device *device, struct bio req->private_bio->bi_end_io = drbd_request_endio; req->rq_state = (bio_data_dir(bio_src) == WRITE ? RQ_WRITE : 0) - | (bio_op(bio_src) == REQ_OP_WRITE_SAME ? RQ_WSAME : 0) | (bio_op(bio_src) == REQ_OP_WRITE_ZEROES ? RQ_ZEROES : 0) | (bio_op(bio_src) == REQ_OP_DISCARD ? RQ_UNMAP : 0); req->device = device; diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index a5e04b38006b6..76af6c249df37 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c @@ -329,11 +329,6 @@ void drbd_csum_bio(struct crypto_shash *tfm, struct bio *bio, void *digest) src = kmap_atomic(bvec.bv_page); crypto_shash_update(desc, src + bvec.bv_offset, bvec.bv_len); kunmap_atomic(src); - - /* REQ_OP_WRITE_SAME has only one segment, - * checksum the payload only once. */ - if (bio_op(bio) == REQ_OP_WRITE_SAME) - break; } crypto_shash_final(desc, digest); shash_desc_zero(desc); From patchwork Wed Feb 9 08:28:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 541321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 680F5C43217 for ; Wed, 9 Feb 2022 08:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbiBII2r (ORCPT ); Wed, 9 Feb 2022 03:28:47 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:35996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241256AbiBII2m (ORCPT ); Wed, 9 Feb 2022 03:28:42 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1063C05CBB1; Wed, 9 Feb 2022 00:28:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=JdN4fbdK7WSMBnVaS60mQB7FbW/jFBWd0pawLUyHjGA=; b=wHNaFwY83lay7D9iwJ8InWcr9u bbmb/7SzRoqUC/miWmB5j8pVQ+s5ZP0M+0ccnP8h34i2LNuszCHuDenLHxCQKV3Ahdy8bMwFEMIu4 NFwTPcfq8Plez6YNfIROUwZX/EVyTahjZlfkxiWUVCIHtUar5yUTezFusFEwZsk61nqE31Qq0vqEi 18vQUqtXweuevpFdt9jOU2TLuY0TupHsCYsIDPgR6IgiJmERIk/McfJGwOdNmQsUZZ7tx1fbZNO6j 9pRc8TF8kfOQYXu+nXlr6+LS3dcBHtEbhVAbacmdcpIZAg++j1/aNJIjngRPQKlJCvXx5peQVqtNi k4RWA4DQ==; Received: from [2001:4bb8:188:3efc:ea2:7599:7eeb:4b5a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHiLC-00GcBy-3d; Wed, 09 Feb 2022 08:28:42 +0000 From: Christoph Hellwig To: axboe@kernel.dk, martin.petersen@oracle.com, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, target-devel@vger.kernel.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, manoj@linux.ibm.com, mrochs@linux.ibm.com, ukrishn@linux.ibm.com Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com, dm-devel@redhat.com Subject: [PATCH 3/7] rnbd: drop WRITE_SAME support Date: Wed, 9 Feb 2022 09:28:24 +0100 Message-Id: <20220209082828.2629273-4-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209082828.2629273-1-hch@lst.de> References: <20220209082828.2629273-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org REQ_OP_WRITE_SAME was only ever submitted by the legacy Linux zeroing code, which has switched to use REQ_OP_WRITE_ZEROES long before rnbd was even merged. Signed-off-by: Christoph Hellwig Acked-by: Jack Wang --- drivers/block/rnbd/rnbd-clt.c | 7 ++----- drivers/block/rnbd/rnbd-clt.h | 1 - drivers/block/rnbd/rnbd-proto.h | 6 ------ drivers/block/rnbd/rnbd-srv.c | 3 +-- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index c08971de369fc..dc192d2738854 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -82,7 +82,6 @@ static int rnbd_clt_set_dev_attr(struct rnbd_clt_dev *dev, dev->nsectors = le64_to_cpu(rsp->nsectors); dev->logical_block_size = le16_to_cpu(rsp->logical_block_size); dev->physical_block_size = le16_to_cpu(rsp->physical_block_size); - dev->max_write_same_sectors = le32_to_cpu(rsp->max_write_same_sectors); dev->max_discard_sectors = le32_to_cpu(rsp->max_discard_sectors); dev->discard_granularity = le32_to_cpu(rsp->discard_granularity); dev->discard_alignment = le32_to_cpu(rsp->discard_alignment); @@ -1359,8 +1358,6 @@ static void setup_request_queue(struct rnbd_clt_dev *dev) blk_queue_logical_block_size(dev->queue, dev->logical_block_size); blk_queue_physical_block_size(dev->queue, dev->physical_block_size); blk_queue_max_hw_sectors(dev->queue, dev->max_hw_sectors); - blk_queue_max_write_same_sectors(dev->queue, - dev->max_write_same_sectors); /* * we don't support discards to "discontiguous" segments @@ -1610,10 +1607,10 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, } rnbd_clt_info(dev, - "map_device: Device mapped as %s (nsectors: %zu, logical_block_size: %d, physical_block_size: %d, max_write_same_sectors: %d, max_discard_sectors: %d, discard_granularity: %d, discard_alignment: %d, secure_discard: %d, max_segments: %d, max_hw_sectors: %d, rotational: %d, wc: %d, fua: %d)\n", + "map_device: Device mapped as %s (nsectors: %zu, logical_block_size: %d, physical_block_size: %d, max_discard_sectors: %d, discard_granularity: %d, discard_alignment: %d, secure_discard: %d, max_segments: %d, max_hw_sectors: %d, rotational: %d, wc: %d, fua: %d)\n", dev->gd->disk_name, dev->nsectors, dev->logical_block_size, dev->physical_block_size, - dev->max_write_same_sectors, dev->max_discard_sectors, + dev->max_discard_sectors, dev->discard_granularity, dev->discard_alignment, dev->secure_discard, dev->max_segments, dev->max_hw_sectors, dev->rotational, dev->wc, dev->fua); diff --git a/drivers/block/rnbd/rnbd-clt.h b/drivers/block/rnbd/rnbd-clt.h index 0c2cae7f39b9f..6946ba23d62e5 100644 --- a/drivers/block/rnbd/rnbd-clt.h +++ b/drivers/block/rnbd/rnbd-clt.h @@ -122,7 +122,6 @@ struct rnbd_clt_dev { bool wc; bool fua; u32 max_hw_sectors; - u32 max_write_same_sectors; u32 max_discard_sectors; u32 discard_granularity; u32 discard_alignment; diff --git a/drivers/block/rnbd/rnbd-proto.h b/drivers/block/rnbd/rnbd-proto.h index de5d5a8df81d7..3eb8b34bd1886 100644 --- a/drivers/block/rnbd/rnbd-proto.h +++ b/drivers/block/rnbd/rnbd-proto.h @@ -249,9 +249,6 @@ static inline u32 rnbd_to_bio_flags(u32 rnbd_opf) case RNBD_OP_SECURE_ERASE: bio_opf = REQ_OP_SECURE_ERASE; break; - case RNBD_OP_WRITE_SAME: - bio_opf = REQ_OP_WRITE_SAME; - break; default: WARN(1, "Unknown RNBD type: %d (flags %d)\n", rnbd_op(rnbd_opf), rnbd_opf); @@ -284,9 +281,6 @@ static inline u32 rq_to_rnbd_flags(struct request *rq) case REQ_OP_SECURE_ERASE: rnbd_opf = RNBD_OP_SECURE_ERASE; break; - case REQ_OP_WRITE_SAME: - rnbd_opf = RNBD_OP_WRITE_SAME; - break; case REQ_OP_FLUSH: rnbd_opf = RNBD_OP_FLUSH; break; diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index 132e950685d59..0e6b5687f8321 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -548,8 +548,7 @@ static void rnbd_srv_fill_msg_open_rsp(struct rnbd_msg_open_rsp *rsp, cpu_to_le16(rnbd_dev_get_max_segs(rnbd_dev)); rsp->max_hw_sectors = cpu_to_le32(rnbd_dev_get_max_hw_sects(rnbd_dev)); - rsp->max_write_same_sectors = - cpu_to_le32(bdev_write_same(rnbd_dev->bdev)); + rsp->max_write_same_sectors = 0; rsp->max_discard_sectors = cpu_to_le32(rnbd_dev_get_max_discard_sects(rnbd_dev)); rsp->discard_granularity = From patchwork Wed Feb 9 08:28:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 541320 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 289EAC433F5 for ; Wed, 9 Feb 2022 08:28:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240701AbiBII2s (ORCPT ); Wed, 9 Feb 2022 03:28:48 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:35848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239879AbiBII2o (ORCPT ); Wed, 9 Feb 2022 03:28:44 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A90CDC05CBB5; Wed, 9 Feb 2022 00:28:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=F8SInqXwzFKmIu39NPS8oaxqXQcDTVHzhDoykq8GHb8=; b=VqQn4/uwroAsWAR8XmNv17jmt7 hSQsVZ7I+PRtC79Vx4pPeogi/ZF3mbm35WDwYf0D/cQT57YWRTbVRvhoIlr5uoFC6qY57OnTBbIkz i5taRtdyXl8PLQ6mi+AEypuInA3w85l8/RWjpYEurW6mVf1lhRdiO/CR/7YrPnWe2Glg3wEGVfhmw vQ/6VcfQ6R+vXJL1JvnTK8RB7mlmFQocWZwuUsV8vWUbG8apJ7ufy/hZoz9/FlIw7dE2TWHeGTTpD VY63du2VKGhWH6hynT/Gf1xPtQGOwTFXY7KzTincprGKoi7Qj5wXTORUrgtUMKXsBxuad0jgMEPRZ 8rb4MLWQ==; Received: from [2001:4bb8:188:3efc:ea2:7599:7eeb:4b5a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHiLF-00GcDH-Cg; Wed, 09 Feb 2022 08:28:46 +0000 From: Christoph Hellwig To: axboe@kernel.dk, martin.petersen@oracle.com, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, target-devel@vger.kernel.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, manoj@linux.ibm.com, mrochs@linux.ibm.com, ukrishn@linux.ibm.com Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com, dm-devel@redhat.com Subject: [PATCH 4/7] sd: remove write same support Date: Wed, 9 Feb 2022 09:28:25 +0100 Message-Id: <20220209082828.2629273-5-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209082828.2629273-1-hch@lst.de> References: <20220209082828.2629273-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There are no more end-users of REQ_OP_WRITE_SAME left, so we can start deleting it. Signed-off-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni --- drivers/scsi/sd.c | 75 ++++--------------------------------------- drivers/scsi/sd_zbc.c | 2 -- 2 files changed, 7 insertions(+), 70 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 2d648d27bfd71..fde2857f9bbf5 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1034,13 +1034,13 @@ static void sd_config_write_same(struct scsi_disk *sdkp) * Reporting a maximum number of blocks that is not aligned * on the device physical size would cause a large write same * request to be split into physically unaligned chunks by - * __blkdev_issue_write_zeroes() and __blkdev_issue_write_same() - * even if the caller of these functions took care to align the - * large request. So make sure the maximum reported is aligned - * to the device physical block size. This is only an optional - * optimization for regular disks, but this is mandatory to - * avoid failure of large write same requests directed at - * sequential write required zones of host-managed ZBC disks. + * __blkdev_issue_write_zeroes() even if the caller of this + * functions took care to align the large request. So make sure + * the maximum reported is aligned to the device physical block + * size. This is only an optional optimization for regular + * disks, but this is mandatory to avoid failure of large write + * same requests directed at sequential write required zones of + * host-managed ZBC disks. */ sdkp->max_ws_blocks = round_down(sdkp->max_ws_blocks, @@ -1049,68 +1049,10 @@ static void sd_config_write_same(struct scsi_disk *sdkp) } out: - blk_queue_max_write_same_sectors(q, sdkp->max_ws_blocks * - (logical_block_size >> 9)); blk_queue_max_write_zeroes_sectors(q, sdkp->max_ws_blocks * (logical_block_size >> 9)); } -/** - * sd_setup_write_same_cmnd - write the same data to multiple blocks - * @cmd: command to prepare - * - * Will set up either WRITE SAME(10) or WRITE SAME(16) depending on - * the preference indicated by the target device. - **/ -static blk_status_t sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) -{ - struct request *rq = scsi_cmd_to_rq(cmd); - struct scsi_device *sdp = cmd->device; - struct scsi_disk *sdkp = scsi_disk(rq->q->disk); - struct bio *bio = rq->bio; - u64 lba = sectors_to_logical(sdp, blk_rq_pos(rq)); - u32 nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq)); - blk_status_t ret; - - if (sdkp->device->no_write_same) - return BLK_STS_TARGET; - - BUG_ON(bio_offset(bio) || bio_iovec(bio).bv_len != sdp->sector_size); - - rq->timeout = SD_WRITE_SAME_TIMEOUT; - - if (sdkp->ws16 || lba > 0xffffffff || nr_blocks > 0xffff) { - cmd->cmd_len = 16; - cmd->cmnd[0] = WRITE_SAME_16; - put_unaligned_be64(lba, &cmd->cmnd[2]); - put_unaligned_be32(nr_blocks, &cmd->cmnd[10]); - } else { - cmd->cmd_len = 10; - cmd->cmnd[0] = WRITE_SAME; - put_unaligned_be32(lba, &cmd->cmnd[2]); - put_unaligned_be16(nr_blocks, &cmd->cmnd[7]); - } - - cmd->transfersize = sdp->sector_size; - cmd->allowed = sdkp->max_retries; - - /* - * For WRITE SAME the data transferred via the DATA OUT buffer is - * different from the amount of data actually written to the target. - * - * We set up __data_len to the amount of data transferred via the - * DATA OUT buffer so that blk_rq_map_sg sets up the proper S/G list - * to transfer a single sector of data first, but then reset it to - * the amount of data to be written right after so that the I/O path - * knows how much to actually write. - */ - rq->__data_len = sdp->sector_size; - ret = scsi_alloc_sgtables(cmd); - rq->__data_len = blk_rq_bytes(rq); - - return ret; -} - static blk_status_t sd_setup_flush_cmnd(struct scsi_cmnd *cmd) { struct request *rq = scsi_cmd_to_rq(cmd); @@ -1343,8 +1285,6 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd) } case REQ_OP_WRITE_ZEROES: return sd_setup_write_zeroes_cmnd(cmd); - case REQ_OP_WRITE_SAME: - return sd_setup_write_same_cmnd(cmd); case REQ_OP_FLUSH: return sd_setup_flush_cmnd(cmd); case REQ_OP_READ: @@ -2039,7 +1979,6 @@ static int sd_done(struct scsi_cmnd *SCpnt) switch (req_op(req)) { case REQ_OP_DISCARD: case REQ_OP_WRITE_ZEROES: - case REQ_OP_WRITE_SAME: case REQ_OP_ZONE_RESET: case REQ_OP_ZONE_RESET_ALL: case REQ_OP_ZONE_OPEN: diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 378d071e47cbc..7f466280993bb 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -423,7 +423,6 @@ static bool sd_zbc_need_zone_wp_update(struct request *rq) return true; case REQ_OP_WRITE: case REQ_OP_WRITE_ZEROES: - case REQ_OP_WRITE_SAME: return blk_rq_zone_is_seq(rq); default: return false; @@ -477,7 +476,6 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd, rq->__sector += sdkp->zones_wp_offset[zno]; fallthrough; case REQ_OP_WRITE_ZEROES: - case REQ_OP_WRITE_SAME: case REQ_OP_WRITE: if (sdkp->zones_wp_offset[zno] < sd_zbc_zone_sectors(sdkp)) sdkp->zones_wp_offset[zno] += From patchwork Wed Feb 9 08:28:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 542345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C919C433F5 for ; Wed, 9 Feb 2022 08:28:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239879AbiBII2v (ORCPT ); Wed, 9 Feb 2022 03:28:51 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:36208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240043AbiBII2s (ORCPT ); Wed, 9 Feb 2022 03:28:48 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C7DFC05CBA9; Wed, 9 Feb 2022 00:28:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=/bt+Oy/BcFTxmfplM5PxJCE5IpUeX2/8fHWE4Zg7BxI=; b=3q5Kzgsf8lajnI+rgsdp8Bdhhy R3u48noc4rOlPQv3T17Kthhn822+iL9Ug3fUyvErnt6I3e1tRAHq6Ej2M+Olpso38aKV7kmCPzm4m 0QiDdTXPpqoJIxNUy3hv0nuJtCGrTvhwjb49BiFQxWv2nYHY8RSv38UFWxULReIujLXU9GxwZ2u/R OQ9ZEaCgZKZZuNsn5BR6kmR5/e5n5DOna3lxiuX6AnC7uuicm2GL2iu1PKH1BkqGWzIBTDeygrAug cRzzQDOC5YaCNqomXeqCSV2aJQ3s5IFqNyirPJ4/1RckSdJlbyL+oXoTu9R15787kLs9MQgcInPNO 4NH1UPEw==; Received: from [2001:4bb8:188:3efc:ea2:7599:7eeb:4b5a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHiLJ-00GcFP-5b; Wed, 09 Feb 2022 08:28:50 +0000 From: Christoph Hellwig To: axboe@kernel.dk, martin.petersen@oracle.com, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, target-devel@vger.kernel.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, manoj@linux.ibm.com, mrochs@linux.ibm.com, ukrishn@linux.ibm.com Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com, dm-devel@redhat.com Subject: [PATCH 5/7] md: drop WRITE_SAME support Date: Wed, 9 Feb 2022 09:28:26 +0100 Message-Id: <20220209082828.2629273-6-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209082828.2629273-1-hch@lst.de> References: <20220209082828.2629273-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There are no more end-users of REQ_OP_WRITE_SAME left, so we can start deleting it. Signed-off-by: Christoph Hellwig --- drivers/md/md-linear.c | 1 - drivers/md/md-multipath.c | 1 - drivers/md/md.h | 7 ------- drivers/md/raid0.c | 2 -- drivers/md/raid1.c | 4 +--- drivers/md/raid10.c | 1 - drivers/md/raid5.c | 1 - 7 files changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c index 1ff51647a6822..0f55b079371b1 100644 --- a/drivers/md/md-linear.c +++ b/drivers/md/md-linear.c @@ -259,7 +259,6 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio) if (mddev->gendisk) trace_block_bio_remap(bio, disk_devt(mddev->gendisk), bio_sector); - mddev_check_writesame(mddev, bio); mddev_check_write_zeroes(mddev, bio); submit_bio_noacct(bio); } diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c index 97fb948e3e741..68dec76694d53 100644 --- a/drivers/md/md-multipath.c +++ b/drivers/md/md-multipath.c @@ -127,7 +127,6 @@ static bool multipath_make_request(struct mddev *mddev, struct bio * bio) mp_bh->bio.bi_opf |= REQ_FAILFAST_TRANSPORT; mp_bh->bio.bi_end_io = multipath_end_request; mp_bh->bio.bi_private = mp_bh; - mddev_check_writesame(mddev, &mp_bh->bio); mddev_check_write_zeroes(mddev, &mp_bh->bio); submit_bio_noacct(&mp_bh->bio); return true; diff --git a/drivers/md/md.h b/drivers/md/md.h index f1bf3625ef4c9..6ac2838645336 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -797,13 +797,6 @@ static inline void mddev_clear_unsupported_flags(struct mddev *mddev, mddev->flags &= ~unsupported_flags; } -static inline void mddev_check_writesame(struct mddev *mddev, struct bio *bio) -{ - if (bio_op(bio) == REQ_OP_WRITE_SAME && - !bio->bi_bdev->bd_disk->queue->limits.max_write_same_sectors) - mddev->queue->limits.max_write_same_sectors = 0; -} - static inline void mddev_check_write_zeroes(struct mddev *mddev, struct bio *bio) { if (bio_op(bio) == REQ_OP_WRITE_ZEROES && diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index b59a77b31b90d..b21e101183f44 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -402,7 +402,6 @@ static int raid0_run(struct mddev *mddev) bool discard_supported = false; blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors); - blk_queue_max_write_same_sectors(mddev->queue, mddev->chunk_sectors); blk_queue_max_write_zeroes_sectors(mddev->queue, mddev->chunk_sectors); blk_queue_max_discard_sectors(mddev->queue, UINT_MAX); @@ -594,7 +593,6 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio) if (mddev->gendisk) trace_block_bio_remap(bio, disk_devt(mddev->gendisk), bio_sector); - mddev_check_writesame(mddev, bio); mddev_check_write_zeroes(mddev, bio); submit_bio_noacct(bio); return true; diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index c3288d46948de..9cec48d335065 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -3147,10 +3147,8 @@ static int raid1_run(struct mddev *mddev) if (IS_ERR(conf)) return PTR_ERR(conf); - if (mddev->queue) { - blk_queue_max_write_same_sectors(mddev->queue, 0); + if (mddev->queue) blk_queue_max_write_zeroes_sectors(mddev->queue, 0); - } rdev_for_each(rdev, mddev) { if (!mddev->gendisk) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 5dd2e17e1d0ea..764ca020b7a40 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -4113,7 +4113,6 @@ static int raid10_run(struct mddev *mddev) if (mddev->queue) { blk_queue_max_discard_sectors(mddev->queue, UINT_MAX); - blk_queue_max_write_same_sectors(mddev->queue, 0); blk_queue_max_write_zeroes_sectors(mddev->queue, 0); blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9); raid10_set_io_opt(conf); diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 8891aaba65964..f5f36fdd37336 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -7767,7 +7767,6 @@ static int raid5_run(struct mddev *mddev) mddev->queue->limits.discard_alignment = stripe; mddev->queue->limits.discard_granularity = stripe; - blk_queue_max_write_same_sectors(mddev->queue, 0); blk_queue_max_write_zeroes_sectors(mddev->queue, 0); rdev_for_each(rdev, mddev) { From patchwork Wed Feb 9 08:28:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 541319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9041C4332F for ; Wed, 9 Feb 2022 08:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241284AbiBII3L (ORCPT ); Wed, 9 Feb 2022 03:29:11 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:36696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241282AbiBII3H (ORCPT ); Wed, 9 Feb 2022 03:29:07 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4CFC050CC8; Wed, 9 Feb 2022 00:28:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6Ljp2leOTsGQNUOBYnhQv9xIriNANEoITJRZY6SLnvw=; b=WkX27R9AZnJd8kSamOqXD0BVgG TOdzq1J/bOVZSgohrayvR6KpRnhRGbhwTV3XZIkUWge/K3Dxww33V4EW6vI98Yu9cGCAYKpZbdQTl TdjU7vAmQ2+t5agHujxpeZLQpGCRJapMuOAhBNsy5mzJvAwQp5FUrtZnRQiqImNFbFT1sglmoUj67 xbspRUwoU2tHQRdA9NMOIs4WFUZSeoGiJGzz09ny3IVMnlk0DCZw9fqbuY5CBrKReQtEhFFUm3iYD +dDMyidOW8GBaO+uRt3cdOZWHce5cJSEkQA6zMg+Q9sgTScpZbcRUp4+w+d4Tnci5w74t+7SUsNYF hvklhc8g==; Received: from [2001:4bb8:188:3efc:ea2:7599:7eeb:4b5a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHiLM-00GcIQ-VN; Wed, 09 Feb 2022 08:28:54 +0000 From: Christoph Hellwig To: axboe@kernel.dk, martin.petersen@oracle.com, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, target-devel@vger.kernel.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, manoj@linux.ibm.com, mrochs@linux.ibm.com, ukrishn@linux.ibm.com Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com, dm-devel@redhat.com Subject: [PATCH 6/7] dm: remove write same support Date: Wed, 9 Feb 2022 09:28:27 +0100 Message-Id: <20220209082828.2629273-7-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209082828.2629273-1-hch@lst.de> References: <20220209082828.2629273-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There are no more end-users of REQ_OP_WRITE_SAME left, so we can start deleting it. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Snitzer --- drivers/md/dm-core.h | 1 - drivers/md/dm-crypt.c | 1 - drivers/md/dm-ebs-target.c | 1 - drivers/md/dm-io.c | 22 ++-------------------- drivers/md/dm-linear.c | 1 - drivers/md/dm-mpath.c | 1 - drivers/md/dm-rq.c | 3 --- drivers/md/dm-stripe.c | 4 +--- drivers/md/dm-table.c | 29 ----------------------------- drivers/md/dm-zone.c | 4 ---- drivers/md/dm.c | 15 --------------- include/linux/device-mapper.h | 6 ------ 12 files changed, 3 insertions(+), 85 deletions(-) diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index 72d18c3fbf1f6..18b26882d25ac 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -140,7 +140,6 @@ struct mapped_device { #define DMF_EMULATE_ZONE_APPEND 9 void disable_discard(struct mapped_device *md); -void disable_write_same(struct mapped_device *md); void disable_write_zeroes(struct mapped_device *md); static inline sector_t dm_get_size(struct mapped_device *md) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index a5006cb6ee8ad..e0e846a35947f 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1996,7 +1996,6 @@ static bool kcryptd_crypt_write_inline(struct crypt_config *cc, */ switch (bio_op(ctx->bio_in)) { case REQ_OP_WRITE: - case REQ_OP_WRITE_SAME: case REQ_OP_WRITE_ZEROES: return true; default: diff --git a/drivers/md/dm-ebs-target.c b/drivers/md/dm-ebs-target.c index 7ce5d509b9403..0221fa63f888f 100644 --- a/drivers/md/dm-ebs-target.c +++ b/drivers/md/dm-ebs-target.c @@ -335,7 +335,6 @@ static int ebs_ctr(struct dm_target *ti, unsigned int argc, char **argv) ti->num_flush_bios = 1; ti->num_discard_bios = 1; ti->num_secure_erase_bios = 0; - ti->num_write_same_bios = 0; ti->num_write_zeroes_bios = 0; return 0; bad: diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index 23e038f8dc845..0969aa39655a4 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c @@ -304,7 +304,6 @@ static void do_region(int op, int op_flags, unsigned region, unsigned num_bvecs; sector_t remaining = where->count; struct request_queue *q = bdev_get_queue(where->bdev); - unsigned short logical_block_size = queue_logical_block_size(q); sector_t num_sectors; unsigned int special_cmd_max_sectors; @@ -315,10 +314,8 @@ static void do_region(int op, int op_flags, unsigned region, special_cmd_max_sectors = q->limits.max_discard_sectors; else if (op == REQ_OP_WRITE_ZEROES) special_cmd_max_sectors = q->limits.max_write_zeroes_sectors; - else if (op == REQ_OP_WRITE_SAME) - special_cmd_max_sectors = q->limits.max_write_same_sectors; - if ((op == REQ_OP_DISCARD || op == REQ_OP_WRITE_ZEROES || - op == REQ_OP_WRITE_SAME) && special_cmd_max_sectors == 0) { + if ((op == REQ_OP_DISCARD || op == REQ_OP_WRITE_ZEROES) && + special_cmd_max_sectors == 0) { atomic_inc(&io->count); dec_count(io, region, BLK_STS_NOTSUPP); return; @@ -337,9 +334,6 @@ static void do_region(int op, int op_flags, unsigned region, case REQ_OP_WRITE_ZEROES: num_bvecs = 0; break; - case REQ_OP_WRITE_SAME: - num_bvecs = 1; - break; default: num_bvecs = bio_max_segs(dm_sector_div_up(remaining, (PAGE_SIZE >> SECTOR_SHIFT))); @@ -355,18 +349,6 @@ static void do_region(int op, int op_flags, unsigned region, num_sectors = min_t(sector_t, special_cmd_max_sectors, remaining); bio->bi_iter.bi_size = num_sectors << SECTOR_SHIFT; remaining -= num_sectors; - } else if (op == REQ_OP_WRITE_SAME) { - /* - * WRITE SAME only uses a single page. - */ - dp->get_page(dp, &page, &len, &offset); - bio_add_page(bio, page, logical_block_size, offset); - num_sectors = min_t(sector_t, special_cmd_max_sectors, remaining); - bio->bi_iter.bi_size = num_sectors << SECTOR_SHIFT; - - offset = 0; - remaining -= num_sectors; - dp->next_page(dp); } else while (remaining) { /* * Try and add as many pages as possible. diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 1b97a11d71517..76b486e4d2be1 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -60,7 +60,6 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) ti->num_flush_bios = 1; ti->num_discard_bios = 1; ti->num_secure_erase_bios = 1; - ti->num_write_same_bios = 1; ti->num_write_zeroes_bios = 1; ti->private = lc; return 0; diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index f4719b65e5e33..9ab971834a535 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -1252,7 +1252,6 @@ static int multipath_ctr(struct dm_target *ti, unsigned argc, char **argv) ti->num_flush_bios = 1; ti->num_discard_bios = 1; - ti->num_write_same_bios = 1; ti->num_write_zeroes_bios = 1; if (m->queue_mode == DM_TYPE_BIO_BASED) ti->per_io_data_size = multipath_per_bio_data_size(); diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c index 579ab6183d4d8..3907950a0ddcc 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -217,9 +217,6 @@ static void dm_done(struct request *clone, blk_status_t error, bool mapped) if (req_op(clone) == REQ_OP_DISCARD && !clone->q->limits.max_discard_sectors) disable_discard(tio->md); - else if (req_op(clone) == REQ_OP_WRITE_SAME && - !clone->q->limits.max_write_same_sectors) - disable_write_same(tio->md); else if (req_op(clone) == REQ_OP_WRITE_ZEROES && !clone->q->limits.max_write_zeroes_sectors) disable_write_zeroes(tio->md); diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index e566115ec0bb8..c81d331d1afe9 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -157,7 +157,6 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) ti->num_flush_bios = stripes; ti->num_discard_bios = stripes; ti->num_secure_erase_bios = stripes; - ti->num_write_same_bios = stripes; ti->num_write_zeroes_bios = stripes; sc->chunk_size = chunk_size; @@ -284,8 +283,7 @@ static int stripe_map(struct dm_target *ti, struct bio *bio) } if (unlikely(bio_op(bio) == REQ_OP_DISCARD) || unlikely(bio_op(bio) == REQ_OP_SECURE_ERASE) || - unlikely(bio_op(bio) == REQ_OP_WRITE_ZEROES) || - unlikely(bio_op(bio) == REQ_OP_WRITE_SAME)) { + unlikely(bio_op(bio) == REQ_OP_WRITE_ZEROES)) { target_bio_nr = dm_bio_get_target_bio_nr(bio); BUG_ON(target_bio_nr >= sc->stripes); return stripe_map_range(sc, bio, target_bio_nr); diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index e43096cfe9e22..88ab986379342 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1822,33 +1822,6 @@ static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev, return !blk_queue_add_random(q); } -static int device_not_write_same_capable(struct dm_target *ti, struct dm_dev *dev, - sector_t start, sector_t len, void *data) -{ - struct request_queue *q = bdev_get_queue(dev->bdev); - - return !q->limits.max_write_same_sectors; -} - -static bool dm_table_supports_write_same(struct dm_table *t) -{ - struct dm_target *ti; - unsigned i; - - for (i = 0; i < dm_table_get_num_targets(t); i++) { - ti = dm_table_get_target(t, i); - - if (!ti->num_write_same_bios) - return false; - - if (!ti->type->iterate_devices || - ti->type->iterate_devices(ti, device_not_write_same_capable, NULL)) - return false; - } - - return true; -} - static int device_not_write_zeroes_capable(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { @@ -2027,8 +2000,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, else blk_queue_flag_set(QUEUE_FLAG_NONROT, q); - if (!dm_table_supports_write_same(t)) - q->limits.max_write_same_sectors = 0; if (!dm_table_supports_write_zeroes(t)) q->limits.max_write_zeroes_sectors = 0; diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c index 6d82a34438c85..c1ca9be4b79e9 100644 --- a/drivers/md/dm-zone.c +++ b/drivers/md/dm-zone.c @@ -130,7 +130,6 @@ bool dm_is_zone_write(struct mapped_device *md, struct bio *bio) switch (bio_op(bio)) { case REQ_OP_WRITE_ZEROES: - case REQ_OP_WRITE_SAME: case REQ_OP_WRITE: return !op_is_flush(bio->bi_opf) && bio_sectors(bio); default: @@ -390,7 +389,6 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md, case REQ_OP_ZONE_FINISH: return true; case REQ_OP_WRITE_ZEROES: - case REQ_OP_WRITE_SAME: case REQ_OP_WRITE: /* Writes must be aligned to the zone write pointer */ if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset) @@ -446,7 +444,6 @@ static blk_status_t dm_zone_map_bio_end(struct mapped_device *md, blk_queue_zone_sectors(md->queue)); return BLK_STS_OK; case REQ_OP_WRITE_ZEROES: - case REQ_OP_WRITE_SAME: case REQ_OP_WRITE: WRITE_ONCE(md->zwp_offset[zno], zwp_offset + nr_sectors); return BLK_STS_OK; @@ -503,7 +500,6 @@ static bool dm_need_zone_wp_tracking(struct bio *orig_bio) return false; switch (bio_op(orig_bio)) { case REQ_OP_WRITE_ZEROES: - case REQ_OP_WRITE_SAME: case REQ_OP_WRITE: case REQ_OP_ZONE_RESET: case REQ_OP_ZONE_FINISH: diff --git a/drivers/md/dm.c b/drivers/md/dm.c index ab9cc91931f99..028771f77aa04 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -856,14 +856,6 @@ void disable_discard(struct mapped_device *md) blk_queue_flag_clear(QUEUE_FLAG_DISCARD, md->queue); } -void disable_write_same(struct mapped_device *md) -{ - struct queue_limits *limits = dm_get_queue_limits(md); - - /* device doesn't really support WRITE SAME, disable it */ - limits->max_write_same_sectors = 0; -} - void disable_write_zeroes(struct mapped_device *md) { struct queue_limits *limits = dm_get_queue_limits(md); @@ -890,9 +882,6 @@ static void clone_endio(struct bio *bio) if (bio_op(bio) == REQ_OP_DISCARD && !q->limits.max_discard_sectors) disable_discard(md); - else if (bio_op(bio) == REQ_OP_WRITE_SAME && - !q->limits.max_write_same_sectors) - disable_write_same(md); else if (bio_op(bio) == REQ_OP_WRITE_ZEROES && !q->limits.max_write_zeroes_sectors) disable_write_zeroes(md); @@ -1320,7 +1309,6 @@ static bool is_abnormal_io(struct bio *bio) switch (bio_op(bio)) { case REQ_OP_DISCARD: case REQ_OP_SECURE_ERASE: - case REQ_OP_WRITE_SAME: case REQ_OP_WRITE_ZEROES: r = true; break; @@ -1342,9 +1330,6 @@ static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti, case REQ_OP_SECURE_ERASE: num_bios = ti->num_secure_erase_bios; break; - case REQ_OP_WRITE_SAME: - num_bios = ti->num_write_same_bios; - break; case REQ_OP_WRITE_ZEROES: num_bios = ti->num_write_zeroes_bios; break; diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index b26fecf6c8e87..721db99f4f630 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -316,12 +316,6 @@ struct dm_target { */ unsigned num_secure_erase_bios; - /* - * The number of WRITE SAME bios that will be submitted to the target. - * The bio number can be accessed with dm_bio_get_target_bio_nr. - */ - unsigned num_write_same_bios; - /* * The number of WRITE ZEROES bios that will be submitted to the target. * The bio number can be accessed with dm_bio_get_target_bio_nr. From patchwork Wed Feb 9 08:28:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 542344 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AE49C433F5 for ; Wed, 9 Feb 2022 08:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241321AbiBII3a (ORCPT ); Wed, 9 Feb 2022 03:29:30 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:36728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240745AbiBII3J (ORCPT ); Wed, 9 Feb 2022 03:29:09 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E259CC050CD9; Wed, 9 Feb 2022 00:28:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=QpI6TxzyLD0VhpyON4GNpHisrhmph+FXrDO9j3YfLGQ=; b=UBklqOmYcspUOr/wfzlQdfCEK4 RUywmec4eJRfgow0ROh7C/shmPfjoV9AX6UxEKLQF6DHIoCIFWohTtj/aBZX1myAAiemMpfT3ptVT GOGILeVbvLfX+nAbnf6ZYNuMSsmcot+08dxbCablm+LWn5SUEooHHqipq3oCMGN3sJhY1+UvoZ0Os e7QJW2SJhNwDTSkWrN9H3FtA6k07L/KlV12vDJG/WMAJUhXCAJdZlfOdV84mn9o8tIk9Uo1L8HFpm udbzALPhDlycmvOzBSLRyRvy/ODVEMj+WDMy9Vb6Ul4BwKeC3V04rmtsIHOl2NRCAuOspFKRw9AY2 rwVglAvQ==; Received: from [2001:4bb8:188:3efc:ea2:7599:7eeb:4b5a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHiLQ-00GcLQ-OJ; Wed, 09 Feb 2022 08:28:57 +0000 From: Christoph Hellwig To: axboe@kernel.dk, martin.petersen@oracle.com, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, target-devel@vger.kernel.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, manoj@linux.ibm.com, mrochs@linux.ibm.com, ukrishn@linux.ibm.com Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com, dm-devel@redhat.com Subject: [PATCH 7/7] block: remove REQ_OP_WRITE_SAME support Date: Wed, 9 Feb 2022 09:28:28 +0100 Message-Id: <20220209082828.2629273-8-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209082828.2629273-1-hch@lst.de> References: <20220209082828.2629273-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org No more users of REQ_OP_WRITE_SAME or drivers implementing it are left, so remove the infrastructure. Signed-off-by: Christoph Hellwig --- block/blk-core.c | 13 +----- block/blk-lib.c | 91 --------------------------------------- block/blk-merge.c | 40 ----------------- block/blk-settings.c | 16 ------- block/blk-sysfs.c | 8 ---- block/blk-zoned.c | 1 - block/blk.h | 1 - block/bounce.c | 3 -- include/linux/bio.h | 3 -- include/linux/blk_types.h | 2 - include/linux/blkdev.h | 19 -------- kernel/trace/blktrace.c | 1 - 12 files changed, 1 insertion(+), 197 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index be8812f5489d4..dabc771538db8 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -122,7 +122,6 @@ static const char *const blk_op_name[] = { REQ_OP_NAME(ZONE_CLOSE), REQ_OP_NAME(ZONE_FINISH), REQ_OP_NAME(ZONE_APPEND), - REQ_OP_NAME(WRITE_SAME), REQ_OP_NAME(WRITE_ZEROES), REQ_OP_NAME(DRV_IN), REQ_OP_NAME(DRV_OUT), @@ -735,10 +734,6 @@ noinline_for_stack bool submit_bio_checks(struct bio *bio) if (!blk_queue_secure_erase(q)) goto not_supported; break; - case REQ_OP_WRITE_SAME: - if (!q->limits.max_write_same_sectors) - goto not_supported; - break; case REQ_OP_ZONE_APPEND: status = blk_check_zone_append(q, bio); if (status != BLK_STS_OK) @@ -934,13 +929,7 @@ void submit_bio(struct bio *bio) * go through the normal accounting stuff before submission. */ if (bio_has_data(bio)) { - unsigned int count; - - if (unlikely(bio_op(bio) == REQ_OP_WRITE_SAME)) - count = queue_logical_block_size( - bdev_get_queue(bio->bi_bdev)) >> 9; - else - count = bio_sectors(bio); + unsigned int count = bio_sectors(bio); if (op_is_write(bio_op(bio))) { count_vm_events(PGPGOUT, count); diff --git a/block/blk-lib.c b/block/blk-lib.c index 1b8ced45e4e55..05d3dbfe24eaa 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -135,97 +135,6 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, } EXPORT_SYMBOL(blkdev_issue_discard); -/** - * __blkdev_issue_write_same - generate number of bios with same page - * @bdev: target blockdev - * @sector: start sector - * @nr_sects: number of sectors to write - * @gfp_mask: memory allocation flags (for bio_alloc) - * @page: page containing data to write - * @biop: pointer to anchor bio - * - * Description: - * Generate and issue number of bios(REQ_OP_WRITE_SAME) with same page. - */ -static int __blkdev_issue_write_same(struct block_device *bdev, sector_t sector, - sector_t nr_sects, gfp_t gfp_mask, struct page *page, - struct bio **biop) -{ - struct request_queue *q = bdev_get_queue(bdev); - unsigned int max_write_same_sectors; - struct bio *bio = *biop; - sector_t bs_mask; - - if (!q) - return -ENXIO; - - if (bdev_read_only(bdev)) - return -EPERM; - - bs_mask = (bdev_logical_block_size(bdev) >> 9) - 1; - if ((sector | nr_sects) & bs_mask) - return -EINVAL; - - if (!bdev_write_same(bdev)) - return -EOPNOTSUPP; - - /* Ensure that max_write_same_sectors doesn't overflow bi_size */ - max_write_same_sectors = bio_allowed_max_sectors(q); - - while (nr_sects) { - bio = blk_next_bio(bio, bdev, 1, REQ_OP_WRITE_SAME, gfp_mask); - bio->bi_iter.bi_sector = sector; - bio->bi_vcnt = 1; - bio->bi_io_vec->bv_page = page; - bio->bi_io_vec->bv_offset = 0; - bio->bi_io_vec->bv_len = bdev_logical_block_size(bdev); - - if (nr_sects > max_write_same_sectors) { - bio->bi_iter.bi_size = max_write_same_sectors << 9; - nr_sects -= max_write_same_sectors; - sector += max_write_same_sectors; - } else { - bio->bi_iter.bi_size = nr_sects << 9; - nr_sects = 0; - } - cond_resched(); - } - - *biop = bio; - return 0; -} - -/** - * blkdev_issue_write_same - queue a write same operation - * @bdev: target blockdev - * @sector: start sector - * @nr_sects: number of sectors to write - * @gfp_mask: memory allocation flags (for bio_alloc) - * @page: page containing data - * - * Description: - * Issue a write same request for the sectors in question. - */ -int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, - sector_t nr_sects, gfp_t gfp_mask, - struct page *page) -{ - struct bio *bio = NULL; - struct blk_plug plug; - int ret; - - blk_start_plug(&plug); - ret = __blkdev_issue_write_same(bdev, sector, nr_sects, gfp_mask, page, - &bio); - if (ret == 0 && bio) { - ret = submit_bio_wait(bio); - bio_put(bio); - } - blk_finish_plug(&plug); - return ret; -} -EXPORT_SYMBOL(blkdev_issue_write_same); - static int __blkdev_issue_write_zeroes(struct block_device *bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask, struct bio **biop, unsigned flags) diff --git a/block/blk-merge.c b/block/blk-merge.c index 4de34a332c9fd..87cee7e82ae15 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -152,22 +152,6 @@ static struct bio *blk_bio_write_zeroes_split(struct request_queue *q, return bio_split(bio, q->limits.max_write_zeroes_sectors, GFP_NOIO, bs); } -static struct bio *blk_bio_write_same_split(struct request_queue *q, - struct bio *bio, - struct bio_set *bs, - unsigned *nsegs) -{ - *nsegs = 1; - - if (!q->limits.max_write_same_sectors) - return NULL; - - if (bio_sectors(bio) <= q->limits.max_write_same_sectors) - return NULL; - - return bio_split(bio, q->limits.max_write_same_sectors, GFP_NOIO, bs); -} - /* * Return the maximum number of sectors from the start of a bio that may be * submitted as a single request to a block device. If enough sectors remain, @@ -351,10 +335,6 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio, split = blk_bio_write_zeroes_split(q, *bio, &q->bio_split, nr_segs); break; - case REQ_OP_WRITE_SAME: - split = blk_bio_write_same_split(q, *bio, &q->bio_split, - nr_segs); - break; default: split = blk_bio_segment_split(q, *bio, &q->bio_split, nr_segs); break; @@ -416,8 +396,6 @@ unsigned int blk_recalc_rq_segments(struct request *rq) return 1; case REQ_OP_WRITE_ZEROES: return 0; - case REQ_OP_WRITE_SAME: - return 1; } rq_for_each_bvec(bv, rq, iter) @@ -555,8 +533,6 @@ int __blk_rq_map_sg(struct request_queue *q, struct request *rq, if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) nsegs = __blk_bvec_map_sg(rq->special_vec, sglist, last_sg); - else if (rq->bio && bio_op(rq->bio) == REQ_OP_WRITE_SAME) - nsegs = __blk_bvec_map_sg(bio_iovec(rq->bio), sglist, last_sg); else if (rq->bio) nsegs = __blk_bios_map_sg(q, rq->bio, sglist, last_sg); @@ -757,13 +733,6 @@ static enum elv_merge blk_try_req_merge(struct request *req, return ELEVATOR_NO_MERGE; } -static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b) -{ - if (bio_page(a) == bio_page(b) && bio_offset(a) == bio_offset(b)) - return true; - return false; -} - /* * For non-mq, this has to be called with the request spinlock acquired. * For mq with scheduling, the appropriate queue wide lock should be held. @@ -780,10 +749,6 @@ static struct request *attempt_merge(struct request_queue *q, if (rq_data_dir(req) != rq_data_dir(next)) return NULL; - if (req_op(req) == REQ_OP_WRITE_SAME && - !blk_write_same_mergeable(req->bio, next->bio)) - return NULL; - /* * Don't allow merge of different write hints, or for a hint with * non-hint IO. @@ -912,11 +877,6 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) if (!bio_crypt_rq_ctx_compatible(rq, bio)) return false; - /* must be using the same buffer */ - if (req_op(rq) == REQ_OP_WRITE_SAME && - !blk_write_same_mergeable(rq->bio, bio)) - return false; - /* * Don't allow merge of different write hints, or for a hint with * non-hint IO. diff --git a/block/blk-settings.c b/block/blk-settings.c index b880c70e22e4e..b83df3d2eebca 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -42,7 +42,6 @@ void blk_set_default_limits(struct queue_limits *lim) lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS; lim->max_dev_sectors = 0; lim->chunk_sectors = 0; - lim->max_write_same_sectors = 0; lim->max_write_zeroes_sectors = 0; lim->max_zone_append_sectors = 0; lim->max_discard_sectors = 0; @@ -79,7 +78,6 @@ void blk_set_stacking_limits(struct queue_limits *lim) lim->max_segment_size = UINT_MAX; lim->max_sectors = UINT_MAX; lim->max_dev_sectors = UINT_MAX; - lim->max_write_same_sectors = UINT_MAX; lim->max_write_zeroes_sectors = UINT_MAX; lim->max_zone_append_sectors = UINT_MAX; } @@ -178,18 +176,6 @@ void blk_queue_max_discard_sectors(struct request_queue *q, } EXPORT_SYMBOL(blk_queue_max_discard_sectors); -/** - * blk_queue_max_write_same_sectors - set max sectors for a single write same - * @q: the request queue for the device - * @max_write_same_sectors: maximum number of sectors to write per command - **/ -void blk_queue_max_write_same_sectors(struct request_queue *q, - unsigned int max_write_same_sectors) -{ - q->limits.max_write_same_sectors = max_write_same_sectors; -} -EXPORT_SYMBOL(blk_queue_max_write_same_sectors); - /** * blk_queue_max_write_zeroes_sectors - set max sectors for a single * write zeroes @@ -519,8 +505,6 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors); t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors); t->max_dev_sectors = min_not_zero(t->max_dev_sectors, b->max_dev_sectors); - t->max_write_same_sectors = min(t->max_write_same_sectors, - b->max_write_same_sectors); t->max_write_zeroes_sectors = min(t->max_write_zeroes_sectors, b->max_write_zeroes_sectors); t->max_zone_append_sectors = min(t->max_zone_append_sectors, diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 9f32882ceb2f6..4a5bb47bee3ce 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -212,12 +212,6 @@ static ssize_t queue_discard_zeroes_data_show(struct request_queue *q, char *pag return queue_var_show(0, page); } -static ssize_t queue_write_same_max_show(struct request_queue *q, char *page) -{ - return sprintf(page, "%llu\n", - (unsigned long long)q->limits.max_write_same_sectors << 9); -} - static ssize_t queue_write_zeroes_max_show(struct request_queue *q, char *page) { return sprintf(page, "%llu\n", @@ -587,7 +581,6 @@ QUEUE_RO_ENTRY(queue_discard_max_hw, "discard_max_hw_bytes"); QUEUE_RW_ENTRY(queue_discard_max, "discard_max_bytes"); QUEUE_RO_ENTRY(queue_discard_zeroes_data, "discard_zeroes_data"); -QUEUE_RO_ENTRY(queue_write_same_max, "write_same_max_bytes"); QUEUE_RO_ENTRY(queue_write_zeroes_max, "write_zeroes_max_bytes"); QUEUE_RO_ENTRY(queue_zone_append_max, "zone_append_max_bytes"); QUEUE_RO_ENTRY(queue_zone_write_granularity, "zone_write_granularity"); @@ -643,7 +636,6 @@ static struct attribute *queue_attrs[] = { &queue_discard_max_entry.attr, &queue_discard_max_hw_entry.attr, &queue_discard_zeroes_data_entry.attr, - &queue_write_same_max_entry.attr, &queue_write_zeroes_max_entry.attr, &queue_zone_append_max_entry.attr, &queue_zone_write_granularity_entry.attr, diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 602bef54c8134..38cd840d88387 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -65,7 +65,6 @@ bool blk_req_needs_zone_write_lock(struct request *rq) switch (req_op(rq)) { case REQ_OP_WRITE_ZEROES: - case REQ_OP_WRITE_SAME: case REQ_OP_WRITE: return blk_rq_zone_is_seq(rq); default: diff --git a/block/blk.h b/block/blk.h index abb663a2a147b..2fe483bcc6d38 100644 --- a/block/blk.h +++ b/block/blk.h @@ -286,7 +286,6 @@ static inline bool blk_may_split(struct request_queue *q, struct bio *bio) case REQ_OP_DISCARD: case REQ_OP_SECURE_ERASE: case REQ_OP_WRITE_ZEROES: - case REQ_OP_WRITE_SAME: return true; /* non-trivial splitting decisions */ default: break; diff --git a/block/bounce.c b/block/bounce.c index 3fd3bc6fd5dbb..d9df1788c440c 100644 --- a/block/bounce.c +++ b/block/bounce.c @@ -178,9 +178,6 @@ static struct bio *bounce_clone_bio(struct bio *bio_src) case REQ_OP_SECURE_ERASE: case REQ_OP_WRITE_ZEROES: break; - case REQ_OP_WRITE_SAME: - bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0]; - break; default: bio_for_each_segment(bv, bio_src, iter) bio->bi_io_vec[bio->bi_vcnt++] = bv; diff --git a/include/linux/bio.h b/include/linux/bio.h index 7523aba4ddf7c..74bf16558ef4b 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -65,7 +65,6 @@ static inline bool bio_no_advance_iter(const struct bio *bio) { return bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_SECURE_ERASE || - bio_op(bio) == REQ_OP_WRITE_SAME || bio_op(bio) == REQ_OP_WRITE_ZEROES; } @@ -186,8 +185,6 @@ static inline unsigned bio_segments(struct bio *bio) case REQ_OP_SECURE_ERASE: case REQ_OP_WRITE_ZEROES: return 0; - case REQ_OP_WRITE_SAME: - return 1; default: break; } diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 5561e58d158ac..e72cb45593fbe 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -361,8 +361,6 @@ enum req_opf { REQ_OP_DISCARD = 3, /* securely erase sectors */ REQ_OP_SECURE_ERASE = 5, - /* write the same sector many times */ - REQ_OP_WRITE_SAME = 7, /* write the zero filled sector many times */ REQ_OP_WRITE_ZEROES = 9, /* Open a zone */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 3bfc75a2a4509..b92345c044991 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -247,7 +247,6 @@ struct queue_limits { unsigned int io_opt; unsigned int max_discard_sectors; unsigned int max_hw_discard_sectors; - unsigned int max_write_same_sectors; unsigned int max_write_zeroes_sectors; unsigned int max_zone_append_sectors; unsigned int discard_granularity; @@ -913,9 +912,6 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, return min(q->limits.max_discard_sectors, UINT_MAX >> SECTOR_SHIFT); - if (unlikely(op == REQ_OP_WRITE_SAME)) - return q->limits.max_write_same_sectors; - if (unlikely(op == REQ_OP_WRITE_ZEROES)) return q->limits.max_write_zeroes_sectors; @@ -958,8 +954,6 @@ extern void blk_queue_max_discard_segments(struct request_queue *, extern void blk_queue_max_segment_size(struct request_queue *, unsigned int); extern void blk_queue_max_discard_sectors(struct request_queue *q, unsigned int max_discard_sectors); -extern void blk_queue_max_write_same_sectors(struct request_queue *q, - unsigned int max_write_same_sectors); extern void blk_queue_max_write_zeroes_sectors(struct request_queue *q, unsigned int max_write_same_sectors); extern void blk_queue_logical_block_size(struct request_queue *, unsigned int); @@ -1096,9 +1090,6 @@ static inline long nr_blockdev_pages(void) extern void blk_io_schedule(void); -extern int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, - sector_t nr_sects, gfp_t gfp_mask, struct page *page); - #define BLKDEV_DISCARD_SECURE (1 << 0) /* issue a secure erase */ extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector, @@ -1325,16 +1316,6 @@ static inline int bdev_discard_alignment(struct block_device *bdev) return q->limits.discard_alignment; } -static inline unsigned int bdev_write_same(struct block_device *bdev) -{ - struct request_queue *q = bdev_get_queue(bdev); - - if (q) - return q->limits.max_write_same_sectors; - - return 0; -} - static inline unsigned int bdev_write_zeroes_sectors(struct block_device *bdev) { struct request_queue *q = bdev_get_queue(bdev); diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index af68a67179b48..19514edc44f71 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -1892,7 +1892,6 @@ void blk_fill_rwbs(char *rwbs, unsigned int op) switch (op & REQ_OP_MASK) { case REQ_OP_WRITE: - case REQ_OP_WRITE_SAME: rwbs[i++] = 'W'; break; case REQ_OP_DISCARD: