From: David Woodhouse <dwmw2@infradead.org>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Ric Wheeler <ricwheeler@gmail.com>,
linux-fsdevel@vger.kernel.org, gilad@codefidence.com,
matthew@wil.cx
Subject: Re: [PATCH 0/7] Discard requests, v2
Date: Tue, 12 Aug 2008 14:04:17 +0100 [thread overview]
Message-ID: <1218546257.2977.167.camel@pmac.infradead.org> (raw)
In-Reply-To: <20080812125315.GH20055@kernel.dk>
On Tue, 2008-08-12 at 14:53 +0200, Jens Axboe wrote:
> On Tue, Aug 12 2008, David Woodhouse wrote:
> > On Tue, 2008-08-12 at 12:16 +0100, David Woodhouse wrote:
> > > There's a check in __make_request() which will return -EOPNOTSUPP for
> > > bios with BIO_RW_BARRIER set, in some circumstances. Is that OK too?
> >
> > A: No, it breaks submission of DISCARD|BARRIER requests. And I have to
> > change blk_empty_barrier() to explicitly omit discards too, to avoid the
> > check at line 1419 (in __generic_make_request()) returning -EOPNOTSUPP
> > before we even get there.
> >
> > Using BIO_RW_BARRIER seems conceptually cleaner, but in practice it's
> > messier. I think this version will work, but I'm inclined to prefer the
> > previous one I posted, using the R/W bit.
>
> Or just match the check before -EOPNOTSUPP with bio_has_data(), since it
> only applies to a barrier that carries data.
Like this, you mean? Empty barriers don't get to there?
I still prefer the R/W version, but I'll commit it this way if you
want...
diff --git a/block/blk-core.c b/block/blk-core.c
index be2fe52..1b38994 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1075,19 +1075,13 @@ void init_request_from_bio(struct request *req, struct bio *bio)
/*
* REQ_BARRIER implies no merging, but lets make it explicit
*/
- if (unlikely(bio_barrier(bio)))
- req->cmd_flags |= (REQ_HARDBARRIER | REQ_NOMERGE);
if (unlikely(bio_discard(bio))) {
req->cmd_flags |= REQ_DISCARD;
- /*
- * READ discard requests are soft barriers; WRITE
- * indicates the file system will take care of that
- * for itself.
- */
- if (!bio_data_dir(bio))
+ if (bio_barrier(bio))
req->cmd_flags |= REQ_SOFTBARRIER;
req->q->prepare_discard_fn(req->q, req);
- }
+ } else if (unlikely(bio_barrier(bio)))
+ req->cmd_flags |= (REQ_HARDBARRIER | REQ_NOMERGE);
if (bio_sync(bio))
req->cmd_flags |= REQ_RW_SYNC;
@@ -1119,7 +1113,8 @@ static int __make_request(struct request_queue *q, struct bio *bio)
blk_queue_bounce(q, &bio);
barrier = bio_barrier(bio);
- if (unlikely(barrier) && (q->next_ordered == QUEUE_ORDERED_NONE)) {
+ if (unlikely(barrier) && bio_has_data(bio) &&
+ (q->next_ordered == QUEUE_ORDERED_NONE)) {
err = -EOPNOTSUPP;
goto end_io;
}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 1fdfc56..33c3947 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -188,8 +188,8 @@ struct bio {
#define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST))
#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD))
#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META))
-#define bio_empty_barrier(bio) (bio_barrier(bio) && !bio_has_data(bio))
#define bio_discard(bio) ((bio)->bi_rw & (1 << BIO_RW_DISCARD))
+#define bio_empty_barrier(bio) (bio_barrier(bio) && !bio_has_data(bio) && !bio_discard(bio))
static inline unsigned int bio_cur_sectors(struct bio *bio)
{
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5cfacb3..860689f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -87,8 +87,8 @@ extern int dir_notify_enable;
#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC))
#define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC))
#define WRITE_BARRIER (WRITE | (1 << BIO_RW_BARRIER))
-#define DISCARD_NOBARRIER (WRITE | (1 << BIO_RW_DISCARD))
-#define DISCARD_BARRIER (1 << BIO_RW_DISCARD)
+#define DISCARD_NOBARRIER (1 << BIO_RW_DISCARD)
+#define DISCARD_BARRIER ((1 << BIO_RW_DISCARD) | (1 << BIO_RW_BARRIER))
#define SEL_IN 1
#define SEL_OUT 2
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
next prev parent reply other threads:[~2008-08-12 13:04 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-09 16:26 [PATCH 0/7] Discard requests, v2 David Woodhouse
2008-08-09 16:29 ` [PATCH 1/7] [BLOCK] Fix typo causing compile error in blk_queue_bounce() David Woodhouse
2008-08-09 16:30 ` [PATCH 2/7] [BLOCK] Fix up comments about matching flags between bio and rq David Woodhouse
2008-08-09 16:30 ` [PATCH 3/7] [BLOCK] Add 'discard' request handling David Woodhouse
2008-08-09 20:39 ` OGAWA Hirofumi
2008-08-09 21:37 ` David Woodhouse
2008-08-10 6:32 ` David Woodhouse
2008-08-09 16:31 ` [PATCH 4/7] [FAT] Let the block device know when sectors can be discarded David Woodhouse
2008-08-09 16:32 ` [PATCH 5/7] [MTD] Support 'discard sectors' operation in translation layer support core David Woodhouse
2008-08-09 16:33 ` [PATCH 6/7] [MTD] [FTL] Support 'discard sectors' operation David Woodhouse
2008-08-09 16:33 ` [PATCH 7/7] [BLOCK] Allow elevators to sort/merge discard requests David Woodhouse
2008-10-03 20:29 ` Andrew Morton
2008-10-07 12:07 ` Jens Axboe
2008-08-09 22:48 ` [PATCH 0/7] Discard requests, v2 OGAWA Hirofumi
2008-08-10 10:25 ` David Woodhouse
2008-08-10 16:37 ` Jamie Lokier
2008-08-10 17:55 ` OGAWA Hirofumi
2008-08-10 20:07 ` David Woodhouse
2008-08-10 21:40 ` OGAWA Hirofumi
2008-08-11 9:40 ` David Woodhouse
2008-08-11 10:25 ` OGAWA Hirofumi
2008-08-11 13:17 ` David Woodhouse
2008-08-11 14:21 ` OGAWA Hirofumi
2008-08-10 10:29 ` [PATCH 8/7] blktrace: support discard requests David Woodhouse
2008-08-10 10:35 ` [USERSPACE PATCH] " David Woodhouse
2008-08-15 8:43 ` Jens Axboe
2008-08-15 9:01 ` David Woodhouse
2008-08-15 9:08 ` Jens Axboe
2008-08-10 10:41 ` [PATCH 8/7] " David Woodhouse
2008-08-13 11:17 ` Jens Axboe
2008-08-10 11:48 ` [PATCH 9/7] blktrace: simplify flags handling in __blk_add_trace David Woodhouse
2008-08-10 11:50 ` David Woodhouse
2008-08-11 15:11 ` [PATCH 10/7] [BLOCK] Add BLKDISCARD ioctl to allow userspace to discard sectors David Woodhouse
2008-08-11 18:27 ` Matthew Wilcox
2008-08-11 20:52 ` David Woodhouse
2008-08-12 9:14 ` [PATCH 0/7] Discard requests, v2 Jens Axboe
2008-08-12 10:00 ` David Woodhouse
2008-08-12 10:54 ` Jens Axboe
2008-08-12 11:16 ` David Woodhouse
2008-08-12 12:19 ` David Woodhouse
2008-08-12 12:53 ` Jens Axboe
2008-08-12 13:04 ` David Woodhouse [this message]
2008-08-12 15:47 ` David Woodhouse
2008-08-12 18:04 ` Jamie Lokier
2008-08-13 10:22 ` David Woodhouse
2008-08-13 12:19 ` Jamie Lokier
2008-08-13 12:26 ` David Woodhouse
2008-08-13 11:15 ` Jens Axboe
2008-08-13 11:23 ` David Woodhouse
2008-08-13 11:32 ` Jens Axboe
2008-08-13 11:34 ` David Woodhouse
2008-08-13 12:07 ` David Woodhouse
2008-08-14 7:49 ` Jens Axboe
2008-08-14 7:52 ` David Woodhouse
2008-08-14 7:25 ` David Woodhouse
2008-08-14 7:33 ` Stephen Rothwell
2008-08-14 7:37 ` David Woodhouse
2008-08-14 7:42 ` Jens Axboe
2008-08-14 7:46 ` Stephen Rothwell
2008-08-12 18:10 ` Jamie Lokier
2008-08-13 10:20 ` David Woodhouse
2008-08-12 11:42 ` Matthew Wilcox
2008-08-12 11:46 ` David Woodhouse
2008-08-12 19:53 ` OGAWA Hirofumi
2008-08-12 20:11 ` OGAWA Hirofumi
2008-08-13 11:39 ` [PATCH 11/7] Kill REQ_TYPE_FLUSH David Woodhouse
2008-08-13 11:58 ` Geert Uytterhoeven
2008-08-13 12:43 ` David Woodhouse
2008-08-13 15:40 ` Jens Axboe
2008-08-13 15:46 ` David Woodhouse
2008-08-16 17:08 ` [PATCH 0/2] MMC discard support (was [PATCH 0/7] Discard requests, v2) Pierre Ossman
2008-08-16 17:11 ` [PATCH 1/2] mmc_block: factor out the mmc request handling Pierre Ossman
2008-08-16 17:12 ` [PATCH 2/2] mmc_block: erase discarded blocks Pierre Ossman
2008-08-16 17:38 ` [PATCH 0/2] MMC discard support (was [PATCH 0/7] Discard requests, v2) David Woodhouse
2008-08-16 17:51 ` Pierre Ossman
2008-08-22 9:24 ` Jens Axboe
2008-08-22 9:45 ` David Woodhouse
2008-08-22 10:50 ` Jens Axboe
2008-08-22 10:58 ` David Woodhouse
2008-08-22 11:11 ` Pierre Ossman
2008-08-22 11:19 ` Jens Axboe
2008-08-22 11:13 ` Pierre Ossman
2008-08-22 11:20 ` Jens Axboe
2008-08-22 14:49 ` OGAWA Hirofumi
2008-08-22 23:02 ` Pierre Ossman
2008-08-22 23:59 ` OGAWA Hirofumi
2008-08-24 11:23 ` Pierre Ossman
2008-08-24 13:39 ` OGAWA Hirofumi
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=1218546257.2977.167.camel@pmac.infradead.org \
--to=dwmw2@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=gilad@codefidence.com \
--cc=jens.axboe@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=ricwheeler@gmail.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).