]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
exports: add a configurable time-to-live for the kernel cache entries
authorChuck Lever <chuck.lever@oracle.com>
Wed, 6 Apr 2011 14:53:57 +0000 (10:53 -0400)
committerSteve Dickson <steved@redhat.com>
Wed, 6 Apr 2011 14:56:39 +0000 (10:56 -0400)
From: Trond Myklebust <Trond.Myklebust@netapp.com>

The fedfs ldap server will specify a ttl for its entries.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This is a refactoring change only.  There should be no change in
behavior.

Original patch had updates to utils/mountd/junctions.c, which no
longer exists.  These are not included here.

Create a macro for the default cache TTL, which is used in several
places besides the export cache.

Make e_ttl unsigned.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
support/include/exportfs.h
support/include/nfslib.h
support/nfs/exports.c
utils/mountd/cache.c

index 3cf1ee82b9461bd20d5b3c16b7dc7cd929b34f36..01e87ddc289252e818f50ab375d9fc25969a8c9f 100644 (file)
@@ -100,6 +100,7 @@ typedef struct mexport {
 } nfs_export;
 
 #define HASH_TABLE_SIZE 1021
 } nfs_export;
 
 #define HASH_TABLE_SIZE 1021
+#define DEFAULT_TTL    (30 * 60)
 
 typedef struct _exp_hash_entry {
        nfs_export * p_first;
 
 typedef struct _exp_hash_entry {
        nfs_export * p_first;
index cee826bb6f5f9ecb160b02dbe019f839ee7edf36..73f3c20cd6c9db64096cd9d53192cd799b9755a8 100644 (file)
@@ -95,6 +95,7 @@ struct exportent {
        char *          e_fslocdata;
        char *          e_uuid;
        struct sec_entry e_secinfo[SECFLAVOR_COUNT+1];
        char *          e_fslocdata;
        char *          e_uuid;
        struct sec_entry e_secinfo[SECFLAVOR_COUNT+1];
+       unsigned int    e_ttl;
 };
 
 struct rmtabent {
 };
 
 struct rmtabent {
index 1744ed667e2dd0e5df186565a4c5aea2914ddce9..6acb2b650bee9e9e22755fdc6064c7ba7c0fc448 100644 (file)
@@ -107,6 +107,7 @@ static void init_exportent (struct exportent *ee, int fromkernel)
        ee->e_nsquids = 0;
        ee->e_nsqgids = 0;
        ee->e_uuid = NULL;
        ee->e_nsquids = 0;
        ee->e_nsqgids = 0;
        ee->e_uuid = NULL;
+       ee->e_ttl = DEFAULT_TTL;
 }
 
 struct exportent *
 }
 
 struct exportent *
index f70f4d6e81a7e1ee7b57061f34b7d1c6d68ba162..1d6e95325c489e35b6b4f05490327a84a2dd5364 100644 (file)
@@ -114,7 +114,7 @@ static void auth_unix_ip(FILE *f)
 
        qword_print(f, "nfsd");
        qword_print(f, ipaddr);
 
        qword_print(f, "nfsd");
        qword_print(f, ipaddr);
-       qword_printint(f, time(0)+30*60);
+       qword_printuint(f, time(0) + DEFAULT_TTL);
        if (use_ipaddr)
                qword_print(f, ipaddr);
        else if (client)
        if (use_ipaddr)
                qword_print(f, ipaddr);
        else if (client)
@@ -161,7 +161,7 @@ static void auth_unix_gid(FILE *f)
                }
        }
        qword_printuint(f, uid);
                }
        }
        qword_printuint(f, uid);
-       qword_printuint(f, time(0)+30*60);
+       qword_printuint(f, time(0) + DEFAULT_TTL);
        if (rv >= 0) {
                qword_printuint(f, ngroups);
                for (i=0; i<ngroups; i++)
        if (rv >= 0) {
                qword_printuint(f, ngroups);
                for (i=0; i<ngroups; i++)
@@ -644,11 +644,11 @@ static int dump_to_cache(FILE *f, char *domain, char *path, struct exportent *ex
 {
        qword_print(f, domain);
        qword_print(f, path);
 {
        qword_print(f, domain);
        qword_print(f, path);
-       qword_printint(f, time(0)+30*60);
        if (exp) {
                int different_fs = strcmp(path, exp->e_path) != 0;
                int flag_mask = different_fs ? ~NFSEXP_FSID : ~0;
 
        if (exp) {
                int different_fs = strcmp(path, exp->e_path) != 0;
                int flag_mask = different_fs ? ~NFSEXP_FSID : ~0;
 
+               qword_printuint(f, time(0) + exp->e_ttl);
                qword_printint(f, exp->e_flags & flag_mask);
                qword_printint(f, exp->e_anonuid);
                qword_printint(f, exp->e_anongid);
                qword_printint(f, exp->e_flags & flag_mask);
                qword_printint(f, exp->e_anonuid);
                qword_printint(f, exp->e_anongid);
@@ -667,7 +667,8 @@ static int dump_to_cache(FILE *f, char *domain, char *path, struct exportent *ex
                        qword_print(f, "uuid");
                        qword_printhex(f, u, 16);
                }
                        qword_print(f, "uuid");
                        qword_printhex(f, u, 16);
                }
-       }
+       } else
+               qword_printuint(f, time(0) + DEFAULT_TTL);
        return qword_eol(f);
 }
 
        return qword_eol(f);
 }
 
@@ -874,8 +875,8 @@ int cache_process_req(fd_set *readfds)
 
 /*
  * Give IP->domain and domain+path->options to kernel
 
 /*
  * Give IP->domain and domain+path->options to kernel
- * % echo nfsd $IP  $[now+30*60] $domain > /proc/net/rpc/auth.unix.ip/channel
- * % echo $domain $path $[now+30*60] $options $anonuid $anongid $fsid > /proc/net/rpc/nfsd.export/channel
+ * % echo nfsd $IP  $[now+DEFAULT_TTL] $domain > /proc/net/rpc/auth.unix.ip/channel
+ * % echo $domain $path $[now+DEFAULT_TTL] $options $anonuid $anongid $fsid > /proc/net/rpc/nfsd.export/channel
  */
 
 static int cache_export_ent(char *domain, struct exportent *exp, char *path)
  */
 
 static int cache_export_ent(char *domain, struct exportent *exp, char *path)
@@ -955,7 +956,7 @@ int cache_export(nfs_export *exp, char *path)
        qword_print(f, "nfsd");
        qword_print(f,
                host_ntop(get_addrlist(exp->m_client, 0), buf, sizeof(buf)));
        qword_print(f, "nfsd");
        qword_print(f,
                host_ntop(get_addrlist(exp->m_client, 0), buf, sizeof(buf)));
-       qword_printint(f, time(0)+30*60);
+       qword_printuint(f, time(0) + exp->m_export.e_ttl);
        qword_print(f, exp->m_client->m_hostname);
        err = qword_eol(f);
        
        qword_print(f, exp->m_client->m_hostname);
        err = qword_eol(f);