[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YRUbXoMzWVX9X/Vf@casper.infradead.org>
Date: Thu, 12 Aug 2021 14:00:14 +0100
From: Matthew Wilcox <willy@...radead.org>
To: David Howells <dhowells@...hat.com>
Cc: trond.myklebust@...marydata.com, darrick.wong@...cle.com,
hch@....de, jlayton@...nel.org, sfrench@...ba.org,
torvalds@...ux-foundation.org, linux-nfs@...r.kernel.org,
linux-mm@...ck.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] mm: Make swap_readpage() for SWP_FS_OPS use
->direct_IO() not ->readpage()
On Thu, Aug 12, 2021 at 12:57:58PM +0100, David Howells wrote:
I'm not quite sure why we need the refcount.
> + refcount_set(&ki->ki_refcnt, 2);
> + init_sync_kiocb(&ki->iocb, swap_file);
> + ki->page = page;
> + ki->iocb.ki_flags = IOCB_DIRECT | IOCB_SWAP;
> + ki->iocb.ki_pos = page_file_offset(page);
> + ki->iocb.ki_filp = get_file(swap_file);
> + if (!synchronous)
> + ki->iocb.ki_complete = swapfile_read_complete;
> +
> + iov_iter_bvec(&to, READ, &bv, 1, PAGE_SIZE);
> + ret = swap_file->f_mapping->a_ops->direct_IO(&ki->iocb, &to);
After submitting the IO here ...
> + if (ret != -EIOCBQUEUED)
> + swapfile_read_complete(&ki->iocb, ret, 0);
We only touch the 'ki' here ... if the caller didn't call read_complete
> + 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?
Powered by blists - more mailing lists