Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1192883 > unrolled thread
| Started by | Christoph Hellwig <hch@infradead.org> |
|---|---|
| First post | 2015-07-27 11:50 +0200 |
| Last post | 2015-07-30 10:10 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v7 4/6] block: loop: prepare for supporing direct IO Christoph Hellwig <hch@infradead.org> - 2015-07-27 11:50 +0200
Re: [PATCH v7 4/6] block: loop: prepare for supporing direct IO Ming Lei <ming.lei@canonical.com> - 2015-07-27 12:00 +0200
Re: [PATCH v7 4/6] block: loop: prepare for supporing direct IO Dave Chinner <david@fromorbit.com> - 2015-07-28 00:10 +0200
Re: [PATCH v7 4/6] block: loop: prepare for supporing direct IO Dave Chinner <david@fromorbit.com> - 2015-07-29 10:50 +0200
Re: [PATCH v7 4/6] block: loop: prepare for supporing direct IO Ming Lei <ming.lei@canonical.com> - 2015-07-30 10:10 +0200
| From | Christoph Hellwig <hch@infradead.org> |
|---|---|
| Date | 2015-07-27 11:50 +0200 |
| Subject | Re: [PATCH v7 4/6] block: loop: prepare for supporing direct IO |
| Message-ID | <pQNcJ-6eN-9@gated-at.bofh.it> |
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. -- 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/
[toc] | [next] | [standalone]
| From | Ming Lei <ming.lei@canonical.com> |
|---|---|
| Date | 2015-07-27 12:00 +0200 |
| Message-ID | <pQNmq-6qa-19@gated-at.bofh.it> |
| In reply to | #1192883 |
On Mon, Jul 27, 2015 at 5:45 AM, Christoph Hellwig <hch@infradead.org> 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/
[toc] | [prev] | [next] | [standalone]
| From | Dave Chinner <david@fromorbit.com> |
|---|---|
| Date | 2015-07-28 00:10 +0200 |
| Message-ID | <pQYKS-6Cs-33@gated-at.bofh.it> |
| In reply to | #1192913 |
On Mon, Jul 27, 2015 at 05:53:33AM -0400, Ming Lei wrote: > On Mon, Jul 27, 2015 at 5:45 AM, Christoph Hellwig <hch@infradead.org> 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. So check that, too. Any >= 4k block size filesystem should be doing mostly 4k aligned and sized IO... Cheers, Dave. -- Dave Chinner david@fromorbit.com -- 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/
[toc] | [prev] | [next] | [standalone]
| From | Dave Chinner <david@fromorbit.com> |
|---|---|
| Date | 2015-07-29 10:50 +0200 |
| Message-ID | <pRvdL-31w-9@gated-at.bofh.it> |
| In reply to | #1192913 |
On Wed, Jul 29, 2015 at 03:33:52AM -0400, Ming Lei wrote: > On Mon, Jul 27, 2015 at 1:33 PM, Christoph Hellwig <hch@infradead.org> wrote: > > On Mon, Jul 27, 2015 at 05:53:33AM -0400, Ming Lei wrote: > >> Because size has to be 4k aligned too. > > > > Yes. But again I don't see any reason to limit us to a hardcoded 512 > > byte block size here, especially considering the patches to finally > > From loop block's view, the request size can be any count of 512-byte > sectors, then the transfer size to backing device can't guarantee to be > 4k aligned always. In theory, yes. In practise, doesn't happen very often. > > allow enabling other block sizes from userspace. > > I have some questions about the patchset, and looks the author doesn't > reply it yet. > > On Mon, Jul 27, 2015 at 6:06 PM, Dave Chinner <david@fromorbit.com> wrote: > >> Because size has to be 4k aligned too. > > > > So check that, too. Any >= 4k block size filesystem should be doing > > mostly 4k aligned and sized IO... > > I guess you mean we only use direct IO for the 4k aligned and sized IO? > If so, that won't be efficient because the page cache has to be flushed > during the switch. It will be extremely rare for a 4k block size filesystem to do anything other than 4k aligned and sized IO. Think about it for a minute: what does the page cache do to unaligned IO patterns (i.e. buffered IO)? It does IO in page sizes, and so if the application if doing badly aligned or sized IO with buffered IO, then the underlying device will only ever size page sized and aligned IO. Hence sector aligned IO will only come from applications doing direct IO. If the application is doing direct IO and it's not properly aligned, then it already is going to get sucky performance because most filesystem serialise sub-block size direct IO because concurrent sub-block IOs to the same block usually leads to data corruption. So, really, sector aligned/sized direct IO is a sucky performance path before we even get to the loop device, so we don't really need to care how fast the loop device handles this case. The loop device just needs to ensure that it doesn't corrupt data when badly aligned IOs come in... ;) Cheers, Dave. -- Dave Chinner david@fromorbit.com -- 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/
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@canonical.com> |
|---|---|
| Date | 2015-07-30 10:10 +0200 |
| Message-ID | <pRR4C-Ty-25@gated-at.bofh.it> |
| In reply to | #1194953 |
On Wed, Jul 29, 2015 at 6:08 PM, Dave Chinner <david@fromorbit.com> wrote: > On Wed, Jul 29, 2015 at 07:21:47AM -0400, Ming Lei wrote: >> On Wed, Jul 29, 2015 at 4:41 AM, Dave Chinner <david@fromorbit.com> wrote: >> > On Wed, Jul 29, 2015 at 03:33:52AM -0400, Ming Lei wrote: >> >> On Mon, Jul 27, 2015 at 1:33 PM, Christoph Hellwig <hch@infradead.org> wrote: >> >> > On Mon, Jul 27, 2015 at 05:53:33AM -0400, Ming Lei wrote: >> >> >> Because size has to be 4k aligned too. >> >> > >> >> > Yes. But again I don't see any reason to limit us to a hardcoded 512 >> >> > byte block size here, especially considering the patches to finally >> >> >> >> From loop block's view, the request size can be any count of 512-byte >> >> sectors, then the transfer size to backing device can't guarantee to be >> >> 4k aligned always. >> > >> > In theory, yes. In practise, doesn't happen very often. >> > >> >> > allow enabling other block sizes from userspace. >> >> >> >> I have some questions about the patchset, and looks the author doesn't >> >> reply it yet. >> >> >> >> On Mon, Jul 27, 2015 at 6:06 PM, Dave Chinner <david@fromorbit.com> wrote: >> >> >> Because size has to be 4k aligned too. >> >> > >> >> > So check that, too. Any >= 4k block size filesystem should be doing >> >> > mostly 4k aligned and sized IO... >> >> >> >> I guess you mean we only use direct IO for the 4k aligned and sized IO? >> >> If so, that won't be efficient because the page cache has to be flushed >> >> during the switch. >> > >> > It will be extremely rare for a 4k block size filesystem to do >> > anything other than 4k aligned and sized IO. Think about it for a >> > minute: what does the page cache do to unaligned IO patterns (i.e. >> > buffered IO)? It does IO in page sizes, and so if the application >> > if doing badly aligned or sized IO with buffered IO, then the >> > underlying device will only ever size page sized and aligned IO. >> > >> > Hence sector aligned IO will only come from applications doing >> > direct IO. If the application is doing direct IO and it's not >> > properly aligned, then it already is going to get sucky performance >> > because most filesystem serialise sub-block size direct IO because >> > concurrent sub-block IOs to the same block usually leads to data >> > corruption. >> >> The blocksize of filesysten over loop can be 512, 1024, 2048, and >> suppose sector size of backing device is 4096, then filesystem >> can see aligned direct IO when IO size/offset from application is aligned >> with fs block size, but loop still can't do direct IO for all this >> kind of requests >> against backing file. > > Sure, but again you're talking about a fairly rare configuration. > The vast majority of filesystems use 4k block sizes, just like the > vast majority of applications use buffered IO. Don't jump through > hoops to optimise a case that probably doesn't need optimising. Make > it work correctly first, then optimise performance later when > someone has a need for it to be really fast. OK, I will support 1024, 2048 and 4096 sector size in v8. > >> Another case is that application may access loop block directly, such >> as 'dd if=/dev/loopN', but it may not be common, and maybe it needn't >> to consider. > > 'dd if=/dev/loopN bs=4k....' > > Cheers, > > Dave. > -- > Dave Chinner > david@fromorbit.com > -- > 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/ -- 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/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web