Skip to content

Commit 6a829eb

Browse files
trondmyamschuma-ntap
authored andcommitted
SUNRPC: Fix TCP receive code on archs with flush_dcache_page()
After receiving data into the page cache, we need to call flush_dcache_page() for the architectures that define it. Fixes: 277e4ab ("SUNRPC: Simplify TCP receive code by switching...") Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Cc: stable@vger.kernel.org # v4.20 Tested-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 6e17f58 commit 6a829eb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

net/sunrpc/xprtsock.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <net/udp.h>
4949
#include <net/tcp.h>
5050
#include <linux/bvec.h>
51+
#include <linux/highmem.h>
5152
#include <linux/uio.h>
5253

5354
#include <trace/events/sunrpc.h>
@@ -376,6 +377,26 @@ xs_read_discard(struct socket *sock, struct msghdr *msg, int flags,
376377
return sock_recvmsg(sock, msg, flags);
377378
}
378379

380+
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
381+
static void
382+
xs_flush_bvec(const struct bio_vec *bvec, size_t count, size_t seek)
383+
{
384+
struct bvec_iter bi = {
385+
.bi_size = count,
386+
};
387+
struct bio_vec bv;
388+
389+
bvec_iter_advance(bvec, &bi, seek & PAGE_MASK);
390+
for_each_bvec(bv, bvec, bi, bi)
391+
flush_dcache_page(bv.bv_page);
392+
}
393+
#else
394+
static inline void
395+
xs_flush_bvec(const struct bio_vec *bvec, size_t count, size_t seek)
396+
{
397+
}
398+
#endif
399+
379400
static ssize_t
380401
xs_read_xdr_buf(struct socket *sock, struct msghdr *msg, int flags,
381402
struct xdr_buf *buf, size_t count, size_t seek, size_t *read)
@@ -409,6 +430,7 @@ xs_read_xdr_buf(struct socket *sock, struct msghdr *msg, int flags,
409430
seek + buf->page_base);
410431
if (ret <= 0)
411432
goto sock_err;
433+
xs_flush_bvec(buf->bvec, ret, seek + buf->page_base);
412434
offset += ret - buf->page_base;
413435
if (offset == count || msg->msg_flags & (MSG_EOR|MSG_TRUNC))
414436
goto out;

0 commit comments

Comments
 (0)