SUNRPC: Optimise away unnecessary data moves in xdr_align_pages
We only have to call xdr_shrink_pagelen() if the remaining RPC message does not fit in the page buffer length that we supplied to xdr_align_pages(). Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
		
					parent
					
						
							
								13fe4ba1b6
							
						
					
				
			
			
				commit
				
					
						a11a2bf4de
					
				
			
		
					 1 changed files with 13 additions and 10 deletions
				
			
		|  | @ -730,21 +730,24 @@ static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len) | ||||||
| 
 | 
 | ||||||
| 	if (xdr->nwords == 0) | 	if (xdr->nwords == 0) | ||||||
| 		return 0; | 		return 0; | ||||||
|  | 	/* Realign pages to current pointer position */ | ||||||
|  | 	iov  = buf->head; | ||||||
|  | 	if (iov->iov_len > cur) { | ||||||
|  | 		xdr_shrink_bufhead(buf, iov->iov_len - cur); | ||||||
|  | 		xdr->nwords = XDR_QUADLEN(buf->len - cur); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	if (nwords > xdr->nwords) { | 	if (nwords > xdr->nwords) { | ||||||
| 		nwords = xdr->nwords; | 		nwords = xdr->nwords; | ||||||
| 		len = nwords << 2; | 		len = nwords << 2; | ||||||
| 	} | 	} | ||||||
| 	/* Realign pages to current pointer position */ | 	if (buf->page_len <= len) | ||||||
| 	iov  = buf->head; |  | ||||||
| 	if (iov->iov_len > cur) |  | ||||||
| 		xdr_shrink_bufhead(buf, iov->iov_len - cur); |  | ||||||
| 
 |  | ||||||
| 	/* Truncate page data and move it into the tail */ |  | ||||||
| 	if (buf->page_len > len) |  | ||||||
| 		xdr_shrink_pagelen(buf, buf->page_len - len); |  | ||||||
| 	else |  | ||||||
| 		len = buf->page_len; | 		len = buf->page_len; | ||||||
| 	xdr->nwords = XDR_QUADLEN(buf->len - cur); | 	else if (nwords < xdr->nwords) { | ||||||
|  | 		/* Truncate page data and move it into the tail */ | ||||||
|  | 		xdr_shrink_pagelen(buf, buf->page_len - len); | ||||||
|  | 		xdr->nwords = XDR_QUADLEN(buf->len - cur); | ||||||
|  | 	} | ||||||
| 	return len; | 	return len; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Trond Myklebust
				Trond Myklebust