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

2015-08-10 Thread Ming Lei
On Mon, Aug 10, 2015 at 4:08 AM, Christoph Hellwig wrote: > On Sun, Aug 09, 2015 at 10:50:41PM -0400, Ming Lei wrote: >> Christoph, could you share your idea again about this approch? >> >> If you still don't think it is good to switch between buffered I/O >> and direct I/O, I will not do that in

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

2015-08-10 Thread Christoph Hellwig
On Sun, Aug 09, 2015 at 10:50:41PM -0400, Ming Lei wrote: > Christoph, could you share your idea again about this approch? > > If you still don't think it is good to switch between buffered I/O > and direct I/O, I will not do that in next post. If we epxose a 512 byte block size to the loop

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

2015-08-10 Thread Ming Lei
On Mon, Aug 10, 2015 at 4:08 AM, Christoph Hellwig h...@infradead.org wrote: On Sun, Aug 09, 2015 at 10:50:41PM -0400, Ming Lei wrote: Christoph, could you share your idea again about this approch? If you still don't think it is good to switch between buffered I/O and direct I/O, I will not

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

2015-08-10 Thread Christoph Hellwig
On Sun, Aug 09, 2015 at 10:50:41PM -0400, Ming Lei wrote: Christoph, could you share your idea again about this approch? If you still don't think it is good to switch between buffered I/O and direct I/O, I will not do that in next post. If we epxose a 512 byte block size to the loop device

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

2015-08-09 Thread Ming Lei
On Sun, Aug 9, 2015 at 7:41 PM, Dave Chinner wrote: > On Sun, Aug 09, 2015 at 10:27:14AM -0400, Ming Lei wrote: >> On Sun, Aug 9, 2015 at 9:44 AM, Christoph Hellwig 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

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

2015-08-09 Thread Dave Chinner
On Sun, Aug 09, 2015 at 10:27:14AM -0400, Ming Lei wrote: > On Sun, Aug 9, 2015 at 9:44 AM, Christoph Hellwig 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

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

2015-08-09 Thread Ming Lei
On Sun, Aug 9, 2015 at 9:44 AM, Christoph Hellwig 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

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

2015-08-09 Thread Christoph Hellwig
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

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

2015-08-09 Thread Ming Lei
On Sun, Aug 9, 2015 at 2:44 AM, Christoph Hellwig wrote: > On Fri, Aug 07, 2015 at 04:25:52AM -0400, Ming Lei wrote: >> On Fri, Aug 7, 2015 at 3:43 AM, Christoph Hellwig wrote: >> > I really disagree with the per-cmd use_dio tracking. >> >> Could you explain it in a bit? >> >> > >> > If we know

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

2015-08-09 Thread Christoph Hellwig
On Fri, Aug 07, 2015 at 04:25:52AM -0400, Ming Lei wrote: > On Fri, Aug 7, 2015 at 3:43 AM, Christoph Hellwig wrote: > > I really disagree with the per-cmd use_dio tracking. > > Could you explain it in a bit? > > > > > If we know at setup time that the loop device sector size is smaller > >

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

2015-08-09 Thread Christoph Hellwig
On Fri, Aug 07, 2015 at 04:25:52AM -0400, Ming Lei wrote: On Fri, Aug 7, 2015 at 3:43 AM, Christoph Hellwig h...@infradead.org wrote: I really disagree with the per-cmd use_dio tracking. Could you explain it in a bit? If we know at setup time that the loop device sector size is smaller

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

2015-08-09 Thread Ming Lei
On Sun, Aug 9, 2015 at 9:44 AM, Christoph Hellwig h...@infradead.org 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

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

2015-08-09 Thread Christoph Hellwig
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

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

2015-08-09 Thread Dave Chinner
On Sun, Aug 09, 2015 at 10:27:14AM -0400, Ming Lei wrote: On Sun, Aug 9, 2015 at 9:44 AM, Christoph Hellwig h...@infradead.org 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

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

2015-08-09 Thread Ming Lei
On Sun, Aug 9, 2015 at 7:41 PM, Dave Chinner da...@fromorbit.com wrote: On Sun, Aug 09, 2015 at 10:27:14AM -0400, Ming Lei wrote: On Sun, Aug 9, 2015 at 9:44 AM, Christoph Hellwig h...@infradead.org wrote: On Sun, Aug 09, 2015 at 09:04:32AM -0400, Ming Lei wrote: Now the logical block size

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

2015-08-09 Thread Ming Lei
On Sun, Aug 9, 2015 at 2:44 AM, Christoph Hellwig h...@infradead.org wrote: On Fri, Aug 07, 2015 at 04:25:52AM -0400, Ming Lei wrote: On Fri, Aug 7, 2015 at 3:43 AM, Christoph Hellwig h...@infradead.org wrote: I really disagree with the per-cmd use_dio tracking. Could you explain it in a

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

2015-08-07 Thread Ming Lei
On Fri, Aug 7, 2015 at 3:43 AM, Christoph Hellwig wrote: > I really disagree with the per-cmd use_dio tracking. Could you explain it in a bit? > > If we know at setup time that the loop device sector size is smaller > than the sector size of the underlying device we should never allow > dio,

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

2015-08-07 Thread Christoph Hellwig
I really disagree with the per-cmd use_dio tracking. If we know at setup time that the loop device sector size is smaller than the sector size of the underlying device we should never allow dio, and othewise it should always work for data. The ->transfer check also is one to be done at setup

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

2015-08-07 Thread Christoph Hellwig
I really disagree with the per-cmd use_dio tracking. If we know at setup time that the loop device sector size is smaller than the sector size of the underlying device we should never allow dio, and othewise it should always work for data. The -transfer check also is one to be done at setup

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

2015-08-07 Thread Ming Lei
On Fri, Aug 7, 2015 at 3:43 AM, Christoph Hellwig h...@infradead.org wrote: I really disagree with the per-cmd use_dio tracking. Could you explain it in a bit? If we know at setup time that the loop device sector size is smaller than the sector size of the underlying device we should never

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

2015-08-06 Thread Ming Lei
There are about 3 advantages to use direct I/O and AIO on read/write loop's backing file: 1) double cache can be avoided, then memory usage gets decreased a lot 2) not like user space direct I/O, there isn't cost of pinning pages 3) avoid context switch for obtaining good throughput - in

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

2015-08-06 Thread Ming Lei
There are about 3 advantages to use direct I/O and AIO on read/write loop's backing file: 1) double cache can be avoided, then memory usage gets decreased a lot 2) not like user space direct I/O, there isn't cost of pinning pages 3) avoid context switch for obtaining good throughput - in