mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	net: splice: avoid high order page splitting
splice() can handle pages of any order, but network code tries hard to split them in PAGE_SIZE units. Not quite successfully anyway, as __splice_segment() assumed poff < PAGE_SIZE. This is true for the skb->data part, not necessarily for the fragments. This patch removes this logic to give the pages as they are in the skb. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Willy Tarreau <w@1wt.eu> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									81135548e6
								
							
						
					
					
						commit
						9ca1b22d6d
					
				
					 1 changed files with 9 additions and 29 deletions
				
			
		| 
						 | 
					@ -1707,20 +1707,6 @@ static bool spd_fill_page(struct splice_pipe_desc *spd,
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline void __segment_seek(struct page **page, unsigned int *poff,
 | 
					 | 
				
			||||||
				  unsigned int *plen, unsigned int off)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	unsigned long n;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	*poff += off;
 | 
					 | 
				
			||||||
	n = *poff / PAGE_SIZE;
 | 
					 | 
				
			||||||
	if (n)
 | 
					 | 
				
			||||||
		*page = nth_page(*page, n);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	*poff = *poff % PAGE_SIZE;
 | 
					 | 
				
			||||||
	*plen -= off;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static bool __splice_segment(struct page *page, unsigned int poff,
 | 
					static bool __splice_segment(struct page *page, unsigned int poff,
 | 
				
			||||||
			     unsigned int plen, unsigned int *off,
 | 
								     unsigned int plen, unsigned int *off,
 | 
				
			||||||
			     unsigned int *len, struct sk_buff *skb,
 | 
								     unsigned int *len, struct sk_buff *skb,
 | 
				
			||||||
| 
						 | 
					@ -1728,6 +1714,8 @@ static bool __splice_segment(struct page *page, unsigned int poff,
 | 
				
			||||||
			     struct sock *sk,
 | 
								     struct sock *sk,
 | 
				
			||||||
			     struct pipe_inode_info *pipe)
 | 
								     struct pipe_inode_info *pipe)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						unsigned int flen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!*len)
 | 
						if (!*len)
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1738,24 +1726,16 @@ static bool __splice_segment(struct page *page, unsigned int poff,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* ignore any bits we already processed */
 | 
						/* ignore any bits we already processed */
 | 
				
			||||||
	if (*off) {
 | 
						poff += *off;
 | 
				
			||||||
		__segment_seek(&page, &poff, &plen, *off);
 | 
						plen -= *off;
 | 
				
			||||||
		*off = 0;
 | 
						*off = 0;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	do {
 | 
						flen = min(*len, plen);
 | 
				
			||||||
		unsigned int flen = min(*len, plen);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* the linear region may spread across several pages  */
 | 
						if (spd_fill_page(spd, pipe, page, &flen, poff, skb, linear, sk))
 | 
				
			||||||
		flen = min_t(unsigned int, flen, PAGE_SIZE - poff);
 | 
							return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (spd_fill_page(spd, pipe, page, &flen, poff, skb, linear, sk))
 | 
						*len -= flen;
 | 
				
			||||||
			return true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		__segment_seek(&page, &poff, &plen, flen);
 | 
					 | 
				
			||||||
		*len -= flen;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	} while (*len && plen);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue