Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3081249pxa; Tue, 18 Aug 2020 06:15:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW3voK5vg15vfbaMFDLm3W9xIMJYe6jnBNeggjPFMeph21nRCuzdWwbei83BQtS0AfJd9I X-Received: by 2002:a50:ee93:: with SMTP id f19mr19542125edr.31.1597756510975; Tue, 18 Aug 2020 06:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597756510; cv=none; d=google.com; s=arc-20160816; b=Vp2FaQs8IkTMhIcq5mXDN9mEQc7ZmYrXW5eCuuwOYuLXBrnxxFNUlNKbznHiTetFB2 npIE3xR5tZUOIcMGHX6pMhpPNM4+Ue/euaALQ2vdEjLFjvO9eVNSn2jJPCDeCjzrarob PwL1E2kz/O20vvXsuG9jC6OkJH8WB8tLKf9VgFTX9l4ijN+/bC+0RrENuV+YAS8alGAj aSyJblli9VAWL4K335QcjCZAn2rJUR6geQuTsEITkWsrGbFnzHtm+U1cE/2s99zsv8rJ oF5HK2z1UbbO3zQOkANEc4nWV5aRZYi5ibf9CwnykjOFj6mipiA0wprTYDRa88VaKEFt CjoQ== 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=imVCeMOuVSM/noEt+oYxb1vPfcc+hvoZ81CfP1uflDI=; b=K22bp/9qVp7XYFczCcLbb19WupjSIK4fNtNkxrNcNyqCKfDB32/t409elzCaTQ53Kn eLmnHx9kXomjQzsGHUTf4van1OV8FVxP840i7ceU/uNYbXvuRve0Ga0QndjlIxQnxI67 OsXQZHeKPQTf/6zH4wSSKPtKAfFoH5asRkTC9EOJZUFHGLpzGg48fQUpZpGLs34aphwD 0JEHoXECxvyWkfGlEome5dLMcjRsTbOxsM1bxj8lXCSpt6K5y1tQa1OvfF+jt2mKdmzI DgXdcbCtZ6QxInexbIPCr3YX6P/sAjcmVoYyscjrMj3c/1xQ+PiHrD4VRL3ybVpjwVRl D53Q== 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 g21si12699389edr.544.2020.08.18.06.14.46; Tue, 18 Aug 2020 06:15:10 -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 S1726904AbgHRNNn (ORCPT + 99 others); Tue, 18 Aug 2020 09:13:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:33534 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726794AbgHRNN3 (ORCPT ); Tue, 18 Aug 2020 09:13:29 -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 427FFB17A; Tue, 18 Aug 2020 13:13: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 , Philipp Reisner , Sagi Grimberg Subject: [PATCH v7 4/6] drbd: code cleanup by using sendpage_ok() to check page for kernel_sendpage() Date: Tue, 18 Aug 2020 21:12:25 +0800 Message-Id: <20200818131227.37020-5-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 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 cb687ccdbd96..55dc0c91781e 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