linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] blkdev: flush disk cache on ->fsync
Date: Mon, 12 Oct 2009 17:06:27 +0200	[thread overview]
Message-ID: <20091012150626.GL9228@kernel.dk> (raw)
In-Reply-To: <x49skdoslfn.fsf@segfault.boston.devel.redhat.com>

On Mon, Oct 12 2009, Jeff Moyer wrote:
> Christoph Hellwig <hch@lst.de> writes:
> 
> > Is anyone going to pick up this patch?
> >
> > On Thu, Aug 20, 2009 at 08:24:32PM +0200, Christoph Hellwig wrote:
> >> Currently there is no barrier support in the block device code.  That
> >> means we cannot guarantee any sort of data integerity when using the
> >> block device node with dis kwrite caches enabled.  Using the raw block
> >> device node is a typical use case for virtualization (and I assume
> >> databases, too).  This patch changes block_fsync to issue a cache flush
> >> and thus make fsync on block device nodes actually useful.
> >> 
> >> Note that in mainline we would also need to add such code to the
> >> ->aio_write method for O_SYNC handling, but assuming that Jan's patch
> >> series for the O_SYNC rewrite goes in it will also call into ->fsync
> >> for 2.6.32.
> >> 
> >> 
> >> Signed-off-by: Christoph Hellwig <hch@lst.de>
> >> 
> >> 
> >> diff --git a/fs/block_dev.c b/fs/block_dev.c
> >> index 94dfda2..298ad75 100644
> >> --- a/fs/block_dev.c
> >> +++ b/fs/block_dev.c
> >> @@ -398,7 +398,17 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin)
> >>   
> >>  static int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
> >>  {
> >> -	return sync_blockdev(I_BDEV(filp->f_mapping->host));
> >> +	struct block_device *bdev = I_BDEV(filp->f_mapping->host);
> >> +	int error;
> >> +
> >> +	error = sync_blockdev(bdev);
> >> +	if (error)
> >> +		return error;
> >> +	
> >> +	error = blkdev_issue_flush(bdev, NULL);
> >> +	if (error == -EOPNOTSUPP)
> >> +		error = 0;
> >> +	return error;
> >>  }
> >>  
> >>  /*
> > ---end quoted text---
> 
> Looks ok to me.  Jens?

Yep ditto!

> 
> Acked-by: Jeff Moyer <jmoyer@redhat.com>

-- 
Jens Axboe


  reply	other threads:[~2009-10-12 15:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-20 18:24 [PATCH] blkdev: flush disk cache on ->fsync Christoph Hellwig
2009-10-10 16:15 ` Christoph Hellwig
2009-10-12 15:04   ` Jeff Moyer
2009-10-12 15:06     ` Jens Axboe [this message]
2009-10-12 15:07   ` Jens Axboe
2009-10-13  1:41     ` Christoph Hellwig
2009-10-13 11:31       ` 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=20091012150626.GL9228@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=hch@lst.de \
    --cc=jmoyer@redhat.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;
as well as URLs for NNTP newsgroup(s).