From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: linux-scsi@vger.kernel.org
Cc: axboe@kernel.dk, shli@kernel.org, snitzer@redhat.com,
"Martin K. Petersen" <martin.petersen@oracle.com>
Subject: [PATCH 4/8] block: Make blkdev_issue_zeroout use WRITE SAME
Date: Tue, 18 Sep 2012 12:19:28 -0400 [thread overview]
Message-ID: <1347985172-2495-5-git-send-email-martin.petersen@oracle.com> (raw)
In-Reply-To: <1347985172-2495-1-git-send-email-martin.petersen@oracle.com>
From: "Martin K. Petersen" <martin.petersen@oracle.com>
If the device supports WRITE SAME, use that to optimize zeroing of
blocks. If the device does not support WRITE SAME or if the operation
fails, fall back to writing zeroes the old-fashioned way.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
---
block/blk-lib.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/block/blk-lib.c b/block/blk-lib.c
index a062543..9373b58 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -214,7 +214,7 @@ EXPORT_SYMBOL(blkdev_issue_write_same);
* Generate and issue number of bios with zerofiled pages.
*/
-int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
+int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
sector_t nr_sects, gfp_t gfp_mask)
{
int ret;
@@ -264,4 +264,32 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
return ret;
}
+
+/**
+ * blkdev_issue_zeroout - zero-fill a block range
+ * @bdev: blockdev to write
+ * @sector: start sector
+ * @nr_sects: number of sectors to write
+ * @gfp_mask: memory allocation flags (for bio_alloc)
+ *
+ * Description:
+ * Generate and issue number of bios with zerofiled pages.
+ */
+
+int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
+ sector_t nr_sects, gfp_t gfp_mask)
+{
+ if (bdev_write_same(bdev)) {
+ unsigned char bdn[BDEVNAME_SIZE];
+
+ if (!blkdev_issue_write_same(bdev, sector, nr_sects, gfp_mask,
+ ZERO_PAGE(0)))
+ return 0;
+
+ bdevname(bdev, bdn);
+ pr_err("%s: WRITE SAME failed. Manually zeroing.\n", bdn);
+ }
+
+ return __blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask);
+}
EXPORT_SYMBOL(blkdev_issue_zeroout);
--
1.7.7.6
next prev parent reply other threads:[~2012-09-18 16:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-18 16:19 Discard merging / Write same support v5 Martin K. Petersen
2012-09-18 16:19 ` [PATCH 1/8] block: Clean up special command handling logic Martin K. Petersen
2012-09-18 16:19 ` [PATCH 2/8] block: Consolidate command flag and queue limit checks for merges Martin K. Petersen
2012-09-18 17:59 ` Mike Snitzer
2012-09-18 16:19 ` [PATCH 3/8] block: Implement support for WRITE SAME Martin K. Petersen
2012-09-18 16:19 ` Martin K. Petersen [this message]
2012-09-18 16:19 ` [PATCH 5/8] block: ioctl to zero block ranges Martin K. Petersen
2012-09-18 16:19 ` [PATCH 6/8] scsi: Add a report opcode helper Martin K. Petersen
2012-09-18 16:19 ` [PATCH 7/8] sd: Permit merged discard requests Martin K. Petersen
2012-09-20 0:35 ` Shaohua Li
2012-09-18 16:19 ` [PATCH 8/8] sd: Implement support for WRITE SAME Martin K. Petersen
2012-09-20 12:33 ` Discard merging / Write same support v5 Jens Axboe
2012-09-20 12:43 ` James Bottomley
2012-09-20 12:47 ` Jens Axboe
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=1347985172-2495-5-git-send-email-martin.petersen@oracle.com \
--to=martin.petersen@oracle.com \
--cc=axboe@kernel.dk \
--cc=linux-scsi@vger.kernel.org \
--cc=shli@kernel.org \
--cc=snitzer@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).