Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753423AbZCRFDg (ORCPT ); Wed, 18 Mar 2009 01:03:36 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751322AbZCRFD1 (ORCPT ); Wed, 18 Mar 2009 01:03:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:53755 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751180AbZCRFD0 (ORCPT ); Wed, 18 Mar 2009 01:03:26 -0400 From: Nikanth Karthikesan Organization: suse.de To: Jens Axboe Subject: Re: [PATCH] Block - Honour barrier requests in loop driver Date: Wed, 18 Mar 2009 10:28:20 +0530 User-Agent: KMail/1.10.3 (Linux/2.6.27.19-3.2-default; KDE/4.1.3; x86_64; ; ) Cc: Christoph Hellwig , Gerd Hoffmann , Constantine Sapuntzakis , Miklos Szeredi , nikanth@gmail.com, linux-kernel@vger.kernel.org References: <200903171417.16760.knikanth@suse.de> <200903171739.50658.knikanth@suse.de> <20090317190905.GA28816@infradead.org> In-Reply-To: <20090317190905.GA28816@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903181028.20689.knikanth@suse.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2367 Lines: 85 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? 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 --- 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); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/