Re: [PATCH 27/33] readahead: laptop mode

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

 



Wu Fengguang <[email protected]> wrote:
>
>   /*
>  + * Set a new look-ahead mark at @new_index.
>  + * Return 0 if the new mark is successfully set.
>  + */
>  +static inline int renew_lookahead(struct address_space *mapping,
>  +				struct file_ra_state *ra,
>  +				pgoff_t index, pgoff_t new_index)
>  +{
>  +	struct page *page;
>  +
>  +	if (index == ra->lookahead_index &&
>  +			new_index >= ra->readahead_index)
>  +		return 1;
>  +
>  +	page = find_page(mapping, new_index);
>  +	if (!page)
>  +		return 1;
>  +
>  +	__SetPageReadahead(page);
>  +	if (ra->lookahead_index == index)
>  +		ra->lookahead_index = new_index;
>  +
>  +	return 0;
>  +}
>  +

This is a pagecache page and other CPUs can look it up and play with it. 
The __SetPageReadahead() is quite wrong here.

And we don't have a reference on this page, so this code appears to be racy.

You could fix that by taking and dropping a ref on the page, but it'd be
quicker to take tree_lock and do the SetPageReadahead() while holding it.

This function is too large to inline.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux