Re: [PATCH v2 1/2] filemap: find_lock_entries() now updates start offset

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

 



On Thu, Oct 13, 2022 at 03:57:07PM -0700, Vishal Moola (Oracle) wrote:
> Initially, find_lock_entries() was being passed in the start offset as a
> value. That left the calculation of the offset to the callers. This led
> to complexity in the callers trying to keep track of the index.
> 
> Now find_lock_entires() takes in a pointer to the start offset and

s/entires/entries/

> updates the value to be directly after the last entry found. If no entry is
> found, the offset is not changed. This gets rid of multiple hacky
> calculations that kept track of the start offset.

> @@ -2120,8 +2120,17 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t start,
>  put:
>  		folio_put(folio);
>  	}
> -	rcu_read_unlock();
>  
> +	if (folio_batch_count(fbatch)) {
> +		unsigned long nr = 1;
> +		int idx = folio_batch_count(fbatch) - 1;
> +
> +		folio = fbatch->folios[idx];
> +		if (!xa_is_value(folio) && !folio_test_hugetlb(folio))
> +			nr = folio_nr_pages(folio);
> +		*start = indices[idx] + nr;
> +	}
> +	rcu_read_unlock();
>  	return folio_batch_count(fbatch);

Do we need to move the rcu_read_unlock()?  Pretty sure we can do all
these calculations without it.

This all looks good.  It's certainly more ergonomic to use.

Reviewed-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux