Thread (24 messages) 24 messages, 5 authors, 2017-03-30

Re: [PATCH 7/7] sd: use ZERO_PAGE for WRITE_SAME payloads

From: Bart Van Assche <hidden>
Date: 2017-03-27 23:40:12
Also in: linux-ide, linux-scsi

On Mon, 2017-03-20 at 16:43 -0400, Christoph Hellwig wrote:
quoted hunk ↗ jump to hunk
We're never touching the contents of the page, so save a memory
allocation for these cases.
=20
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/sd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
=20
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index c18fe9ff1f8f..af632e350ab4 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -756,7 +756,7 @@ static int sd_setup_write_same16_cmnd(struct scsi_cmn=
d *cmd)
quoted hunk ↗ jump to hunk
 	u32 nr_sectors =3D blk_rq_sectors(rq) >> (ilog2(sdp->sector_size) - 9);
 	u32 data_len =3D sdp->sector_size;
=20
-	rq->special_vec.bv_page =3D alloc_page(GFP_ATOMIC | __GFP_ZERO);
+	rq->special_vec.bv_page =3D ZERO_PAGE(0);
 	if (!rq->special_vec.bv_page)
 		return BLKPREP_DEFER;
 	rq->special_vec.bv_offset =3D 0;
@@ -785,7 +785,7 @@ static int sd_setup_write_same10_cmnd(struct scsi_cmn=
d *cmd, bool unmap)
quoted hunk ↗ jump to hunk
 	u32 nr_sectors =3D blk_rq_sectors(rq) >> (ilog2(sdp->sector_size) - 9);
 	u32 data_len =3D sdp->sector_size;
=20
-	rq->special_vec.bv_page =3D alloc_page(GFP_ATOMIC | __GFP_ZERO);
+	rq->special_vec.bv_page =3D ZERO_PAGE(0);
 	if (!rq->special_vec.bv_page)
 		return BLKPREP_DEFER;
 	rq->special_vec.bv_offset =3D 0;
@@ -1256,7 +1256,8 @@ static void sd_uninit_command(struct scsi_cmnd *SCp=
nt)
 {
 	struct request *rq =3D SCpnt->request;
=20
-	if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
+	if ((rq->rq_flags & RQF_SPECIAL_PAYLOAD) &&
+	    rq->special_vec.bv_page !=3D ZERO_PAGE(0))
 		__free_page(rq->special_vec.bv_page);
=20
 	if (SCpnt->cmnd !=3D scsi_req(rq)->cmd) {
Reviewed-by: Bart Van Assche <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help