From: Jan Kara <jack@suse.cz>
To: Jan Beulich <JBeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Jeremy Fitzhardinge <jeremy@goop.org>,
hch@infradead.org, axboe@kernel.dk, Jan Kara <jack@suse.cz>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH]: xen/blkback: Add support for old BARRIER requests - 'feature-barrier', was "Help with implementing some form of barriers in 3.0 kernels."
Date: Thu, 15 Sep 2011 15:24:08 +0200 [thread overview]
Message-ID: <20110915132408.GB4739@quack.suse.cz> (raw)
In-Reply-To: <4E70EEB302000078000561AE@nat28.tlf.novell.com>
On Wed 14-09-11 17:13:07, Jan Beulich wrote:
> >>> On 14.09.11 at 17:01, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> wrote:
> > On Wed, Sep 14, 2011 at 10:32:47AM -0400, Konrad Rzeszutek Wilk wrote:
> >
> > Let me just post the one that I've succesfully tested. Not sure
> > about the need for the check for q->elvator in the dispatch_rw_block_io
> > so if you guys want me to remove it I can certainly do it.
> >
> > commit a5a12f729697161522ecae0564915cf4145cb65c
> > Author: Jan Kara <jack@suse.cz>
> > Date: Tue Sep 13 11:44:07 2011 +0100
> >
> > xen/blkback: Add support for old BARRIER requests - 'feature-barrier'
> >
> > Recent kernels do not support BARRIER operation but only FLUSH
> > operation. But
> > older xenblk frontends still use the BARRIER operation to achieve data
> > integrity requirements. So add support for BARRIER operation into xenblk
> > backend so that all guests do not corrupt their filesystem on host
> > crash.
> >
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > Signed-off-by: Jan Beulich <JBeulich@suse.com>
> > [v1: Added some extra functions, and other cases]
> > [v2: Added check for q->elevator]
> > [v3: Changed EXPORT_SYMBOL to EXPORT_SYMBOL_GPL]
> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> >
> > diff --git a/block/elevator.c b/block/elevator.c
> > index a3b64bc..4e6c5b6 100644
> > --- a/block/elevator.c
> > +++ b/block/elevator.c
> > @@ -616,6 +616,7 @@ void elv_drain_elevator(struct request_queue *q)
> > q->elevator->elevator_type->elevator_name, q->nr_sorted);
> > }
> > }
> > +EXPORT_SYMBOL_GPL(elv_drain_elevator);
> >
> > /*
> > * Call with queue lock held, interrupts disabled
> > diff --git a/drivers/block/xen-blkback/blkback.c
> > b/drivers/block/xen-blkback/blkback.c
> > index 9713d5a..573744e 100644
> > --- a/drivers/block/xen-blkback/blkback.c
> > +++ b/drivers/block/xen-blkback/blkback.c
> > @@ -464,6 +464,11 @@ static void __end_block_io_op(struct pending_req
> > *pending_req, int error)
> > pr_debug(DRV_PFX "flush diskcache op failed, not supported\n");
> > xen_blkbk_flush_diskcache(XBT_NIL, pending_req->blkif->be, 0);
> > pending_req->status = BLKIF_RSP_EOPNOTSUPP;
> > + } else if ((pending_req->operation == BLKIF_OP_WRITE_BARRIER) &&
> > + (error == -EOPNOTSUPP)) {
> > + pr_debug(DRV_PFX "write barrier op failed, not supported\n");
> > + xen_blkbk_barrier(XBT_NIL, pending_req->blkif->be, 0);
> > + pending_req->status = BLKIF_RSP_EOPNOTSUPP;
> > } else if (error) {
> > pr_debug(DRV_PFX "Buffer not up-to-date at end of operation,"
> > " error=%d\n", error);
> > @@ -590,6 +595,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
> > struct bio *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
> > int i, nbio = 0;
> > int operation;
> > + bool drain = false;
> > struct blk_plug plug;
> >
> > switch (req->operation) {
> > @@ -601,6 +607,8 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
> > blkif->st_wr_req++;
> > operation = WRITE_ODIRECT;
> > break;
> > + case BLKIF_OP_WRITE_BARRIER:
> > + drain = true;
> > case BLKIF_OP_FLUSH_DISKCACHE:
> > blkif->st_f_req++;
> > operation = WRITE_FLUSH;
> > @@ -609,7 +617,6 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
> > blkif->st_ds_req++;
> > operation = REQ_DISCARD;
> > break;
> > - case BLKIF_OP_WRITE_BARRIER:
> > default:
> > operation = 0; /* make gcc happy */
> > goto fail_response;
> > @@ -668,6 +675,21 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
> > }
> > }
> >
> > + if (drain) {
> > + struct request_queue *q = bdev_get_queue(preq.bdev);
> > + unsigned long flags;
> > +
> > + if (!q->elevator) {
> > + __end_block_io_op(pending_req, -EOPNOTSUPP);
> > + return -EOPNOTSUPP;
> > + }
>
> You shouldn't return here - barrier requests may be "non-empty" (i.e.
> carry data to be written), and hence you'd need to make sure the
> writes get carried out nevertheless.
>
> Jan - this suggests that the placement isn't correct either: The
> draining of the queue - as I understand it - should be happening
> *after* these writes completed, not before they get started.
The draining should really happen before. It was like that in older
kernels as well. But you are right that we should probably make the
operation be WRITE_FLUSH_FUA to properly simulate the old behavior.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2011-09-15 13:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-07 17:48 Help with implementing some form of barriers in 3.0 kernels Konrad Rzeszutek Wilk
2011-09-07 18:17 ` Vivek Goyal
2011-09-07 18:27 ` Konrad Rzeszutek Wilk
2011-09-07 18:36 ` Vivek Goyal
2011-09-07 20:16 ` Christoph Hellwig
2011-09-07 21:31 ` Vivek Goyal
2011-09-08 8:22 ` Christoph Hellwig
2011-09-08 8:02 ` Jan Beulich
2011-09-08 8:08 ` Christoph Hellwig
2011-09-13 10:44 ` Jan Beulich
2011-09-14 8:59 ` Konrad Rzeszutek Wilk
2011-09-14 9:12 ` Jan Beulich
2011-09-14 9:30 ` Konrad Rzeszutek Wilk
2011-09-14 10:15 ` Jan Beulich
2011-09-14 14:32 ` Konrad Rzeszutek Wilk
2011-09-14 15:01 ` [PATCH]: xen/blkback: Add support for old BARRIER requests - 'feature-barrier', was "Help with implementing some form of barriers in 3.0 kernels." Konrad Rzeszutek Wilk
2011-09-14 16:13 ` Jan Beulich
2011-09-15 12:51 ` Konrad Rzeszutek Wilk
2011-09-15 13:00 ` Jan Beulich
2011-09-15 14:21 ` Konrad Rzeszutek Wilk
2011-09-15 15:13 ` Jan Kara
2011-09-15 15:15 ` Christoph Hellwig
2011-09-16 9:24 ` Konrad Rzeszutek Wilk
2011-09-15 13:24 ` Jan Kara [this message]
2011-09-14 15:34 ` Help with implementing some form of barriers in 3.0 kernels Mike Snitzer
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=20110915132408.GB4739@quack.suse.cz \
--to=jack@suse.cz \
--cc=JBeulich@suse.com \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=jeremy@goop.org \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
/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®