From patchwork Tue Aug 11 12:20:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709175 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2252016B1 for ; Tue, 11 Aug 2020 12:20:47 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0ABAF206C3 for ; Tue, 11 Aug 2020 12:20:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0ABAF206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id E47382F37DF; Tue, 11 Aug 2020 05:20:34 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 956C921F5A4 for ; Tue, 11 Aug 2020 05:20:25 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 0A3BB10055FF; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 011FD2D3; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:05 -0400 Message-Id: <1597148419-20629-10-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 09/23] lustre: sec: check if page is empty with ZERO_PAGE X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Sebastien Buisson In osc_brw_fini_request(), page needs decryption only if it is not empty. To check this, use ZERO_PAGE macro available for all architectures, and compare with memcmp. It will likely be faster/more efficient than comparing the words by hand as may use optimized CPU instructions or ASM code. WC-bug-id: https://jira.whamcloud.com/browse/LU-12275 Lustre-commit: 45c26bc11b7b1e ("LU-12275 sec: check if page is empty with ZERO_PAGE") Signed-off-by: Sebastien Buisson Reviewed-on: https://review.whamcloud.com/38918 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/osc/osc_request.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/lustre/osc/osc_request.c b/fs/lustre/osc/osc_request.c index 1968d62..3bbe3d9 100644 --- a/fs/lustre/osc/osc_request.c +++ b/fs/lustre/osc/osc_request.c @@ -2075,16 +2075,11 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) } for (idx = 0; idx < aa->aa_page_count; idx++) { struct brw_page *pg = aa->aa_ppga[idx]; - u64 *p, *q; /* do not decrypt if page is all 0s */ - p = q = page_address(pg->pg); - while (p - q < PAGE_SIZE / sizeof(*p)) { - if (*p != 0) - break; - p++; - } - if (p - q == PAGE_SIZE / sizeof(*p)) { + if (memcmp(page_address(pg->pg), + page_address(ZERO_PAGE(0)), + PAGE_SIZE) == 0) { /* if page is empty forward info to upper layers * (ll_io_zero_page) by clearing PagePrivate2 */