From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-kernel@vger.kernel.org
Cc: jens.axboe@oracle.com, hch@infradead.org, mkp@mkp.net,
Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 4/5] blkdev: add discard payload flag
Date: Wed, 24 Mar 2010 20:21:20 +0300 [thread overview]
Message-ID: <1269451281-4944-5-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1269451281-4944-4-git-send-email-dmonakhov@openvz.org>
Not all implementations require discard bio to be filled with one-sector
sized payload. Let's allocate payload only when necessary.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
block/blk-lib.c | 24 +++++++++++++-----------
drivers/scsi/sd.c | 1 +
include/linux/blkdev.h | 5 ++++-
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 67b641e..321d150 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -184,17 +184,19 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
if (flags & BLKDEV_IFL_BARRIER)
bio->bi_private = &wait;
- /*
- * Add a zeroed one-sector payload as that's what
- * our current implementations need. If we'll ever need
- * more the interface will need revisiting.
- */
- page = alloc_page(gfp_mask | __GFP_ZERO);
- if (!page)
- goto out_free_bio;
- if (bio_add_pc_page(q, bio, page, sector_size, 0) < sector_size)
- goto out_free_page;
-
+ if (blk_queue_discard_mem(q)) {
+ /*
+ * Add a zeroed one-sector payload as that's what
+ * our current implementations need. If we'll ever
+ * need more the interface will need revisiting.
+ */
+ page = alloc_page(gfp_mask | __GFP_ZERO);
+ if (!page)
+ goto out_free_bio;
+ if (bio_add_pc_page(q, bio, page, sector_size, 0) <
+ sector_size)
+ goto out_free_page;
+ }
/*
* And override the bio size - the way discard works we
* touch many more blocks on disk than the actual payload
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 1dd4d84..9994977 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1513,6 +1513,7 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
q->limits.discard_zeroes_data = 1;
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
+ queue_flag_set_unlocked(QUEUE_FLAG_DISCARD_MEM, q);
}
sdkp->capacity = lba + 1;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 78180b7..e232a0d 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -461,7 +461,8 @@ struct request_queue
#define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */
#define QUEUE_FLAG_IO_STAT 15 /* do IO stats */
#define QUEUE_FLAG_DISCARD 16 /* supports DISCARD */
-#define QUEUE_FLAG_NOXMERGES 17 /* No extended merges */
+#define QUEUE_FLAG_DISCARD_MEM 17 /* require memory in DISCARD request*/
+#define QUEUE_FLAG_NOXMERGES 18 /* No extended merges */
#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
(1 << QUEUE_FLAG_CLUSTER) | \
@@ -595,6 +596,8 @@ enum {
#define blk_queue_stackable(q) \
test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags)
#define blk_queue_discard(q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags)
+#define blk_queue_discard_mem(q) \
+ test_bit(QUEUE_FLAG_DISCARD_MEM, &(q)->queue_flags)
#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS)
#define blk_pc_request(rq) ((rq)->cmd_type == REQ_TYPE_BLOCK_PC)
--
1.6.6.1
next prev parent reply other threads:[~2010-03-24 17:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-24 17:21 [PATCH 0/5] blkdev: discard optimizations v2 Dmitry Monakhov
2010-03-24 17:21 ` [PATCH 1/5] blkdev: pass gfp_mask and flags to blkdev_issue_flush Dmitry Monakhov
[not found] ` <1269451281-4944-3-git-send-email-dmonakhov@openvz.org>
[not found] ` <1269451281-4944-4-git-send-email-dmonakhov@openvz.org>
2010-03-24 17:21 ` Dmitry Monakhov [this message]
2010-03-24 17:21 ` [PATCH 5/5] blkdev: optimize discard request logic Dmitry Monakhov
2010-03-24 17:29 [PATCH 0/5] blkdev: discard optimizations v2 RESEND Dmitry Monakhov
2010-03-24 17:29 ` [PATCH 1/5] blkdev: pass gfp_mask and flags to blkdev_issue_flush Dmitry Monakhov
[not found] ` <1269451792-5205-3-git-send-email-dmonakhov@openvz.org>
[not found] ` <1269451792-5205-4-git-send-email-dmonakhov@openvz.org>
2010-03-24 17:29 ` [PATCH 4/5] blkdev: add discard payload flag Dmitry Monakhov
2010-03-24 17:33 [PATCH 0/5] blkdev: discard optimizations v2 RESEND2 Dmitry Monakhov
2010-03-24 17:33 ` [PATCH 1/5] blkdev: pass gfp_mask and flags to blkdev_issue_flush Dmitry Monakhov
2010-03-24 17:33 ` [PATCH 2/5] blkdev: generalize flags for blkdev_issue functions Dmitry Monakhov
2010-03-24 17:33 ` [PATCH 3/5] blkdev: add blkdev_issue helper functions Dmitry Monakhov
2010-03-24 17:33 ` [PATCH 4/5] blkdev: add discard payload flag Dmitry Monakhov
2010-04-05 20:00 ` Christoph Hellwig
2010-04-06 8:29 ` Dmitry Monakhov
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=1269451281-4944-5-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=hch@infradead.org \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mkp@mkp.net \
/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
all inboxes | Powered by JetHome®