Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp573317pxj; Thu, 3 Jun 2021 13:52:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygj2PhFmXXeUmCTaPuuXYKQ3dsSjMdw45a5x1rKyJVeDQwUxZxN/UjGyb1QGJ44/iQtI4u X-Received: by 2002:a17:906:7c02:: with SMTP id t2mr1085776ejo.0.1622753577105; Thu, 03 Jun 2021 13:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622753577; cv=none; d=google.com; s=arc-20160816; b=r27nNAVNNJnID8tSweYQAGz2ztS9WBoYI1ulrsG5021oM7DfW58JlymjkrOOpO5U57 PPau39EbRgg1GGqICKeJyNZTE5cdBhGZHIQI/Q0tbO5ZAG/qo+CPYs/zUC25o4P7NvXz q5z/9WLHNrv8vRxDzpVmCuMyXAEFrKJmlfAIU8i03nbKuSZyU//ECwh8e4gkc21GZtx8 zQdl/clP6IqugggZB7Q/urEmmuJrmRj8Y6A1xUmHlq/iNALbuTwAPasO1HZNnaR72mh/ 6e3qmkPEC1ExvAyiuXrX18ExHGiiT33lWTANebK/2f920KqkbwxHwxgjp93lZwML+87x Dwvg== 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:cc:to:from :subject; bh=0BOj9YvbFJFnKQHPX3dZlLjh/nt5mGADJPqa4GefHVA=; b=xzpgKSsOc1IRvNJPnSLHMup3uASoeYHELk2euz49/uppgMQX5rp8azWpNs9MCga5Gz e972jUvuMwK4l1jYmz83gmcQCCS6XmpYmwtYv9QMvh3stDt51xKu150eS1aClLyz1qWn w7cpfPw7N6IJfuJ4rX2d+Pr9izgv5L/rowf18OFDkofmM+FYESCv0nOVqQRgqVtnaM0f wxQcY1gFcpHrBydPBue4wLFzkNtGTlnCj1Y3VpNnkfeLvPxXX09/6sj4ZcD2ljqtuB8F kjFUfHwhK9OsGm/dSwrmhsKINHbRocsjbiaFrt4KBbsxsfmLRypA4N0DjjVKrKc7+epP qeXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si2894948eju.144.2021.06.03.13.52.34; Thu, 03 Jun 2021 13:52:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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-nfs-owner@vger.kernel.org designates 23.128.96.18 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 S230010AbhFCUxI (ORCPT + 99 others); Thu, 3 Jun 2021 16:53:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:44740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhFCUxI (ORCPT ); Thu, 3 Jun 2021 16:53:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0E091613E7; Thu, 3 Jun 2021 20:51:22 +0000 (UTC) Subject: [PATCH 08/29] lockd: Update the NLMv1 UNLOCK arguments decoder to use struct xdr_stream From: Chuck Lever To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Date: Thu, 03 Jun 2021 16:51:22 -0400 Message-ID: <162275348234.32691.8142324748173211160.stgit@klimt.1015granger.net> In-Reply-To: <162275337584.32691.3943139351165347555.stgit@klimt.1015granger.net> References: <162275337584.32691.3943139351165347555.stgit@klimt.1015granger.net> User-Agent: StGit/1.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/lockd/xdr.c | 53 +++++++++++++---------------------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c index ef38f07d1224..b59e02b4417c 100644 --- a/fs/lockd/xdr.c +++ b/fs/lockd/xdr.c @@ -140,36 +140,6 @@ nlm_encode_oh(__be32 *p, struct xdr_netobj *oh) return xdr_encode_netobj(p, oh); } -static __be32 * -nlm_decode_lock(__be32 *p, struct nlm_lock *lock) -{ - struct file_lock *fl = &lock->fl; - s32 start, len, end; - - if (!(p = xdr_decode_string_inplace(p, &lock->caller, - &lock->len, - NLM_MAXSTRLEN)) - || !(p = nlm_decode_fh(p, &lock->fh)) - || !(p = nlm_decode_oh(p, &lock->oh))) - return NULL; - lock->svid = ntohl(*p++); - - locks_init_lock(fl); - fl->fl_flags = FL_POSIX; - fl->fl_type = F_RDLCK; /* as good as anything else */ - start = ntohl(*p++); - len = ntohl(*p++); - end = start + len - 1; - - fl->fl_start = s32_to_loff_t(start); - - if (len == 0 || end < 0) - fl->fl_end = OFFSET_MAX; - else - fl->fl_end = s32_to_loff_t(end); - return p; -} - static bool svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) { @@ -315,25 +285,28 @@ nlmsvc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p) } int -nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p) +nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p) { - struct nlm_res *resp = rqstp->rq_resp; + struct xdr_stream *xdr = &rqstp->rq_arg_stream; + struct nlm_args *argp = rqstp->rq_argp; - if (!(p = nlm_encode_testres(p, resp))) + if (!svcxdr_decode_cookie(xdr, &argp->cookie)) return 0; - return xdr_ressize_check(rqstp, p); + if (!svcxdr_decode_lock(xdr, &argp->lock)) + return 0; + argp->lock.fl.fl_type = F_UNLCK; + + return 1; } int -nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p) +nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p) { - struct nlm_args *argp = rqstp->rq_argp; + struct nlm_res *resp = rqstp->rq_resp; - if (!(p = nlm_decode_cookie(p, &argp->cookie)) - || !(p = nlm_decode_lock(p, &argp->lock))) + if (!(p = nlm_encode_testres(p, resp))) return 0; - argp->lock.fl.fl_type = F_UNLCK; - return xdr_argsize_check(rqstp, p); + return xdr_ressize_check(rqstp, p); } int