Re: [PATCH] netfs: fix test for whether we can skip read when writing beyond EOF

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

 



Jeff Layton <jlayton@xxxxxxxxxx> wrote:

> +/**
> + * prep_noread_page - prep a page for writing without reading first

It's a static function, so I'm not sure it needs the kernel doc marker.

It also needs prefixing with "netfs_".

> +	/* pos beyond last page in the file */
> +	if (index > ((i_size - 1) / thp_size(page)))
> +		goto zero_out;

thp_size() is not a constant, so this gets you a DIV instruction.

Why not:

	if (page_offset(page) >= i_size)

or maybe:

	if (pos - offset >= i_size)

> +	zero_user_segments(page, 0, offset, offset + len, thp_size(page));

If you're going to leave a hole in the file, this will break afs, so this
patch needs to deal with that too (basically if copied < len, then the
remainder needs clearing, give or take len being trimmed to the end of the
page).  I can look at adding that.

Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:

> > +	size_t offset = offset_in_page(pos);
> 
> offset_in_thp(page, pos);

I can make this change too.

(btw, can offset_in_thp() have it's second arg renamed to 'pos', not just 'p'?
 'p' is normally used to indicate a pointer of some sort).

--
Linux-cachefs mailing list
Linux-cachefs@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/linux-cachefs




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]
  Powered by Linux