write hints for nvme fdp
Subsystems (7)
v8 cover write hints for nvme fdp
From: Keith Busch <[email protected]>
Changes from v7:
Limits io_uring per-io hints to raw block, and only if the block device registers a new queue limit indicating support for it.
The per-io hints are opaque to the kernel.
Minor changelog and code organization changes.
I don't really understand the io_uring suggestions, so I just made the write_hint a first class field without the "meta" indirection. It's kind of like ioprio, which has it's own field too. Actually, might be neat if we could use ioprio since it already has a "hints" field that is currently only used by command duration limits.
Kanchan Joshi (3):
block, fs: restore kiocb based write hint processing
io_uring: enable per-io hinting capability
nvme: enable FDP support
Keith Busch (3):
block: use generic u16 for write hints
block: introduce max_write_hints queue limit
fs: introduce per-io hint support flag
Documentation/ABI/stable/sysfs-block | 7 +++ block/blk-settings.c | 3 + block/blk-sysfs.c | 3 + block/fops.c | 10 ++-- drivers/nvme/host/core.c | 82 ++++++++++++++++++++++++++++ drivers/nvme/host/nvme.h | 5 ++ fs/aio.c | 1 + fs/cachefiles/io.c | 1 + fs/direct-io.c | 2 +- fs/iomap/direct-io.c | 2 +- include/linux/blk-mq.h | 3 +- include/linux/blk_types.h | 2 +- include/linux/blkdev.h | 12 ++++ include/linux/fs.h | 10 ++++ include/linux/nvme.h | 19 +++++++ include/uapi/linux/io_uring.h | 4 ++ io_uring/rw.c | 10 +++- 17 files changed, 166 insertions(+), 10 deletions(-)
Signature · 1 line
2.43.5
PATCH v8 1/6 block, fs: restore kiocb based write hint processing
From: Kanchan Joshi <[email protected]>
struct kiocb has a 2 bytes hole that developed post commit 41d36a9f3e53 ("fs: remove kiocb.ki_hint"). But write hint returned with commit 449813515d3e ("block, fs: Restore the per-bio/request data lifetime fields").
This patch uses the leftover space in kiocb to carve 2 byte field ki_write_hint. Restore the code that operates on kiocb to use ki_write_hint instead of inode hint value.
This does not change any behavior, but needed to enable per-io hints.
--- block/fops.c | 6 +++--- fs/aio.c | 1 + fs/cachefiles/io.c | 1 + fs/direct-io.c | 2 +- fs/iomap/direct-io.c | 2 +- include/linux/fs.h | 8 ++++++++ io_uring/rw.c | 1 + 7 files changed, 16 insertions(+), 5 deletions(-)
block/fops.c +3 -3
@@ -74,7 +74,7 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb,bio_init (&bio, bdev, vecs, nr_pages,dio_bio_write_op (iocb)); } bio.bi_iter.bi_sector = pos >>SECTOR_SHIFT ; - bio.bi_write_hint =file_inode (iocb->ki_filp)->i_write_hint; + bio.bi_write_hint = iocb->ki_write_hint; bio.bi_ioprio = iocb->ki_ioprio;if (iocb->ki_flags &IOCB_ATOMIC ) bio.bi_opf |=REQ_ATOMIC ;
@@ -203,7 +203,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,for (;;) { bio->bi_iter.bi_sector = pos >>SECTOR_SHIFT ; - bio->bi_write_hint =file_inode (iocb->ki_filp)->i_write_hint; + bio->bi_write_hint = iocb->ki_write_hint; bio->bi_private = dio; bio->bi_end_io = blkdev_bio_end_io; bio->bi_ioprio = iocb->ki_ioprio;
@@ -319,7 +319,7 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, dio->flags =0 ; dio->iocb = iocb; bio->bi_iter.bi_sector = pos >>SECTOR_SHIFT ; - bio->bi_write_hint =file_inode (iocb->ki_filp)->i_write_hint; + bio->bi_write_hint = iocb->ki_write_hint; bio->bi_end_io = blkdev_bio_end_io_async; bio->bi_ioprio = iocb->ki_ioprio;
fs/aio.c +1 -0
@@ -1517,6 +1517,7 @@ static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb, int rw_type) req->ki_flags = req->ki_filp->f_iocb_flags |IOCB_AIO_RW ;if (iocb->aio_flags &IOCB_FLAG_RESFD ) req->ki_flags |=IOCB_EVENTFD ; + req->ki_write_hint =file_write_hint (req->ki_filp);if (iocb->aio_flags &IOCB_FLAG_IOPRIO ) {/* * If the IOCB_FLAG_IOPRIO flag of aio_flags is set, then
fs/cachefiles/io.c +1 -0
@@ -309,6 +309,7 @@ int __cachefiles_write(struct cachefiles_object *object, ki->iocb.ki_pos = start_pos; ki->iocb.ki_flags =IOCB_DIRECT |IOCB_WRITE ; ki->iocb.ki_ioprio =get_current_ioprio (); + ki->iocb.ki_write_hint =file_write_hint (file); ki->object = object; ki->start = start_pos; ki->len = len;
fs/direct-io.c +1 -1
@@ -409,7 +409,7 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio, bio->bi_end_io = dio_bio_end_io;if (dio->is_pinned)bio_set_flag (bio,BIO_PAGE_PINNED ); - bio->bi_write_hint =file_inode (dio->iocb->ki_filp)->i_write_hint; + bio->bi_write_hint = dio->iocb->ki_write_hint; sdio->bio = bio; sdio->logical_offset_in_bio = sdio->cur_page_fs_offset;
fs/iomap/direct-io.c +1 -1
@@ -397,7 +397,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,fscrypt_set_bio_crypt_ctx (bio, inode, pos >> inode->i_blkbits,GFP_KERNEL ); bio->bi_iter.bi_sector =iomap_sector (iomap, pos); - bio->bi_write_hint = inode->i_write_hint; + bio->bi_write_hint = dio->iocb->ki_write_hint; bio->bi_ioprio = dio->iocb->ki_ioprio; bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io;
include/linux/fs.h +8 -0
@@ -370,6 +370,7 @@ struct kiocb {void *private;int ki_flags;u16 ki_ioprio;/* See linux/ioprio.h */ +u16 ki_write_hint;union {/* * Only used for async buffered reads, where it denotes the
@@ -2337,12 +2338,18 @@ static inline bool HAS_UNMAPPED_ID(struct mnt_idmap *idmap, !vfsgid_valid (i_gid_into_vfsgid (idmap, inode)); } +static inline enum rw_hint file_write_hint (struct file *filp) +{ +return file_inode (filp)->i_write_hint; +} +static inline void init_sync_kiocb (struct kiocb *kiocb,struct file *filp) { *kiocb = (struct kiocb ) { .ki_filp = filp, .ki_flags = filp->f_iocb_flags, .ki_ioprio =get_current_ioprio (), + .ki_write_hint =file_write_hint (filp), }; }
@@ -2353,6 +2360,7 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src, .ki_filp = filp, .ki_flags = kiocb_src->ki_flags, .ki_ioprio = kiocb_src->ki_ioprio, + .ki_write_hint = kiocb_src->ki_write_hint, .ki_pos = kiocb_src->ki_pos, }; }
io_uring/rw.c +1 -0
@@ -1027,6 +1027,7 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)if (unlikely (ret))return ret; req->cqe.res =iov_iter_count (&io->iter); + rw->kiocb.ki_write_hint =file_write_hint (rw->kiocb.ki_filp);if (force_nonblock) {/* If the file doesn't support async, just async punt */
Signature · 1 line
2.43.5
Christoph Hellwig
maintainerRe: [PATCHv8 1/6] block, fs: restore kiocb based write hint processing
Quoted 7 lines · Keith Busch
From: Kanchan Joshi <[email protected]>
struct kiocb has a 2 bytes hole that developed post commit
41d36a9f3e53("fs: remove kiocb.ki_hint"). But write hint returned with commit449813515d3e("block, fs: Restore the per-bio/request data lifetime fields").
Quoted 5 lines
This patch uses the leftover space in kiocb to carve 2 byte field
ki_write_hint. Restore the code that operates on kiocb to useki_write_hintinstead of inode hint value.This does not change any behavior, but needed to enable per-io hints.
In this version it doesn't really restore anything, but adds a new
write hinting capability. Similarly to the bio patch we'll probably
need to make clear what is in there instead of having it completely untyped (the exact same appraoch as for the bio should work).
Quoted 17 lines
index
bbd05f1a21453..73629e26becbe100644fs/direct-io.c +1
-1@@ -409,7 +409,7 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio, bio->bi_end_io = dio_bio_end_io;if (dio->is_pinned)bio_set_flag (bio,BIO_PAGE_PINNED ); - bio->bi_write_hint =file_inode (dio->iocb->ki_filp)->i_write_hint; + bio->bi_write_hint = dio->iocb->ki_write_hint; sdio->bio = bio; sdio->logical_offset_in_bio = sdio->cur_page_fs_offset;fs/iomap/direct-io.c +0
-0
fs/iomap/direct-io.c static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, · line 400
Quoted 5 lines
fs/iomap/direct-io.c +1
-1@@ -397,7 +397,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,fscrypt_set_bio_crypt_ctx (bio, inode, pos >> inode->i_blkbits,GFP_KERNEL ); bio->bi_iter.bi_sector =iomap_sector (iomap, pos); - bio->bi_write_hint = inode->i_write_hint; + bio->bi_write_hint = dio->iocb->ki_write_hint;
File system (helper) code should not directly apply this limit, but the file system needs to set it.
fs/iomap/direct-io.c static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,
Quoted 12 lines
fs/iomap/direct-io.c +6
-0+static inline enum rw_hint file_write_hint (struct file *filp) +{ +return file_inode (filp)->i_write_hint; +} +static inline void init_sync_kiocb (struct kiocb *kiocb,struct file *filp) { *kiocb = (struct kiocb ) { .ki_filp = filp, .ki_flags = filp->f_iocb_flags, .ki_ioprio =get_current_ioprio (), + .ki_write_hint =file_write_hint (filp),
And we'll need to distinguish between the per-inode and per file hint. I.e. don't blindly initialize ki_write_hint to the per-inode one here, but make that conditional in the file operation.
Keith Busch
maintainerRe: [PATCHv8 1/6] block, fs: restore kiocb based write hint processing
Quoted 11 lines · Christoph Hellwig
include/linux/fs.h static inline bool HAS_UNMAPPED_ID(struct mnt_idmap *idmap, · line 2352
Quoted 6 lines · Keith Busch
{
include/linux/fs.h +1
-0*kiocb = (struct kiocb ) { .ki_filp = filp, .ki_flags = filp->f_iocb_flags, .ki_ioprio =get_current_ioprio (), + .ki_write_hint =file_write_hint (filp),And we'll need to distinguish between the per-inode and per file hint. I.e. don't blindly initialize
ki_write_hintto the per-inode one here, but make that conditional in the file operation.
Maybe someone wants to do direct-io with partions where each partition has a different default "hint" when not provided a per-io hint? I don't know of such a case, but it doesn't sound terrible. In any case, I feel if you're directing writes through these interfaces, you get to keep all the pieces: user space controls policy, kernel just provides the mechanisms to do it.
Re: [PATCHv8 1/6] block, fs: restore kiocb based write hint processing
Quoted 13 lines · Keith Busch
Quoted 11 lines · Christoph Hellwig
include/linux/fs.h static inline bool HAS_UNMAPPED_ID(struct mnt_idmap *idmap, · line 2352
Quoted 6 lines · Keith Busch
{ *kiocb = (struct kiocb) { .ki_filp = filp, .ki_flags = filp->f_iocb_flags, .ki_ioprio = get_current_ioprio(),include/linux/fs.h +1
-0+ .ki_write_hint = file_write_hint(filp),And we'll need to distinguish between the per-inode and per file hint. I.e. don't blindly initialize
ki_write_hintto the per-inode one here, but make that conditional in the file operation.
Quoted 6 lines
Maybe someone wants to do direct-io with partions where each partition has a different default "hint" when not provided a per-io hint? I don't know of such a case, but it doesn't sound terrible. In any case, I feel if you're directing writes through these interfaces, you get to keep all the pieces: user space controls policy, kernel just provides the mechanisms to do it.
Is it important to support partitions on top of FDP namespaces? We could follow the example of zoned block devices and not support partitions on top of FDP devices. From block/core.c, function add_partition():
/*
* Partitions are not supported on zoned block devices that are used as
* such.
*/
if (bdev_is_zoned(disk->part0)) {
pr_warn("%s: partitions not supported on host managed zoned block
device\n",
disk->disk_name);
return ERR_PTR(-ENXIO);
}Thanks,
Bart.
Keith Busch
maintainerRe: [PATCHv8 1/6] block, fs: restore kiocb based write hint processing
Quoted 14 lines · Bart Van Assche
Quoted 13 lines · Keith Busch
Quoted 11 lines · Christoph Hellwig
include/linux/fs.h static inline bool HAS_UNMAPPED_ID(struct mnt_idmap *idmap, · line 2352
Quoted 6 lines · Keith Busch
{ *kiocb = (struct kiocb) { .ki_filp = filp, .ki_flags = filp->f_iocb_flags, .ki_ioprio = get_current_ioprio(),include/linux/fs.h +1
-0+ .ki_write_hint = file_write_hint(filp),And we'll need to distinguish between the per-inode and per file hint. I.e. don't blindly initialize
ki_write_hintto the per-inode one here, but make that conditional in the file operation.
Quoted 8 lines
Quoted 6 lines
Maybe someone wants to do direct-io with partions where each partition has a different default "hint" when not provided a per-io hint? I don't know of such a case, but it doesn't sound terrible. In any case, I feel if you're directing writes through these interfaces, you get to keep all the pieces: user space controls policy, kernel just provides the mechanisms to do it.
Is it important to support partitions on top of FDP namespaces?
It's already used with partitions, so yes, it's important. Breaking that as a condition to make it work with the block stack is a non-starter.
Christoph Hellwig
maintainerRe: [PATCHv8 1/6] block, fs: restore kiocb based write hint processing
In reply to Keith BuschQuoted 13 lines · Keith Busch
Quoted 11 lines · Christoph Hellwig
include/linux/fs.h static inline bool HAS_UNMAPPED_ID(struct mnt_idmap *idmap, · line 2352
Quoted 6 lines · Keith Busch
{
include/linux/fs.h +1
-0*kiocb = (struct kiocb ) { .ki_filp = filp, .ki_flags = filp->f_iocb_flags, .ki_ioprio =get_current_ioprio (), + .ki_write_hint =file_write_hint (filp),And we'll need to distinguish between the per-inode and per file hint. I.e. don't blindly initialize
ki_write_hintto the per-inode one here, but make that conditional in the file operation.
Quoted 6 lines
Maybe someone wants to do direct-io with partions where each partition has a different default "hint" when not provided a per-io hint? I don't know of such a case, but it doesn't sound terrible. In any case, I feel if you're directing writes through these interfaces, you get to keep all the pieces: user space controls policy, kernel just provides the mechanisms to do it.
Eww. You actually pointed out a real problem here: if a device has multiple partitions the write streams as of this series are shared by them, which breaks their use case as the applications or file systems in different partitions will get other users of the write stream randomly overlayed onto theirs.
So either the available streams need to be split into smaller pools by partitions, or we just assigned them to the first partition to make these scheme work for partitioned devices.
Either way mixing up the per-inode hint and the dynamic one remains a bad idea.
Keith Busch
maintainerRe: [PATCHv8 1/6] block, fs: restore kiocb based write hint processing
Quoted 27 lines · Christoph Hellwig
Quoted 13 lines · Keith Busch
Quoted 11 lines · Christoph Hellwig
include/linux/fs.h static inline bool HAS_UNMAPPED_ID(struct mnt_idmap *idmap, · line 2352
Quoted 6 lines · Keith Busch
{
include/linux/fs.h +1
-0*kiocb = (struct kiocb ) { .ki_filp = filp, .ki_flags = filp->f_iocb_flags, .ki_ioprio =get_current_ioprio (), + .ki_write_hint =file_write_hint (filp),And we'll need to distinguish between the per-inode and per file hint. I.e. don't blindly initialize
ki_write_hintto the per-inode one here, but make that conditional in the file operation.Quoted 6 lines
Maybe someone wants to do direct-io with partions where each partition has a different default "hint" when not provided a per-io hint? I don't know of such a case, but it doesn't sound terrible. In any case, I feel if you're directing writes through these interfaces, you get to keep all the pieces: user space controls policy, kernel just provides the mechanisms to do it.
Eww. You actually pointed out a real problem here: if a device has multiple partitions the write streams as of this series are shared by them, which breaks their use case as the applications or file systems in different partitions will get other users of the write stream randomly overlayed onto theirs.
Quoted 6 lines
So either the available streams need to be split into smaller pools by partitions, or we just assigned them to the first partition to make these scheme work for partitioned devices.
Either way mixing up the per-inode hint and the dynamic one remains a bad idea.
No doubt it's almost certainly not a good idea to mix different stream usages, but that's not the kernels problem. It's user space policy. I don't think the kernel needs to perform any heroic efforts to split anything here. Just keep it simple.
Christoph Hellwig
maintainerRe: [PATCHv8 1/6] block, fs: restore kiocb based write hint processing
Quoted 4 lines · Keith Busch
No doubt it's almost certainly not a good idea to mix different stream usages, but that's not the kernels problem. It's user space policy. I don't think the kernel needs to perform any heroic efforts to split anything here. Just keep it simple.
Unfortunately it's not. This complicated breaks any intelligent scheme to manage them. You can't write portable code assuming you can know write streams when you need to cope with someone else using some or all of the same resources.
Re: [PATCHv8 1/6] block, fs: restore kiocb based write hint processing
In reply to Keith Buschinclude/linux/fs.h struct kiocb { · line 376
Quoted 12 lines · Keith Busch
include/linux/fs.h +1
-0@@ -370,6 +370,7 @@ struct kiocb {void *private;int ki_flags;u16 ki_ioprio;/* See linux/ioprio.h */ +u16 ki_write_hint;union {/* * Only used for async buffered reads, where it denotes the
Why 'u16'? Shouldn't this patch use the type 'enum rw_hint' for ki_write_hint and shouldn't this type be changed into u16 in a later patch?
Thanks,
Bart.
PATCH v8 2/6 block: use generic u16 for write hints
In reply to Keith BuschFrom: Keith Busch <[email protected]>
This is still backwards compatible with lifetime hints. It just doesn't constrain the hints to that definition.
--- include/linux/blk-mq.h | 3 +-- include/linux/blk_types.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
include/linux/blk-mq.h +1 -2
@@ -8,7 +8,6 @@#include <linux/scatterlist.h> #include <linux/prefetch.h> #include <linux/srcu.h> -#include <linux/rw_hint.h> struct blk_mq_tags ;struct blk_flush_queue ;
@@ -156,7 +155,7 @@ struct request {struct blk_crypto_keyslot *crypt_keyslot;#endif -enum rw_hint write_hint; +unsigned short write_hint;unsigned short ioprio;enum mq_rq_state state;
include/linux/blk_types.h +1 -1
@@ -219,7 +219,7 @@ struct bio {*/ unsigned short bi_flags;/* BIO_* below */ unsigned short bi_ioprio; -enum rw_hint bi_write_hint; +unsigned short bi_write_hint;blk_status_t bi_status;atomic_t __bi_remaining;
Signature · 1 line
2.43.5
Christoph Hellwig
maintainerRe: [PATCHv8 2/6] block: use generic u16 for write hints
Quoted 4 lines · Keith Busch
From: Keith Busch <[email protected]>
This is still backwards compatible with lifetime hints. It just doesn't constrain the hints to that definition.
So in the end we'll end up with two uses of it - the existing 5 temperature hints and the new stream separation. I think it would be cleaner to make it a union, but I don't care that strongly.
But we probably want a way to distinguish which one is supported.
E.g. for SCSI we set a net BLK_FEAT_WRITE_HINTS, for NVMe we'll set BLK_FEAT_STREAM_SEPARATION.
Either way this should probably be the first patch in the series.
Keith Busch
maintainerRe: [PATCHv8 2/6] block: use generic u16 for write hints
Quoted 11 lines · Christoph Hellwig
Quoted 4 lines · Keith Busch
From: Keith Busch <[email protected]>
This is still backwards compatible with lifetime hints. It just doesn't constrain the hints to that definition.
So in the end we'll end up with two uses of it - the existing 5 temperature hints and the new stream separation. I think it would be cleaner to make it a union, but I don't care that strongly.
Quoted 6 lines
But we probably want a way to distinguish which one is supported.
E.g. for SCSI we set a net
BLK_FEAT_WRITE_HINTS, for NVMe we'll setBLK_FEAT_STREAM_SEPARATION.Either way this should probably be the first patch in the series.
I'm not sure I follow this feedback. The SCSI feature is defined as a lifetime stream association in SBC-5. So it's still a stream for SCSI, but you want to call it "WRITE_HINT", which is not a term used in the SCSI spec for this feature. But, you want to call it STREAM_SEPARATION for NVMe only, even though the FDP spec doesn't use that term? What's wrong with just calling it a generic hint support feature?
I also don't see why SCSI couldn't use per-io hints just like this enables for NVMe. The spec doesn't limit SCSI to just 5 streams, so this provides a way to access them all through the raw block device.
Christoph Hellwig
maintainerRe: [PATCHv8 2/6] block: use generic u16 for write hints
Quoted 6 lines · Keith Busch
I'm not sure I follow this feedback. The SCSI feature is defined as a lifetime stream association in SBC-5. So it's still a stream for SCSI, but you want to call it "
WRITE_HINT", which is not a term used in the SCSI spec for this feature. But, you want to call itSTREAM_SEPARATIONfor NVMe only, even though the FDP spec doesn't use that term? What's wrong with just calling it a generic hint support feature?
The "Constrained Streams with Data Lifetimes" are called streams for political reasons but they are not. They are buckets of different data lifetimes.
Quoted 3 lines
I also don't see why SCSI couldn't use per-io hints just like this enables for NVMe. The spec doesn't limit SCSI to just 5 streams, so this provides a way to access them all through the raw block device.
I don't mind passing per-I/O temperature hints to SCSI block devices.
But we should not confuse a streams/FDP like streams that are different context which are assumed to be discarded together and have a concept of Stream Granularity Size or Reclaim Unit size with the data temperature hints that are at the storage level fundamentally per-I/O and just bucket into temperature group without any indication of data locality.
Re: [PATCHv8 2/6] block: use generic u16 for write hints
In reply to Keith BuschQuoted 11 lines · Keith Busch
From: Keith Busch <[email protected]>
This is still backwards compatible with lifetime hints. It just doesn't constrain the hints to that definition.
Signed-off-by Keith Busch <[email protected]>--- include/linux/blk-mq.h | 3 +-- include/linux/blk_types.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCHv8 2/6] block: use generic u16 for write hints
In reply to Keith Buschinclude/linux/blk-mq.h struct request { · line 158
Quoted 6 lines · Keith Busch
include/linux/blk-mq.h +1
-1@@ -156,7 +155,7 @@ struct request {struct blk_crypto_keyslot *crypt_keyslot;#endif -enum rw_hint write_hint; +unsigned short write_hint;
Why 'u16' for ki_write_hint and 'unsigned short' for write_hint? Isn't that inconsistent?
Thanks,
Bart.
Keith Busch
maintainerRe: [PATCHv8 2/6] block: use generic u16 for write hints
Quoted 9 lines · Bart Van Assche
include/linux/blk-mq.h struct request { · line 157
Quoted 5 lines · Keith Busch
include/linux/blk-mq.h +1
-1@@ -156,7 +155,7 @@ struct request {struct blk_crypto_keyslot *crypt_keyslot;#endif -enum rw_hint write_hint; +unsigned short write_hint;Why 'u16' for
ki_write_hintand 'unsigned short' forwrite_hint? Isn't that inconsistent?
It's consistent with the local convetion of the existing structs. Some use unsiged short, others use u16. It looks weird to mix the types within the same struct.
PATCH v8 3/6 block: introduce max_write_hints queue limit
In reply to Keith BuschFrom: Keith Busch <[email protected]>
Drivers with hardware that support write hints need a way to export how many are available so applications can generically query this.
--- Documentation/ABI/stable/sysfs-block | 7 +++++++ block/blk-settings.c | 3 +++ block/blk-sysfs.c | 3 +++ block/fops.c | 2 ++ include/linux/blkdev.h | 12 ++++++++++++ 5 files changed, 27 insertions(+)
Documentation/ABI/stable/sysfs-block +7 -0
@@ -506,6 +506,13 @@ Description: [RO] Maximum size in bytes of a single element in a DMA scatter/gather list. +What: /sys/block/<disk>/queue/max_write_hints +Date: October 2024 +Contact: [email protected] +Description: + [RO] Maximum number of write hints supported, 0 if not + supported. If supported, valid values are 1 through + max_write_hints, inclusive. What: /sys/block/<disk>/queue/max_segments Date: March 2010
block/blk-settings.c +3 -0
@@ -43,6 +43,7 @@ void blk_set_stacking_limits(struct queue_limits *lim) lim->seg_boundary_mask =BLK_SEG_BOUNDARY_MASK ;/* Inherit limits from component devices */ + lim->max_write_hints =USHRT_MAX ; lim->max_segments =USHRT_MAX ; lim->max_discard_segments =USHRT_MAX ; lim->max_hw_sectors =UINT_MAX ;
@@ -544,6 +545,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->max_segment_size =min_not_zero (t->max_segment_size, b->max_segment_size); + t->max_write_hints =min (t->max_write_hints, b->max_write_hints); + alignment =queue_limit_alignment_offset (b, start);/* Bottom device has different alignment. Check that it is
block/blk-sysfs.c +3 -0
@@ -104,6 +104,7 @@ QUEUE_SYSFS_LIMIT_SHOW(max_segments) QUEUE_SYSFS_LIMIT_SHOW(max_discard_segments) QUEUE_SYSFS_LIMIT_SHOW(max_integrity_segments) QUEUE_SYSFS_LIMIT_SHOW(max_segment_size) +QUEUE_SYSFS_LIMIT_SHOW(max_write_hints) QUEUE_SYSFS_LIMIT_SHOW(logical_block_size) QUEUE_SYSFS_LIMIT_SHOW(physical_block_size) QUEUE_SYSFS_LIMIT_SHOW(chunk_sectors)
@@ -457,6 +458,7 @@ QUEUE_RO_ENTRY(queue_max_hw_sectors, "max_hw_sectors_kb");QUEUE_RO_ENTRY (queue_max_segments,"max_segments" );QUEUE_RO_ENTRY (queue_max_integrity_segments,"max_integrity_segments" );QUEUE_RO_ENTRY (queue_max_segment_size,"max_segment_size" ); +QUEUE_RO_ENTRY (queue_max_write_hints,"max_write_hints" );QUEUE_RW_LOAD_MODULE_ENTRY (elv_iosched,"scheduler" );QUEUE_RO_ENTRY (queue_logical_block_size,"logical_block_size" );
@@ -591,6 +593,7 @@ static struct attribute *queue_attrs[] = { &queue_max_discard_segments_entry.attr, &queue_max_integrity_segments_entry.attr, &queue_max_segment_size_entry.attr, + &queue_max_write_hints_entry.attr, &queue_hw_sector_size_entry.attr, &queue_logical_block_size_entry.attr, &queue_physical_block_size_entry.attr,
block/fops.c +2 -0
@@ -376,6 +376,8 @@ static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter)if (blkdev_dio_invalid (bdev, iocb->ki_pos, iter, is_atomic))return -EINVAL ; +if (iocb->ki_write_hint >bdev_max_write_hints (bdev)) +return -EINVAL ; nr_pages =bio_iov_vecs_to_alloc (iter,BIO_MAX_VECS +1 );if (likely (nr_pages <=BIO_MAX_VECS )) {
include/linux/blkdev.h +12 -0
@@ -393,6 +393,8 @@ struct queue_limits {unsigned short max_integrity_segments;unsigned short max_discard_segments; +unsigned short max_write_hints; +unsigned int max_open_zones;unsigned int max_active_zones;
@@ -1183,6 +1185,11 @@ static inline unsigned short queue_max_segments(const struct request_queue *q)return q->limits.max_segments; } +static inline unsigned short queue_max_write_hints (struct request_queue *q) +{ +return q->limits.max_write_hints; +} +static inline unsigned short queue_max_discard_segments (const struct request_queue *q) {return q->limits.max_discard_segments;
@@ -1230,6 +1237,11 @@ static inline unsigned int bdev_max_segments(struct block_device *bdev)return queue_max_segments (bdev_get_queue (bdev)); } +static inline unsigned short bdev_max_write_hints (struct block_device *bdev) +{ +return queue_max_write_hints (bdev_get_queue (bdev)); +} +static inline unsigned queue_logical_block_size (const struct request_queue *q) {return q->limits.logical_block_size;
Signature · 1 line
2.43.5
Christoph Hellwig
maintainerRe: [PATCHv8 3/6] block: introduce max_write_hints queue limit
Quoted 4 lines · Keith Busch
From: Keith Busch <[email protected]>
Drivers with hardware that support write hints need a way to export how many are available so applications can generically query this.
Calling this write hints vs write streams is very confusing.
Otherwise this looks reasonable.
Re: [PATCHv8 3/6] block: introduce max_write_hints queue limit
In reply to Keith BuschQuoted 5 lines · Keith Busch
From: Keith Busch <[email protected]>
Drivers with hardware that support write hints need a way to export how many are available so applications can generically query this.
Quoted 9 lines
Signed-off-by Keith Busch <[email protected]>--- Documentation/ABI/stable/sysfs-block | 7 +++++++ block/blk-settings.c | 3 +++ block/blk-sysfs.c | 3 +++ block/fops.c | 2 ++ include/linux/blkdev.h | 12 ++++++++++++ 5 files changed, 27 insertions(+)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCHv8 3/6] block: introduce max_write_hints queue limit
In reply to Keith BuschQuoted 2 lines · Keith Busch
Drivers with hardware that support write hints need a way to export how many are available so applications can generically query this.
Something is missing from this patch, namely a change for the SCSI disk (sd) driver that sets max_write_hints to sdkp->permanent_stream_count.
Documentation/ABI/stable/sysfs-block Description: · line 515
Quoted 7 lines
Documentation/ABI/stable/sysfs-block +7
-0+What: /sys/block/<disk>/queue/max_write_hints +Date: October 2024 +Contact: [email protected] +Description: + [RO] Maximum number of write hints supported, 0 if not + supported. If supported, valid values are 1 through + max_write_hints, inclusive.
That's a bit short. I think it would help to add a reference to the aspects of the standards related to this attribute: permanent streams for SCSI and FDP for NVMe.
Quoted 13 lines
block/blk-settings.c +1
-0@@ -43,6 +43,7 @@ void blk_set_stacking_limits(struct queue_limits *lim) lim->seg_boundary_mask =BLK_SEG_BOUNDARY_MASK ;/* Inherit limits from component devices */ + lim->max_write_hints =USHRT_MAX ; lim->max_segments =USHRT_MAX ; lim->max_discard_segments =USHRT_MAX ; lim->max_hw_sectors =UINT_MAX ;
block/blk-settings.c int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, · line 551
Quoted 7 lines
block/blk-settings.c +2
-0@@ -544,6 +545,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->max_segment_size =min_not_zero (t->max_segment_size, b->max_segment_size); + t->max_write_hints =min (t->max_write_hints, b->max_write_hints); + alignment =queue_limit_alignment_offset (b, start);
I prefer that lim->max_write_hints is initialized to zero in blk_set_stacking_limits() and that blk_stack_limits() uses min_not_zero().
Thanks,
Bart.
Keith Busch
maintainerRe: [PATCHv8 3/6] block: introduce max_write_hints queue limit
Quoted 6 lines · Bart Van Assche
Quoted 2 lines · Keith Busch
Drivers with hardware that support write hints need a way to export how many are available so applications can generically query this.
Something is missing from this patch, namely a change for the SCSI disk (sd) driver that sets
max_write_hintstosdkp->permanent_stream_count.
Shouldn't someone who cares about scsi do that? I certainly don't care, nor have I been keeping up with what's happening there, so I'm also unqualified.
Quoted 11 lines
Documentation/ABI/stable/sysfs-block Description: · line 515
Quoted 7 lines
Documentation/ABI/stable/sysfs-block +7
-0+What: /sys/block/<disk>/queue/max_write_hints +Date: October 2024 +Contact: [email protected] +Description: + [RO] Maximum number of write hints supported, 0 if not + supported. If supported, valid values are 1 through + max_write_hints, inclusive.That's a bit short. I think it would help to add a reference to the aspects of the standards related to this attribute: permanent streams for SCSI and FDP for NVMe.
The specs regarding write hints have not historically been stable, so I'd rather not tie kernel docs to volatile external specifications.
Quoted 13 lines
Quoted 13 lines
block/blk-settings.c +1
-0@@ -43,6 +43,7 @@ void blk_set_stacking_limits(struct queue_limits *lim) lim->seg_boundary_mask =BLK_SEG_BOUNDARY_MASK ;/* Inherit limits from component devices */ + lim->max_write_hints =USHRT_MAX ; lim->max_segments =USHRT_MAX ; lim->max_discard_segments =USHRT_MAX ; lim->max_hw_sectors =UINT_MAX ;@@ -544,6 +545,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->max_segment_size = min_not_zero(t->max_segment_size,
Quoted 8 lines
block/blk-settings.c int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, · line 550
Quoted 4 lines
block/blk-settings.c +2
-0b->max_segment_size); + t->max_write_hints =min (t->max_write_hints, b->max_write_hints); + alignment =queue_limit_alignment_offset (b, start);I prefer that
lim->max_write_hintsis initialized to zero inblk_set_stacking_limits()and thatblk_stack_limits()usesmin_not_zero().
How is a device supposed to report it doesn't support a write hint if 0 gets overridden?
PATCH v8 4/6 fs: introduce per-io hint support flag
In reply to Keith BuschFrom: Keith Busch <[email protected]>
A block device may support write hints on a per-io basis. The raw block file operations can effectively use these, but real filesystems are not ready to make use of this. Provide a file_operations flag to indicate support, and set it for the block file operations.
--- block/fops.c | 2 +- include/linux/fs.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
block/fops.c +1 -1
@@ -869,7 +869,7 @@ const struct file_operations def_blk_fops = { .splice_write = iter_file_splice_write, .fallocate = blkdev_fallocate, .uring_cmd = blkdev_uring_cmd, - .fop_flags = FOP_BUFFER_RASYNC, + .fop_flags = FOP_BUFFER_RASYNC | FOP_PER_IO_HINTS, };static __init int blkdev_init (void )
include/linux/fs.h +2 -0
@@ -2117,6 +2117,8 @@ struct file_operations {#define FOP_HUGE_PAGES ((__force fop_flags_t)(1 << 4))/* Treat loff_t as unsigned (e.g., /dev/mem) */ #define FOP_UNSIGNED_OFFSET ((__force fop_flags_t)(1 << 5)) +/* File system can handle per-io hints */ +#define FOP_PER_IO_HINTS ((__force fop_flags_t)(1 << 6))/* Wrap a directory iterator that needs exclusive inode access */ int wrap_directory_iterator(struct file *, struct dir_context *,
Signature · 1 line
2.43.5
Christoph Hellwig
maintainerRe: [PATCHv8 4/6] fs: introduce per-io hint support flag
Quoted 6 lines · Keith Busch
From: Keith Busch <[email protected]>
A block device may support write hints on a per-io basis. The raw block file operations can effectively use these, but real filesystems are not ready to make use of this. Provide a
file_operationsflag to indicate support, and set it for the block file operations.
I'm a little worried about the overly generic "hint" think again. Make it very explicit about the write streams and this make sense.
Re: [PATCHv8 4/6] fs: introduce per-io hint support flag
In reply to Keith BuschQuoted 7 lines · Keith Busch
From: Keith Busch <[email protected]>
A block device may support write hints on a per-io basis. The raw block file operations can effectively use these, but real filesystems are not ready to make use of this. Provide a
file_operationsflag to indicate support, and set it for the block file operations.
Quoted 6 lines
Signed-off-by Keith Busch <[email protected]>--- block/fops.c | 2 +- include/linux/fs.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
PATCH v8 5/6 io_uring: enable per-io hinting capability
In reply to Keith BuschFrom: Kanchan Joshi <[email protected]>
With F_SET_RW_HINT fcntl, user can set a hint on the file inode, and all the subsequent writes on the file pass that hint value down. This can be limiting for block device as all the writes can be tagged with only one lifetime hint value. Concurrent writes (with different hint values) are hard to manage. Per-IO hinting solves that problem.
Allow userspace to pass additional metadata in the SQE.
__u16 write_hint;
This accepts all hint values that the file allows.
The write handlers (io_prep_rw, io_write) send the hint value to lower-layer using kiocb. This is good for upporting direct IO, but not when kiocb is not available (e.g., buffered IO).
When per-io hints are not passed, the per-inode hint values are set in the kiocb (as before). Otherwise, per-io hints take the precedence over per-inode hints.
--- include/uapi/linux/io_uring.h | 4 ++++ io_uring/rw.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
include/uapi/linux/io_uring.h +4 -0
@@ -92,6 +92,10 @@ struct io_uring_sqe {__u16 addr_len;__u16 __pad3[1 ]; }; +struct { +__u16 write_hint; +__u16 __pad4[1 ]; + }; }; union { struct {
io_uring/rw.c +9 -2
@@ -279,7 +279,11 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, rw->kiocb.ki_ioprio =get_current_ioprio (); } rw->kiocb.dio_complete =NULL ; - +if (ddir ==ITER_SOURCE && + req->file->f_op->fop_flags &FOP_PER_IO_HINTS ) + rw->kiocb.ki_write_hint =READ_ONCE (sqe->write_hint); +else + rw->kiocb.ki_write_hint =WRITE_LIFE_NOT_SET ; rw->addr =READ_ONCE (sqe->addr); rw->len =READ_ONCE (sqe->len); rw->flags =READ_ONCE (sqe->rw_flags);
@@ -1027,7 +1031,10 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)if (unlikely (ret))return ret; req->cqe.res =iov_iter_count (&io->iter); - rw->kiocb.ki_write_hint =file_write_hint (rw->kiocb.ki_filp); + +/* Use per-file hint only if per-io hint is not set. */ +if (rw->kiocb.ki_write_hint ==WRITE_LIFE_NOT_SET ) + rw->kiocb.ki_write_hint =file_write_hint (rw->kiocb.ki_filp);if (force_nonblock) {/* If the file doesn't support async, just async punt */
Signature · 1 line
2.43.5
Christoph Hellwig
maintainerRe: [PATCHv8 5/6] io_uring: enable per-io hinting capability
Same hint vs write stream thing here as well.
io_uring/rw.c static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, · line 286
Quoted 5 lines
io_uring/rw.c +5
-0+if (ddir ==ITER_SOURCE && + req->file->f_op->fop_flags &FOP_PER_IO_HINTS ) + rw->kiocb.ki_write_hint =READ_ONCE (sqe->write_hint); +else + rw->kiocb.ki_write_hint =WRITE_LIFE_NOT_SET ;
WRITE_LIFE_NOT_SET is in the wrong namespae vs the separate streams.
Either use 0 directly or add a separate constant for it.
Re: [PATCHv8 5/6] io_uring: enable per-io hinting capability
In reply to Keith BuschQuoted 22 lines · Keith Busch
From: Kanchan Joshi <[email protected]>
With
F_SET_RW_HINTfcntl, user can set a hint on the file inode, and all the subsequent writes on the file pass that hint value down. This can be limiting for block device as all the writes can be tagged with only one lifetime hint value. Concurrent writes (with different hint values) are hard to manage. Per-IO hinting solves that problem.Allow userspace to pass additional metadata in the SQE.
__u16 write_hint;This accepts all hint values that the file allows.
The write handlers (
io_prep_rw,io_write) send the hint value to lower-layer using kiocb. This is good for upporting direct IO, but not when kiocb is not available (e.g., buffered IO).When per-io hints are not passed, the per-inode hint values are set in the kiocb (as before). Otherwise, per-io hints take the precedence over per-inode hints.
Quoted 8 lines
Signed-off-by Kanchan Joshi <[email protected]>Signed-off-by Nitesh Shetty <[email protected]>Signed-off-by Keith Busch <[email protected]>--- include/uapi/linux/io_uring.h | 4 ++++ io_uring/rw.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Keith Busch
NAKPATCH v8 6/6 nvme: enable FDP support
In reply to Keith BuschFrom: Kanchan Joshi <[email protected]>
Flexible Data Placement (FDP), as ratified in TP 4146a, allows the host to control the placement of logical blocks so as to reduce the SSD WAF. Userspace can send the write hint information using io_uring or fcntl.
Fetch the placement-identifiers if the device supports FDP. The incoming write-hint is mapped to a placement-identifier, which in turn is set in the DSPEC field of the write command.
--- drivers/nvme/host/core.c | 82 ++++++++++++++++++++++++++++++++++++++++ drivers/nvme/host/nvme.h | 5 +++ include/linux/nvme.h | 19 ++++++++++ 3 files changed, 106 insertions(+)
drivers/nvme/host/core.c +82 -0
@@ -44,6 +44,20 @@ struct nvme_ns_info {bool is_removed; }; +struct nvme_fdp_ruh_status_desc { +u16 pid; +u16 ruhid; +u32 earutr; +u64 ruamw; +u8 rsvd16[16 ]; +}; + +struct nvme_fdp_ruh_status { +u8 rsvd0[14 ]; +__le16 nruhsd; +struct nvme_fdp_ruh_status_desc ruhsd[]; +}; +unsigned int admin_timeout =60 ;module_param (admin_timeout, uint,0644 );MODULE_PARM_DESC (admin_timeout,"timeout in seconds for admin commands" );
@@ -657,6 +671,7 @@ static void nvme_free_ns_head(struct kref *ref)ida_free (&head->subsys->ns_ida, head->instance);cleanup_srcu_struct (&head->srcu);nvme_put_subsystem (head->subsys); +kfree (head->plids);kfree (head); }
@@ -974,6 +989,13 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,if (req->cmd_flags &REQ_RAHEAD ) dsmgmt |=NVME_RW_DSM_FREQ_PREFETCH ; +if (req->write_hint !=WRITE_LIFE_NOT_SET && ns->head->nr_plids) { +u16 hint =max (req->write_hint, ns->head->nr_plids); + + dsmgmt |= ns->head->plids[hint -1 ] <<16 ; + control |=NVME_RW_DTYPE_DPLCMT ; + } +if (req->cmd_flags &REQ_ATOMIC && !nvme_valid_atomic_write (req))return BLK_STS_INVAL ;
@@ -2114,6 +2136,52 @@ static int nvme_update_ns_info_generic(struct nvme_ns *ns,return ret; } +static int nvme_fetch_fdp_plids (struct nvme_ns *ns,u32 nsid) +{ +struct nvme_fdp_ruh_status_desc *ruhsd; +struct nvme_ns_head *head = ns->head; +struct nvme_fdp_ruh_status *ruhs; +struct nvme_command c = {}; +int size, ret, i; + +if (head->plids) +return 0 ; + + size =struct_size (ruhs, ruhsd,NVME_MAX_PLIDS ); + ruhs =kzalloc (size,GFP_KERNEL ); +if (!ruhs) +return -ENOMEM ; + + c.imr.opcode = nvme_cmd_io_mgmt_recv; + c.imr.nsid =cpu_to_le32 (nsid); + c.imr.mo =0x1 ; + c.imr.numd =cpu_to_le32 ((size >>2 ) -1 ); + + ret =nvme_submit_sync_cmd (ns->queue, &c, ruhs, size); +if (ret) + goto out; + + i =le16_to_cpu (ruhs->nruhsd); +if (!i) + goto out; + + ns->head->nr_plids =min_t (u16, i,NVME_MAX_PLIDS ); + head->plids =kcalloc (ns->head->nr_plids,sizeof (head->plids), +GFP_KERNEL ); +if (!head->plids) { + ret = -ENOMEM ; + goto out; + } + +for (i =0 ; i < ns->head->nr_plids; i++) { + ruhsd = &ruhs->ruhsd[i]; + head->plids[i] =le16_to_cpu (ruhsd->pid); + } +out: +kfree (ruhs); +return ret; +} +static int nvme_update_ns_info_block (struct nvme_ns *ns,struct nvme_ns_info *info) {
@@ -2150,6 +2218,19 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, goto out; } +if (ns->ctrl->ctratt &NVME_CTRL_ATTR_FDPS ) { + ret =nvme_fetch_fdp_plids (ns, info->nsid); +if (ret) +dev_warn (ns->ctrl->device, +"FDP failure status:0x%x\n" , ret); +if (ret <0 ) + goto out; + }else { + ns->head->nr_plids =0 ; +kfree (ns->head->plids); + ns->head->plids =NULL ; + } +blk_mq_freeze_queue (ns->disk->queue); ns->head->lba_shift = id->lbaf[lbaf].ds; ns->head->nuse =le64_to_cpu (id->nuse);
@@ -2180,6 +2261,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,if (!nvme_init_integrity (ns->head, &lim, info)) capacity =0 ; + lim.max_write_hints = ns->head->nr_plids; ret =queue_limits_commit_update (ns->disk->queue, &lim);if (ret) {blk_mq_unfreeze_queue (ns->disk->queue);
drivers/nvme/host/nvme.h +5 -0
@@ -454,6 +454,8 @@ struct nvme_ns_ids {u8 csi; }; +#define NVME_MAX_PLIDS (NVME_CTRL_PAGE_SIZE / sizeof(16)) +/* * Anchor structure for namespaces. There is one for each namespace in a * NVMe subsystem that any of our controllers can see, and the namespace
@@ -490,6 +492,9 @@ struct nvme_ns_head {struct device cdev_device;struct gendisk *disk; + +u16 nr_plids; +u16 *plids;#ifdef CONFIG_NVME_MULTIPATH struct bio_list requeue_list;spinlock_t requeue_lock;
include/linux/nvme.h +19 -0
@@ -275,6 +275,7 @@ enum nvme_ctrl_attr {NVME_CTRL_ATTR_HID_128_BIT = (1 <<0 ),NVME_CTRL_ATTR_TBKAS = (1 <<6 ),NVME_CTRL_ATTR_ELBAS = (1 <<15 ), + NVME_CTRL_ATTR_FDPS = (1 << 19), }; struct nvme_id_ctrl {
@@ -843,6 +844,7 @@ enum nvme_opcode { nvme_cmd_resv_register =0x0d , nvme_cmd_resv_report =0x0e , nvme_cmd_resv_acquire =0x11 , + nvme_cmd_io_mgmt_recv =0x12 , nvme_cmd_resv_release =0x15 , nvme_cmd_zone_mgmt_send =0x79 , nvme_cmd_zone_mgmt_recv = 0x7a,
@@ -864,6 +866,7 @@ enum nvme_opcode {nvme_opcode_name (nvme_cmd_resv_register), \nvme_opcode_name (nvme_cmd_resv_report), \nvme_opcode_name (nvme_cmd_resv_acquire), \ +nvme_opcode_name (nvme_cmd_io_mgmt_recv), \nvme_opcode_name (nvme_cmd_resv_release), \nvme_opcode_name (nvme_cmd_zone_mgmt_send), \ nvme_opcode_name(nvme_cmd_zone_mgmt_recv), \
@@ -1015,6 +1018,7 @@ enum {NVME_RW_PRINFO_PRCHK_GUARD =1 <<12 ,NVME_RW_PRINFO_PRACT =1 <<13 ,NVME_RW_DTYPE_STREAMS =1 <<4 , +NVME_RW_DTYPE_DPLCMT =2 <<4 , NVME_WZ_DEAC = 1 << 9, };
@@ -1102,6 +1106,20 @@ struct nvme_zone_mgmt_recv_cmd {__le32 cdw14[2 ]; }; +struct nvme_io_mgmt_recv_cmd { +__u8 opcode; +__u8 flags; +__u16 command_id; +__le32 nsid; +__le64 rsvd2[2 ]; +union nvme_data_ptr dptr; +__u8 mo; +__u8 rsvd11; +__u16 mos; +__le32 numd; +__le32 cdw12[4 ]; +}; +enum {NVME_ZRA_ZONE_REPORT =0 ,NVME_ZRASF_ZONE_REPORT_ALL =0 ,
@@ -1822,6 +1840,7 @@ struct nvme_command {struct nvmf_auth_receive_command auth_receive;struct nvme_dbbuf dbbuf;struct nvme_directive_cmd directive; +struct nvme_io_mgmt_recv_cmd imr; }; };
Signature · 1 line
2.43.5
Re: [PATCHv8 6/6] nvme: enable FDP support
drivers/nvme/host/nvme.h struct nvme_ns_ids { · line 458
Quoted 3 lines · Keith Busch
drivers/nvme/host/nvme.h +2
-0+#define NVME_MAX_PLIDS (NVME_CTRL_PAGE_SIZE / sizeof(16)) +
Seems you intended sizeof(u16).
Keith Busch
maintainerRe: [PATCHv8 6/6] nvme: enable FDP support
Quoted 6 lines · Kanchan Joshi
drivers/nvme/host/nvme.h struct nvme_ns_ids { · line 458
Quoted 3 lines · Keith Busch
drivers/nvme/host/nvme.h +2
-0+#define NVME_MAX_PLIDS (NVME_CTRL_PAGE_SIZE / sizeof(16)) +Seems you intended sizeof(u16).
Ha, yes, that's the intended type. I don't have anything close to 1k placement hints, so would have never noticed this was the wrong size.
kernel test robot
build botRe: [PATCHv8 6/6] nvme: enable FDP support
In reply to Keith Buschkernel test robot noticed the following build warnings:
Hi Keith,
kernel test robot noticed the following build warnings:
[auto build test WARNING on axboe-block/for-next]
[also build test WARNING on linus/master v6.12-rc3]
[cannot apply to brauner-vfs/vfs.all next-20241018]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Keith-Busch/block-fs-restore-kiocb-based-write-hint-processing/20241018-041459 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next patch link: https://lore.kernel.org/r/20241017160937.2283225-7-kbusch%40meta.com patch subject: [PATCHv8 6/6] nvme: enable FDP support config: i386-randconfig-061-20241019 (https://download.01.org/0day-ci/archive/20241019/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241019/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/nvme/host/core.c:2178:34: sparse: sparse: cast to restricted __le16
vim +2178 drivers/nvme/host/core.c
2138
2139 static int nvme_fetch_fdp_plids(struct nvme_ns *ns, u32 nsid)
2140 {
2141 struct nvme_fdp_ruh_status_desc *ruhsd;
2142 struct nvme_ns_head *head = ns->head;
2143 struct nvme_fdp_ruh_status *ruhs;
2144 struct nvme_command c = {};
2145 int size, ret, i;
2146
2147 if (head->plids)
2148 return 0;
2149
2150 size = struct_size(ruhs, ruhsd, NVME_MAX_PLIDS);
2151 ruhs = kzalloc(size, GFP_KERNEL);
2152 if (!ruhs)
2153 return -ENOMEM;
2154
2155 c.imr.opcode = nvme_cmd_io_mgmt_recv;
2156 c.imr.nsid = cpu_to_le32(nsid);
2157 c.imr.mo = 0x1;
2158 c.imr.numd = cpu_to_le32((size >> 2) - 1);
2159
2160 ret = nvme_submit_sync_cmd(ns->queue, &c, ruhs, size);
2161 if (ret)
2162 goto out;
2163
2164 i = le16_to_cpu(ruhs->nruhsd);
2165 if (!i)
2166 goto out;
2167
2168 ns->head->nr_plids = min_t(u16, i, NVME_MAX_PLIDS);
2169 head->plids = kcalloc(ns->head->nr_plids, sizeof(head->plids),
2170 GFP_KERNEL);
2171 if (!head->plids) {
2172 ret = -ENOMEM;
2173 goto out;
2174 }
2175
2176 for (i = 0; i < ns->head->nr_plids; i++) {
2177 ruhsd = &ruhs->ruhsd[i];
> 2178 head->plids[i] = le16_to_cpu(ruhsd->pid);
2179 }
2180 out:
2181 kfree(ruhs);
2182 return ret;
2183 }
2184
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCHv8 6/6] nvme: enable FDP support
In reply to Keith BuschHi Keith,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Keith-Busch/block-fs-restore-kiocb-based-write-hint-processing/20241018-041459 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next patch link: https://lore.kernel.org/r/20241017160937.2283225-7-kbusch%40meta.com patch subject: [PATCHv8 6/6] nvme: enable FDP support config: nios2-randconfig-r072-20241019 (https://download.01.org/0day-ci/archive/20241020/[email protected]/config) compiler: nios2-linux-gcc (GCC) 14.1.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
New smatch warnings:drivers/nvme/host/core.c:2150 nvme_fetch_fdp_plids() warn: sizeof(NUMBER)?
vim +2150 drivers/nvme/host/core.c
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2139 static int nvme_fetch_fdp_plids(struct nvme_ns *ns, u32 nsid)
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2140 {
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2141 struct nvme_fdp_ruh_status_desc *ruhsd;
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2142 struct nvme_ns_head *head = ns->head;
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2143 struct nvme_fdp_ruh_status *ruhs;
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2144 struct nvme_command c = {};
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2145 int size, ret, i;
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2146
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2147 if (head->plids)
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2148 return 0;
b5bb76d576eb00 Kanchan Joshi 2024-10-17 2149 b5bb76d576eb00 Kanchan Joshi 2024-10-17 @2150 size = struct_size(ruhs, ruhsd, NVME_MAX_PLIDS);
NVME_MAX_PLIDS is defined as:
#define NVME_MAX_PLIDS (NVME_CTRL_PAGE_SIZE / sizeof(16))
Probably it should be just 16. Or possibly sizeof(int) but that seems unlikely.
regards,
dan carpenter