@@ -37,6 +37,8 @@ nsdb-create-fsn \- create a fileset name (FSN) record on an NSDB
.IR nsdbname ]
.RB [ \-r
.IR nsdbport ]
+.RB [ \-t
+.IR ttl ]
.I fsn-uuid
.SH INTRODUCTION
RFC 5716 introduces the Federated File System (FedFS, for short).
@@ -146,6 +148,12 @@ If the
option is not specified,
the value of the FEDFS_NSDB_PORT environment variable is consulted.
The default value if the variable is not set is 389.
+.IP "\fB\-t, \-\-ttl=\fITTL\fP"
+Specifies the number of seconds a file server may cache the information
+in this record. If the
+.B \-\-ttl
+option is not specified,
+a value of 300 seconds is used.
.SH EXIT CODES
The NSDB returns a value that reflects the success of the requested operation.
.TP
@@ -243,8 +243,8 @@ void nsdb_env(char **nsdbname, unsigned short *nsdbport,
* Create an FSN (5.1.1)
*/
FedFsStatus nsdb_create_fsn_s(nsdb_t host, const char *nce,
- const char *fsn_uuid, const char *nsdbname,
- const unsigned short nsdbport,
+ const char *fsn_uuid,
+ const unsigned int ttl,
unsigned int *ldap_err);
/**
@@ -85,8 +85,7 @@ nsdb_construct_fsn_dn(const char *nce, const char *fsn_uuid)
* @param ld an initialized LDAP server descriptor
* @param nce a NUL-terminated C string containing DN of NSDB container entry
* @param fsn_uuid a NUL-terminated C string containing FSN UUID
- * @param nsdbname a NUL-terminated C string containing DNS hostname of NSDB server
- * @param nsdbport port number of NSDB server
+ * @param ttl number of seconds fileservers may cache this FSN
* @param ldap_err OUT: possibly an LDAP error code
* @return a FedFsStatus code
*
@@ -98,18 +97,18 @@ nsdb_construct_fsn_dn(const char *nce, const char *fsn_uuid)
changeType: add
objectClass: fedfsFsn
fedfsFsnUuid: "fsn_uuid"
- fedfsNsdbName: "nsdbname"
+ fedfsFsnTTL: "ttl"
@endverbatim
*/
static FedFsStatus
nsdb_create_fsn_add_entry(LDAP *ld, const char *nce,
- const char *fsn_uuid, const char *nsdbname,
- const unsigned short nsdbport, unsigned int *ldap_err)
+ const char *fsn_uuid, const unsigned int ttl,
+ unsigned int *ldap_err)
{
- char *ocvals[2], *uuidvals[2], *namevals[2], *portvals[2];
+ char *ocvals[2], *uuidvals[2], *ttlvals[2];
LDAPMod *attrs[5];
LDAPMod attr[4];
- char portbuf[8];
+ char ttlbuf[16];
int i, rc;
char *dn;
@@ -121,11 +120,9 @@ nsdb_create_fsn_add_entry(LDAP *ld, const char *nce,
"objectClass", ocvals, "fedfsFsn");
nsdb_init_add_attribute(attrs[i++],
"fedfsFsnUuid", uuidvals, fsn_uuid);
+ sprintf(ttlbuf, "%u", ttl);
nsdb_init_add_attribute(attrs[i++],
- "fedfsNsdbName", namevals, nsdbname);
- sprintf(portbuf, "%u", nsdbport);
- nsdb_init_add_attribute(attrs[i++],
- "fedfsNsdbPort", portvals, portbuf);
+ "fedfsFsnTTL", ttlvals, ttlbuf);
attrs[i] = NULL;
@@ -152,29 +149,26 @@ nsdb_create_fsn_add_entry(LDAP *ld, const char *nce,
* @param host an initialized and bound nsdb_t object
* @param nce a NUL-terminated C string containing DN of NSDB container entry
* @param fsn_uuid a NUL-terminated C string containing FSN UUID
- * @param nsdbname a NUL-terminated C string containing DNS hostname of NSDB server
- * @param nsdbport port number of NSDB server
+ * @param ttl number of seconds fileservers may cache this FSN
* @param ldap_err OUT: possibly an LDAP error code
* @return a FedFsStatus code
*/
FedFsStatus
nsdb_create_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid,
- const char *nsdbname, const unsigned short nsdbport,
- unsigned int *ldap_err)
+ const unsigned int ttl, unsigned int *ldap_err)
{
if (host->fn_ldap == NULL) {
xlog(L_ERROR, "%s: NSDB not open", __func__);
return FEDFS_ERR_INVAL;
}
- if (nce == NULL || fsn_uuid == NULL ||
- nsdbname == NULL || ldap_err == NULL) {
+ if (nce == NULL || fsn_uuid == NULL || ldap_err == NULL) {
xlog(L_ERROR, "%s: Invalid parameter", __func__);
return FEDFS_ERR_INVAL;
}
return nsdb_create_fsn_add_entry(host->fn_ldap, nce, fsn_uuid,
- nsdbname, nsdbport, ldap_err);
+ ttl, ldap_err);
}
/**
@@ -42,6 +42,11 @@
#include "nfsref.h"
/**
+ * Default cache expiration for FSN information
+ */
+#define FSN_DEFAULT_TTL (300)
+
+/**
* Fill in default settings for NFSv4.0 fs_locations4
*
* @param new NFS location structure to fill in
@@ -239,8 +244,7 @@ nfsref_add_create_fedfs_fsn(nsdb_t host, const char *nce, char **fsn_uuid)
uuid_unparse(uu, fsnuuid);
retval = nsdb_create_fsn_s(host, nce, fsnuuid,
- nsdb_hostname(host), nsdb_port(host),
- &ldap_err);
+ FSN_DEFAULT_TTL, &ldap_err);
switch (retval) {
case FEDFS_OK:
xlog(D_GENERAL, "%s: Successfully created FSN record "
@@ -48,9 +48,14 @@
#include "gpl-boiler.h"
/**
+ * Default cache expiration for FSN information
+ */
+#define FSN_DEFAULT_TTL (300)
+
+/**
* Short form command line options
*/
-static const char nsdb_create_fsn_opts[] = "?dD:e:l:r:";
+static const char nsdb_create_fsn_opts[] = "?dD:e:l:r:t:";
/**
* Long form command line options
@@ -62,6 +67,7 @@ static const struct option nsdb_create_fsn_longopts[] = {
{ "nce", 1, NULL, 'e', },
{ "nsdbname", 1, NULL, 'l', },
{ "nsdbport", 1, NULL, 'r', },
+ { "ttl", 1, NULL, 't', },
{ NULL, 0, NULL, 0, },
};
@@ -74,7 +80,7 @@ static void
nsdb_create_fsn_usage(const char *progname)
{
fprintf(stderr, "\n%s version " VERSION "\n", progname);
- fprintf(stderr, "Usage: %s [ -d ] [ -D binddn ] "
+ fprintf(stderr, "Usage: %s [ -d ] [ -D binddn ] [ -t ttl ] "
"[ -l nsdbname ] [ -r nsdbport ] [ -e nce ] "
"fsn-uuid\n\n",
progname);
@@ -85,6 +91,7 @@ nsdb_create_fsn_usage(const char *progname)
fprintf(stderr, "\t-e, --nce DN of NSDB container entry\n");
fprintf(stderr, "\t-l, --nsdbname NSDB hostname\n");
fprintf(stderr, "\t-r, --nsdbport NSDB port\n");
+ fprintf(stderr, "\t-t, --ttl FSN TTL\n");
fprintf(stderr, "%s", fedfs_gpl_boilerplate);
@@ -101,11 +108,12 @@ nsdb_create_fsn_usage(const char *progname)
int
main(int argc, char **argv)
{
- char *progname, *binddn, *nsdbname;
+ char *progname, *binddn, *nsdbname, *endptr;
unsigned short nsdbport;
- unsigned int ldap_err;
+ unsigned int ttl, ldap_err;
char *nce, *fsn_uuid;
FedFsStatus retval;
+ unsigned long tmp;
nsdb_t host;
int arg;
@@ -130,6 +138,7 @@ main(int argc, char **argv)
xlog_open(progname);
nsdb_env(&nsdbname, &nsdbport, &binddn, &nce);
+ ttl = FSN_DEFAULT_TTL;
while ((arg = getopt_long(argc, argv, nsdb_create_fsn_opts,
nsdb_create_fsn_longopts, NULL)) != -1) {
@@ -153,6 +162,19 @@ main(int argc, char **argv)
nsdb_create_fsn_usage(progname);
}
break;
+ case 't':
+ if (optarg == NULL || *optarg == '\0') {
+ fprintf(stderr, "Missing TTL value\n");
+ nsdb_create_fsn_usage(progname);
+ }
+ errno = 0;
+ tmp = strtoul(optarg, &endptr, 10);
+ if (errno != 0 || *endptr != '\0') {
+ fprintf(stderr, "Bad TTL value\n");
+ nsdb_create_fsn_usage(progname);
+ }
+ ttl = (unsigned int)tmp;
+ break;
default:
fprintf(stderr, "Invalid command line "
"argument: %c\n", (char)arg);
@@ -230,8 +252,7 @@ main(int argc, char **argv)
goto out_free;
}
- retval = nsdb_create_fsn_s(host, nce, fsn_uuid,
- nsdbname, nsdbport, &ldap_err);
+ retval = nsdb_create_fsn_s(host, nce, fsn_uuid, ttl, &ldap_err);
switch (retval) {
case FEDFS_OK:
printf("Successfully created FSN record for %s under %s\n",
The latest NSDB schema removes the NSDB name attribute from the fedfsFsn object class, but adds a TTL. Update nsdb_create_fsn_s() to comply with the new schema, and allow nsdb-create-fsn to take an optional TTL argument. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> --- doc/man/nsdb-create-fsn.8 | 8 ++++++++ src/include/nsdb.h | 4 ++-- src/libnsdb/administrator.c | 30 ++++++++++++------------------ src/nfsref/add.c | 8 ++++++-- src/nsdbc/nsdb-create-fsn.c | 33 +++++++++++++++++++++++++++------ 5 files changed, 55 insertions(+), 28 deletions(-)