From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754603AbbHINoL (ORCPT ); Sun, 9 Aug 2015 09:44:11 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:42396 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753972AbbHINoH (ORCPT ); Sun, 9 Aug 2015 09:44:07 -0400 Date: Sun, 9 Aug 2015 06:44:04 -0700 From: Christoph Hellwig To: Ming Lei Cc: Christoph Hellwig , Jens Axboe , Linux Kernel Mailing List , Dave Kleikamp , Zach Brown , Maxim Patlasov , Andrew Morton , Alexander Viro , Tejun Heo , Dave Chinner Subject: Re: [PATCH v9 6/6] block: loop: support DIO & AIO Message-ID: <20150809134404.GA7190@infradead.org> References: <1438850538-15682-1-git-send-email-ming.lei@canonical.com> <1438850538-15682-7-git-send-email-ming.lei@canonical.com> <20150807074342.GA30547@infradead.org> <20150809064439.GC2436@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Sun, Aug 09, 2015 at 09:04:32AM -0400, Ming Lei wrote: > Now the logical block size of loop is 512byte, but the sector size of > backing device may be 4K, so we can't do 512 byte algined direct > I/O to the filesystem in this situation. > > With runtime switch to buffered I/O we can fix this problem, but > most of times it won't fall in this case. The right way to handle this case is to not allow direct I/O at all, you'll be constantly switching between direct and buffered I/O otherwise, which is a bad idea. > For non-512 byte sector size of backing device, it is needed as > I described above. If the backing device sector size is smaller than that of the loop device you should not allow direct I/O as you will be switching forth and back ue to the IO patterns all the time.