diff options
author | Long Li <longli@microsoft.com> | 2018-12-17 02:17:04 +0300 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2018-12-24 07:42:19 +0300 |
commit | b6bc8a7b993e62f82415a5e3e4a6469e80fea19c (patch) | |
tree | f605009680eb4847774849021be4f4fc045009ee /fs/cifs/file.c | |
parent | 59a63e479ce36a3f24444c3a36efe82b78e4a8e0 (diff) | |
download | linux-b6bc8a7b993e62f82415a5e3e4a6469e80fea19c.tar.xz |
CIFS: use the correct length when pinning memory for direct I/O for write
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
Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Joey Pabalinas <joeypabalinas@gmail.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r-- | fs/cifs/file.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index c9bc56b1baac..179991435777 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 " |