]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nvme-tcp: don't use sendpage for SLAB pages
authorMikhail Skorzhinskii <mskorzhinskiy@solarflare.com>
Mon, 8 Jul 2019 10:31:29 +0000 (12:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Jul 2019 05:24:51 +0000 (07:24 +0200)
[ Upstream commit 37c15219599f7a4baa73f6e3432afc69ba7cc530 ]

According to commit a10674bf2406 ("tcp: detecting the misuse of
.sendpage for Slab objects") and previous discussion, tcp_sendpage
should not be used for pages that is managed by SLAB, as SLAB is not
taking page reference counters into consideration.

Signed-off-by: Mikhail Skorzhinskii <mskorzhinskiy@solarflare.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/tcp.c

index 08a2501b9357735cb7ac1848efac3a3189a22aaa..606b13d35d16f52be5152720b3b65d6bc46ea28e 100644 (file)
@@ -860,7 +860,14 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
                else
                        flags |= MSG_MORE;
 
-               ret = kernel_sendpage(queue->sock, page, offset, len, flags);
+               /* can't zcopy slab pages */
+               if (unlikely(PageSlab(page))) {
+                       ret = sock_no_sendpage(queue->sock, page, offset, len,
+                                       flags);
+               } else {
+                       ret = kernel_sendpage(queue->sock, page, offset, len,
+                                       flags);
+               }
                if (ret <= 0)
                        return ret;