Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1127648pxk; Fri, 2 Oct 2020 01:30:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDvMqJV7FWPdRwzfXtGyHp5zEzi7ZGXH/8LjziK6Ik7qDs43WRrCTWWSyeqTTh0qyxOkqg X-Received: by 2002:a05:6402:1558:: with SMTP id p24mr1126421edx.194.1601627416690; Fri, 02 Oct 2020 01:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601627416; cv=none; d=google.com; s=arc-20160816; b=d07kn8cFKl3DDUQgabn2lB6Tj5AiMf1jLS9sG/QFOVDHNMMxLWDrXmZ88sH6ptKrmH lLSl3noG5QETz3PrnjPJz7HxRAsYyjeqNeF5AYF6OascqC9lnY2LNblIjEFwq9DG9kO5 5K2WzeBrJDsaKJM+hNYmEag0Enxr/Wk4cISUJJb/Sy7hFw9ii4czFJZq27waumClXzfg p2NGbyUIgXnoO3c94OeJTE/Ol71e2x2qOCQWoK0f2LxTQOFKtxdTRI2tr44sH7BjSDN7 mKzI54INIW7OkU7N71+tYRRuF4FuqqwKOY/has8AO9dOHGQKJcpVahNQdWz+E/S8xgRF io2g== 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=gK3itV9zYDQbxOF88qGlpL4MmQYqLwQH2CTqaXSy650=; b=X8AVj8fx3hw539JofVdyD/8I6nvAy7n9r/SswEJ54vYe5CjfqeQ8hg2iivSyZI57uX Lzx1qjyS95Gyw9WWrc3bAbQl/QEbw6/m5QXv/3zf0k6hKrG+IVLCBq53n1krSQI46g60 CSZzIHUA292+hmci/tzuFO00j+JfROD0Gjge55H+zRvknFrXa+CBS71Pt0CdSDxH60F6 gM774PteUuAOpxEzSpW2Wp4VICcakmwY17DA+P9zNmlHXR6hRyPlzIMl8nnaUHG6hZQg IsLR5DyEvzFZ74Su+WQIAFUOaSy9U7CjeFaIJrGNM5sBpWKIqZV3iFLKGCMtLBs3EgFp PRpA== 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 m13si586733edi.602.2020.10.02.01.29.54; Fri, 02 Oct 2020 01:30:16 -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 S2387713AbgJBI23 (ORCPT + 99 others); Fri, 2 Oct 2020 04:28:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:50202 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730433AbgJBI21 (ORCPT ); Fri, 2 Oct 2020 04:28:27 -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 EDB60AF4D; Fri, 2 Oct 2020 08:28:25 +0000 (UTC) From: Coly Li To: davem@davemloft.net, 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 , Philipp Reisner , Sagi Grimberg Subject: [PATCH v10 5/7] drbd: code cleanup by using sendpage_ok() to check page for kernel_sendpage() Date: Fri, 2 Oct 2020 16:27:32 +0800 Message-Id: <20201002082734.13925-6-colyli@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002082734.13925-1-colyli@suse.de> References: <20201002082734.13925-1-colyli@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In _drbd_send_page() a page is checked by following code before sending it by kernel_sendpage(), (page_count(page) < 1) || PageSlab(page) If the check is true, this page won't be send by kernel_sendpage() and handled by sock_no_sendpage(). This kind of check is exactly what macro sendpage_ok() does, which is introduced into include/linux/net.h to solve a similar send page issue in nvme-tcp code. This patch uses macro sendpage_ok() to replace the open coded checks to page type and refcount in _drbd_send_page(), as a code cleanup. Signed-off-by: Coly Li Cc: Philipp Reisner Cc: Sagi Grimberg --- drivers/block/drbd/drbd_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 04b6bde9419d..573dbf6f0c31 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -1553,7 +1553,7 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa * put_page(); and would cause either a VM_BUG directly, or * __page_cache_release a page that would actually still be referenced * by someone, leading to some obscure delayed Oops somewhere else. */ - if (drbd_disable_sendpage || (page_count(page) < 1) || PageSlab(page)) + if (drbd_disable_sendpage || !sendpage_ok(page)) return _drbd_no_send_page(peer_device, page, offset, size, msg_flags); msg_flags |= MSG_NOSIGNAL; -- 2.26.2