Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1174544pxk; Fri, 25 Sep 2020 08:04:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuAV+376zjZARIZfF3PvGxbUbHlXKllI5oURg446w/GYl1ogxJGOFSHjBuxaKifudWI2NG X-Received: by 2002:aa7:cd06:: with SMTP id b6mr1727415edw.196.1601046244282; Fri, 25 Sep 2020 08:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601046244; cv=none; d=google.com; s=arc-20160816; b=WJvI2FFmgR+b4aAVy4CtpRChypOd5qRZJpWFXU6+Og0uN1ulBt1oa4tBa7DmAyd+ap E3myxMGgrA1MZEsdKmek8/I83uk6FEcu7wpsSg4CXLsPETTAj8rNdt7VPYxADUpBYa/X KO4xaRb7iMzj/XAOIcMiQVOnAjXXaA9KYB+UOnYOol478oLr52ffIZahSoT91cu5sfEs PxX/GKa/wA1jqxrkGzHY4EYrvO6XLWnLAmFl4P+SWrC3nYxT6xMBS0gAduumC+AUB4Wd q8I5uz3il+hgyRAsYGnPeSJjCBKYOlb4yZzR41+OigvSTQp4v5DgvfvIr8xq7Lic8SxX V6cQ== 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=Nk5TX1sHx/bs4tXFS8aRydw7Q9y+/v/tEOKmE9reeZI21g0ww/i2ODY1nHPZJM8RrW sx70kPyqgNkqU46rE3YkYSXIu4hQQAmWSBpatApc92TqKhOxzQTkuedEUOJVbzzdf2A5 gnY82YAQFyh+GF47xoGqbUJ+g0r6vT1+F3jmU/7DLmEAgS0963zuMpLpGdkBHdYK1+IG doArmsJKHnxtnDB0lHoIZ6cY3dRBZga5QaognDeJVESWEkf7ULs5wcviHFpqmImzILI6 mVE3qzPvjkWoZocWjEp8MSsg4r5uYf5xTDBL9rozh2TxGezQQtLeBqWjqT7PqdcnEIRM 8BGQ== 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 a4si2028519edq.101.2020.09.25.08.03.39; Fri, 25 Sep 2020 08:04: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 S1729446AbgIYPCK (ORCPT + 99 others); Fri, 25 Sep 2020 11:02:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:34556 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729431AbgIYPCJ (ORCPT ); Fri, 25 Sep 2020 11:02:09 -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 A357BB036; Fri, 25 Sep 2020 15:02:07 +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 v8 5/7] drbd: code cleanup by using sendpage_ok() to check page for kernel_sendpage() Date: Fri, 25 Sep 2020 23:01:17 +0800 Message-Id: <20200925150119.112016-6-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 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