linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] CIFS: use the correct length when pinning memory for direct I/O for write
@ 2018-12-16 23:17 Long Li
  2018-12-17  1:10 ` Joey Pabalinas
  2018-12-18  5:05 ` Steve French
  0 siblings, 2 replies; 3+ messages in thread
From: Long Li @ 2018-12-16 23:17 UTC (permalink / raw)
  To: Steve French, linux-cifs, samba-technical, linux-kernel, linux-rdma
  Cc: Long Li, stable

From: Long Li <longli@microsoft.com>

The current code attempts to pin memory using the largest possible wsize
based on the currect SMB credits. This doesn't cause kernel oops but this is
not optimal as we may pin more pages then actually needed.

Fix this by only pinning what are needed for doing this write I/O.

Signed-off-by: Long Li <longli@microsoft.com>
Cc: stable@vger.kernel.org
---
 fs/cifs/file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 3467351..c23bf9d 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2617,11 +2617,13 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from,
 		if (rc)
 			break;
 
+		cur_len = min_t(const size_t, len, wsize);
+
 		if (ctx->direct_io) {
 			ssize_t result;
 
 			result = iov_iter_get_pages_alloc(
-				from, &pagevec, wsize, &start);
+				from, &pagevec, cur_len, &start);
 			if (result < 0) {
 				cifs_dbg(VFS,
 					"direct_writev couldn't get user pages "
-- 
2.7.4


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

* Re: [PATCH] CIFS: use the correct length when pinning memory for direct I/O for write
  2018-12-16 23:17 [PATCH] CIFS: use the correct length when pinning memory for direct I/O for write Long Li
@ 2018-12-17  1:10 ` Joey Pabalinas
  2018-12-18  5:05 ` Steve French
  1 sibling, 0 replies; 3+ messages in thread
From: Joey Pabalinas @ 2018-12-17  1:10 UTC (permalink / raw)
  To: longli
  Cc: Steve French, linux-cifs, samba-technical, linux-kernel,
	linux-rdma, stable, Joey Pabalinas

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

On Sun, Dec 16, 2018 at 11:17:04PM +0000, Long Li wrote:
> From: Long Li <longli@microsoft.com>
> 
> The current code attempts to pin memory using the largest possible wsize
> based on the currect SMB credits. This doesn't cause kernel oops but this is
> not optimal as we may pin more pages then actually needed.
> 
> Fix this by only pinning what are needed for doing this write I/O.
> 
> Signed-off-by: Long Li <longli@microsoft.com>
> Cc: stable@vger.kernel.org

Looks sane to me.

Reviewed-by: Joey Pabalinas <joeypabalinas@gmail.com>

> ---
>  fs/cifs/file.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index 3467351..c23bf9d 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -2617,11 +2617,13 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from,
>  		if (rc)
>  			break;
>  
> +		cur_len = min_t(const size_t, len, wsize);
> +
>  		if (ctx->direct_io) {
>  			ssize_t result;
>  
>  			result = iov_iter_get_pages_alloc(
> -				from, &pagevec, wsize, &start);
> +				from, &pagevec, cur_len, &start);
>  			if (result < 0) {
>  				cifs_dbg(VFS,
>  					"direct_writev couldn't get user pages "
> -- 
> 2.7.4
> 

-- 
Cheers,
Joey Pabalinas

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

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

* Re: [PATCH] CIFS: use the correct length when pinning memory for direct I/O for write
  2018-12-16 23:17 [PATCH] CIFS: use the correct length when pinning memory for direct I/O for write Long Li
  2018-12-17  1:10 ` Joey Pabalinas
@ 2018-12-18  5:05 ` Steve French
  1 sibling, 0 replies; 3+ messages in thread
From: Steve French @ 2018-12-18  5:05 UTC (permalink / raw)
  To: Long Li; +Cc: Steve French, CIFS, samba-technical, LKML, linux-rdma, Stable

merged into cifs-2.6.git for-next

On Sun, Dec 16, 2018 at 5:18 PM Long Li <longli@linuxonhyperv.com> wrote:
>
> From: Long Li <longli@microsoft.com>
>
> The current code attempts to pin memory using the largest possible wsize
> based on the currect SMB credits. This doesn't cause kernel oops but this is
> not optimal as we may pin more pages then actually needed.
>
> Fix this by only pinning what are needed for doing this write I/O.
>
> Signed-off-by: Long Li <longli@microsoft.com>
> Cc: stable@vger.kernel.org
> ---
>  fs/cifs/file.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index 3467351..c23bf9d 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -2617,11 +2617,13 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from,
>                 if (rc)
>                         break;
>
> +               cur_len = min_t(const size_t, len, wsize);
> +
>                 if (ctx->direct_io) {
>                         ssize_t result;
>
>                         result = iov_iter_get_pages_alloc(
> -                               from, &pagevec, wsize, &start);
> +                               from, &pagevec, cur_len, &start);
>                         if (result < 0) {
>                                 cifs_dbg(VFS,
>                                         "direct_writev couldn't get user pages "
> --
> 2.7.4
>


-- 
Thanks,

Steve

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

end of thread, other threads:[~2018-12-18  5:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-16 23:17 [PATCH] CIFS: use the correct length when pinning memory for direct I/O for write Long Li
2018-12-17  1:10 ` Joey Pabalinas
2018-12-18  5:05 ` Steve French

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).