--- /dev/null
+From 9a596f5b39593414c0ec80f71b94a226286f084e Mon Sep 17 00:00:00 2001
+From: Georgy A Bystrenin <gkot@altlinux.org>
+Date: Fri, 21 Dec 2018 00:11:42 -0600
+Subject: CIFS: Fix error mapping for SMB2_LOCK command which caused OFD lock problem
+
+From: Georgy A Bystrenin <gkot@altlinux.org>
+
+commit 9a596f5b39593414c0ec80f71b94a226286f084e upstream.
+
+While resolving a bug with locks on samba shares found a strange behavior.
+When a file locked by one node and we trying to lock it from another node
+it fail with errno 5 (EIO) but in that case errno must be set to
+(EACCES | EAGAIN).
+This isn't happening when we try to lock file second time on same node.
+In this case it returns EACCES as expected.
+Also this issue not reproduces when we use SMB1 protocol (vers=1.0 in
+mount options).
+
+Further investigation showed that the mapping from status_to_posix_error
+is different for SMB1 and SMB2+ implementations.
+For SMB1 mapping is [NT_STATUS_LOCK_NOT_GRANTED to ERRlock]
+(See fs/cifs/netmisc.c line 66)
+but for SMB2+ mapping is [STATUS_LOCK_NOT_GRANTED to -EIO]
+(see fs/cifs/smb2maperror.c line 383)
+
+Quick changes in SMB2+ mapping from EIO to EACCES has fixed issue.
+
+BUG: https://bugzilla.kernel.org/show_bug.cgi?id=201971
+
+Signed-off-by: Georgy A Bystrenin <gkot@altlinux.org>
+Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
+CC: Stable <stable@vger.kernel.org>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/cifs/smb2maperror.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/fs/cifs/smb2maperror.c
++++ b/fs/cifs/smb2maperror.c
+@@ -379,8 +379,8 @@ static const struct status_to_posix_erro
+ {STATUS_NONEXISTENT_EA_ENTRY, -EIO, "STATUS_NONEXISTENT_EA_ENTRY"},
+ {STATUS_NO_EAS_ON_FILE, -ENODATA, "STATUS_NO_EAS_ON_FILE"},
+ {STATUS_EA_CORRUPT_ERROR, -EIO, "STATUS_EA_CORRUPT_ERROR"},
+- {STATUS_FILE_LOCK_CONFLICT, -EIO, "STATUS_FILE_LOCK_CONFLICT"},
+- {STATUS_LOCK_NOT_GRANTED, -EIO, "STATUS_LOCK_NOT_GRANTED"},
++ {STATUS_FILE_LOCK_CONFLICT, -EACCES, "STATUS_FILE_LOCK_CONFLICT"},
++ {STATUS_LOCK_NOT_GRANTED, -EACCES, "STATUS_LOCK_NOT_GRANTED"},
+ {STATUS_DELETE_PENDING, -ENOENT, "STATUS_DELETE_PENDING"},
+ {STATUS_CTL_FILE_NOT_SUPPORTED, -ENOSYS,
+ "STATUS_CTL_FILE_NOT_SUPPORTED"},
--- /dev/null
+From 54e94ff94eac887ddb59cfd46b18896da5695e35 Mon Sep 17 00:00:00 2001
+From: Long Li <longli@microsoft.com>
+Date: Sun, 16 Dec 2018 22:41:07 +0000
+Subject: CIFS: return correct errors when pinning memory failed for direct I/O
+
+From: Long Li <longli@microsoft.com>
+
+commit 54e94ff94eac887ddb59cfd46b18896da5695e35 upstream.
+
+When pinning memory failed, we should return the correct error code and
+rewind the SMB credits.
+
+Reported-by: Murphy Zhou <jencce.kernel@gmail.com>
+Signed-off-by: Long Li <longli@microsoft.com>
+Cc: stable@vger.kernel.org
+Cc: Murphy Zhou <jencce.kernel@gmail.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/cifs/file.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+--- a/fs/cifs/file.c
++++ b/fs/cifs/file.c
+@@ -2630,6 +2630,9 @@ cifs_write_from_iter(loff_t offset, size
+ result, from->type,
+ from->iov_offset, from->count);
+ dump_stack();
++
++ rc = result;
++ add_credits_and_wake_if(server, credits, 0);
+ break;
+ }
+ cur_len = (size_t)result;
+@@ -3313,13 +3316,16 @@ cifs_send_async_read(loff_t offset, size
+ cur_len, &start);
+ if (result < 0) {
+ cifs_dbg(VFS,
+- "couldn't get user pages (cur_len=%zd)"
++ "couldn't get user pages (rc=%zd)"
+ " iter type %d"
+ " iov_offset %zd count %zd\n",
+ result, direct_iov.type,
+ direct_iov.iov_offset,
+ direct_iov.count);
+ dump_stack();
++
++ rc = result;
++ add_credits_and_wake_if(server, credits, 0);
+ break;
+ }
+ cur_len = (size_t)result;
--- /dev/null
+From b6bc8a7b993e62f82415a5e3e4a6469e80fea19c Mon Sep 17 00:00:00 2001
+From: Long Li <longli@microsoft.com>
+Date: Sun, 16 Dec 2018 23:17:04 +0000
+Subject: CIFS: use the correct length when pinning memory for direct I/O for write
+
+From: Long Li <longli@microsoft.com>
+
+commit b6bc8a7b993e62f82415a5e3e4a6469e80fea19c upstream.
+
+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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/cifs/file.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/fs/cifs/file.c
++++ b/fs/cifs/file.c
+@@ -2617,11 +2617,13 @@ cifs_write_from_iter(loff_t offset, size
+ 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 "
mips-expand-mips32-asids-to-64-bits.patch
mips-octeon-mark-rgmii-interface-disabled-on-octeon-iii.patch
mips-fix-a-r10000_llsc_war-logic-in-atomic.h.patch
+cifs-fix-error-mapping-for-smb2_lock-command-which-caused-ofd-lock-problem.patch
+smb3-fix-large-reads-on-encrypted-connections.patch
+cifs-return-correct-errors-when-pinning-memory-failed-for-direct-i-o.patch
+cifs-use-the-correct-length-when-pinning-memory-for-direct-i-o-for-write.patch
--- /dev/null
+From 6d2f84eee098540ae857998fe32f29b9e2cd9613 Mon Sep 17 00:00:00 2001
+From: Paul Aurich <paul@darkrain42.org>
+Date: Mon, 31 Dec 2018 14:13:34 -0800
+Subject: smb3: fix large reads on encrypted connections
+
+From: Paul Aurich <paul@darkrain42.org>
+
+commit 6d2f84eee098540ae857998fe32f29b9e2cd9613 upstream.
+
+When passing a large read to receive_encrypted_read(), ensure that the
+demultiplex_thread knows that a MID was processed. Without this, those
+operations never complete.
+
+This is a similar issue/fix to lease break handling:
+commit 7af929d6d05ba5564139718e30d5bc96bdbc716a
+("smb3: fix lease break problem introduced by compounding")
+
+CC: Stable <stable@vger.kernel.org> # 4.19+
+Fixes: b24df3e30cbf ("cifs: update receive_encrypted_standard to handle compounded responses")
+Signed-off-by: Paul Aurich <paul@darkrain42.org>
+Tested-by: Yves-Alexis Perez <corsac@corsac.net>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/cifs/smb2ops.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/fs/cifs/smb2ops.c
++++ b/fs/cifs/smb2ops.c
+@@ -3384,8 +3384,10 @@ smb3_receive_transform(struct TCP_Server
+ }
+
+ /* TODO: add support for compounds containing READ. */
+- if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server))
++ if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server)) {
++ *num_mids = 1;
+ return receive_encrypted_read(server, &mids[0]);
++ }
+
+ return receive_encrypted_standard(server, mids, bufs, num_mids);
+ }