Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1310915pxa; Sat, 15 Aug 2020 15:26:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHN2ABdxv5t6/s0RTpF9Ob9YdLYlnejO/PlvlKthjpA4fVGXexm2QMp1WquSob7fYBmUmF X-Received: by 2002:aa7:c513:: with SMTP id o19mr8621354edq.327.1597530393367; Sat, 15 Aug 2020 15:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597530393; cv=none; d=google.com; s=arc-20160816; b=p89I29H6SdfqeKHsPBoiYJr/jrVM1qCZDS83KB/jPBFZJMzRMAtBBKvUYrrZi4PkrF /YU2UNZyuV/GA41wkUmzubRx76Sg+firnQvmaAGxYvmZyfK3O10+vQwJgePwOBZaF303 TttQMVFXwIU8TjR002jbPi/4W81nHyi7kmq5ymYwT2WKxtawg6r6sQCBg7wA4SckqoGJ UzFo5oExwDxA6x+YlYZDFwDtcdNicpCxktMhHtjL2ax08d7DFF8/AwKEmHQc2wqd3zLF i1vcXa5MMeKYhQwO4jhDMNG1auajEtnI1eHDQ9I34ZXamXe1IAfgoC+xTWKTk1pUImdR GCpQ== 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=h6WLi6hQWKnB2OMvMxUhJTv4GBHgP9+kgSyb+hnOV60AvO2WeCgK5WkOqPJRHyuJ5U J9s3enePasM6VjgSE8VbHldj4RSvkQxbcYuby5LF1W6wfdsuwFkXySU9At0mo+evSUv9 xxqzaYex+hxMJlwhrJvbC+9Orgb1i+jGbQCjP939jdC4WBLquzX4NrA7lXDaDb2dCo5W XwFIB+RSp9Ly4hGmZlVDWnsqR++tv2CgPNnQZ+L1VuvlzIzBHZg1svRVacsIRDm+f4BY 8iX78oCdE3+NR8aeMvruT0v3GTRaHFps2O3ndb36z91BX4sZ3Yp+MEx2kdOzS5O1Wh2V Dzig== 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 c34si9857777edd.267.2020.08.15.15.26.10; Sat, 15 Aug 2020 15:26:33 -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 S1728678AbgHOWXo (ORCPT + 99 others); Sat, 15 Aug 2020 18:23:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:37780 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726511AbgHOWXn (ORCPT ); Sat, 15 Aug 2020 18:23:43 -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 BA693B65C; Sat, 15 Aug 2020 07:48:52 +0000 (UTC) From: Coly Li To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: netdev@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, Coly Li , Philipp Reisner , Sagi Grimberg Subject: [PATCH 3/3] drbd: code cleanup by using sendpage_ok() to check page for kernel_sendpage() Date: Sat, 15 Aug 2020 15:48:04 +0800 Message-Id: <20200815074804.46995-3-colyli@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200815074804.46995-1-colyli@suse.de> References: <20200815074804.46995-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