dm-zoned target for ZBC devices
Subsystems (5)
cover dm-zoned target for ZBC devices
Hi all,
this patchset implements a 'dm-zoned' device-mapper target to handle ZBC host-managed (and host-aware) devices as 'normal' disks.
Patch has been made over Tejuns 'libata/for-4.8' repository. It relies on the patchsets "Support for zoned block devices" and "Add support for ZBC host-managed devices" posted earlier.
As usual, comments and reviews are welcome.
Damien Le Moal (1):
dm-zoned: New device mapper target for zoned block devices
Hannes Reinecke (2):
block: add flag for single-threaded submission
sd: enable single-threaded I/O submission for zoned devices
Documentation/device-mapper/dm-zoned.txt | 147 +++ block/blk-core.c | 2 + drivers/md/Kconfig | 14 + drivers/md/Makefile | 2 + drivers/md/dm-zoned-io.c | 1186 ++++++++++++++++++ drivers/md/dm-zoned-meta.c | 1950 ++++++++++++++++++++++++++++++ drivers/md/dm-zoned-reclaim.c | 770 ++++++++++++ drivers/md/dm-zoned.h | 687 +++++++++++ drivers/scsi/sd.c | 1 + include/linux/blkdev.h | 2 + 10 files changed, 4761 insertions(+) create mode 100644 Documentation/device-mapper/dm-zoned.txt create mode 100644 drivers/md/dm-zoned-io.c create mode 100644 drivers/md/dm-zoned-meta.c create mode 100644 drivers/md/dm-zoned-reclaim.c create mode 100644 drivers/md/dm-zoned.h
Signature · 1 line
1.8.5.6
PATCH 3/3 dm-zoned: New device mapper target for zoned block devices
From: Damien Le Moal <[email protected]>
dm-zoned presents a regular block device fully randomly writeable, hiding write constraints of host-managed zoned block devices and mitigating potential performance degradation of host-aware devices.
--- Documentation/device-mapper/dm-zoned.txt | 147 +++ drivers/md/Kconfig | 14 + drivers/md/Makefile | 2 + drivers/md/dm-zoned-io.c | 1186 ++++++++++++++++++ drivers/md/dm-zoned-meta.c | 1950 ++++++++++++++++++++++++++++++ drivers/md/dm-zoned-reclaim.c | 770 ++++++++++++ drivers/md/dm-zoned.h | 687 +++++++++++ 7 files changed, 4756 insertions(+) create mode 100644 Documentation/device-mapper/dm-zoned.txt create mode 100644 drivers/md/dm-zoned-io.c create mode 100644 drivers/md/dm-zoned-meta.c create mode 100644 drivers/md/dm-zoned-reclaim.c create mode 100644 drivers/md/dm-zoned.h
Documentation/device-mapper/dm-zoned.txt new file +147 -0
@@ -0,0 +1,147 @@ +dm-zoned +======== + +The dm-zoned device mapper target provides transparent write access to +zoned block devices (ZBC and ZAC compliant devices). It hides to the +device user (a file system or an application doing raw block device +accesses) any sequential write constraint on host-managed devices and +can mitigate potential device performance degradation with host-aware +zoned devices. + +For a more detailed description of the zoned block device models and +constraints see (for SCSI devices): + +http://www.t10.org/drafts.htm#ZBC_Family + +And (for ATA devices): + +http://www.t13.org/Documents/UploadedDocuments/docs2015/di537r05-Zoned_Device_ATA_Command_Set_ZAC.pdf + + +Algorithm +========= + +The zones of the device are separated into 3 sets: +1) Metadata zones: these are randomly writeable zones used to store metadata. +Randomly writeable zones may be conventional zones or sequential write preferred +zones (host-aware devices only). These zones have a fixed mapping and must be +available at the beginning of the device address space (from LBA 0). +2) Buffer zones: these are randomly writeable zones used to temporarily +buffer unaligned writes to data zones. Buffer zones zones may be conventional +zones or sequential write preferred zones (host-aware devivces only) and any +random zone in the device address space can be used as a buffer zone (there +are no constraint on these zones location). +3) Data zones: all remaining zones. Most will likely be sequential zones, +either sequiential write required zones (host-managed devices) or sequential +write preferred zones (host-aware devices). Conventional zones unused as +metadata zone or buffer zone will be part of the set of data zones. dm-zoned +tries to efficiently allocate and map these zones to limit the performance +impact of buffering random writes for chunks of the logical device that are +being heavily randomly written. + +dm-zoned exposes a logical device with a sector size of 4096 bytes, irespectively +of the physical sector size of the backend device being used. This allows +reducing the amount of metadata needed to manage valid blocks (blocks written) +and buffering of random writes. In more detail, the on-disk metadata format +is as follows: +1) Block 0 contains the super block which describes the amount of metadata +blocks used, the number of buffer zones reserved, their position on disk and +the data zones being buffered. +2) Following block 0, a set of blocks is used to describe the mapping to data +zones of the logical chunks of the logical device (the size of a logical chunk +is equal to the device zone size). +3) A set of blocks used to store bitmaps indicating the validity of blocks in +the buffer zones and data zones. A valid block is a block that was writen and +not discarded. For a buffered data zone, a block can be valid only in the data +zone or in the buffer zone. + +For a logical chunk mapped to a conventional data zone, all write operations are +processed by directly writing the data zone. If the mapping zone is a sequential +zone, the write operation is processed directly only and only if the write offset +within the logical chunk equals the write pointer offset within the data zone +(i.e. the write operation is aligned on the zone write pointer). + +Otherwise, write operations are processed indirectly using a buffer zone: a buffer +zone is allocated and assigned to the data zone being accessed and data written to +the buffer zone. This results in the invalidation of the written block in the data +zone and validation in the buffer zone. + +Read operations are processed according to the block validity information provided +by the bitmaps: valid blocks are read either from the data zone or, if the data +zone is buffered, from the buffer zone assigned to the data zone. + +After some time, the limited number of buffer zones available may be exhausted and +unaligned writes to unbuffered zones become impossible. To avoid such situation, a +reclaim process regularly scan used buffer zones and try to "reclaim" them by +rewriting (sequentially) the buffered data blocks and the valid blocks in the data +zone being buffered into a new data zone. This "merge" operation completes with the +remapping of the data zone chunk to the newly writen data zone and the release of +the buffer zone. + +This reclaim process is optimized to try to detect data zones that are being +heavily randomly written and try to do the merge operation into a conventional +data zone (if available). + +Usage +===== + +Parameters: <zoned device path> [Options] +Options: + debug : Enable debug messages + format : Reset and format the device metadata. This will + invalidate all blocks of the device and trigger + a reset write pointer of all zones, causing the + loss of all previously written data. + num_bzones=<num> : If the format option is specified, change the + default number of buffer zones from 64 to <num>. + If <num> is too large and cannot be accomodated + with the number of available random zones, the + maximum possible number of buffer zones is used. + align_wp=<blocks> : Use write same command to move an SMR zone write + pointer position to the offset of a write request, + limiting the write same operation to at most + <blocks>. This can reduce the use of buffer zones, + but can also significantly decrease the disk + useable throughput. Set to 0 (default) to disable + this feature. The maximum allowed is half the + disk zone size. + +Example scripts +=============== + +[[ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "Usage: $0 <Zoned device path> [Options]" + echo "Options:" + echo " debug : Enable debug messages" + echo " format : Reset and format the device metadata. This will" + echo " invalidate all blocks of the device and trigger" + echo " a reset write pointer of all zones, causing the" + echo " loss of all previously written data." + echo " num_bzones=<num> : If the format option is specified, change the" + echo " default number of buffer zones from 64 to <num>." + echo " If <num> is too large and cannot be accomodated" + echo " with the number of available random zones, the" + echo " maximum possible number of buffer zones is used." + echo " align_wp=<blocks> : Use write same command to move an SMR zone write" + echo " pointer position to the offset of a write request," + echo " limiting the write same operation to at most" + echo " <blocks>. This can reduce the use of buffer zones," + echo " but can also significantly decrease the disk" + echo " useable throughput. Set to 0 (default) to disable" + echo " this feature. The maximum allowed is half the" + echo " disk zone size." + exit 1 +fi + +dev="${1}" +shift +options="$@" + +modprobe dm-zoned + +echo "0 `blockdev --getsize ${dev}` dm-zoned ${dev} ${options}" | dmsetup create zoned-`basename ${dev}` +]] +
drivers/md/Kconfig +14 -0
@@ -500,4 +500,18 @@ config DM_LOG_WRITES If unsure, say N. +config DM_ZONED + tristate "Zoned block device cache write target support (EXPERIMENTAL)" + depends on BLK_DEV_DM && BLK_DEV_ZONED + default n + ---help--- + This device-mapper target implements an on-disk caching layer for + zoned block devices (ZBC), doing so hiding random write constraints + of the backend device. + + To compile this code as a module, choose M here: the module will + be called dm-zoned. + + If unsure, say N. + endif # MD
drivers/md/Makefile +2 -0
@@ -18,6 +18,7 @@ dm-era-y += dm-era-target.o dm-verity-y += dm-verity-target.o md-mod-y += md.o bitmap.o raid456-y += raid5.o raid5-cache.o +dm-zoned-y += dm-zoned-io.o dm-zoned-meta.o dm-zoned-reclaim.o # Note: link order is important. All raid personalities # and must come before md.o, as they each initialise
@@ -58,6 +59,7 @@ obj-$(CONFIG_DM_CACHE_SMQ) += dm-cache-smq.o obj-$(CONFIG_DM_CACHE_CLEANER) += dm-cache-cleaner.o obj-$(CONFIG_DM_ERA) += dm-era.o obj-$(CONFIG_DM_LOG_WRITES) += dm-log-writes.o +obj-$(CONFIG_DM_ZONED) += dm-zoned.o ifeq ($(CONFIG_DM_UEVENT),y) dm-mod-objs += dm-uevent.o
drivers/md/dm-zoned-io.c new file +1186 -0
1,186 lines not on this page · raw message
drivers/md/dm-zoned-meta.c new file +1950 -0
1,635 lines not on this page · raw message
drivers/md/dm-zoned-reclaim.c new file +770 -0
770 lines not on this page · raw message
drivers/md/dm-zoned.h new file +687 -0
687 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.5.6
Part of the diff is not shown here. View the raw message.
PATCH 1/3 block: add flag for single-threaded submission
In reply to Hannes ReineckeSome devices (most notably SMR drives) support only one I/O stream eg for ensuring ordered I/O submission. This patch adds a new block queue flag 'BLK_QUEUE_SINGLE' to support these devices.
--- block/blk-core.c | 2 ++ include/linux/blkdev.h | 2 ++ 2 files changed, 4 insertions(+)
block/blk-core.c +2 -0
@@ -320,6 +320,8 @@ inline void __blk_run_queue_uncond(struct request_queue *q)* number of active request_fn invocations such that blk_drain_queue() * can wait until all these request_fn calls have finished. */ +if (blk_queue_single (q) && q->request_fn_active) +return ; q->request_fn_active++; q->request_fn (q); q->request_fn_active--;
include/linux/blkdev.h +2 -0
@@ -539,6 +539,7 @@ struct request_queue {#define QUEUE_FLAG_WC 23/* Write back caching */ #define QUEUE_FLAG_FUA 24/* device supports FUA writes */ #define QUEUE_FLAG_FLUSH_NQ 25/* flush not queueuable */ +#define QUEUE_FLAG_SINGLE 26/* single-threaded submission only */ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_STACKABLE) | \
@@ -628,6 +629,7 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)#define blk_queue_discard (q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags)#define blk_queue_secdiscard (q) (blk_queue_discard(q) && \ test_bit(QUEUE_FLAG_SECDISCARD, &(q)->queue_flags)) +#define blk_queue_single (q) test_bit(QUEUE_FLAG_SINGLE, &(q)->queue_flags)#define blk_noretry_request (rq) \ ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \
Signature · 1 line
1.8.5.6
PATCH 2/3 sd: enable single-threaded I/O submission for zoned devices
In reply to Hannes Reineckezoned devices require single-thread I/O submission to guarantee sequential I/O, so enable the block layer flag for it.
--- drivers/scsi/sd.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/sd.c +1 -0
@@ -2154,6 +2154,7 @@ static void sd_read_zones(struct scsi_disk *sdkp, unsigned char *buffer)blk_queue_chunk_sectors (sdkp->disk->queue,logical_to_sectors (sdkp->device, zone_len));sd_config_discard (sdkp,SD_ZBC_RESET_WP ); +queue_flag_set_unlocked (QUEUE_FLAG_SINGLE , sdkp->disk->queue);sd_zbc_setup (sdkp, buffer,SD_BUF_SIZE ); }
Signature · 1 line
1.8.5.6
Re: [PATCH 1/3] block: add flag for single-threaded submission
In reply to Hannes ReineckeQuoted 10 lines · Hannes Reinecke
Some devices (most notably SMR drives) support only one I/O stream eg for ensuring ordered I/O submission. This patch adds a new block queue flag '
BLK_QUEUE_SINGLE' to support these devices.Signed-off-by Hannes Reinecke <[email protected]>--- block/blk-core.c | 2 ++ include/linux/blkdev.h | 2 ++ 2 files changed, 4 insertions(+)
Signature · 11 lines
Damien Le Moal, Ph.D. Sr. Manager, System Software Group, HGST Research, HGST, a Western Digital brand [email protected] (+81) 0466-98-3593 (ext. 513593) 1 kirihara-cho, Fujisawa, Kanagawa, 252-0888 Japan www.hgst.com Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer: This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.
Re: [PATCH 2/3] sd: enable single-threaded I/O submission for zoned devices
In reply to Hannes ReineckeQuoted 7 lines · Hannes Reinecke
zoned devices require single-thread I/O submission to guarantee sequential I/O, so enable the block layer flag for it.
Signed-off-by Hannes Reinecke <[email protected]>--- drivers/scsi/sd.c | 1 + 1 file changed, 1 insertion(+)
Signature · 11 lines
Damien Le Moal, Ph.D. Sr. Manager, System Software Group, HGST Research, HGST, a Western Digital brand [email protected] (+81) 0466-98-3593 (ext. 513593) 1 kirihara-cho, Fujisawa, Kanagawa, 252-0888 Japan www.hgst.com Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer: This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.
Re: [PATCH 1/3] block: add flag for single-threaded submission
In reply to Hannes ReineckeQuoted 4 lines · Hannes Reinecke
Some devices (most notably SMR drives) support only one I/O stream eg for ensuring ordered I/O submission. This patch adds a new block queue flag '
BLK_QUEUE_SINGLE' to support these devices.
We'll need a blk-mq implementation of this flag as well before it can be merged.
Re: [PATCH 1/3] block: add flag for single-threaded submission
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Hannes Reinecke
Some devices (most notably SMR drives) support only one I/O stream eg for ensuring ordered I/O submission. This patch adds a new block queue flag '
BLK_QUEUE_SINGLE' to support these devices.We'll need a blk-mq implementation of this flag as well before it can be merged.
Yes, indeed. Will be fixed for the next round of submissions.
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] block: add flag for single-threaded submission
Quoted 7 lines · Hannes Reinecke
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Hannes Reinecke
Some devices (most notably SMR drives) support only one I/O stream eg for ensuring ordered I/O submission. This patch adds a new block queue flag '
BLK_QUEUE_SINGLE' to support these devices.
Quoted 5 lines
Quoted 3 lines
We'll need a blk-mq implementation of this flag as well before it can be merged.
Yes, indeed. Will be fixed for the next round of submissions.
Hmm.
Looking closer do I _really_ need that for blk-mq?
From my understanding any hctx can only run on one dedicated cpu, to which the hctx is bound.
So if we only have one CPU serving that hctx how can we have several concurrent calls to queue_rq() here?
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] block: add flag for single-threaded submission
Hannes,
Quoted 13 lines · Hannes Reinecke
Quoted 10 lines · Hannes Reinecke
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Hannes Reinecke
Some devices (most notably SMR drives) support only one I/O stream eg for ensuring ordered I/O submission. This patch adds a new block queue flag '
BLK_QUEUE_SINGLE' to support these devices.We'll need a blk-mq implementation of this flag as well before it can be merged.
Quoted 8 lines
Quoted 2 lines
Yes, indeed. Will be fixed for the next round of submissions.
Hmm.
Looking closer do I _really_ need that for blk-mq?
From my understanding any hctx can only run on one dedicated cpu, to which the hctx is bound.
So if we only have one CPU serving that hctx how can we have several concurrent calls toqueue_rq()here?
Ex: an application with 2 threads running on different CPUs, with both threads writing to the same sequential zone with a proper mutual exclusion to ensure sequential write order at the application level.
For this example, each thread requests will end up in a different hw queue (hctx), and a single CPU serving each hctx may not result in an overall in-order delivery to the disk.
So we need to ensure that all requests for a sequential zone end up in the same hctx, which I think means simply that we need to allow only a single queue for a ZBC device. If one day we get a fast SSD supporting ZBC/ZAC commands, this may impact performance though...
I may be completely wrong about this though.
Cheers.
------------------------
Damien Le Moal, Ph.D.
Sr. Manager, System Software Group, HGST Research,
HGST, a Western Digital brand
[email protected]
(+81) 0466-98-3593 (ext. 513593)
1 kirihara-cho, Fujisawa,
Kanagawa, 252-0888 Japan
www.hgst.com
Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer:
This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.
Re: [PATCH 1/3] block: add flag for single-threaded submission
In reply to Hannes ReineckeQuoted 3 lines · Hannes Reinecke
Looking closer do I _really_ need that for blk-mq?
Quoted 1 line
From my understanding any hctx can only run on one dedicated cpu, to
which the hctx is bound.
That's not the case. A hctx exists for each hardware queue, and a CPU must be mapped to a hctx. So if you have less hctx than CPUs (e.g. just one) you have multiple CPUs that could submit on a hctx.