Re: [PATCH v9 6/6] block: loop: support DIO & AIO

From: Ming Lei
Date: Sun Aug 09 2015 - 10:27:21 EST

On Sun, Aug 9, 2015 at 9:44 AM, Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
> 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.

In theory we should not allow dio for this case, but in reality,
as Dave Chinner mentioned, all buffered I/O and normal dio
are page aligned, so we can make most of sane applications
benefited from this patch, and for few insane applications,
frequent swich between buffered I/O and direct I/O shouldn't
be very bad too since draining dio is just like batched sync I/O.

>> 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

I guess you mean bigger? Suppose the backing device sector
size is 256(smaller), direct I/O should be used without problem.

> device you should not allow direct I/O as you will be switching forth
> and back ue to the IO patterns all the time.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at