From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bart Van Assche Subject: Re: [PATCH 12/23] sd: handle REQ_UNMAP Date: Tue, 28 Mar 2017 16:48:55 +0000 Message-ID: <1490719722.2573.8.camel@sandisk.com> References: <20170323143341.31549-1-hch@lst.de> <20170323143341.31549-13-hch@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20170323143341.31549-13-hch-jcswGhMUV9g@public.gmane.org> Content-Language: en-US Content-ID: <67C38495A74E4545A8ECDA6712B7DBC1-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: drbd-dev-bounces-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org Errors-To: drbd-dev-bounces-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org To: "agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org" , "lars.ellenberg-63ez5xqkn6DQT0dZR+AlfA@public.gmane.org" , "snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org" , "hch-jcswGhMUV9g@public.gmane.org" , "martin.petersen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org" , "philipp.reisner-63ez5xqkn6DQT0dZR+AlfA@public.gmane.org" , "axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org" , "shli-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org" Cc: "linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-raid-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org" , "linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "drbd-dev-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org" List-Id: linux-scsi@vger.kernel.org On Thu, 2017-03-23 at 10:33 -0400, Christoph Hellwig wrote: > Try to use a write same with unmap bit variant if the device supports it > and the caller asks for it. > = > Signed-off-by: Christoph Hellwig > --- > drivers/scsi/sd.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > = > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c > index b6f70a09a301..ca96bb33471b 100644 > --- a/drivers/scsi/sd.c > +++ b/drivers/scsi/sd.c > @@ -871,6 +871,16 @@ static int sd_setup_write_zeroes_cmnd(struct scsi_cm= nd *cmd) > return BLKPREP_INVALID; > return sd_setup_ata_trim_cmnd(cmd); > } > + > + if (rq->cmd_flags & REQ_UNMAP) { > + switch (sdkp->provisioning_mode) { > + case SD_LBP_WS16: > + return sd_setup_write_same16_cmnd(cmd, true); > + case SD_LBP_WS10: > + return sd_setup_write_same10_cmnd(cmd, true); > + } > + } > + > if (sdp->no_write_same) > return BLKPREP_INVALID; > if (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) Users can change the provisioning mode from user space from=A0SD_LBP_WS16 i= nto SD_LBP_WS10 so I'm not sure it's safe to skip the (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) check if REQ_UNMAP is set. Bart.