From: Bart Van Assche <bart.vanassche@sandisk.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
James Bottomley <jejb@linux.vnet.ibm.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
Jens Axboe <axboe@fb.com>,
"lsf@lists.linux-foundation.org" <lsf@lists.linux-foundation.org>
Subject: Re: [Lsf] LSF/MM Schedule and improving discard support
Date: Wed, 13 Apr 2016 09:57:19 -0700 [thread overview]
Message-ID: <570E7A6F.5040206@sandisk.com> (raw)
In-Reply-To: <yq1twj5v4qs.fsf@sermon.lab.mkp.net>
On 04/13/2016 09:43 AM, Martin K. Petersen wrote:
>>>>>> "Bart" == Bart Van Assche <bart.vanassche@sandisk.com> writes:
>
> Bart> Today if a BLKDISCARD ioctl passes a non-aligned start and/or end
> Bart> sector to the kernel then the block layer will submit invalid
> Bart> (non-aligned) REQ_DISCARD requests to the block driver the ioctl
> Bart> applies to.
>
> I do not know what you mean by "invalid".
>
> A device that implements UNMAP can freely ignore any parts of a request
> block range that are not aligned to its internal allocation units.
>
> From SBC: "An unmap request with a number of logical blocks that is not
> a multiple of this value (OPTIMAL UNMAP GRANULARITY) may result in unmap
> operations on fewer LBAs than requested." and "An unmap request with a
> starting LBA that is not optimal may result in unmap operations on fewer
> LBAs than requested."
>
> The same is true for SATA which has no way report granularity and
> alignment at all.
>
> Nowhere does it say that a request that is not an aligned multiple of
> any reported granularity should be considered "invalid" or rejected by
> the storage.
Hello Martin,
Sorry if I wasn't clear enough. Regarding the SCSI UNMAP command,
consider e.g. the following code from drivers/scsi/sd.c:
static int sd_setup_discard_cmnd(struct scsi_cmnd *cmd)
{
[ ... ]
sector >>= ilog2(sdp->sector_size) - 9;
nr_sectors >>= ilog2(sdp->sector_size) - 9;
[ ... ]
case SD_LBP_UNMAP:
[ ... ]
cmd->cmd_len = 10;
cmd->cmnd[0] = UNMAP;
cmd->cmnd[8] = 24;
put_unaligned_be16(6 + 16, &buf[0]);
put_unaligned_be16(16, &buf[2]);
put_unaligned_be64(sector, &buf[8]);
put_unaligned_be32(nr_sectors, &buf[16]);
[ ... ]
}
For sdp->sector_size > 512, should we allow the block layer to pass
sector and nr_sector values to this function that are not a multiple of
sdp->sector_size? And if so, how should this code behave and if sector
and/or nr_sectors is not a multiple of sdp->sector_size? As one can see
the above code rounds down sector and nr_sectors while converting from
sectors to logical blocks. This means that if a non-aligned BLKDISCARD
is submitted from user space that one or more sectors *before* the start
of the range specified in the ioctl will be discarded. Isn't that a bug?
Bart.
next prev parent reply other threads:[~2016-04-13 16:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 15:39 LSF/MM Schedule and improving discard support Bart Van Assche
2016-04-07 15:51 ` James Bottomley
2016-04-13 15:57 ` Bart Van Assche
2016-04-13 16:21 ` Martin K. Petersen
2016-04-13 16:29 ` Bart Van Assche
2016-04-13 16:43 ` [Lsf] " Martin K. Petersen
2016-04-13 16:57 ` Bart Van Assche [this message]
2016-04-13 17:13 ` Martin K. Petersen
2016-04-13 16:51 ` James Bottomley
2016-04-13 17:30 ` Darrick J. Wong
2016-04-13 22:04 ` Douglas Gilbert
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=570E7A6F.5040206@sandisk.com \
--to=bart.vanassche@sandisk.com \
--cc=axboe@fb.com \
--cc=darrick.wong@oracle.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=lsf@lists.linux-foundation.org \
--cc=martin.petersen@oracle.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.