[PATCH v2] nvme: check if the namespace supports metadata in nvme_map_user_request()
Puranjay Mohan
pjy at amazon.com
Wed Aug 28 08:31:09 PDT 2024
Keith Busch <kbusch at kernel.org> writes:
> On Tue, Aug 27, 2024 at 01:23:27PM +0000, Puranjay Mohan wrote:
>> @@ -119,9 +120,13 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
>> struct request_queue *q = req->q;
>> struct nvme_ns *ns = q->queuedata;
>> struct block_device *bdev = ns ? ns->disk->part0 : NULL;
>> + bool has_metadata = bdev && meta_buffer && meta_len;
>
> If this is an admin command, then bdev is NULL, so "has_metadata" is
> false.
>
>> struct bio *bio = NULL;
>> int ret;
>>
>> + if (has_metadata && !blk_get_integrity(bdev->bd_disk))
>> + return -EINVAL;
>> +
>
> Since has_metadata is false, we continue on to process this admin
> command, but ignore the user's metadata settings. Do we want to return
> error there too?
As an admin command with metadata is an invalid configuration, we can
ignore the metada and go ahead with the admin command or I can add the
following after the above check:
if (!bdev && (meta_buffer || meta_len))
return -EINVAL;
I don't know what is the best approach here.
Thanks,
Puranjay
More information about the Linux-nvme
mailing list