Re: [PATCH v3] ceph: fix write_begin optimization when write is beyond EOF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jun 12, 2021 at 02:35:31PM -0400, Jeff Layton wrote:
>  
> +/**
> + * prep_noread_page - prep a page for writing without reading first
> + * @page: page being prepared
> + * @pos: starting position for the write
> + * @len: length of write
> + *
> + * In some cases we don't need to read at all:
> + * - full page write
> + * - file is currently zero-length
> + * - write that lies in a page that is completely beyond EOF
> + * - write that covers the the page from start to EOF or beyond it
> + *
> + * If any of these criteria are met, then zero out the unwritten parts
> + * of the page and return true. Otherwise, return false.
> + */
> +static bool prep_noread_page(struct page *page, loff_t pos, unsigned int len)
> +{
> +	struct inode *inode = page->mapping->host;
> +	loff_t i_size = i_size_read(inode);
> +	pgoff_t index = pos / PAGE_SIZE;
> +	int pos_in_page = pos & ~PAGE_MASK;

Like the helper.  A couple of minor tweaks ...

	size_t offset = offset_in_page(pos);

> +	/* full page write */
> +	if (pos_in_page == 0 && len == PAGE_SIZE)
> +		goto zero_out;

At some point, we're going to need to pass the full len to
->write_begin, so that we can decide whether it's worth allocating
more than a single page.  Could you make 'len' here size_t, and
check for len >= PAGE_SIZE?

(with the current code, the offset of 0 is a redundant check, but
I'd rather see this future-proofed).




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux