Skip to contentSkip to conversation

linux-next: manual merge of the block tree with the mm tree

DISCUSSION Stephen Rothwell 4 participants 7 messages Mar 22, 2023 – Mar 23, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi all,

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

lib/iov_iter.c

between commit:

c4cf24ce34b7 ("iov_iter: add copy_page_to_iter_atomic()")

from the mm tree and commit:

a53f5dee3448 ("iov_iter: Kill ITER_PIPE")

from the block 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.

Signature · 68 lines
Cheers,
Stephen Rothwell

diff --cc lib/iov_iter.c
index 48ca1c5dfc04,fad95e4cf372..000000000000
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@@ -821,60 -532,6 +532,34 @@@ size_t copy_page_from_iter_atomic(struc
  }
  EXPORT_SYMBOL(copy_page_from_iter_atomic);
  
 +size_t copy_page_to_iter_atomic(struct page *page, unsigned offset, size_t bytes,
 +				struct iov_iter *i)
 +{
 +	char *kaddr = kmap_local_page(page);
 +	char *p = kaddr + offset;
 +	size_t copied = 0;
 +
 +	if (!page_copy_sane(page, offset, bytes) ||
 +	    WARN_ON_ONCE(i->data_source))
 +		goto out;
 +
 +	if (unlikely(iov_iter_is_pipe(i))) {
 +		copied = copy_page_to_iter_pipe(page, offset, bytes, i);
 +		goto out;
 +	}
 +
 +	iterate_and_advance(i, bytes, base, len, off,
 +		copyout(base, p + off, len),
 +		memcpy(base, p + off, len)
 +	)
 +	copied = bytes;
 +
 +out:
 +	kunmap_local(kaddr);
 +	return copied;
 +}
 +EXPORT_SYMBOL(copy_page_to_iter_atomic);
 +
- static void pipe_advance(struct iov_iter *i, size_t size)
- {
- 	struct pipe_inode_info *pipe = i->pipe;
- 	int off = i->last_offset;
- 
- 	if (!off && !size) {
- 		pipe_discard_from(pipe, i->start_head); // discard everything
- 		return;
- 	}
- 	i->count -= size;
- 	while (1) {
- 		struct pipe_buffer *buf = pipe_buf(pipe, i->head);
- 		if (off) /* make it relative to the beginning of buffer */
- 			size += abs(off) - buf->offset;
- 		if (size <= buf->len) {
- 			buf->len = size;
- 			i->last_offset = last_offset(buf);
- 			break;
- 		}
- 		size -= buf->len;
- 		i->head++;
- 		off = 0;
- 	}
- 	pipe_discard_from(pipe, i->head + 1); // discard everything past this one
- }
- 
  static void iov_iter_bvec_advance(struct iov_iter *i, size_t size)
  {
  	const struct bio_vec *bvec, *end;
#1 lore raw
Quoted 4 lines · Stephen Rothwell

+ if (unlikely(iov_iter_is_pipe(i))) {
+ copied = copy_page_to_iter_pipe(page, offset, bytes, i);
+ goto out;
+ }

This bit would need to be removed from copy_page_to_iter_atomic() as the two functions it calls should be removed by the patch in the block tree.

David

#2 lore raw
Quoted 9 lines · David Howells
Quoted 4 lines · Stephen Rothwell

+ if (unlikely(iov_iter_is_pipe(i))) {
+ copied = copy_page_to_iter_pipe(page, offset, bytes, i);
+ goto out;
+ }

This bit would need to be removed from copy_page_to_iter_atomic() as the two functions it calls should be removed by the patch in the block tree.

Maybe it'd be better to consolidate rather than split the changes over two trees?

Signature · 1 line
Jens Axboe
maintainer
#3 lore raw
Quoted 8 lines · On Wed, 22 Mar 2023 17:15:48 -0600 Jens Axboe <[email protected]> wrote:
Quoted 7 lines · David Howells
Quoted 4 lines · Stephen Rothwell

+ if (unlikely(iov_iter_is_pipe(i))) {
+ copied = copy_page_to_iter_pipe(page, offset, bytes, i);
+ goto out;
+ }

Quoted 5 lines
Quoted 2 lines

This bit would need to be removed from copy_page_to_iter_atomic() as the two functions it calls should be removed by the patch in the block tree.

Maybe it'd be better to consolidate rather than split the changes over two trees?

fyi, Lorenzo has sent out v7 of this series. I'll be pushing this in an hour or so. After which I suggest Stephen removes those (now) two lines and sends out one of his "build fix" emails which can be the basis for Linus's resolution.

Or I can just steal "iov_iter: Kill ITER_PIPE"...

From: Lorenzo Stoakes <[email protected]>
Subject: iov_iter: add copy_page_to_iter_nofault()
Date: Wed, 22 Mar 2023 18:57:03 +0000

Provide a means to copy a page to user space from an iterator, aborting if a page fault would occur. This supports compound pages, but may be passed a tail page with an offset extending further into the compound page, so we cannot pass a folio.

This allows for this function to be called from atomic context and _try_ to user pages if they are faulted in, aborting if not.

The function does not use _copy_to_iter() in order to not specify might_fault(), this is similar to copy_page_from_iter_atomic().

This is being added in order that an iteratable form of vread() can be implemented while holding spinlocks.

---

include/linux/uio.h renamed from include/linux/uio.h~iov_iter-add-copy_page_to_iter_nofault +2 -0
@@ -173,6 +173,8 @@ static inline size_t copy_folio_to_iter(
 {
 	return copy_page_to_iter(&folio->page, offset, bytes, i);
 }
+size_t copy_page_to_iter_nofault(struct page *page, unsigned offset,
+				 size_t bytes, struct iov_iter *i);
 
 static __always_inline __must_check
 size_t copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i)
lib/iov_iter.c renamed from lib/iov_iter.c~iov_iter-add-copy_page_to_iter_nofault +48 -0

60 lines not on this page · raw message

_

#4 lore raw

Hi all,

Quoted 5 lines · On Wed, 22 Mar 2023 16:26:38 -0700 Andrew Morton <[email protected]>…

fyi, Lorenzo has sent out v7 of this series. I'll be pushing this in an hour or so. After which I suggest Stephen removes those (now) two lines and sends out one of his "build fix" emails which can be the basis for Linus's resolution.

I have not picked up v7 (I will get that tomorrow), but I have gone back in today's tree and changed the merge resolution to be as below.

Signature · 68 lines
Cheers,
Stephen Rothwell

diff --cc lib/iov_iter.c
index 48ca1c5dfc04,fad95e4cf372..389cc8a53097
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@@ -821,60 -532,6 +532,29 @@@ size_t copy_page_from_iter_atomic(struc
  }
  EXPORT_SYMBOL(copy_page_from_iter_atomic);
  
 +size_t copy_page_to_iter_atomic(struct page *page, unsigned offset, size_t bytes,
 +				struct iov_iter *i)
 +{
 +	char *kaddr = kmap_local_page(page);
 +	char *p = kaddr + offset;
 +	size_t copied = 0;
 +
 +	if (!page_copy_sane(page, offset, bytes) ||
 +	    WARN_ON_ONCE(i->data_source))
 +		goto out;
 +
- 	if (unlikely(iov_iter_is_pipe(i))) {
- 		copied = copy_page_to_iter_pipe(page, offset, bytes, i);
- 		goto out;
- 	}
- 
 +	iterate_and_advance(i, bytes, base, len, off,
 +		copyout(base, p + off, len),
 +		memcpy(base, p + off, len)
 +	)
 +	copied = bytes;
 +
 +out:
 +	kunmap_local(kaddr);
 +	return copied;
 +}
 +EXPORT_SYMBOL(copy_page_to_iter_atomic);
 +
- static void pipe_advance(struct iov_iter *i, size_t size)
- {
- 	struct pipe_inode_info *pipe = i->pipe;
- 	int off = i->last_offset;
- 
- 	if (!off && !size) {
- 		pipe_discard_from(pipe, i->start_head); // discard everything
- 		return;
- 	}
- 	i->count -= size;
- 	while (1) {
- 		struct pipe_buffer *buf = pipe_buf(pipe, i->head);
- 		if (off) /* make it relative to the beginning of buffer */
- 			size += abs(off) - buf->offset;
- 		if (size <= buf->len) {
- 			buf->len = size;
- 			i->last_offset = last_offset(buf);
- 			break;
- 		}
- 		size -= buf->len;
- 		i->head++;
- 		off = 0;
- 	}
- 	pipe_discard_from(pipe, i->head + 1); // discard everything past this one
- }
- 
  static void iov_iter_bvec_advance(struct iov_iter *i, size_t size)
  {
  	const struct bio_vec *bvec, *end;
#5 lore raw
In reply to Andrew Morton
Quoted 1 line · Andrew Morton

Or I can just steal "iov_iter: Kill ITER_PIPE"...

You'd need to steal the eight patches before it too.

https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/log/?h=for-6.4/splice

iov_iter: Kill ITER_PIPE
cifs: Use generic_file_splice_read()
splice: Do splice read from a file without using ITER_PIPE tty, proc, kernfs, random: Use direct_splice_read()
coda: Implement splice-read
overlayfs: Implement splice-read
shmem: Implement splice-read
splice: Make do_splice_to() generic and export it
splice: Clean up direct_splice_read() a bit

David

#6 lore raw
In reply to Andrew Morton
Quoted 16 lines · Andrew Morton
Quoted 8 lines · On Wed, 22 Mar 2023 17:15:48 -0600 Jens Axboe <[email protected]> wrote:
Quoted 7 lines · David Howells
Quoted 4 lines · Stephen Rothwell

+ if (unlikely(iov_iter_is_pipe(i))) {
+ copied = copy_page_to_iter_pipe(page, offset, bytes, i);
+ goto out;
+ }

Quoted 5 lines
Quoted 2 lines

This bit would need to be removed from copy_page_to_iter_atomic() as the two functions it calls should be removed by the patch in the block tree.

Maybe it'd be better to consolidate rather than split the changes over two trees?

Quoted 6 lines

fyi, Lorenzo has sent out v7 of this series. I'll be pushing this in an hour or so. After which I suggest Stephen removes those (now) two lines and sends out one of his "build fix" emails which can be the basis for Linus's resolution.

Or I can just steal "iov_iter: Kill ITER_PIPE"...

Or how about we just make sure to queue up items that touch them same stuff in the same tree? I've already had this queued for a week, and seems pretty silly to shuffle things around because some thing got posted in 4 iterations today and then queued up right after.

Plus the build is now broken, so maybe a bit more diligence would be required here than the drive-by-merging.

Signature · 1 line
Jens Axboe