public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Kanchan Joshi <joshi.k@samsung.com>
To: John Garry <john.g.garry@oracle.com>,
	axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me,
	jejb@linux.ibm.com, martin.petersen@oracle.com,
	viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com,
	jack@suse.cz
Cc: djwong@kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
	linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com,
	linux-scsi@vger.kernel.org, ojaswin@linux.ibm.com,
	linux-aio@kvack.org, linux-btrfs@vger.kernel.org,
	io-uring@vger.kernel.org, nilay@linux.ibm.com,
	ritesh.list@gmail.com, willy@infradead.org, agk@redhat.com,
	snitzer@kernel.org, mpatocka@redhat.com,
	dm-devel@lists.linux.dev, hare@suse.de,
	Alan Adamson <alan.adamson@oracle.com>
Subject: Re: [PATCH v8 10/10] nvme: Atomic write support
Date: Mon, 17 Jun 2024 22:54:00 +0530	[thread overview]
Message-ID: <faaa5c15-a80d-339a-d9dd-2dd05fb26621@samsung.com> (raw)
In-Reply-To: <20240610104329.3555488-11-john.g.garry@oracle.com>

On 6/10/2024 4:13 PM, John Garry wrote:
> +static bool nvme_valid_atomic_write(struct request *req)
> +{
> +	struct request_queue *q = req->q;
> +	u32 boundary_bytes = queue_atomic_write_boundary_bytes(q);
> +
> +	if (blk_rq_bytes(req) > queue_atomic_write_unit_max_bytes(q))
> +		return false;
> +
> +	if (boundary_bytes) {
> +		u64 mask = boundary_bytes - 1, imask = ~mask;
> +		u64 start = blk_rq_pos(req) << SECTOR_SHIFT;
> +		u64 end = start + blk_rq_bytes(req) - 1;
> +
> +		/* If greater then must be crossing a boundary */
> +		if (blk_rq_bytes(req) > boundary_bytes)
> +			return false;

Nit: I'd cache blk_rq_bytes(req), since that is repeating and this 
function is called for each atomic IO.

> +
> +		if ((start & imask) != (end & imask))
> +			return false;
> +	}
> +
> +	return true;
> +}
> +
>   static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
>   		struct request *req, struct nvme_command *cmnd,
>   		enum nvme_opcode op)
> @@ -941,6 +965,12 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
>   
>   	if (req->cmd_flags & REQ_RAHEAD)
>   		dsmgmt |= NVME_RW_DSM_FREQ_PREFETCH;
> +	/*
> +	 * Ensure that nothing has been sent which cannot be executed
> +	 * atomically.
> +	 */
> +	if (req->cmd_flags & REQ_ATOMIC && !nvme_valid_atomic_write(req))
> +		return BLK_STS_INVAL;
>   

Is this validity check specific to NVMe or should this be moved up to 
block layer as it also knows the limits?

  reply	other threads:[~2024-06-17 17:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10 10:43 [PATCH v8 00/10] block atomic writes John Garry
2024-06-10 10:43 ` [PATCH v8 01/10] block: Pass blk_queue_get_max_sectors() a request pointer John Garry
2024-06-10 10:43 ` [PATCH v8 02/10] block: Generalize chunk_sectors support as boundary support John Garry
2024-06-10 10:43 ` [PATCH v8 03/10] fs: Initial atomic write support John Garry
2024-06-12 20:51   ` Darrick J. Wong
2024-06-10 10:43 ` [PATCH v8 04/10] fs: Add initial atomic write support info to statx John Garry
2024-06-12 20:54   ` Darrick J. Wong
2024-06-13  7:25     ` John Garry
2024-06-10 10:43 ` [PATCH v8 05/10] block: Add core atomic write support John Garry
2024-06-17 18:56   ` Keith Busch
2024-06-18  6:51     ` Christoph Hellwig
2024-06-18  7:46       ` John Garry
2024-06-18 17:25         ` Keith Busch
2024-06-19  7:59           ` John Garry
2024-06-19  8:02             ` Christoph Hellwig
2024-06-19 10:42               ` John Garry
2024-06-19 16:07               ` Martin K. Petersen
2024-06-10 10:43 ` [PATCH v8 06/10] block: Add atomic write support for statx John Garry
2024-06-10 10:43 ` [PATCH v8 07/10] block: Add fops atomic write support John Garry
2024-06-10 10:43 ` [PATCH v8 08/10] scsi: sd: Atomic " John Garry
2024-06-10 10:43 ` [PATCH v8 09/10] scsi: scsi_debug: " John Garry
2024-06-10 10:43 ` [PATCH v8 10/10] nvme: " John Garry
2024-06-17 17:24   ` Kanchan Joshi [this message]
2024-06-17 18:04     ` John Garry
2024-06-18  6:49       ` Christoph Hellwig
2024-06-18  7:22         ` John Garry
2024-06-14  2:01 ` [PATCH v8 00/10] block atomic writes Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=faaa5c15-a80d-339a-d9dd-2dd05fb26621@samsung.com \
    --to=joshi.k@samsung.com \
    --cc=agk@redhat.com \
    --cc=alan.adamson@oracle.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=dchinner@redhat.com \
    --cc=djwong@kernel.org \
    --cc=dm-devel@lists.linux.dev \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=io-uring@vger.kernel.org \
    --cc=jack@suse.cz \
    --cc=jbongio@google.com \
    --cc=jejb@linux.ibm.com \
    --cc=john.g.garry@oracle.com \
    --cc=kbusch@kernel.org \
    --cc=linux-aio@kvack.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mpatocka@redhat.com \
    --cc=nilay@linux.ibm.com \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=sagi@grimberg.me \
    --cc=snitzer@kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox