lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 12 Aug 2021 22:23:46 +0100
From:   Matthew Wilcox <willy@...radead.org>
To:     David Howells <dhowells@...hat.com>
Cc:     trond.myklebust@...marydata.com, darrick.wong@...cle.com,
        hch@....de, viro@...iv.linux.org.uk, 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: [RFC PATCH v2 3/5] mm: Make swap_readpage() for SWP_FS_OPS use
 ->direct_IO() not ->readpage()

On Thu, Aug 12, 2021 at 09:22:24PM +0100, David Howells wrote:
> +++ b/include/linux/fs.h
> @@ -336,6 +336,7 @@ struct kiocb {
>  	union {
>  		unsigned int		ki_cookie; /* for ->iopoll */
>  		struct wait_page_queue	*ki_waitq; /* for async buffered IO */
> +		struct page	*ki_swap_page;	/* For swapfile_read/write */

Nice idea.

> +static void __swapfile_read_complete(struct kiocb *iocb, long ret, long ret2)

I would make this take a struct page * and just one 'ret'.

> +{
> +	struct page *page = iocb->ki_swap_page;
> +
> +	if (ret == PAGE_SIZE) {

page_size(page)?

> +	kiocb.ki_pos		= page_file_offset(page);

We talked about swap_file_pos(), right?

> +	ret = swap_file->f_mapping->a_ops->direct_IO(&kiocb, &to);
> +
> +	__swapfile_read_complete(&kiocb, ret, 0);
> +	return (ret > 0) ? 0 : ret;

What if it returns a short read?

> +static int swapfile_read(struct swap_info_struct *sis, struct page *page,
> +			 bool synchronous)
> +{
> +	struct swapfile_kiocb *ki;
> +	struct file *swap_file = sis->swap_file;
> +	struct bio_vec bv = {
> +		.bv_page = page,
> +		.bv_len  = thp_size(page),
> +		.bv_offset = 0
> +	};
> +	struct iov_iter to;
> +	int ret;
> +
> +	if (synchronous)
> +		return swapfile_read_sync(sis, page);

Seems a shame to set up the bio_vec and iov_iter twice.  Maybe call:

	iov_iter_bvec(&to, READ, &bv, 1, thp_size(page));

before swapfile_read_sync() and pass a pointer to 'to' to
swapfile_read_sync?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ