Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jun 2019 00:37:55 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r349127 - stable/12/usr.sbin/mountd
Message-ID:  <201906170037.x5H0btNZ028173@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Mon Jun 17 00:37:55 2019
New Revision: 349127
URL: https://svnweb.freebsd.org/changeset/base/349127

Log:
  MFC: r347583
  Replace global list for grouplist with list(s) for each exportlist element.
  
  In mountd.c, the grouplist structures are linked into a single global
  linked list headed by "grphead". The only use of this linked list is
  to free all list elements when the exportlist elements are also all being
  free'd at the time the exports are being reloaded.
  This patch replaces this one global linked list head with a list head in
  each exportlist structure, where the grouplist elements for that exported
  file system are linked.
  The only change is that now the grouplist elements are free'd with the
  associated exportlist element as they are free'd instead of all grouplist
  elements being free'd after the exportlist elements are free'd. This
  change should have no effect in practice.
  This is being done, since a future patch that will add a "-I" option for
  incrementally updating the exports in the kernel needs to know which
  grouplist elements are associated with each exported file system and
  having them linked into a list headed by the exportlist element does that.
  
  PR:		237860

Modified:
  stable/12/usr.sbin/mountd/mountd.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/mountd/mountd.c
==============================================================================
--- stable/12/usr.sbin/mountd/mountd.c	Mon Jun 17 00:29:40 2019	(r349126)
+++ stable/12/usr.sbin/mountd/mountd.c	Mon Jun 17 00:37:55 2019	(r349127)
@@ -114,6 +114,7 @@ struct dirlist {
 struct exportlist {
 	struct dirlist	*ex_dirl;
 	struct dirlist	*ex_defdir;
+	struct grouplist *ex_grphead;
 	int		ex_flag;
 	fsid_t		ex_fs;
 	char		*ex_fsdir;
@@ -235,7 +236,6 @@ static void	terminate(int);
 
 static struct exportlisthead exphead = SLIST_HEAD_INITIALIZER(&exphead);
 static SLIST_HEAD(, mountlist) mlhead = SLIST_HEAD_INITIALIZER(&mlhead);
-static struct grouplist *grphead;
 static char *exnames_default[2] = { _PATH_EXPORTS, NULL };
 static char **exnames;
 static char **hosts = NULL;
@@ -455,7 +455,6 @@ main(int argc, char **argv)
 
 	argc -= optind;
 	argv += optind;
-	grphead = (struct grouplist *)NULL;
 	if (argc > 0)
 		exnames = argv;
 	else
@@ -1692,8 +1691,8 @@ get_exportlist_one(void)
 		 */
 		if (has_host) {
 			hang_dirp(dirhead, tgrp, ep, opt_flags);
-			grp->gr_next = grphead;
-			grphead = tgrp;
+			grp->gr_next = ep->ex_grphead;
+			ep->ex_grphead = tgrp;
 		} else {
 			hang_dirp(dirhead, (struct grouplist *)NULL, ep,
 				opt_flags);
@@ -1720,7 +1719,6 @@ nextline:
 static void
 get_exportlist(void)
 {
-	struct grouplist *grp, *tgrp;
 	struct export_args export;
 	struct iovec *iov;
 	struct statfs *mntbufp;
@@ -1743,14 +1741,6 @@ get_exportlist(void)
 	 */
 	free_exports(&exphead);
 
-	grp = grphead;
-	while (grp) {
-		tgrp = grp;
-		grp = grp->gr_next;
-		free_grp(tgrp);
-	}
-	grphead = (struct grouplist *)NULL;
-
 	/*
 	 * and the old V4 root dir.
 	 */
@@ -2448,6 +2438,7 @@ get_host(char *cp, struct grouplist *grp, struct group
 static void
 free_exp(struct exportlist *ep)
 {
+	struct grouplist *grp, *tgrp;
 
 	if (ep->ex_defdir) {
 		free_host(ep->ex_defdir->dp_hosts);
@@ -2458,6 +2449,12 @@ free_exp(struct exportlist *ep)
 	if (ep->ex_indexfile)
 		free(ep->ex_indexfile);
 	free_dir(ep->ex_dirl);
+	grp = ep->ex_grphead;
+	while (grp) {
+		tgrp = grp;
+		grp = grp->gr_next;
+		free_grp(tgrp);
+	}
 	free((caddr_t)ep);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906170037.x5H0btNZ028173>