Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp244597pxk; Thu, 1 Oct 2020 00:58:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFTI7O/wVVrHKy3VVppSUKWkq2AtqPSEFkRs/g7SzjPo9TZ9BzkVFBEF6sMzY6hca5C2+0 X-Received: by 2002:a17:906:b790:: with SMTP id dt16mr6512805ejb.33.1601539112720; Thu, 01 Oct 2020 00:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601539112; cv=none; d=google.com; s=arc-20160816; b=mY07vneIULhx8rfQu+24vkPWY0P2HEz9PbHjApSdHmqd6nok6XImgYWUnP/eWIFHLT FHw+tHgOGW0KK7cNyb9+XS/lHGYKI6t6G1lMdcZR3xRLl5Q2GWeAm/H6z3zv4pXjSW/l dMwde+OC6xFrFxGu2CnN5SCKdxn7PRwJfGpPZs40btSc4gQ5EMJuDl2ppblt3nJn6F74 bAbpS/2ULRSARt7vsyG0pQ0Jg3fwqDkYZOjL+2PvDRBBanklgPJURzCBr16i3PcP+/fL EMLR6R4M0T7Pa2MAJ99X9ywcDgfVoJxKKXyNCZc0f27TETd7mEf/3IXce1N2WjAzWMIE VGug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jlP9uJs8N1dLuhXyn9htTbd+21VDbVbTbOTVrTcNL7Q=; b=n/F2jZorBdNYQ02AhtAmeDXA0fk76g3iJFLnikt1vEQYGBeZ3k3b2QqxsNStSCfJLL nplNT8BAerV01MbJTNZxweNXvfv/rQDnqF+SpGSOmLdRVsJ10wSxXJX/8u8F5zjFS35Y AWoFLr4kgFc2fOPcGsofPkit87mhN7714gLVEndzMHo9xdfyR4m6Ee5+z0uPYQbDu65u AxBope6crTYFyjHlcHBVC8ib3IsnVVXh1f7a8mluZQKewMTi5MtKhwgkcHi+9rb8OzjS ys97R8xX/h0JlYQ26SASv5OGNEFniSD2gz86kJ50wKdgv2THEAgOgnGxcVhL5V64EIrb VsNQ== 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 v12si2968570ejb.434.2020.10.01.00.58.10; Thu, 01 Oct 2020 00:58:32 -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 S1731677AbgJAHy5 (ORCPT + 99 others); Thu, 1 Oct 2020 03:54:57 -0400 Received: from mx2.suse.de ([195.135.220.15]:44372 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731649AbgJAHyz (ORCPT ); Thu, 1 Oct 2020 03:54:55 -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 14467AC83; Thu, 1 Oct 2020 07:54:53 +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 v9 3/7] nvme-tcp: check page by sendpage_ok() before calling kernel_sendpage() Date: Thu, 1 Oct 2020 15:54:04 +0800 Message-Id: <20201001075408.25508-4-colyli@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201001075408.25508-1-colyli@suse.de> References: <20201001075408.25508-1-colyli@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 8f4f29f18b8c..d6a3e1487354 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -913,12 +913,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