Thread (18 messages) 18 messages, 6 authors, 2021-08-13

Re: [PATCH 2/2] mm: Make swap_readpage() for SWP_FS_OPS use ->direct_IO() not ->readpage()

From: Matthew Wilcox <willy@infradead.org>
Date: 2021-08-12 13:52:35
Also in: linux-fsdevel, linux-nfs, lkml

On Thu, Aug 12, 2021 at 02:37:59PM +0100, David Howells wrote:
David Howells [off-list ref] wrote:
quoted
Matthew Wilcox [off-list ref] wrote:
quoted
After submitting the IO here ...
quoted
+	if (ret != -EIOCBQUEUED)
+		swapfile_read_complete(&ki->iocb, ret, 0);
We only touch the 'ki' here ... if the caller didn't call read_complete
quoted
+	swapfile_put_kiocb(ki);
Except for here, which is only touched in order to put the refcount.

So why can't swapfile_read_complete() do the work of freeing the ki?
When I was doing something similar for cachefiles, I couldn't get it to work
like that.  I'll have another look at that.
Ah, yes.  generic_file_direct_write() accesses in the kiocb *after* calling
->direct_IO(), so the kiocb *must not* go away until after
generic_file_direct_write() has returned.
This is a read, not a write ... but we don't care about ki_pos being
updated, so that store can be conditioned on IOCB_SWAP being clear.
Or instead of storing directly to ki_pos, we take a pointer to ki_pos
and then redirect that pointer somewhere harmless.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help