Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3081013pxa; Tue, 18 Aug 2020 06:14:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxklh0RipU1gessWl4G8anjxS3vEvV1st8ZbCHz/pNrtQWgGwxu7fHzeLMgXHZP8kXXx2xK X-Received: by 2002:a17:906:5495:: with SMTP id r21mr19389900ejo.33.1597756493071; Tue, 18 Aug 2020 06:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597756493; cv=none; d=google.com; s=arc-20160816; b=VWW2I7aYZXBjeck978jLwdMrINmX6ApmL2jwxtoGe9w3wzs9tHSQVo24Xil2IVzoGg aa8JJYbnPBoHGPtZJV4pj3xxneskx+H0ZDgN0Slm8u1mizzK1qXAsNsPFwkOL7I5HlPB sOfFVpeQIJRGrTiKtfTd0UOMxcyle8J0BY82S34yIfGEeSukW8C1v0IwQnSlQqNJlo8e whwqfvvY1IcrrO7ykwSOm4384TxTfaRob2Gy4XAMKGEx4ZjXiL7Nt2QlZx1r0/eljyGP qAYPnh0WX9Y0fzLf6rXi0Fpy1yry7v3QHdFfHha07wLjqfknJ4BOzgfIu45n/SsdY8cf Sxvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=u6lh5LWsmSTqi9Ds5pCl9l4eR+3garWymWsPWK5d4Yk=; b=luBWqZJWZmbgkQpNxoAeaTG69lgsxUFC5xRA1wpOpiD6Shbst4pPLjcJhC5+Vi5/y3 +TJogExrAZJVWSzC0Juyq7CRxMnb9FN+ybiOPZXzmyW/TXuS+3daTq5MOvixIxu69b8I EJfW1/R3kVe1AFokSGn7LT3iFhGcYBk/0ZKAc07RGM8rsqXA0xANZvOeJNFdEOX6jHyR Jhgli2ho3sQ2xT+Vr8QA2xSRmUPCJ6Zhz9K0HT5eGjy3WrGNuWf2hQdpqimlB0zBGUQF pKvqzuahEWQ1cZBDg4t+ocuBzys86c6pSrSsnbrf5TunnyfpSLihJ2c8003NNARzVW92 WaQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f27si14124241ejt.13.2020.08.18.06.14.28; Tue, 18 Aug 2020 06:14:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726782AbgHRNN1 (ORCPT + 99 others); Tue, 18 Aug 2020 09:13:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:33412 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726731AbgHRNNZ (ORCPT ); Tue, 18 Aug 2020 09:13:25 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2008BB167; Tue, 18 Aug 2020 13:13:44 +0000 (UTC) From: Coly Li To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, netdev@vger.kernel.org, open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org, ceph-devel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Coly Li , Chaitanya Kulkarni , Christoph Hellwig , Hannes Reinecke , Jan Kara , Jens Axboe , Mikhail Skorzhinskii , Philipp Reisner , Sagi Grimberg , Vlastimil Babka , stable@vger.kernel.org Subject: [PATCH v7 2/6] nvme-tcp: check page by sendpage_ok() before calling kernel_sendpage() Date: Tue, 18 Aug 2020 21:12:23 +0800 Message-Id: <20200818131227.37020-3-colyli@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818131227.37020-1-colyli@suse.de> References: <20200818131227.37020-1-colyli@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently nvme_tcp_try_send_data() doesn't use kernel_sendpage() to send slab pages. But for pages allocated by __get_free_pages() without __GFP_COMP, which also have refcount as 0, they are still sent by kernel_sendpage() to remote end, this is problematic. The new introduced helper sendpage_ok() checks both PageSlab tag and page_count counter, and returns true if the checking page is OK to be sent by kernel_sendpage(). This patch fixes the page checking issue of nvme_tcp_try_send_data() with sendpage_ok(). If sendpage_ok() returns true, send this page by kernel_sendpage(), otherwise use sock_no_sendpage to handle this page. Signed-off-by: Coly Li Cc: Chaitanya Kulkarni Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Jan Kara Cc: Jens Axboe Cc: Mikhail Skorzhinskii Cc: Philipp Reisner Cc: Sagi Grimberg Cc: Vlastimil Babka Cc: stable@vger.kernel.org --- drivers/nvme/host/tcp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 62fbaecdc960..902fe742762b 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -912,12 +912,11 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req) else flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; - /* can't zcopy slab pages */ - if (unlikely(PageSlab(page))) { - ret = sock_no_sendpage(queue->sock, page, offset, len, + if (sendpage_ok(page)) { + ret = kernel_sendpage(queue->sock, page, offset, len, flags); } else { - ret = kernel_sendpage(queue->sock, page, offset, len, + ret = sock_no_sendpage(queue->sock, page, offset, len, flags); } if (ret <= 0) -- 2.26.2