Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752562AbbG3PJF (ORCPT ); Thu, 30 Jul 2015 11:09:05 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:44089 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751384AbbG3PJC (ORCPT ); Thu, 30 Jul 2015 11:09:02 -0400 Date: Thu, 30 Jul 2015 08:09:00 -0700 From: Christoph Hellwig To: Ming Lei Cc: Jens Axboe , linux-kernel@vger.kernel.org, Dave Kleikamp , Zach Brown , Christoph Hellwig , Maxim Patlasov , Andrew Morton , Alexander Viro , Tejun Heo , Dave Chinner , linux-api@vger.kernel.org Subject: Re: [PATCH v8 4/6] block: loop: prepare for supporing direct IO Message-ID: <20150730150900.GA13082@infradead.org> References: <1438256184-23645-1-git-send-email-ming.lei@canonical.com> <1438256184-23645-5-git-send-email-ming.lei@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438256184-23645-5-git-send-email-ming.lei@canonical.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1568 Lines: 43 On Thu, Jul 30, 2015 at 07:36:22AM -0400, Ming Lei wrote: > This patches provides one interface for enabling direct IO > from user space: > > - userspace(such as losetup) can pass 'file' which is > opened/fcntl as O_DIRECT > > Also __loop_update_dio() is introduced to check if direct I/O > can be used on current loop setting. > > The last big change is to introduce LO_FLAGS_DIRECT_IO flag > for userspace to know if direct IO is used to access backing > file. Maybe i'm missing something because I was too busy to follow the current discussion, but this still doesn't check that the loop device sector size is aligned to the sector size of the underlying filesystem. E.g. with this you could create a loop device with a 512 byte sector size on a filesystem with 4k sector size, and it would attempt to use direct I/O and fail. > + unsigned dio_align = inode->i_sb->s_bdev ? > + (bdev_io_min(inode->i_sb->s_bdev) - 1) : 0; > + > + /* > + * We support direct I/O only if lo_offset is aligned > + * with the min I/O size of backing device. > + * > + * Request's offset and size will be checked in I/O path. > + */ > + if (dio) { > + if (!dio_align || (lo->lo_offset & dio_align)) > + use_dio = false; Also this means you'll never use direct I/O on network filesystems, which really would benefit from it. -- 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/