From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org,
	dm-devel@lists.linux.dev,
	Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>,
	linux-scsi@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Ming Lei <ming.lei@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Christoph Hellwig <hch@lst.de>
Subject: [PATCH 0/5] Remove zone reset all emulation
Date: Thu,  4 Jul 2024 08:39:27 +0900
Message-ID: <20240703233932.545228-1-dlemoal@kernel.org>
X-Mailing-List: linux-block@vger.kernel.org
List-Id: <linux-block.vger.kernel.org>
List-Subscribe: <mailto:linux-block+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-block+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Xref: photonic.trudheim.com org.kernel.vger.linux-block:93793
Newsgroups: org.kernel.vger.linux-block,dev.linux.lists.dm-devel,org.kernel.vger.linux-scsi
Path: photonic.trudheim.com!nntp.lore.kernel.org!not-for-mail

Jens, Mike,

Here is a set of patches based on block/for-next to remove the emulation
for zone reset all from the block layer and move it to device mapper.
This is done because device mapper is the only zoned device driver that
does not natively support REQ_OP_ZONE_RESET_ALL. With this change, the
emulation that may be required depending on a mapped device zone mapping
is moved to device mapper and the reset all feature
(BLK_FEAT_ZONE_RESETALL) can be deleted, as well as all the code
handling this feature in blk-zoned.c. The DM-based handling of
REQ_OP_ZONE_RESET_ALL can also be much faster than the block layer
emulation as that operation can be forwarded as is to targets mapping
all sequential write required zones.

Patch 1 modifies null_blk to add the zone_full parameter to initialize
the sequential zones of a zoned null_blk device to be full. This is
convenient when testing read workloads as well as zone management
operations as that avoids having to first write to device to make the
zones full.

Patch 2 is a simple prep patch for patch 3. Patch 3 implements the
emulation for zone reset all in device mapper core code.

Patch 4 removes the block layer based emulation and modifies all drivers
setting the BLK_FEAT_ZONE_RESETALL queue limit feature to not set this
feature (and the feature is removed). This enables the use of the device
mapper emulation.

Patch 5 is a cleanup of blk-zoned.c made possible with patch 4.

Damien Le Moal (5):
  null_blk: Introduce the zone_full parameter
  dm: Refactor is_abnormal_io()
  dm: handle REQ_OP_ZONE_RESET_ALL
  block: Remove REQ_OP_ZONE_RESET_ALL emulation
  block: Remove blk_alloc_zone_bitmap()

 block/blk-core.c                  |   2 +-
 block/blk-zoned.c                 |  88 +----------------
 drivers/block/null_blk/main.c     |   9 +-
 drivers/block/null_blk/null_blk.h |   1 +
 drivers/block/null_blk/zoned.c    |  12 ++-
 drivers/block/ublk_drv.c          |   2 +-
 drivers/block/virtio_blk.c        |   2 +-
 drivers/md/dm-zone.c              |  50 +++++++++-
 drivers/md/dm.c                   | 159 +++++++++++++++++++++++++++---
 drivers/md/dm.h                   |  10 ++
 drivers/nvme/host/zns.c           |   2 +-
 drivers/scsi/sd_zbc.c             |   2 +-
 include/linux/blkdev.h            |   5 -
 include/linux/device-mapper.h     |   7 ++
 14 files changed, 236 insertions(+), 115 deletions(-)

-- 
2.45.2

.

From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: axboe@kernel.dk,
	linux-block@vger.kernel.org
Cc: Zhu Yanjun <yanjun.zhu@linux.dev>
Subject: [PATCH 1/1] null_blk: Fix error "ERROR:INITIALISED_STATIC: do not initialise statics to false"
Date: Thu,  4 Jul 2024 03:06:38 +0200
Message-Id: <20240704010638.324349-1-yanjun.zhu@linux.dev>
X-Mailing-List: linux-block@vger.kernel.org
List-Id: <linux-block.vger.kernel.org>
List-Subscribe: <mailto:linux-block+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-block+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Xref: photonic.trudheim.com org.kernel.vger.linux-block:93801
Newsgroups: org.kernel.vger.linux-block
Path: photonic.trudheim.com!nntp.lore.kernel.org!not-for-mail

No functional changes intended.

Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
---
 drivers/block/null_blk/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 75f189e42f88..ea3989dce3be 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -77,7 +77,7 @@ enum {
 	NULL_IRQ_TIMER		= 2,
 };
 
-static bool g_virt_boundary = false;
+static bool g_virt_boundary;
 module_param_named(virt_boundary, g_virt_boundary, bool, 0444);
 MODULE_PARM_DESC(virt_boundary, "Require a virtual boundary for the device. Default: False");
 
-- 
2.34.1

.

From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org,
	dm-devel@lists.linux.dev,
	Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>,
	linux-scsi@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Ming Lei <ming.lei@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Christoph Hellwig <hch@lst.de>
Subject: [PATCH v2 0/5] Remove zone reset all emulation
Date: Thu,  4 Jul 2024 14:28:11 +0900
Message-ID: <20240704052816.623865-1-dlemoal@kernel.org>
X-Mailing-List: linux-block@vger.kernel.org
List-Id: <linux-block.vger.kernel.org>
List-Subscribe: <mailto:linux-block+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-block+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Xref: photonic.trudheim.com org.kernel.vger.linux-block:93806
Newsgroups: org.kernel.vger.linux-block,dev.linux.lists.dm-devel,org.kernel.vger.linux-scsi
Path: photonic.trudheim.com!nntp.lore.kernel.org!not-for-mail

Jens, Mike,

Here is a set of patches based on block/for-next to remove the emulation
for zone reset all from the block layer and move it to device mapper.
This is done because device mapper is the only zoned device driver that
does not natively support REQ_OP_ZONE_RESET_ALL. With this change, the
emulation that may be required depending on a mapped device zone mapping
is moved to device mapper and the reset all feature
(BLK_FEAT_ZONE_RESETALL) can be deleted, as well as all the code
handling this feature in blk-zoned.c. The DM-based handling of
REQ_OP_ZONE_RESET_ALL can also be much faster than the block layer
emulation as that operation can be forwarded as is to targets mapping
all sequential write required zones.

Patch 1 modifies null_blk to add the zone_full parameter to initialize
the sequential zones of a zoned null_blk device to be full. This is
convenient when testing read workloads as well as zone management
operations as that avoids having to first write to device to make the
zones full.

Patch 2 is a simple prep patch for patch 3. Patch 3 implements the
emulation for zone reset all in device mapper core code.

Patch 4 removes the block layer based emulation and modifies all drivers
setting the BLK_FEAT_ZONE_RESETALL queue limit feature to not set this
feature (and the feature is removed). This enables the use of the device
mapper emulation.

Patch 5 is a cleanup of blk-zoned.c made possible with patch 4.

Changes from v1:
 - Fixed typo in the commit message and long comment line of patch 3.
   Also removed the stubbed definition of dm_zone_get_reset_bitmap() in
   dm.h as it is not necessary.
 - Modified patch 4 to have submit_bio_noacct() treat
   REQ_OP_ZONE_RESET_ALL the same way as other zone operations.

Damien Le Moal (5):
  null_blk: Introduce the zone_full parameter
  dm: Refactor is_abnormal_io()
  dm: handle REQ_OP_ZONE_RESET_ALL
  block: Remove REQ_OP_ZONE_RESET_ALL emulation
  block: Remove blk_alloc_zone_bitmap()

 block/blk-core.c                  |   5 +-
 block/blk-zoned.c                 |  88 +----------------
 drivers/block/null_blk/main.c     |   9 +-
 drivers/block/null_blk/null_blk.h |   1 +
 drivers/block/null_blk/zoned.c    |  12 ++-
 drivers/block/ublk_drv.c          |   2 +-
 drivers/block/virtio_blk.c        |   2 +-
 drivers/md/dm-zone.c              |  50 +++++++++-
 drivers/md/dm.c                   | 159 +++++++++++++++++++++++++++---
 drivers/md/dm.h                   |   3 +
 drivers/nvme/host/zns.c           |   2 +-
 drivers/scsi/sd_zbc.c             |   2 +-
 include/linux/blkdev.h            |   5 -
 include/linux/device-mapper.h     |   7 ++
 14 files changed, 229 insertions(+), 118 deletions(-)

-- 
2.45.2

.

From: Kanchan Joshi <joshi.k@samsung.com>
To: axboe@kernel.dk, hch@lst.de, martin.petersen@oracle.com
Cc: linux-block@vger.kernel.org, Anuj Gupta <anuj20.g@samsung.com>
Subject: [PATCH] block: t10-pi: Return correct ref tag when queue has no
 integrity profile
Date: Thu,  4 Jul 2024 11:45:15 +0530
Message-Id: <20240704061515.282343-1-joshi.k@samsung.com>
X-Mailing-List: linux-block@vger.kernel.org
List-Id: <linux-block.vger.kernel.org>
List-Subscribe: <mailto:linux-block+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-block+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"
References: <CGME20240704062234epcas5p1dd4ae6e7c91555b9573418d618086c1e@epcas5p1.samsung.com>
Xref: photonic.trudheim.com org.kernel.vger.linux-block:93814
Newsgroups: org.kernel.vger.linux-block
Path: photonic.trudheim.com!nntp.lore.kernel.org!not-for-mail

From: Anuj Gupta <anuj20.g@samsung.com>

Commit <c6e56cf6b2e7> (block: move integrity information into
queue_limits) changed the ref tag calculation logic. It would break if
there is no integrity profile. This in turn causes read/write failures
for such cases.

Fixes: <c6e56cf6b2e7> (block: move integrity information into queue_limits)
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
 include/linux/t10-pi.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/linux/t10-pi.h b/include/linux/t10-pi.h
index 1773610010eb..2c59fe3efcd4 100644
--- a/include/linux/t10-pi.h
+++ b/include/linux/t10-pi.h
@@ -39,8 +39,11 @@ struct t10_pi_tuple {
 
 static inline u32 t10_pi_ref_tag(struct request *rq)
 {
-	unsigned int shift = rq->q->limits.integrity.interval_exp;
+	unsigned int shift = ilog2(queue_logical_block_size(rq->q));
 
+	if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) &&
+	    rq->q->limits.integrity.interval_exp)
+		shift = rq->q->limits.integrity.interval_exp;
 	return blk_rq_pos(rq) >> (shift - SECTOR_SHIFT) & 0xffffffff;
 }
 
@@ -61,8 +64,11 @@ static inline u64 lower_48_bits(u64 n)
 
 static inline u64 ext_pi_ref_tag(struct request *rq)
 {
-	unsigned int shift = rq->q->limits.integrity.interval_exp;
+	unsigned int shift = ilog2(queue_logical_block_size(rq->q));
 
+	if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) &&
+	    rq->q->limits.integrity.interval_exp)
+		shift = rq->q->limits.integrity.interval_exp;
 	return lower_48_bits(blk_rq_pos(rq) >> (shift - SECTOR_SHIFT));
 }
 
-- 
2.25.1

.

From: Kundan Kumar <kundan.kumar@samsung.com>
To: axboe@kernel.dk, hch@lst.de, willy@infradead.org, kbusch@kernel.org
Cc: linux-block@vger.kernel.org, joshi.k@samsung.com, mcgrof@kernel.org,
	anuj20.g@samsung.com, nj.shetty@samsung.com, c.gameti@samsung.com,
	gost.dev@samsung.com, Kundan Kumar <kundan.kumar@samsung.com>
Subject: [PATCH v7 0/4] block: add larger order folio instead of pages
Date: Thu,  4 Jul 2024 12:33:53 +0530
Message-Id: <20240704070357.1993-1-kundan.kumar@samsung.com>
X-Mailing-List: linux-block@vger.kernel.org
List-Id: <linux-block.vger.kernel.org>
List-Subscribe: <mailto:linux-block+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-block+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"
References: <CGME20240704071118epcas5p141ef3c2cbcde0ce31d342b5743a7dcf1@epcas5p1.samsung.com>
Xref: photonic.trudheim.com org.kernel.vger.linux-block:93818
Newsgroups: org.kernel.vger.linux-block
Path: photonic.trudheim.com!nntp.lore.kernel.org!not-for-mail

User space memory is mapped in kernel in form of pages array. These pages
are iterated and added to BIO. In process, pages are also checked for
contiguity and merged.

When mTHP is enabled the pages generally belong to larger order folio. This
patch series enables adding large folio to bio. It fetches folio for
page in the page array. The page might start from an offset in the folio
which could be multiples of PAGE_SIZE. Subsequent pages in page array
might belong to same folio. Using the length of folio, folio_offset and
remaining size, determine length in folio which can be added to the bio.
Check if pages are contiguous and belong to same folio. If yes then skip
further processing for the contiguous pages.

This complete scheme reduces the overhead of iterating through pages.

perf diff before and after this change(with mTHP enabled):

Perf diff for write I/O with 128K block size:
    1.24%     -0.20%  [kernel.kallsyms]  [k] bio_iov_iter_get_pages
    1.71%             [kernel.kallsyms]  [k] bvec_try_merge_page
Perf diff for read I/O with 128K block size:
    4.03%     -1.59%  [kernel.kallsyms]  [k] bio_iov_iter_get_pages
    5.14%             [kernel.kallsyms]  [k] bvec_try_merge_page

Patch 1: Adds folio-lized version of bvec_try_merge_hw_page()
Patch 2: Adds folio-lized version of bio_add_hw_page()
Patch 3: Adds bigger size from folio to BIO
Patch 4: Unpin user pages belonging to folio at once

Changes since v6:
- folio-lize bvec_try_merge_hw_page() to bvec_try_merge_hw_folio()
- restructured the code as per comments
- typecast with size_t while calculating the offset in folio.

Changes since v5:
- Made offset and len as size_t in function bio_add_hw_folio()
- Avoid unpinning skipped pages at submission, rather unpin all pages at
  once on IO completion

Changes since v4:
- folio-lize bio_add_hw_page() to bio_add_hw_folio()
- make bio_add_hw_page() as a wrapper around bio_add_hw_folio()
- make new functions bio_release_folio() and unpin_user_folio()
- made a helper function to check for contiguous pages of folio
- changed &folio->page to folio_page(folio, 0)
- reworded comments

Changes since v3:
- Added change to see if pages are contiguous and belong to same folio.
  If not then avoid skipping of pages.(Suggested by Matthew Wilcox)

Changes since v2:
- Made separate patches
- Corrected code as per kernel coding style
- Removed size_folio variable

Changes since v1:
- Changed functions bio_iov_add_page() and bio_iov_add_zone_append_page()
  to accept a folio
- Removed branch and calculate folio_offset and len in same fashion for
  both 0 order and larger folios
- Added change in NVMe driver to use nvme_setup_prp_simple() by
  ignoring multiples of PAGE_SIZE in offset
- Added a change to unpin_user_pages which were added as folios. Also
  stopped the unpin of pages one by one from __bio_release_pages()
  (Suggested by Keith)

Kundan Kumar (4):
  block: Added folio-lized version of bvec_try_merge_hw_page()
  block: Added folio-lized version of bio_add_hw_page()
  block: introduce folio awareness and add a bigger size from folio
  block: unpin user pages belonging to a folio at once

 block/bio.c        | 133 ++++++++++++++++++++++++++++++++++++---------
 block/blk.h        |  15 +++++
 include/linux/mm.h |   1 +
 mm/gup.c           |  13 +++++
 4 files changed, 135 insertions(+), 27 deletions(-)

-- 
2.25.1

.

