linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the btrfs tree with Linus' tree
@ 2021-10-31 23:53 Stephen Rothwell
  2021-11-02 10:42 ` David Sterba
  0 siblings, 1 reply; 11+ messages in thread
From: Stephen Rothwell @ 2021-10-31 23:53 UTC (permalink / raw)
  To: David Sterba
  Cc: David Sterba, Linux Kernel Mailing List, Linux Next Mailing List,
	Qu Wenruo

[-- Attachment #1: Type: text/plain, Size: 7862 bytes --]

Hi all,

Today's linux-next merge of the btrfs tree got a conflict in:

  fs/btrfs/lzo.c

between commit:

  ccaa66c8dd27 ("Revert "btrfs: compression: drop kmap/kunmap from lzo"")

from Linus' tree and commit:

  d4088803f511 ("btrfs: subpage: make lzo_compress_pages() compatible")

from the btrfs tree.

I fixed it up (this may be completely wrong or incomplete :-( - see below)
and can carry the fix as necessary. This is now fixed as far as linux-next
is concerned, but any non trivial conflicts should be mentioned to your
upstream maintainer when your tree is submitted for merging.  You may
also want to consider cooperating with the maintainer of the conflicting
tree to minimise any particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/btrfs/lzo.c
index 3dbe6eb5fda7,00cffc183ec0..000000000000
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@@ -112,61 -112,126 +112,130 @@@ static inline size_t read_compress_leng
  	return le32_to_cpu(dlen);
  }
  
+ /*
+  * Will do:
+  *
+  * - Write a segment header into the destination
+  * - Copy the compressed buffer into the destination
+  * - Make sure we have enough space in the last sector to fit a segment header
+  *   If not, we will pad at most (LZO_LEN (4)) - 1 bytes of zeros.
+  *
+  * Will allocate new pages when needed.
+  */
+ static int copy_compressed_data_to_page(char *compressed_data,
+ 					size_t compressed_size,
+ 					struct page **out_pages,
+ 					u32 *cur_out,
+ 					const u32 sectorsize)
+ {
+ 	u32 sector_bytes_left;
+ 	u32 orig_out;
+ 	struct page *cur_page;
+ 
+ 	/*
+ 	 * We never allow a segment header crossing sector boundary, previous
+ 	 * run should ensure we have enough space left inside the sector.
+ 	 */
+ 	ASSERT((*cur_out / sectorsize) == (*cur_out + LZO_LEN - 1) / sectorsize);
+ 
+ 	cur_page = out_pages[*cur_out / PAGE_SIZE];
+ 	/* Allocate a new page */
+ 	if (!cur_page) {
+ 		cur_page = alloc_page(GFP_NOFS);
+ 		if (!cur_page)
+ 			return -ENOMEM;
+ 		out_pages[*cur_out / PAGE_SIZE] = cur_page;
+ 	}
+ 
 -	write_compress_length(page_address(cur_page) + offset_in_page(*cur_out),
++	write_compress_length(kmap(cur_page) + offset_in_page(*cur_out),
+ 			      compressed_size);
++	kunmap(cur_page);
+ 	*cur_out += LZO_LEN;
+ 
+ 	orig_out = *cur_out;
+ 
+ 	/* Copy compressed data */
+ 	while (*cur_out - orig_out < compressed_size) {
+ 		u32 copy_len = min_t(u32, sectorsize - *cur_out % sectorsize,
+ 				     orig_out + compressed_size - *cur_out);
+ 
+ 		cur_page = out_pages[*cur_out / PAGE_SIZE];
+ 		/* Allocate a new page */
+ 		if (!cur_page) {
+ 			cur_page = alloc_page(GFP_NOFS);
+ 			if (!cur_page)
+ 				return -ENOMEM;
+ 			out_pages[*cur_out / PAGE_SIZE] = cur_page;
+ 		}
+ 
 -		memcpy(page_address(cur_page) + offset_in_page(*cur_out),
++		memcpy(kmap(cur_page) + offset_in_page(*cur_out),
+ 		       compressed_data + *cur_out - orig_out, copy_len);
++		kunmap(cur_page);
+ 
+ 		*cur_out += copy_len;
+ 	}
+ 
+ 	/*
+ 	 * Check if we can fit the next segment header into the remaining space
+ 	 * of the sector.
+ 	 */
+ 	sector_bytes_left = round_up(*cur_out, sectorsize) - *cur_out;
+ 	if (sector_bytes_left >= LZO_LEN || sector_bytes_left == 0)
+ 		return 0;
+ 
+ 	/* The remaining size is not enough, pad it with zeros */
 -	memset(page_address(cur_page) + offset_in_page(*cur_out), 0,
++	memset(kmap(cur_page) + offset_in_page(*cur_out), 0,
+ 	       sector_bytes_left);
++	kunmap(cur_page);
+ 	*cur_out += sector_bytes_left;
+ 	return 0;
+ }
+ 
  int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
  		u64 start, struct page **pages, unsigned long *out_pages,
  		unsigned long *total_in, unsigned long *total_out)
  {
  	struct workspace *workspace = list_entry(ws, struct workspace, list);
+ 	const u32 sectorsize = btrfs_sb(mapping->host->i_sb)->sectorsize;
+ 	struct page *page_in = NULL;
  	int ret = 0;
- 	char *data_in;
- 	char *cpage_out, *sizes_ptr;
- 	int nr_pages = 0;
- 	struct page *in_page = NULL;
- 	struct page *out_page = NULL;
- 	unsigned long bytes_left;
- 	unsigned long len = *total_out;
- 	unsigned long nr_dest_pages = *out_pages;
- 	const unsigned long max_out = nr_dest_pages * PAGE_SIZE;
- 	size_t in_len;
- 	size_t out_len;
- 	char *buf;
- 	unsigned long tot_in = 0;
- 	unsigned long tot_out = 0;
- 	unsigned long pg_bytes_left;
- 	unsigned long out_offset;
- 	unsigned long bytes;
+ 	/* Points to the file offset of input data */
+ 	u64 cur_in = start;
+ 	/* Points to the current output byte */
+ 	u32 cur_out = 0;
+ 	u32 len = *total_out;
++	char *sizes_ptr;
  
  	*out_pages = 0;
  	*total_out = 0;
  	*total_in = 0;
  
- 	in_page = find_get_page(mapping, start >> PAGE_SHIFT);
- 	data_in = kmap(in_page);
- 
  	/*
- 	 * store the size of all chunks of compressed data in
- 	 * the first 4 bytes
+ 	 * Skip the header for now, we will later come back and write the total
+ 	 * compressed size
  	 */
- 	out_page = alloc_page(GFP_NOFS);
- 	if (out_page == NULL) {
- 		ret = -ENOMEM;
- 		goto out;
- 	}
- 	cpage_out = kmap(out_page);
- 	out_offset = LZO_LEN;
- 	tot_out = LZO_LEN;
- 	pages[0] = out_page;
- 	nr_pages = 1;
- 	pg_bytes_left = PAGE_SIZE - LZO_LEN;
- 
- 	/* compress at most one page of data each time */
- 	in_len = min(len, PAGE_SIZE);
- 	while (tot_in < len) {
- 		ret = lzo1x_1_compress(data_in, in_len, workspace->cbuf,
- 				       &out_len, workspace->mem);
- 		if (ret != LZO_E_OK) {
- 			pr_debug("BTRFS: lzo in loop returned %d\n",
- 			       ret);
+ 	cur_out += LZO_LEN;
+ 	while (cur_in < start + len) {
+ 		const u32 sectorsize_mask = sectorsize - 1;
+ 		u32 sector_off = (cur_in - start) & sectorsize_mask;
+ 		u32 in_len;
+ 		size_t out_len;
+ 
+ 		/* Get the input page first */
+ 		if (!page_in) {
+ 			page_in = find_get_page(mapping, cur_in >> PAGE_SHIFT);
+ 			ASSERT(page_in);
+ 		}
+ 
+ 		/* Compress at most one sector of data each time */
+ 		in_len = min_t(u32, start + len - cur_in, sectorsize - sector_off);
+ 		ASSERT(in_len);
 -		ret = lzo1x_1_compress(page_address(page_in) +
++		ret = lzo1x_1_compress(kmap(page_in) +
+ 				       offset_in_page(cur_in), in_len,
+ 				       workspace->cbuf, &out_len,
+ 				       workspace->mem);
+ 		if (ret < 0) {
+ 			pr_debug("BTRFS: lzo in loop returned %d\n", ret);
  			ret = -EIO;
  			goto out;
  		}
@@@ -236,46 -252,21 +256,24 @@@
  			goto out;
  		}
  
- 		/* we're all done */
- 		if (tot_in >= len)
- 			break;
- 
- 		if (tot_out > max_out)
- 			break;
- 
- 		bytes_left = len - tot_in;
- 		kunmap(in_page);
- 		put_page(in_page);
- 
- 		start += PAGE_SIZE;
- 		in_page = find_get_page(mapping, start >> PAGE_SHIFT);
- 		data_in = kmap(in_page);
- 		in_len = min(bytes_left, PAGE_SIZE);
- 	}
- 
- 	if (tot_out >= tot_in) {
- 		ret = -E2BIG;
- 		goto out;
+ 		/* Check if we have reached page boundary */
+ 		if (IS_ALIGNED(cur_in, PAGE_SIZE)) {
++			kunmap(page_in);
+ 			put_page(page_in);
+ 			page_in = NULL;
+ 		}
  	}
  
- 	/* store the size of all chunks of compressed data */
+ 	/* Store the size of all chunks of compressed data */
 -	write_compress_length(page_address(pages[0]), cur_out);
 +	sizes_ptr = kmap_local_page(pages[0]);
- 	write_compress_length(sizes_ptr, tot_out);
++	write_compress_length(sizes_ptr, cur_out);
 +	kunmap_local(sizes_ptr);
  
  	ret = 0;
- 	*total_out = tot_out;
- 	*total_in = tot_in;
+ 	*total_out = cur_out;
+ 	*total_in = cur_in - start;
  out:
- 	*out_pages = nr_pages;
- 	if (out_page)
- 		kunmap(out_page);
- 
- 	if (in_page) {
- 		kunmap(in_page);
- 		put_page(in_page);
- 	}
- 
+ 	*out_pages = DIV_ROUND_UP(cur_out, PAGE_SIZE);
  	return ret;
  }
  

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: linux-next: manual merge of the btrfs tree with Linus' tree
  2021-10-31 23:53 linux-next: manual merge of the btrfs tree with Linus' tree Stephen Rothwell
@ 2021-11-02 10:42 ` David Sterba
  2021-11-02 11:44   ` Stephen Rothwell
  0 siblings, 1 reply; 11+ messages in thread
From: David Sterba @ 2021-11-02 10:42 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: David Sterba, Linux Kernel Mailing List, Linux Next Mailing List,
	Qu Wenruo

On Mon, Nov 01, 2021 at 10:53:41AM +1100, Stephen Rothwell wrote:
> Hi all,
> 
> Today's linux-next merge of the btrfs tree got a conflict in:
> 
>   fs/btrfs/lzo.c
> 
> between commit:
> 
>   ccaa66c8dd27 ("Revert "btrfs: compression: drop kmap/kunmap from lzo"")
> 
> from Linus' tree and commit:
> 
>   d4088803f511 ("btrfs: subpage: make lzo_compress_pages() compatible")
> 
> from the btrfs tree.
> 
> I fixed it up (this may be completely wrong or incomplete :-( - see below)
> and can carry the fix as necessary. This is now fixed as far as linux-next
> is concerned, but any non trivial conflicts should be mentioned to your
> upstream maintainer when your tree is submitted for merging.  You may
> also want to consider cooperating with the maintainer of the conflicting
> tree to minimise any particularly complex conflicts.

Thanks, it's a bit different that I did as a proposed conflict
resulution and Linus resolved it in a yet another way. I'll refresh my
for-next branch today to minimize the conflict surface.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: linux-next: manual merge of the btrfs tree with Linus' tree
  2021-11-02 10:42 ` David Sterba
@ 2021-11-02 11:44   ` Stephen Rothwell
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Rothwell @ 2021-11-02 11:44 UTC (permalink / raw)
  To: David Sterba
  Cc: David Sterba, Linux Kernel Mailing List, Linux Next Mailing List,
	Qu Wenruo

[-- Attachment #1: Type: text/plain, Size: 390 bytes --]

Hi David,

On Tue, 2 Nov 2021 11:42:44 +0100 David Sterba <dsterba@suse.cz> wrote:
>
> Thanks, it's a bit different that I did as a proposed conflict
> resulution and Linus resolved it in a yet another way. I'll refresh my
> for-next branch today to minimize the conflict surface.

Thanks.  I really could only try to pattern match my resolution.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* linux-next: manual merge of the btrfs tree with Linus' tree
@ 2024-01-10 23:03 Stephen Rothwell
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Rothwell @ 2024-01-10 23:03 UTC (permalink / raw)
  To: David Sterba
  Cc: Christian Brauner, David Sterba, Linus Torvalds,
	Linux Kernel Mailing List, Linux Next Mailing List,
	Matthew Wilcox (Oracle),
	Qu Wenruo

[-- Attachment #1: Type: text/plain, Size: 1477 bytes --]

Hi all,

FIXME: Add owner of second tree to To:
       Add author(s)/SOB of conflicting commits.

Today's linux-next merge of the btrfs tree got a conflict in:

  fs/btrfs/extent_io.c

between commits:

  affc5af36bbb ("Merge tag 'for-6.8-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux")
  600f111ef51d ("fs: Rename mapping private members")

from Linus' tree and commit:

  08236d11031b ("btrfs: cache folio size and shift in extent_buffer")

from the btrfs tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/btrfs/extent_io.c
index cfd2967f04a2,c8aabe3be169..000000000000
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@@ -3677,7 -3668,9 +3668,9 @@@ reallocate
  		 * and free the allocated page.
  		 */
  		folio = eb->folios[i];
+ 		eb->folio_size = folio_size(folio);
+ 		eb->folio_shift = folio_shift(folio);
 -		spin_lock(&mapping->private_lock);
 +		spin_lock(&mapping->i_private_lock);
  		/* Should not fail, as we have preallocated the memory */
  		ret = attach_extent_buffer_folio(eb, folio, prealloc);
  		ASSERT(!ret);

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* linux-next: manual merge of the btrfs tree with Linus' tree
@ 2024-01-08 22:54 Stephen Rothwell
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Rothwell @ 2024-01-08 22:54 UTC (permalink / raw)
  To: David Sterba
  Cc: Christian Brauner, David Sterba, Linux Kernel Mailing List,
	Linux Next Mailing List, Matthew Wilcox (Oracle),
	Qu Wenruo

[-- Attachment #1: Type: text/plain, Size: 11454 bytes --]

Hi all,

Today's linux-next merge of the btrfs tree got a conflict in:

  fs/btrfs/extent_io.c

between commit:

  600f111ef51d ("fs: Rename mapping private members")

from Linus' tree and commits:

  08236d11031b ("btrfs: cache folio size and shift in extent_buffer")
  13df3775efca ("btrfs: cleanup metadata page pointer usage")
  082d5bb9b336 ("btrfs: migrate extent_buffer::pages[] to folio")
  09e6cef19c9f ("btrfs: refactor alloc_extent_buffer() to allocate-then-attach method")
  cfbf07e2787e ("btrfs: migrate to use folio private instead of page private")

from the btrfs tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/btrfs/extent_io.c
index b6ff6f320198,c8aabe3be169..000000000000
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@@ -874,14 -901,14 +901,14 @@@ static int attach_extent_buffer_folio(s
  	 * For cloned or dummy extent buffers, their pages are not mapped and
  	 * will not race with any other ebs.
  	 */
- 	if (page->mapping)
- 		lockdep_assert_held(&page->mapping->i_private_lock);
+ 	if (folio->mapping)
 -		lockdep_assert_held(&folio->mapping->private_lock);
++		lockdep_assert_held(&folio->mapping->i_private_lock);
  
  	if (fs_info->nodesize >= PAGE_SIZE) {
- 		if (!PagePrivate(page))
- 			attach_page_private(page, eb);
+ 		if (!folio_test_private(folio))
+ 			folio_attach_private(folio, eb);
  		else
- 			WARN_ON(page->private != (unsigned long)eb);
+ 			WARN_ON(folio_get_private(folio) != eb);
  		return 0;
  	}
  
@@@ -1741,9 -1775,9 +1775,9 @@@ static int submit_eb_subpage(struct pag
  		 * Take private lock to ensure the subpage won't be detached
  		 * in the meantime.
  		 */
 -		spin_lock(&page->mapping->private_lock);
 +		spin_lock(&page->mapping->i_private_lock);
- 		if (!PagePrivate(page)) {
+ 		if (!folio_test_private(folio)) {
 -			spin_unlock(&page->mapping->private_lock);
 +			spin_unlock(&page->mapping->i_private_lock);
  			break;
  		}
  		spin_lock_irqsave(&subpage->lock, flags);
@@@ -1816,9 -1851,9 +1851,9 @@@ static int submit_eb_page(struct page *
  	if (btrfs_sb(page->mapping->host->i_sb)->nodesize < PAGE_SIZE)
  		return submit_eb_subpage(page, wbc);
  
 -	spin_lock(&mapping->private_lock);
 +	spin_lock(&mapping->i_private_lock);
- 	if (!PagePrivate(page)) {
+ 	if (!folio_test_private(folio)) {
 -		spin_unlock(&mapping->private_lock);
 +		spin_unlock(&mapping->i_private_lock);
  		return 0;
  	}
  
@@@ -3062,10 -3097,10 +3097,10 @@@ static bool folio_range_has_eb(struct b
  {
  	struct btrfs_subpage *subpage;
  
- 	lockdep_assert_held(&page->mapping->i_private_lock);
 -	lockdep_assert_held(&folio->mapping->private_lock);
++	lockdep_assert_held(&folio->mapping->i_private_lock);
  
- 	if (PagePrivate(page)) {
- 		subpage = (struct btrfs_subpage *)page->private;
+ 	if (folio_test_private(folio)) {
+ 		subpage = folio_get_private(folio);
  		if (atomic_read(&subpage->eb_refs))
  			return true;
  		/*
@@@ -3084,15 -3119,15 +3119,15 @@@ static void detach_extent_buffer_folio(
  	const bool mapped = !test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags);
  
  	/*
- 	 * For mapped eb, we're going to change the page private, which should
+ 	 * For mapped eb, we're going to change the folio private, which should
 -	 * be done under the private_lock.
 +	 * be done under the i_private_lock.
  	 */
  	if (mapped)
- 		spin_lock(&page->mapping->i_private_lock);
 -		spin_lock(&folio->mapping->private_lock);
++		spin_lock(&folio->mapping->i_private_lock);
  
- 	if (!PagePrivate(page)) {
+ 	if (!folio_test_private(folio)) {
  		if (mapped)
- 			spin_unlock(&page->mapping->i_private_lock);
 -			spin_unlock(&folio->mapping->private_lock);
++			spin_unlock(&folio->mapping->i_private_lock);
  		return;
  	}
  
@@@ -3101,22 -3136,18 +3136,18 @@@
  		 * We do this since we'll remove the pages after we've
  		 * removed the eb from the radix tree, so we could race
  		 * and have this page now attached to the new eb.  So
- 		 * only clear page_private if it's still connected to
+ 		 * only clear folio if it's still connected to
  		 * this eb.
  		 */
- 		if (PagePrivate(page) &&
- 		    page->private == (unsigned long)eb) {
+ 		if (folio_test_private(folio) && folio_get_private(folio) == eb) {
  			BUG_ON(test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags));
- 			BUG_ON(PageDirty(page));
- 			BUG_ON(PageWriteback(page));
- 			/*
- 			 * We need to make sure we haven't be attached
- 			 * to a new eb.
- 			 */
- 			detach_page_private(page);
+ 			BUG_ON(folio_test_dirty(folio));
+ 			BUG_ON(folio_test_writeback(folio));
+ 			/* We need to make sure we haven't be attached to a new eb. */
+ 			folio_detach_private(folio);
  		}
  		if (mapped)
- 			spin_unlock(&page->mapping->i_private_lock);
 -			spin_unlock(&folio->mapping->private_lock);
++			spin_unlock(&folio->mapping->i_private_lock);
  		return;
  	}
  
@@@ -3130,16 -3161,16 +3161,16 @@@
  		return;
  	}
  
- 	btrfs_page_dec_eb_refs(fs_info, page);
+ 	btrfs_folio_dec_eb_refs(fs_info, folio);
  
  	/*
- 	 * We can only detach the page private if there are no other ebs in the
+ 	 * We can only detach the folio private if there are no other ebs in the
  	 * page range and no unfinished IO.
  	 */
- 	if (!page_range_has_eb(fs_info, page))
- 		btrfs_detach_subpage(fs_info, page);
+ 	if (!folio_range_has_eb(fs_info, folio))
+ 		btrfs_detach_subpage(fs_info, folio);
  
- 	spin_unlock(&page->mapping->i_private_lock);
 -	spin_unlock(&folio->mapping->private_lock);
++	spin_unlock(&folio->mapping->i_private_lock);
  }
  
  /* Release all pages attached to the extent buffer */
@@@ -3516,11 -3603,9 +3603,9 @@@ struct extent_buffer *alloc_extent_buff
  
  	btrfs_set_buffer_lockdep_class(lockdep_owner, eb, level);
  
- 	num_pages = num_extent_pages(eb);
- 
  	/*
- 	 * Preallocate page->private for subpage case, so that we won't
+ 	 * Preallocate folio private for subpage case, so that we won't
 -	 * allocate memory with private_lock nor page lock hold.
 +	 * allocate memory with i_private_lock nor page lock hold.
  	 *
  	 * The memory will be freed by attach_extent_buffer_page() or freed
  	 * manually if we exit earlier.
@@@ -3533,26 -3618,61 +3618,61 @@@
  		}
  	}
  
- 	for (i = 0; i < num_pages; i++, index++) {
- 		p = find_or_create_page(mapping, index, GFP_NOFS|__GFP_NOFAIL);
- 		if (!p) {
- 			exists = ERR_PTR(-ENOMEM);
- 			btrfs_free_subpage(prealloc);
- 			goto free_eb;
+ reallocate:
+ 	/* Allocate all pages first. */
+ 	ret = alloc_eb_folio_array(eb, __GFP_NOFAIL);
+ 	if (ret < 0) {
+ 		btrfs_free_subpage(prealloc);
+ 		goto out;
+ 	}
+ 
+ 	num_folios = num_extent_folios(eb);
+ 	/* Attach all pages to the filemap. */
+ 	for (int i = 0; i < num_folios; i++) {
+ 		struct folio *folio;
+ 
+ 		ret = attach_eb_folio_to_filemap(eb, i, &existing_eb);
+ 		if (ret > 0) {
+ 			ASSERT(existing_eb);
+ 			goto out;
  		}
  
- 		spin_lock(&mapping->i_private_lock);
- 		exists = grab_extent_buffer(fs_info, p);
- 		if (exists) {
- 			spin_unlock(&mapping->i_private_lock);
- 			unlock_page(p);
- 			put_page(p);
- 			mark_extent_buffer_accessed(exists, p);
- 			btrfs_free_subpage(prealloc);
- 			goto free_eb;
+ 		/*
+ 		 * TODO: Special handling for a corner case where the order of
+ 		 * folios mismatch between the new eb and filemap.
+ 		 *
+ 		 * This happens when:
+ 		 *
+ 		 * - the new eb is using higher order folio
+ 		 *
+ 		 * - the filemap is still using 0-order folios for the range
+ 		 *   This can happen at the previous eb allocation, and we don't
+ 		 *   have higher order folio for the call.
+ 		 *
+ 		 * - the existing eb has already been freed
+ 		 *
+ 		 * In this case, we have to free the existing folios first, and
+ 		 * re-allocate using the same order.
+ 		 * Thankfully this is not going to happen yet, as we're still
+ 		 * using 0-order folios.
+ 		 */
+ 		if (unlikely(ret == -EAGAIN)) {
+ 			ASSERT(0);
+ 			goto reallocate;
  		}
+ 		attached++;
+ 
+ 		/*
+ 		 * Only after attach_eb_folio_to_filemap(), eb->folios[] is
+ 		 * reliable, as we may choose to reuse the existing page cache
+ 		 * and free the allocated page.
+ 		 */
+ 		folio = eb->folios[i];
+ 		eb->folio_size = folio_size(folio);
+ 		eb->folio_shift = folio_shift(folio);
 -		spin_lock(&mapping->private_lock);
++		spin_lock(&mapping->i_private_lock);
  		/* Should not fail, as we have preallocated the memory */
- 		ret = attach_extent_buffer_page(eb, p, prealloc);
+ 		ret = attach_extent_buffer_folio(eb, folio, prealloc);
  		ASSERT(!ret);
  		/*
  		 * To inform we have extra eb under allocation, so that
@@@ -3563,12 -3683,21 +3683,21 @@@
  		 * detach_extent_buffer_page().
  		 * Thus needs no special handling in error path.
  		 */
- 		btrfs_page_inc_eb_refs(fs_info, p);
+ 		btrfs_folio_inc_eb_refs(fs_info, folio);
 -		spin_unlock(&mapping->private_lock);
 +		spin_unlock(&mapping->i_private_lock);
  
- 		WARN_ON(btrfs_page_test_dirty(fs_info, p, eb->start, eb->len));
- 		eb->pages[i] = p;
- 		if (!btrfs_page_test_uptodate(fs_info, p, eb->start, eb->len))
+ 		WARN_ON(btrfs_folio_test_dirty(fs_info, folio, eb->start, eb->len));
+ 
+ 		/*
+ 		 * Check if the current page is physically contiguous with previous eb
+ 		 * page.
+ 		 * At this stage, either we allocated a large folio, thus @i
+ 		 * would only be 0, or we fall back to per-page allocation.
+ 		 */
+ 		if (i && folio_page(eb->folios[i - 1], 0) + 1 != folio_page(folio, 0))
+ 			page_contig = false;
+ 
+ 		if (!btrfs_folio_test_uptodate(fs_info, folio, eb->start, eb->len))
  			uptodate = 0;
  
  		/*
@@@ -4566,11 -4773,11 +4773,11 @@@ static int try_release_subpage_extent_b
  		release_extent_buffer(eb);
  	}
  	/*
- 	 * Finally to check if we have cleared page private, as if we have
- 	 * released all ebs in the page, the page private should be cleared now.
+ 	 * Finally to check if we have cleared folio private, as if we have
+ 	 * released all ebs in the page, the folio private should be cleared now.
  	 */
 -	spin_lock(&page->mapping->private_lock);
 +	spin_lock(&page->mapping->i_private_lock);
- 	if (!PagePrivate(page))
+ 	if (!folio_test_private(page_folio(page)))
  		ret = 1;
  	else
  		ret = 0;
@@@ -4587,12 -4795,12 +4795,12 @@@ int try_release_extent_buffer(struct pa
  		return try_release_subpage_extent_buffer(page);
  
  	/*
- 	 * We need to make sure nobody is changing page->private, as we rely on
- 	 * page->private as the pointer to extent buffer.
+ 	 * We need to make sure nobody is changing folio private, as we rely on
+ 	 * folio private as the pointer to extent buffer.
  	 */
 -	spin_lock(&page->mapping->private_lock);
 +	spin_lock(&page->mapping->i_private_lock);
- 	if (!PagePrivate(page)) {
+ 	if (!folio_test_private(folio)) {
 -		spin_unlock(&page->mapping->private_lock);
 +		spin_unlock(&page->mapping->i_private_lock);
  		return 1;
  	}
  

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* linux-next: manual merge of the btrfs tree with Linus' tree
@ 2023-10-31  0:18 Stephen Rothwell
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Rothwell @ 2023-10-31  0:18 UTC (permalink / raw)
  To: David Sterba
  Cc: Christian Brauner, David Sterba, Filipe Manana, Jeff Layton,
	Linux Kernel Mailing List, Linux Next Mailing List

[-- Attachment #1: Type: text/plain, Size: 7847 bytes --]

Hi all,

Today's linux-next merge of the btrfs tree got conflicts in:

  fs/btrfs/file.c
  fs/btrfs/inode.c
  fs/btrfs/transaction.c

between commit:

  b1c38a1338c9 ("btrfs: convert to new timestamp accessors")

from Linus' tree and commits:

  8b9d032225be ("btrfs: remove redundant root argument from btrfs_update_inode()")
  0a5d0dc55fcb ("btrfs: remove redundant root argument from btrfs_update_inode_fallback()")
  8b9d032225be ("btrfs: remove redundant root argument from btrfs_update_inode()")
  c6e8f898f56f ("btrfs: open code timespec64 in struct btrfs_inode")

from the btrfs tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/btrfs/file.c
index 278a4ea651e1,92419cb8508a..000000000000
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@@ -2474,10 -2476,9 +2477,10 @@@ int btrfs_replace_file_extents(struct b
  		inode_inc_iversion(&inode->vfs_inode);
  
  		if (!extent_info || extent_info->update_times)
 -			inode->vfs_inode.i_mtime = inode_set_ctime_current(&inode->vfs_inode);
 +			inode_set_mtime_to_ts(&inode->vfs_inode,
 +					      inode_set_ctime_current(&inode->vfs_inode));
  
- 		ret = btrfs_update_inode(trans, root, inode);
+ 		ret = btrfs_update_inode(trans, inode);
  		if (ret)
  			break;
  
@@@ -2716,8 -2717,8 +2719,8 @@@ static int btrfs_punch_hole(struct fil
  
  	ASSERT(trans != NULL);
  	inode_inc_iversion(inode);
 -	inode->i_mtime = inode_set_ctime_current(inode);
 +	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
- 	ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ 	ret = btrfs_update_inode(trans, BTRFS_I(inode));
  	updated_inode = true;
  	btrfs_end_transaction(trans);
  	btrfs_btree_balance_dirty(fs_info);
diff --cc fs/btrfs/inode.c
index 6e3ce1aecb6e,b388505c91cc..000000000000
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@@ -3922,24 -3928,22 +3928,22 @@@ static void fill_inode_item(struct btrf
  	btrfs_set_token_inode_nlink(&token, item, inode->i_nlink);
  
  	btrfs_set_token_timespec_sec(&token, &item->atime,
 -				     inode->i_atime.tv_sec);
 +				     inode_get_atime_sec(inode));
  	btrfs_set_token_timespec_nsec(&token, &item->atime,
 -				      inode->i_atime.tv_nsec);
 +				      inode_get_atime_nsec(inode));
  
  	btrfs_set_token_timespec_sec(&token, &item->mtime,
 -				     inode->i_mtime.tv_sec);
 +				     inode_get_mtime_sec(inode));
  	btrfs_set_token_timespec_nsec(&token, &item->mtime,
 -				      inode->i_mtime.tv_nsec);
 +				      inode_get_mtime_nsec(inode));
  
  	btrfs_set_token_timespec_sec(&token, &item->ctime,
 -				     inode_get_ctime(inode).tv_sec);
 +				     inode_get_ctime_sec(inode));
  	btrfs_set_token_timespec_nsec(&token, &item->ctime,
 -				      inode_get_ctime(inode).tv_nsec);
 +				      inode_get_ctime_nsec(inode));
  
- 	btrfs_set_token_timespec_sec(&token, &item->otime,
- 				     BTRFS_I(inode)->i_otime.tv_sec);
- 	btrfs_set_token_timespec_nsec(&token, &item->otime,
- 				      BTRFS_I(inode)->i_otime.tv_nsec);
+ 	btrfs_set_token_timespec_sec(&token, &item->otime, BTRFS_I(inode)->i_otime_sec);
+ 	btrfs_set_token_timespec_nsec(&token, &item->otime, BTRFS_I(inode)->i_otime_nsec);
  
  	btrfs_set_token_inode_nbytes(&token, item, inode_get_bytes(inode));
  	btrfs_set_token_inode_generation(&token, item,
@@@ -4132,8 -4135,9 +4135,8 @@@ err
  	btrfs_i_size_write(dir, dir->vfs_inode.i_size - name->len * 2);
  	inode_inc_iversion(&inode->vfs_inode);
  	inode_inc_iversion(&dir->vfs_inode);
 -	inode_set_ctime_current(&inode->vfs_inode);
 -	dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode);
 + 	inode_set_mtime_to_ts(&dir->vfs_inode, inode_set_ctime_current(&dir->vfs_inode));
- 	ret = btrfs_update_inode(trans, root, dir);
+ 	ret = btrfs_update_inode(trans, dir);
  out:
  	return ret;
  }
@@@ -4305,8 -4309,8 +4308,8 @@@ static int btrfs_unlink_subvol(struct b
  
  	btrfs_i_size_write(dir, dir->vfs_inode.i_size - fname.disk_name.len * 2);
  	inode_inc_iversion(&dir->vfs_inode);
 -	dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode);
 +	inode_set_mtime_to_ts(&dir->vfs_inode, inode_set_ctime_current(&dir->vfs_inode));
- 	ret = btrfs_update_inode_fallback(trans, root, dir);
+ 	ret = btrfs_update_inode_fallback(trans, dir);
  	if (ret)
  		btrfs_abort_transaction(trans, ret);
  out:
@@@ -5583,6 -5586,6 +5586,7 @@@ static struct inode *new_simple_dir(str
  				    struct btrfs_root *root)
  {
  	struct inode *inode = new_inode(dir->i_sb);
++	struct timespec64 mtime;
  
  	if (!inode)
  		return ERR_PTR(-ENOMEM);
@@@ -5600,9 -5603,10 +5604,11 @@@
  	inode->i_opflags &= ~IOP_XATTR;
  	inode->i_fop = &simple_dir_operations;
  	inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
 -	inode->i_mtime = inode_set_ctime_current(inode);
 -	inode->i_atime = dir->i_atime;
 -	BTRFS_I(inode)->i_otime_sec = inode->i_mtime.tv_sec;
 -	BTRFS_I(inode)->i_otime_nsec = inode->i_mtime.tv_nsec;
 +	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 +	inode_set_atime_to_ts(inode, inode_get_atime(dir));
- 	BTRFS_I(inode)->i_otime = inode_get_mtime(inode);
++	mtime = inode_get_mtime(inode);
++	BTRFS_I(inode)->i_otime_sec = mtime.tv_sec;
++	BTRFS_I(inode)->i_otime_nsec = mtime.tv_nsec;
  	inode->i_uid = dir->i_uid;
  	inode->i_gid = dir->i_gid;
  
@@@ -6173,6 -6177,6 +6179,7 @@@ int btrfs_create_new_inode(struct btrfs
  	struct btrfs_key key[2];
  	u32 sizes[2];
  	struct btrfs_item_batch batch;
++	struct timespec64 otime;
  	unsigned long ptr;
  	int ret;
  
@@@ -6277,8 -6281,10 +6284,10 @@@
  		goto discard;
  	}
  
 -	inode->i_mtime = inode_set_ctime_current(inode);
 -	inode->i_atime = inode->i_mtime;
 -	BTRFS_I(inode)->i_otime_sec = inode->i_mtime.tv_sec;
 -	BTRFS_I(inode)->i_otime_nsec = inode->i_mtime.tv_nsec;
 +	simple_inode_init_ts(inode);
- 	BTRFS_I(inode)->i_otime = inode_get_mtime(inode);
++	otime = inode_get_mtime(inode);
++	BTRFS_I(inode)->i_otime_sec = otime.tv_sec;
++	BTRFS_I(inode)->i_otime_nsec = otime.tv_nsec;
  
  	/*
  	 * We're going to fill the inode item now, so at this point the inode
@@@ -6443,10 -6449,10 +6452,10 @@@ int btrfs_add_link(struct btrfs_trans_h
  	 * values (the ones it had when the fsync was done).
  	 */
  	if (!test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags))
 -		parent_inode->vfs_inode.i_mtime =
 -			inode_set_ctime_current(&parent_inode->vfs_inode);
 +		inode_set_mtime_to_ts(&parent_inode->vfs_inode,
 +				      inode_set_ctime_current(&parent_inode->vfs_inode));
  
- 	ret = btrfs_update_inode(trans, root, parent_inode);
+ 	ret = btrfs_update_inode(trans, parent_inode);
  	if (ret)
  		btrfs_abort_transaction(trans, ret);
  	return ret;
diff --cc fs/btrfs/transaction.c
index 38a2775c5c7b,9694a3ca1739..000000000000
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@@ -1860,9 -1911,8 +1911,9 @@@ static noinline int create_pending_snap
  
  	btrfs_i_size_write(BTRFS_I(parent_inode), parent_inode->i_size +
  						  fname.disk_name.len * 2);
 -	parent_inode->i_mtime = inode_set_ctime_current(parent_inode);
 +	inode_set_mtime_to_ts(parent_inode,
 +			      inode_set_ctime_current(parent_inode));
- 	ret = btrfs_update_inode_fallback(trans, parent_root, BTRFS_I(parent_inode));
+ 	ret = btrfs_update_inode_fallback(trans, BTRFS_I(parent_inode));
  	if (ret) {
  		btrfs_abort_transaction(trans, ret);
  		goto fail;

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: linux-next: manual merge of the btrfs tree with Linus' tree
  2020-10-15  0:35 Stephen Rothwell
@ 2020-10-15 14:42 ` David Sterba
  0 siblings, 0 replies; 11+ messages in thread
From: David Sterba @ 2020-10-15 14:42 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: David Sterba, Linux Kernel Mailing List, Linux Next Mailing List,
	Linus Torvalds

On Thu, Oct 15, 2020 at 11:35:30AM +1100, Stephen Rothwell wrote:
> Hi all,
> 
> Please do *not* rebase/rewrite your linux-next included tree and then
> immediately send it to Linus.  Or if you do, the please also update
> what you have in linux-next (so you can sneak it past me :-().
> (mutter, mutter, unnecessary conflicts :-().
> 
> I have dropped the brtfs tree from linux-next today.

I've pushed updated for-next and next-fixes to k.org, sorry for
inconvenience.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* linux-next: manual merge of the btrfs tree with Linus' tree
@ 2020-10-15  0:35 Stephen Rothwell
  2020-10-15 14:42 ` David Sterba
  0 siblings, 1 reply; 11+ messages in thread
From: Stephen Rothwell @ 2020-10-15  0:35 UTC (permalink / raw)
  To: David Sterba
  Cc: Linux Kernel Mailing List, Linux Next Mailing List, Linus Torvalds

[-- Attachment #1: Type: text/plain, Size: 351 bytes --]

Hi all,

Please do *not* rebase/rewrite your linux-next included tree and then
immediately send it to Linus.  Or if you do, the please also update
what you have in linux-next (so you can sneak it past me :-().
(mutter, mutter, unnecessary conflicts :-().

I have dropped the brtfs tree from linux-next today.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* linux-next: manual merge of the btrfs tree with Linus' tree
@ 2014-02-03  0:13 Stephen Rothwell
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Rothwell @ 2014-02-03  0:13 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik; +Cc: linux-next, linux-kernel, Linus

[-- Attachment #1: Type: text/plain, Size: 497 bytes --]

Hi all,

Today's linux-next merge of the btrfs tree got conflicts in lost of files
between commits from Linus' tree and commits from the btrfs tree.

Not only did you rebase/rewrite your tree before asking Linus to pull it,
but you added a whole lot of commits beyond what had been in linux-next!
I have dropped your (now redundant) tree from linux-next for today.
Please clean it up and try a bit harder, thanks.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: linux-next: manual merge of the btrfs tree with Linus' tree
  2014-01-29  0:54 Stephen Rothwell
@ 2014-01-29 13:07 ` Michal Nazarewicz
  0 siblings, 0 replies; 11+ messages in thread
From: Michal Nazarewicz @ 2014-01-29 13:07 UTC (permalink / raw)
  To: Stephen Rothwell, Chris Mason, Josef Bacik, Al Viro
  Cc: linux-next, linux-kernel, Christoph Hellwig, Linus

[-- Attachment #1: Type: text/plain, Size: 852 bytes --]

On Wed, Jan 29 2014, Stephen Rothwell wrote:
> Today's linux-next merge of the btrfs tree got a conflict in
> fs/btrfs/acl.c between commit 996a710d4641 ("btrfs: use generic posix ACL
> infrastructure") from the  tree and commit cfad95253440 ("btrfs: remove
> dead code") from the btrfs tree.
>
> I fixed it up (I used the version from Linus' tree) and can carry the fix
> as necessary (no action is required).

That sounds correct.  My commit [cfad95253440: btrfs: remove dead code]
can be dropped, since Christoph's commit completely rewrites
btrfs_init_acl function.

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--

[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* linux-next: manual merge of the btrfs tree with Linus' tree
@ 2014-01-29  0:54 Stephen Rothwell
  2014-01-29 13:07 ` Michal Nazarewicz
  0 siblings, 1 reply; 11+ messages in thread
From: Stephen Rothwell @ 2014-01-29  0:54 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, Al Viro
  Cc: linux-next, linux-kernel, Michal Nazarewicz, Christoph Hellwig, Linus

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

Hi all,

Today's linux-next merge of the btrfs tree got a conflict in
fs/btrfs/acl.c between commit 996a710d4641 ("btrfs: use generic posix ACL
infrastructure") from the  tree and commit cfad95253440 ("btrfs: remove
dead code") from the btrfs tree.

I fixed it up (I used the version from Linus' tree) and can carry the fix
as necessary (no action is required).

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-01-10 23:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-31 23:53 linux-next: manual merge of the btrfs tree with Linus' tree Stephen Rothwell
2021-11-02 10:42 ` David Sterba
2021-11-02 11:44   ` Stephen Rothwell
  -- strict thread matches above, loose matches on Subject: below --
2024-01-10 23:03 Stephen Rothwell
2024-01-08 22:54 Stephen Rothwell
2023-10-31  0:18 Stephen Rothwell
2020-10-15  0:35 Stephen Rothwell
2020-10-15 14:42 ` David Sterba
2014-02-03  0:13 Stephen Rothwell
2014-01-29  0:54 Stephen Rothwell
2014-01-29 13:07 ` Michal Nazarewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).