Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753507AbbG0Jxh (ORCPT ); Mon, 27 Jul 2015 05:53:37 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:36653 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752481AbbG0Jxf (ORCPT ); Mon, 27 Jul 2015 05:53:35 -0400 MIME-Version: 1.0 In-Reply-To: <20150727094530.GA15507@infradead.org> References: <1437061068-26118-1-git-send-email-ming.lei@canonical.com> <1437061068-26118-5-git-send-email-ming.lei@canonical.com> <20150727084020.GA28336@infradead.org> <20150727094530.GA15507@infradead.org> Date: Mon, 27 Jul 2015 05:53:33 -0400 Message-ID: Subject: Re: [PATCH v7 4/6] block: loop: prepare for supporing direct IO From: Ming Lei To: Christoph Hellwig , Dave Chinner Cc: Jens Axboe , Linux Kernel Mailing List , "Justin M. Forbes" , Jeff Moyer , Tejun Heo , linux-api@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1707 Lines: 40 On Mon, Jul 27, 2015 at 5:45 AM, Christoph Hellwig wrote: > On Mon, Jul 27, 2015 at 05:41:57AM -0400, Ming Lei wrote: >> > Why the hardcoded value? I suspect this should be more like: >> > >> > if (dio && inode->i_sb->s_bdev && >> > (lo->lo_offset & (bdev_io_min(inode->i_sb->s_bdev) - 1)) != 0) >> > dio = false; >> >> The above can't work if the backing device has a bigger sector size >> (such as 4K), that is why loop's direct-io requires 512 min_io_size of >> backing device. > > Why doesn't it work? If the backing device sector size is 4k > and lo_offset is 0 or a multiple of 4k it should allow direct I/O, > and my code sniplet will allow that. Because size has to be 4k aligned too. And it can't work in the example posted by Dave Chinner: > I have a 4k sector backing device and a 512 byte sector filesystem > image. I can't do 512 byte direct IO to the filesystem image, so I > can't run tools that handle fs images in files using direct Io on > that file. Create a loop device with the filesystem image, and now I > can do 512 byte direct IO to the filesystem image, because all that > direct IO to the filesystem image is now buffered by the loop > device. > > If the loop device does direct io in this situation, the backing > filesystem rejects direct IO from the loop device because it is not > sector (4k) sized/aligned. User now swears, shouts and curses you > from afar. Thanks, -- 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/