Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1174410pxk; Fri, 25 Sep 2020 08:03:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+EF46IvBuIpJ6bxQWPxCFHX0T1L2qSJx+0Q914AImQqEZx7Z9mgeWRs+/xulVVgLQo4e/ X-Received: by 2002:a05:6402:1503:: with SMTP id f3mr1821378edw.307.1601046234432; Fri, 25 Sep 2020 08:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601046234; cv=none; d=google.com; s=arc-20160816; b=ITncHF7cDBsX748yiDNGOG7vnLZ0XMNSvH80UiEld/8rpaG7hixcBY8uKHED+KBPA7 3wWmvGgcdGgfZoKGwZB6Pku3y3TpCjwnVC5jfoWVJEsDfD+TAdp8RgOt2huGZOhaXYcz KM8xBgsAXTgThZcAVuF0ohNPmnwytFMJuhj88mPOXDJqQ86jteznQzo3F/jplBu3G7gv HSwsM/ulv/cax52ZaD25HWm7uk4AvPHtqUle+7/yMGL6K8lIzEUjdx8FVen0tgvD+9UC 0AkTaJv4ck/CLFbwQmGBizhBwI7pneG/pgOdVXfrs0wz2d9u24BGVfAJuy3PlXnO2jIL TROw== 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=BE/K7v4QilnwI8Rph3+r9Z0zvihlYwlY6CWZQAKcNQw9PGUAg+VlveXFnmwqEqVSWy JNQV/wXg1dDtgDtcLdZpqsz/IQ84utePDYl8IauYRuSfdEGjJJq1CK1rm2aAzAIrFaar zVLyIcVBAzMixQYtlUnTSE4PeE99zPmOqEOyIqfj8vvWzI9QCZTqkvdw3vQhYMVrUeqF cSTwwHxiUqRQ/vItskSkADvNY5y9zN8rF8p8sjHekzXy1B8qL+ne6da93JMiMoxuct36 fYF8JsrwlDQQzwVE2s+6x5FWoPzAmKoeTcZZmlhwHAwpKzBb+xXaPsA9nLTHMy5jjvoX rBkA== 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 v13si2043264edw.171.2020.09.25.08.03.30; Fri, 25 Sep 2020 08:03:54 -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 S1729397AbgIYPCB (ORCPT + 99 others); Fri, 25 Sep 2020 11:02:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:34308 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728693AbgIYPCA (ORCPT ); Fri, 25 Sep 2020 11:02:00 -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 8C1C0B039; Fri, 25 Sep 2020 15:01:57 +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 v8 3/7] nvme-tcp: check page by sendpage_ok() before calling kernel_sendpage() Date: Fri, 25 Sep 2020 23:01:15 +0800 Message-Id: <20200925150119.112016-4-colyli@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200925150119.112016-1-colyli@suse.de> References: <20200925150119.112016-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