Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3064424pxa; Tue, 18 Aug 2020 05:52:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCJVZC271k9YoEFpp7mU+zd4fYVsK+ts9Q29E7ZM8fUEWGx9vq7r6nRQ1col8T4u8U9alQ X-Received: by 2002:a17:906:2296:: with SMTP id p22mr19783364eja.510.1597755124070; Tue, 18 Aug 2020 05:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597755124; cv=none; d=google.com; s=arc-20160816; b=oaBY7/eIywG9fPORziZh9GKJ/HvJVas6iZ3lQ8hKKCmVwPUmgD61NrmQquizqM3Tsn Hbd7pOzHZ3/wnvzxpoHkUv+RRHZkNeJ3vuDeqOohP07WEOGnkhyY5Cbakd9Kw6v9T0K0 oFsAN+4Gjga/wtcM7OFsjcV1REBP56txZ8L12JmBNPpHKQ8FAf7roI8ZrcYwLUGZT2j9 xeUwX2pzrz8ddhtRfDohXfuPOgOgkp1Ipc13+YJ9kgZy5nn7Za1LM7x0rc7Tm0uFcwzt rxYItGsVkPCRDrL5r2dLKTTjU6QT4lV4t5YdjAqchTG1jBUlAQtT1QUWrpivQKxkRXRW adWg== 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=zk5prBpBconaagMal5lVNBmWMThUcEY+HWHyfTcjOyYGVM8UnMVQE8gw8jR7FQTrkW kB4nMTFMKAMdSOCsZ2ZynEFq/j27g6Eg6jsB/i5f4cJN9OiNo5VbA+hrmVTpMCsbDpPb uhF9Ow6XQiVxFnTflgZzzhKwBGn2BrEdIhLIcH8nJ9ZwLzxaKWd09znw/eVvKMnuAQpd xWnc8muTszRACwhatC/ftMLSni5HwB9w4BQe5rNzw9gDDcsmXbPwUgkioKCvFSOJcHee Q7EpgetSyq7P2eUHC1Xb2RQmyFkhdc2hHVuzm3ajSff3ngSJosh2wi/7t00sGsK/OMWi uWuw== 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 r9si13742508eji.408.2020.08.18.05.51.39; Tue, 18 Aug 2020 05:52:04 -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 S1726905AbgHRMs3 (ORCPT + 99 others); Tue, 18 Aug 2020 08:48:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:49570 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726858AbgHRMsX (ORCPT ); Tue, 18 Aug 2020 08:48:23 -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 1F62AADF2; Tue, 18 Aug 2020 12:48:47 +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 v6 4/6] drbd: code cleanup by using sendpage_ok() to check page for kernel_sendpage() Date: Tue, 18 Aug 2020 20:47:34 +0800 Message-Id: <20200818124736.5790-5-colyli@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818124736.5790-1-colyli@suse.de> References: <20200818124736.5790-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