Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5230430ybi; Tue, 30 Jul 2019 16:39:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIEADL705ZhDiENtV7LhYRwX9YRa/SOQiUWiJBK5Oidjvjh0keHKbImIsWmidBwBZhOFX9 X-Received: by 2002:a17:90a:eb08:: with SMTP id j8mr12313pjz.72.1564529942911; Tue, 30 Jul 2019 16:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564529942; cv=none; d=google.com; s=arc-20160816; b=hOUBmYaa58M4oNCfEBW+1QY5ke+nbMi1VcSaEIOCSS2YdQLjs7pVcutIWrclDM64ue +nY20t6XYNYzINUu871YFe1a6pCXOSfeoCsJeG8g0gEcSQKTc1dr2CqVOmRCf5JXa01C OJY7bRlVChyR5F9L8Q4tAl2Ve/IIl+zcT9Uga1YFesb+8Qhr2yEyGb6Pg8z9aKE57Ixo AGqrII/T2S3SO/htzLOm5/rZLgK4uLnSLcY+c0lhAm7Ckv1A7IbEyD363Fhd14UPSyxk /WUAGbf3HeBRxl0P91uBkWOCUP9AJGWgFhpXcdnorIJOakfX/AnUW5tVbJOWJXzjo3Ed +OIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=wciSAhavC9PXyvns0mLZaQmsagfQFafVPGpPWd3daEs=; b=xbV5ZM5m/QzLf1rTlGMSdydX1+VS2okAcAzJUW2iOfldc4CIbayzRwqzCcbo0nUBdC Asd+PMACbT11yrhR8hKjvuliXAHLPEolqLMFVQ0gmu/oNJrkGQpOe2Q3h3pWbk7hwDxq yJGKXs1ifC+isDHi7f/UepGI4cl0imdKE9ONoDXwlL3bx3jO+u4xfDodUkLizGfAJx4k YXKetud10DnzcNoIOH1/yp/3M6vaGeHOhJZJnG1hzgjU1Xfw/pdfIY7wz52qG3EBZ6WP P2gj++5wpDaT3rwkJ30Dzjg/BuqywZkyAcXP0LzvHl3IVoeO7xXEOLEZbRCE7EVIQAcb EbnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5si14338825pgl.536.2019.07.30.16.38.46; Tue, 30 Jul 2019 16:39:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387566AbfG3VJw (ORCPT + 99 others); Tue, 30 Jul 2019 17:09:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48598 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387511AbfG3VJv (ORCPT ); Tue, 30 Jul 2019 17:09:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53E9BC049E12 for ; Tue, 30 Jul 2019 21:09:51 +0000 (UTC) Received: from coeurl.usersys.redhat.com (ovpn-120-110.rdu2.redhat.com [10.10.120.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26C595D9C5; Tue, 30 Jul 2019 21:09:51 +0000 (UTC) Received: by coeurl.usersys.redhat.com (Postfix, from userid 1000) id CF2AE20A25; Tue, 30 Jul 2019 17:09:50 -0400 (EDT) From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH RFC 1/2] nfsdcld: add a "GetVersion" upcall Date: Tue, 30 Jul 2019 17:09:49 -0400 Message-Id: <20190730210950.10545-2-smayhew@redhat.com> In-Reply-To: <20190730210950.10545-1-smayhew@redhat.com> References: <20190730210950.10545-1-smayhew@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 30 Jul 2019 21:09:51 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add a "GetVersion" upcall to allow the kernel to determine the maximum upcall version that nfsdcld supports. Signed-off-by: Scott Mayhew --- support/include/cld.h | 11 ++++++++- utils/nfsdcld/cld-internal.h | 4 ++- utils/nfsdcld/nfsdcld.c | 47 ++++++++++++++++++++++++++++++------ utils/nfsdcld/sqlite.c | 2 +- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/support/include/cld.h b/support/include/cld.h index c1f5b70..00a40da 100644 --- a/support/include/cld.h +++ b/support/include/cld.h @@ -33,7 +33,8 @@ enum cld_command { Cld_Remove, /* remove record of this cm_id */ Cld_Check, /* is this cm_id allowed? */ Cld_GraceDone, /* grace period is complete */ - Cld_GraceStart, + Cld_GraceStart, /* grace start (upload client records) */ + Cld_GetVersion, /* query max supported upcall version */ }; /* representation of long-form NFSv4 client ID */ @@ -51,7 +52,15 @@ struct cld_msg { union { int64_t cm_gracetime; /* grace period start time */ struct cld_name cm_name; + uint8_t cm_version; /* for getting max version */ } __attribute__((packed)) cm_u; } __attribute__((packed)); +struct cld_msg_hdr { + uint8_t cm_vers; /* upcall version */ + uint8_t cm_cmd; /* upcall command */ + int16_t cm_status; /* return code */ + uint32_t cm_xid; /* transaction id */ +} __attribute__((packed)); + #endif /* !_NFSD_CLD_H */ diff --git a/utils/nfsdcld/cld-internal.h b/utils/nfsdcld/cld-internal.h index 76e97db..f33cb04 100644 --- a/utils/nfsdcld/cld-internal.h +++ b/utils/nfsdcld/cld-internal.h @@ -21,7 +21,9 @@ struct cld_client { int cl_fd; struct event cl_event; - struct cld_msg cl_msg; + union { + struct cld_msg cl_msg; + } cl_u; }; uint64_t current_epoch; diff --git a/utils/nfsdcld/nfsdcld.c b/utils/nfsdcld/nfsdcld.c index cbf71fc..aa5594b 100644 --- a/utils/nfsdcld/nfsdcld.c +++ b/utils/nfsdcld/nfsdcld.c @@ -343,7 +343,7 @@ cld_not_implemented(struct cld_client *clnt) { int ret; ssize_t bsize, wsize; - struct cld_msg *cmsg = &clnt->cl_msg; + struct cld_msg *cmsg = &clnt->cl_u.cl_msg; xlog(D_GENERAL, "%s: downcalling with not implemented error", __func__); @@ -365,12 +365,40 @@ cld_not_implemented(struct cld_client *clnt) } } +static void +cld_get_version(struct cld_client *clnt) +{ + int ret; + ssize_t bsize, wsize; + struct cld_msg *cmsg = &clnt->cl_u.cl_msg; + + xlog(D_GENERAL, "%s: version = %u.", __func__, UPCALL_VERSION); + + cmsg->cm_u.cm_version = UPCALL_VERSION; + cmsg->cm_status = 0; + + bsize = sizeof(*cmsg); + + xlog(D_GENERAL, "Doing downcall with status %d", cmsg->cm_status); + wsize = atomicio((void *)write, clnt->cl_fd, cmsg, bsize); + if (wsize != bsize) { + xlog(L_ERROR, "%s: problem writing to cld pipe (%ld): %m", + __func__, wsize); + ret = cld_pipe_open(clnt); + if (ret) { + xlog(L_FATAL, "%s: unable to reopen pipe: %d", + __func__, ret); + exit(ret); + } + } +} + static void cld_create(struct cld_client *clnt) { int ret; ssize_t bsize, wsize; - struct cld_msg *cmsg = &clnt->cl_msg; + struct cld_msg *cmsg = &clnt->cl_u.cl_msg; ret = cld_check_grace_period(); if (ret) @@ -406,7 +434,7 @@ cld_remove(struct cld_client *clnt) { int ret; ssize_t bsize, wsize; - struct cld_msg *cmsg = &clnt->cl_msg; + struct cld_msg *cmsg = &clnt->cl_u.cl_msg; ret = cld_check_grace_period(); if (ret) @@ -442,7 +470,7 @@ cld_check(struct cld_client *clnt) { int ret; ssize_t bsize, wsize; - struct cld_msg *cmsg = &clnt->cl_msg; + struct cld_msg *cmsg = &clnt->cl_u.cl_msg; /* * If we get a check upcall at all, it means we're talking to an old @@ -489,7 +517,7 @@ cld_gracedone(struct cld_client *clnt) { int ret; ssize_t bsize, wsize; - struct cld_msg *cmsg = &clnt->cl_msg; + struct cld_msg *cmsg = &clnt->cl_u.cl_msg; /* * If we got a "gracedone" upcall while we're not in grace, then @@ -543,7 +571,7 @@ reply: static int gracestart_callback(struct cld_client *clnt) { ssize_t bsize, wsize; - struct cld_msg *cmsg = &clnt->cl_msg; + struct cld_msg *cmsg = &clnt->cl_u.cl_msg; cmsg->cm_status = -EINPROGRESS; @@ -562,7 +590,7 @@ cld_gracestart(struct cld_client *clnt) { int ret; ssize_t bsize, wsize; - struct cld_msg *cmsg = &clnt->cl_msg; + struct cld_msg *cmsg = &clnt->cl_u.cl_msg; xlog(D_GENERAL, "%s: updating grace epochs", __func__); @@ -598,7 +626,7 @@ cldcb(int UNUSED(fd), short which, void *data) { ssize_t len; struct cld_client *clnt = data; - struct cld_msg *cmsg = &clnt->cl_msg; + struct cld_msg *cmsg = &clnt->cl_u.cl_msg; if (which != EV_READ) goto out; @@ -633,6 +661,9 @@ cldcb(int UNUSED(fd), short which, void *data) case Cld_GraceStart: cld_gracestart(clnt); break; + case Cld_GetVersion: + cld_get_version(clnt); + break; default: xlog(L_WARNING, "%s: command %u is not yet implemented", __func__, cmsg->cm_cmd); diff --git a/utils/nfsdcld/sqlite.c b/utils/nfsdcld/sqlite.c index fa81df8..6525fc1 100644 --- a/utils/nfsdcld/sqlite.c +++ b/utils/nfsdcld/sqlite.c @@ -1152,7 +1152,7 @@ sqlite_iterate_recovery(int (*cb)(struct cld_client *clnt), struct cld_client *c { int ret; sqlite3_stmt *stmt = NULL; - struct cld_msg *cmsg = &clnt->cl_msg; + struct cld_msg *cmsg = &clnt->cl_u.cl_msg; if (recovery_epoch == 0) { xlog(D_GENERAL, "%s: not in grace!", __func__); -- 2.17.2