From: Christoph Hellwig <hch@infradead.org>
To: Nikanth Karthikesan <knikanth@suse.de>
Cc: Jens Axboe <jens.axboe@oracle.com>,
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, 17 Mar 2009 05:19:26 -0400 [thread overview]
Message-ID: <20090317091926.GA26016@infradead.org> (raw)
In-Reply-To: <200903171417.16760.knikanth@suse.de>
On Tue, Mar 17, 2009 at 02:17:16PM +0530, Nikanth Karthikesan wrote:
> +static int sync_file(struct file *file)
> +{
> + struct address_space *mapping;
> + int ret;
> +
> + if (!file->f_op || !file->f_op->fsync)
> + return -EOPNOTSUPP;
> +
> + mapping = file->f_mapping;
> +
> + ret = filemap_fdatawrite(mapping);
> + if (!ret) {
> + int ret2;
> +
> + mutex_lock(&mapping->host->i_mutex);
> + ret = file->f_op->fsync(file, file->f_dentry, 1);
> + mutex_unlock(&mapping->host->i_mutex);
> +
> + ret2 = filemap_fdatawait(mapping);
> + if (!ret)
> + ret = ret2;
Please use vfs_fsync.
> + int barrier = bio_barrier(bio);
> +
> + if (barrier) {
> + ret = sync_file(lo->lo_backing_file);
> + if (unlikely(ret))
> + goto out;
> + }
>
> pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset;
> + if (bio_rw(bio) == WRITE) {
> ret = lo_send(lo, bio, pos);
> + if (barrier && !ret)
> + ret = sync_file(lo->lo_backing_file);
> + } else
> ret = lo_receive(lo, bio, lo->lo_blocksize, pos);
> +
> +out:
> return ret;
We only use barrier requests for reads, which this code relies on for
the second sync, too. So just move the whole thing into one if block,
ala:
pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset;
if (bio_rw(bio) == WRITE) {
int barrier = bio_barrier(bio);
if (barrier) {
ret = sync_file(lo->lo_backing_file);
if (unlikely(ret))
goto out;
}
ret = lo_send(lo, bio, pos);
if (ret)
goto out;
if (barrier)
ret = sync_file(lo->lo_backing_file);
} else
ret = lo_receive(lo, bio, lo->lo_blocksize, pos);
out:
return ret;
You also should advertise the barrier capability with a queue flag.
next prev parent reply other threads:[~2009-03-17 9:19 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 [this message]
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
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=20090317091926.GA26016@infradead.org \
--to=hch@infradead.org \
--cc=csapuntz@gmail.com \
--cc=jens.axboe@oracle.com \
--cc=knikanth@suse.de \
--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