Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp943557imi; Fri, 22 Jul 2022 13:10:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t7y9UfQ47YkEY3COTy6/+zjKtgroTGQCog0boHkZUbaVQHt9YmebabaLE9l4A78LadDS/h X-Received: by 2002:a17:906:3f02:b0:718:bdf7:790d with SMTP id c2-20020a1709063f0200b00718bdf7790dmr1166531ejj.479.1658520650582; Fri, 22 Jul 2022 13:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658520650; cv=none; d=google.com; s=arc-20160816; b=jd6eUGPQcoxanB0imverRdWjlNPWIbcBWumpehwjh/pzUp8UUg/YIjBkMpUDv3hB7S YThA58DG2Q2pSnFrGUkNt1npQHxtSGXsj0gUF28CDWOpxmfK7kQhc+ZojskvyxIqMzxY hqkinIVRrUDSeP5rw1hMNvotdx448Lz6pxHnOSAGAUPjz1BbHXJRkanttKES5GJhmYyc AdmAPZFBKCq/mboS4YAqLC58EYzSdbSct5/5gnnvLQOAmY87gRJ/oKVF8hEwGTuw7wyQ uMFoY0oOsvMZMtywbQQeVpZQRU54srKw4lJITXyZNAeettaU2hOqWDzoqiffz4hDxBZc Cwjw== 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 :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=ZBD0k8Yd1E4O5PRDqFZOCS+rOD/mA3ndReIQHrPBXDY=; b=QnRTUtKh/N5IAkxkypmZtPIPwqk7gOQDRdcZ58EdfWkcznGXoTp4wZOl2XoK3Hc0bO h6haeJkCkzoY2cnSyy++J5o1nMZOeey1xsBNckfqRmVRn1zm3yWheFRx9zTbgWPhX/ej f/sL8IlwpTB26GcVuMdx/HJ1DYOqVbXvx5/oV5gREF4QGtkGt61cRM95qIIXoQEehMHj 0iVxflVp0Vy/cq+4NESAHoXr3vnDg9dve8ZlxvpIlGsKxmqc19DA6J0d6sYXi8okf8/l H7CRfgxtSvYZawfBNAUFI72tlGcgByRC6rvVLDNJHZ2UdlmByVU3x/Ka5uJslxuBNqN0 YSQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w7-20020a05640234c700b004356a5f330fsi7523460edc.445.2022.07.22.13.10.20; Fri, 22 Jul 2022 13:10:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236829AbiGVUJT (ORCPT + 99 others); Fri, 22 Jul 2022 16:09:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236786AbiGVUI5 (ORCPT ); Fri, 22 Jul 2022 16:08:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3542A894A for ; Fri, 22 Jul 2022 13:08:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5045B61F5E for ; Fri, 22 Jul 2022 20:08:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4A84C341C6 for ; Fri, 22 Jul 2022 20:08:52 +0000 (UTC) Subject: [PATCH v1 3/8] NFSD: Clean up SPLICE_OK in nfsd4_encode_read() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Fri, 22 Jul 2022 16:08:51 -0400 Message-ID: <165852053165.11198.4403935829192122901.stgit@manet.1015granger.net> In-Reply-To: <165852051841.11198.2929614302983292322.stgit@manet.1015granger.net> References: <165852051841.11198.2929614302983292322.stgit@manet.1015granger.net> User-Agent: StGit/1.5.dev2+g9ce680a5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Do the test_bit() once -- this reduces the number of locked-bus operations and makes the function a little easier to read. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index e590236a60ab..c9468f205dad 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3980,6 +3980,7 @@ static __be32 nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_read *read) { + bool splice_ok = test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags); unsigned long maxcount; struct xdr_stream *xdr = resp->xdr; struct file *file; @@ -3992,11 +3993,10 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, p = xdr_reserve_space(xdr, 8); /* eof flag and byte count */ if (!p) { - WARN_ON_ONCE(test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)); + WARN_ON_ONCE(splice_ok); return nfserr_resource; } - if (resp->xdr->buf->page_len && - test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) { + if (resp->xdr->buf->page_len && splice_ok) { WARN_ON_ONCE(1); return nfserr_resource; } @@ -4005,8 +4005,7 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, maxcount = min_t(unsigned long, read->rd_length, (xdr->buf->buflen - xdr->buf->len)); - if (file->f_op->splice_read && - test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) + if (file->f_op->splice_read && splice_ok) nfserr = nfsd4_encode_splice_read(resp, read, file, maxcount); else nfserr = nfsd4_encode_readv(resp, read, file, maxcount);