public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikanth Karthikesan <knikanth@suse.de>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Constantine Sapuntzakis <csapuntz@gmail.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	nikanth@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Block - Honour barrier requests in loop driver
Date: Tue, 24 Mar 2009 11:24:35 +0530	[thread overview]
Message-ID: <200903241124.36223.knikanth@suse.de> (raw)
In-Reply-To: <200903181028.20689.knikanth@suse.de>

On Wednesday 18 March 2009 10:28:20 Nikanth Karthikesan wrote:
> On Wednesday 18 March 2009 00:39:05 Christoph Hellwig wrote:
> > On Tue, Mar 17, 2009 at 05:39:49PM +0530, Nikanth Karthikesan wrote:
> > > +			if (!file->f_op || !file->f_op->fsync) {
> > > +				ret = -EOPNOTSUPP;
> > > +				goto out;
> > > +			}
> >
> > file->f_op is never zero, so you can remove the checks for that.
> > Otherwise looks good.
>
> Thanks for reviewing. I've removed that check.
>
> Jens, Can you merge this?
>
Hi Jens

Did you get to look at this? Can you merge this?

Thanks
Nikanth

>
> Honour barrier requests in the loop back block device driver.
> In case of barrier bios, flush the backing file once before processing the
> barrier and once after to guarantee ordering. In case of filesystems that
> does not support fsync, barrier bios would be failed with -EOPNOTSUPP.
>
> Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
>
> ---
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index bf03455..cac7894 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -474,10 +474,35 @@ static int do_bio_filebacked(struct loop_device *lo,
> struct bio *bio) int ret;
>
>  	pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset;
> -	if (bio_rw(bio) == WRITE)
> +
> +	if (bio_rw(bio) == WRITE) {
> +		int barrier = bio_barrier(bio);
> +		struct file *file = lo->lo_backing_file;
> +
> +		if (barrier) {
> +			if (unlikely(!file->f_op->fsync)) {
> +				ret = -EOPNOTSUPP;
> +				goto out;
> +			}
> +
> +			ret = vfs_fsync(file, file->f_path.dentry, 0);
> +			if (unlikely(ret)) {
> +				ret = -EIO;
> +				goto out;
> +			}
> +		}
> +
>  		ret = lo_send(lo, bio, pos);
> -	else
> +
> +		if (barrier && !ret) {
> +			ret = vfs_fsync(file, file->f_path.dentry, 0);
> +			if (unlikely(ret))
> +				ret = -EIO;
> +		}
> +	} else
>  		ret = lo_receive(lo, bio, lo->lo_blocksize, pos);
> +
> +out:
>  	return ret;
>  }
>
> @@ -825,6 +850,10 @@ static int loop_set_fd(struct loop_device *lo, fmode_t
> mode, blk_queue_make_request(lo->lo_queue, loop_make_request);
>  	lo->lo_queue->queuedata = lo;
>  	lo->lo_queue->unplug_fn = loop_unplug;
> +	if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op &&
> +						file->f_op->fsync) {
> +		blk_queue_ordered(lo->lo_queue, QUEUE_ORDERED_DRAIN, NULL);
> +	}
>
>  	set_capacity(lo->lo_disk, size);
>  	bd_set_size(bdev, size << 9);


  reply	other threads:[~2009-03-24  5:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-17  8:47 [PATCH] Block - Honour barrier requests in loop driver Nikanth Karthikesan
2009-03-17  9:19 ` Christoph Hellwig
2009-03-17 12:09   ` Nikanth Karthikesan
2009-03-17 19:09     ` Christoph Hellwig
2009-03-18  4:58       ` Nikanth Karthikesan
2009-03-24  5:54         ` Nikanth Karthikesan [this message]
2009-03-24 11:24           ` Jens Axboe
2009-03-24 11:26             ` 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=200903241124.36223.knikanth@suse.de \
    --to=knikanth@suse.de \
    --cc=csapuntz@gmail.com \
    --cc=hch@infradead.org \
    --cc=jens.axboe@oracle.com \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=nikanth@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