* [PATCH] block: Fix dio_cleanup() to advance the head index
@ 2023-06-13 21:54 David Howells
2023-06-14 6:23 ` Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: David Howells @ 2023-06-13 21:54 UTC (permalink / raw)
To: Jens Axboe, David Hildenbrand, kernel test robot
Cc: dhowells, Christoph Hellwig, Andrew Morton, Al Viro,
Matthew Wilcox, Jan Kara, Jeff Layton, Jason Gunthorpe,
Logan Gunthorpe, Hillf Danton, Christian Brauner,
Lorenzo Stoakes, linux-fsdevel, linux-block, linux-mm, oe-lkp,
lkp, linux-kernel
Fix dio_bio_cleanup() to advance the head index into the list of pages past
the pages it has released, as __blockdev_direct_IO() will call it twice if
do_direct_IO() fails.
The issue was causing:
WARNING: CPU: 6 PID: 2220 at mm/gup.c:76 try_get_folio
This can be triggered by setting up a clean pair of UDF filesystems on
loopback devices and running the generic/451 xfstest with them as the
scratch and test partitions. Something like the following:
fallocate /mnt2/udf_scratch -l 1G
fallocate /mnt2/udf_test -l 1G
mknod /dev/lo0 b 7 0
mknod /dev/lo1 b 7 1
losetup lo0 /mnt2/udf_scratch
losetup lo1 /mnt2/udf_test
mkfs -t udf /dev/lo0
mkfs -t udf /dev/lo1
cd xfstests
./check generic/451
with xfstests configured by putting the following into local.config:
export FSTYP=udf
export DISABLE_UDF_TEST=1
export TEST_DEV=/dev/lo1
export TEST_DIR=/xfstest.test
export SCRATCH_DEV=/dev/lo0
export SCRATCH_MNT=/xfstest.scratch
Fixes: 1ccf164ec866 ("block: Use iov_iter_extract_pages() and page pinning in direct-io.c")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202306120931.a9606b88-oliver.sang@intel.com
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Christoph Hellwig <hch@infradead.org>
cc: David Hildenbrand <david@redhat.com>
cc: Andrew Morton <akpm@linux-foundation.org>
cc: Jens Axboe <axboe@kernel.dk>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: Matthew Wilcox <willy@infradead.org>
cc: Jan Kara <jack@suse.cz>
cc: Jeff Layton <jlayton@kernel.org>
cc: Jason Gunthorpe <jgg@nvidia.com>
cc: Logan Gunthorpe <logang@deltatee.com>
cc: Hillf Danton <hdanton@sina.com>
cc: Christian Brauner <brauner@kernel.org>
cc: Linus Torvalds <torvalds@linux-foundation.org>
cc: linux-fsdevel@vger.kernel.org
cc: linux-block@vger.kernel.org
cc: linux-kernel@vger.kernel.org
cc: linux-mm@kvack.org
---
fs/direct-io.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 0643f1bb4b59..2ceb378b93c0 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -459,6 +459,7 @@ static inline void dio_cleanup(struct dio *dio, struct dio_submit *sdio)
if (dio->is_pinned)
unpin_user_pages(dio->pages + sdio->head,
sdio->tail - sdio->head);
+ sdio->head = sdio->tail;
}
/*
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: Fix dio_cleanup() to advance the head index
2023-06-13 21:54 [PATCH] block: Fix dio_cleanup() to advance the head index David Howells
@ 2023-06-14 6:23 ` Christoph Hellwig
2023-06-14 7:28 ` David Hildenbrand
2023-06-14 12:59 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2023-06-14 6:23 UTC (permalink / raw)
To: David Howells
Cc: Jens Axboe, David Hildenbrand, kernel test robot,
Christoph Hellwig, Andrew Morton, Al Viro, Matthew Wilcox,
Jan Kara, Jeff Layton, Jason Gunthorpe, Logan Gunthorpe,
Hillf Danton, Christian Brauner, Lorenzo Stoakes, linux-fsdevel,
linux-block, linux-mm, oe-lkp, lkp, linux-kernel
On Tue, Jun 13, 2023 at 10:54:39PM +0100, David Howells wrote:
> --- a/fs/direct-io.c
> +++ b/fs/direct-io.c
> @@ -459,6 +459,7 @@ static inline void dio_cleanup(struct dio *dio, struct dio_submit *sdio)
> if (dio->is_pinned)
> unpin_user_pages(dio->pages + sdio->head,
> sdio->tail - sdio->head);
> + sdio->head = sdio->tail;
So looking at the original patch, it does:
- while (sdio->head < sdio->tail)
- put_page(dio->pages[sdio->head++]);
+ if (dio->is_pinned)
+ unpin_user_pages(dio->pages + sdio->head,
+ sdio->tail - sdio->head);
so yes, we're this looks correct:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: Fix dio_cleanup() to advance the head index
2023-06-13 21:54 [PATCH] block: Fix dio_cleanup() to advance the head index David Howells
2023-06-14 6:23 ` Christoph Hellwig
@ 2023-06-14 7:28 ` David Hildenbrand
2023-06-14 12:59 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2023-06-14 7:28 UTC (permalink / raw)
To: David Howells, Jens Axboe, kernel test robot
Cc: Christoph Hellwig, Andrew Morton, Al Viro, Matthew Wilcox,
Jan Kara, Jeff Layton, Jason Gunthorpe, Logan Gunthorpe,
Hillf Danton, Christian Brauner, Lorenzo Stoakes, linux-fsdevel,
linux-block, linux-mm, oe-lkp, lkp, linux-kernel
On 13.06.23 23:54, David Howells wrote:
>
> Fix dio_bio_cleanup() to advance the head index into the list of pages past
> the pages it has released, as __blockdev_direct_IO() will call it twice if
> do_direct_IO() fails.
>
> The issue was causing:
>
> WARNING: CPU: 6 PID: 2220 at mm/gup.c:76 try_get_folio
>
> This can be triggered by setting up a clean pair of UDF filesystems on
> loopback devices and running the generic/451 xfstest with them as the
> scratch and test partitions. Something like the following:
>
> fallocate /mnt2/udf_scratch -l 1G
> fallocate /mnt2/udf_test -l 1G
> mknod /dev/lo0 b 7 0
> mknod /dev/lo1 b 7 1
> losetup lo0 /mnt2/udf_scratch
> losetup lo1 /mnt2/udf_test
> mkfs -t udf /dev/lo0
> mkfs -t udf /dev/lo1
> cd xfstests
> ./check generic/451
>
> with xfstests configured by putting the following into local.config:
>
> export FSTYP=udf
> export DISABLE_UDF_TEST=1
> export TEST_DEV=/dev/lo1
> export TEST_DIR=/xfstest.test
> export SCRATCH_DEV=/dev/lo0
> export SCRATCH_MNT=/xfstest.scratch
>
> Fixes: 1ccf164ec866 ("block: Use iov_iter_extract_pages() and page pinning in direct-io.c")
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202306120931.a9606b88-oliver.sang@intel.com
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Christoph Hellwig <hch@infradead.org>
> cc: David Hildenbrand <david@redhat.com>
> cc: Andrew Morton <akpm@linux-foundation.org>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: Al Viro <viro@zeniv.linux.org.uk>
> cc: Matthew Wilcox <willy@infradead.org>
> cc: Jan Kara <jack@suse.cz>
> cc: Jeff Layton <jlayton@kernel.org>
> cc: Jason Gunthorpe <jgg@nvidia.com>
> cc: Logan Gunthorpe <logang@deltatee.com>
> cc: Hillf Danton <hdanton@sina.com>
> cc: Christian Brauner <brauner@kernel.org>
> cc: Linus Torvalds <torvalds@linux-foundation.org>
> cc: linux-fsdevel@vger.kernel.org
> cc: linux-block@vger.kernel.org
> cc: linux-kernel@vger.kernel.org
> cc: linux-mm@kvack.org
> ---
> fs/direct-io.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/direct-io.c b/fs/direct-io.c
> index 0643f1bb4b59..2ceb378b93c0 100644
> --- a/fs/direct-io.c
> +++ b/fs/direct-io.c
> @@ -459,6 +459,7 @@ static inline void dio_cleanup(struct dio *dio, struct dio_submit *sdio)
> if (dio->is_pinned)
> unpin_user_pages(dio->pages + sdio->head,
> sdio->tail - sdio->head);
> + sdio->head = sdio->tail;
> }
>
> /*
>
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: Fix dio_cleanup() to advance the head index
2023-06-13 21:54 [PATCH] block: Fix dio_cleanup() to advance the head index David Howells
2023-06-14 6:23 ` Christoph Hellwig
2023-06-14 7:28 ` David Hildenbrand
@ 2023-06-14 12:59 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2023-06-14 12:59 UTC (permalink / raw)
To: David Hildenbrand, kernel test robot, David Howells
Cc: Christoph Hellwig, Andrew Morton, Al Viro, Matthew Wilcox,
Jan Kara, Jeff Layton, Logan Gunthorpe, Hillf Danton,
Christian Brauner, Lorenzo Stoakes, linux-fsdevel, linux-block,
linux-mm, oe-lkp, lkp, linux-kernel, Jason Gunthorpe
On Tue, 13 Jun 2023 22:54:39 +0100, David Howells wrote:
>
> Fix dio_bio_cleanup() to advance the head index into the list of pages past
> the pages it has released, as __blockdev_direct_IO() will call it twice if
> do_direct_IO() fails.
>
> The issue was causing:
>
> [...]
Applied, thanks!
[1/1] block: Fix dio_cleanup() to advance the head index
commit: d44c404207831dfe3b301ff479e964b77914488b
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-14 12:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 21:54 [PATCH] block: Fix dio_cleanup() to advance the head index David Howells
2023-06-14 6:23 ` Christoph Hellwig
2023-06-14 7:28 ` David Hildenbrand
2023-06-14 12:59 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox