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

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

 



On Tue, Oct 11, 2022 at 02:56:31PM -0700, Vishal Moola (Oracle) wrote:
> @@ -2116,7 +2118,16 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t start,
>  		folio_put(folio);
>  	}
>  	rcu_read_unlock();
> +	nr = folio_batch_count(fbatch);
> +
> +	if (nr) {
> +		folio = fbatch->folios[nr - 1];
> +		nr = folio_nr_pages(folio);
>  
> +		if (folio_test_hugetlb(folio))
> +			nr = 1;
> +		*start = folio->index + nr;
> +	}

Hmm ... this is going to go wrong if the folio is actually a shadow
entry, isn't it?

> +++ b/mm/shmem.c
> @@ -922,21 +922,18 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
>  
>  	folio_batch_init(&fbatch);
>  	index = start;
> -	while (index < end && find_lock_entries(mapping, index, end - 1,
> +	while (index < end && find_lock_entries(mapping, &index, end - 1,
>  			&fbatch, indices)) {
>  		for (i = 0; i < folio_batch_count(&fbatch); i++) {
>  			folio = fbatch.folios[i];
>  
> -			index = indices[i];
> -
>  			if (xa_is_value(folio)) {
>  				if (unfalloc)
>  					continue;
>  				nr_swaps_freed += !shmem_free_swap(mapping,
> -								index, folio);
> +							folio->index, folio);

We know this is a value entry, so we definitely can't look at
folio->index.  This should probably be:

+							indices[i], folio);

> @@ -510,20 +509,18 @@ unsigned long invalidate_mapping_pagevec(struct address_space *mapping,
>  	int i;
>  
>  	folio_batch_init(&fbatch);
> -	while (find_lock_entries(mapping, index, end, &fbatch, indices)) {
> +	while (find_lock_entries(mapping, &index, end, &fbatch, indices)) {
>  		for (i = 0; i < folio_batch_count(&fbatch); i++) {
>  			struct folio *folio = fbatch.folios[i];
>  
>  			/* We rely upon deletion not changing folio->index */
> -			index = indices[i];
>  
>  			if (xa_is_value(folio)) {
>  				count += invalidate_exceptional_entry(mapping,
> -								      index,
> -								      folio);
> +								  folio->index,
> +								  folio);

Same here.  I'd fix the indent while you're at it to get more on that
second line and not need a third line.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux