]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Extend the exportfs/mountd interface to pass fslocations info into the kernel
authorFred Isaman <iisaman@citi.umich.edu>
Tue, 27 Feb 2007 04:31:04 +0000 (15:31 +1100)
committerNeil Brown <neilb@suse.de>
Tue, 27 Feb 2007 04:31:04 +0000 (15:31 +1100)
Fix up a few issues with the fsloc code.

Signed-off-by: Fred Isaman <iisaman@citi.umich.edu>
Signed-off-by: Kevin Coffman <kwc@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
support/export/export.c
support/nfs/exports.c
utils/exportfs/exportfs.c
utils/exportfs/exports.man
utils/mountd/fsloc.c

index cfb6681093fe8e629eb38ff1289794115191b10b..a4b0788e4f6977057be760769e1b680c9440cc64 100644 (file)
@@ -240,6 +240,8 @@ export_freeall(void)
                                xfree(exp->m_export.e_sqgids);
                        if (exp->m_export.e_mountpoint)
                                free(exp->m_export.e_mountpoint);
+                       if (exp->m_export.e_fslocdata)
+                               xfree(exp->m_export.e_fslocdata);
                        xfree(exp);
                }
                exportlist[i] = NULL;
index 31b38c3735b7be7776fac5cefd9e31cfa3775a53..294e1c90986e443f9e0dacf4d9e4b9e190cdb7b6 100644 (file)
@@ -236,9 +236,11 @@ putexportent(struct exportent *ep)
        case FSLOC_REPLICA:
                fprintf(fp, "replicas=%s,", ep->e_fslocdata);
                break;
+#ifdef DEBUG
        case FSLOC_STUB:
                fprintf(fp, "fsloc=stub,");
                break;
+#endif
        default:
                xlog(L_ERROR, "unknown fsloc method for %s:%s",
                     ep->e_hostname, ep->e_path);
@@ -504,6 +506,7 @@ bad_option:
                                ep->e_mountpoint = strdup(mp+1);
                        else
                                ep->e_mountpoint = strdup("");
+#ifdef DEBUG
                } else if (strncmp(opt, "fsloc=", 6) == 0) {
                        if (strcmp(opt+6, "stub") == 0)
                                ep->e_fslocmethod = FSLOC_STUB;
@@ -512,6 +515,7 @@ bad_option:
                                     flname, flline, opt);
                                goto bad_option;
                        }
+#endif
                } else if (strncmp(opt, "refer=", 6) == 0) {
                        ep->e_fslocmethod = FSLOC_REFER;
                        ep->e_fslocdata = strdup(opt+6);
index 40a6b56bc9fa15ccfe611af7d39ea728400f4295..22e13a35b9ac9675589fc62512a133d6d45fedc4 100644 (file)
@@ -427,9 +427,11 @@ dump(int verbose)
                        case FSLOC_REPLICA:
                                c = dumpopt(c, "replicas=%s", ep->e_fslocdata);
                                break;
+#ifdef DEBUG
                        case FSLOC_STUB:
                                c = dumpopt(c, "fsloc=stub");
                                break;
+#endif
                        }
                        printf("%c\n", (c != '(')? ')' : ' ');
                }
index 27a30f9448a73abe3aaba240cd0c2dfd4845d7f6..ab63b03cfd6be56bdd56f8fda5ae5b1b53a55f39 100644 (file)
@@ -348,6 +348,20 @@ If the client asks for alternative locations for the export point, it
 will be given this list of alternatives. (Note that actual replication
 of the filesystem must be handled elsewhere.)
 
+.TP
+.IR refer= path@host[+host][:path@host[+host]]
+A client referencing the export point will be directed to choose from
+the given list an alternative location for the filesystem.
+(Note that the server must have a mountpoint here, though a different
+filesystem is not required; so, for example,
+.IR "mount --bind" " /path /path"
+is sufficient.)
+.TP
+.IR replicas= path@host[+host][:path@host[+host]]
+If the client asks for alternative locations for the export point, it
+will be given this list of alternatives. (Note that actual replication
+of the filesystem must be handled elsewhere.)
+
 .SS User ID Mapping
 .PP
 .I nfsd
index 44b5b979cc34eecb374103e2e68dde547b89ca51..5b094b09f4eb9d7bb2ce1fc7731cf8f51abd1c3c 100644 (file)
@@ -40,16 +40,17 @@ static void replicas_print(struct servers *sp)
 {
        int i;
        if (!sp) {
-               syslog(LOG_INFO, "NULL replicas pointer");
+               xlog(L_NOTICE, "NULL replicas pointer\n");
                return;
        }
-       syslog(LOG_INFO, "replicas listsize=%i", sp->h_num);
+       xlog(L_NOTICE, "replicas listsize=%i\n", sp->h_num);
        for (i=0; i<sp->h_num; i++) {
-               syslog(LOG_INFO, "%s:%s",
+               xlog(L_NOTICE, "    %s:%s\n",
                       sp->h_mp[i]->h_host, sp->h_mp[i]->h_path);
        }
 }
 
+#ifdef DEBUG
 /* Called by setting 'Method = stub' in config file.  Just returns
  * some syntactically correct gibberish for testing purposes.
  */
@@ -58,7 +59,7 @@ static struct servers *method_stub(char *key)
        struct servers *sp;
        struct mount_point *mp;
 
-       syslog(LOG_INFO, "called method_stub");
+       xlog(L_NOTICE, "called method_stub\n");
        sp = malloc(sizeof(struct servers));
        if (!sp)
                return NULL;
@@ -74,6 +75,7 @@ static struct servers *method_stub(char *key)
        sp->h_referral = 1;
        return sp;
 }
+#endif /* DEBUG */
 
 /* Scan @list, which is a NULL-terminated array of strings of the
  * form path@host[+host], and return corresponding servers structure.
@@ -99,7 +101,7 @@ static struct servers *parse_list(char **list)
                }
                cp = strchr(list[i], '@');
                if ((!cp) || list[i][0] != '/') {
-                       syslog(LOG_WARNING, "invalid entry '%s'", list[i]);
+                       xlog(L_WARNING, "invalid entry '%s'", list[i]);
                        continue; /* XXX Need better error handling */
                }
                res->h_mp[i] = mp;
@@ -123,13 +125,13 @@ static struct servers *method_list(char *data)
        int i, listsize;
        struct servers *rv=NULL;
 
-       syslog(LOG_INFO, "method_list(%s)\n", data);
+       xlog(L_NOTICE, "method_list(%s)\n", data);
        for (ptr--, listsize=1; ptr; ptr=index(ptr, ':'), listsize++)
                ptr++;
        list = malloc(listsize * sizeof(char *));
        copy = strdup(data);
        if (copy)
-               syslog(LOG_INFO, "converted to %s\n", copy);
+               xlog(L_NOTICE, "converted to %s\n", copy);
        if (list && copy) {
                ptr = copy;
                for (i=0; i<listsize; i++) {
@@ -160,11 +162,13 @@ struct servers *replicas_lookup(int method, char *data, char *key)
                if (sp)
                        sp->h_referral = 0;
                break;
+#ifdef DEBUG
        case FSLOC_STUB:
                sp = method_stub(data);
                break;
+#endif
        default:
-               syslog(LOG_WARNING, "Unknown method = %i", method);
+               xlog(L_WARNING, "Unknown method = %i", method);
        }
        replicas_print(sp);
        return sp;