From d55e640fa8c0fe76518f2a5937cda36b35268a9f Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Thu, 23 Oct 2008 03:24:17 +0000 Subject: [PATCH] - don't close file handle for rootless direct mounti-mount at mount. - wait submount expire thread completion when expire successful. - add inadvertantly ommitted server list locking in LDAP module. --- ...-5.0.3-add-missing-uris-list-locking.patch | 129 ++++++++++++++++++ ...x-rootless-direct-multi-mount-expire.patch | 36 +++++ ...-5.0.3-wait-submount-expire-complete.patch | 48 +++++++ autofs.spec | 13 +- 4 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 autofs-5.0.3-add-missing-uris-list-locking.patch create mode 100644 autofs-5.0.3-fix-rootless-direct-multi-mount-expire.patch create mode 100644 autofs-5.0.3-wait-submount-expire-complete.patch diff --git a/autofs-5.0.3-add-missing-uris-list-locking.patch b/autofs-5.0.3-add-missing-uris-list-locking.patch new file mode 100644 index 0000000..d89f0d7 --- /dev/null +++ b/autofs-5.0.3-add-missing-uris-list-locking.patch @@ -0,0 +1,129 @@ +autofs-5.0.3 - add missing uris list locking + +From: Ian Kent + +Add inadvertantly ommitted server list locking in LDAP module. +--- + + include/lookup_ldap.h | 1 + + modules/lookup_ldap.c | 39 ++++++++++++++++++++++++++++++++++++++- + 2 files changed, 39 insertions(+), 1 deletion(-) + + +--- autofs-5.0.3.orig/include/lookup_ldap.h ++++ autofs-5.0.3/include/lookup_ldap.h +@@ -54,6 +54,7 @@ struct lookup_context { + * sdns is the list of basdns to check, done in the order + * given in configuration. + */ ++ pthread_mutex_t uris_mutex; + struct list_head *uri; + char *cur_host; + struct ldap_searchdn *sdns; +--- autofs-5.0.3.orig/modules/lookup_ldap.c ++++ autofs-5.0.3/modules/lookup_ldap.c +@@ -122,6 +122,22 @@ int ldap_parse_page_control(LDAP *ldap, + } + #endif /* HAVE_LDAP_PARSE_PAGE_CONTROL */ + ++static void uris_mutex_lock(struct lookup_context *ctxt) ++{ ++ int status = pthread_mutex_lock(&ctxt->uris_mutex); ++ if (status) ++ fatal(status); ++ return; ++} ++ ++static void uris_mutex_unlock(struct lookup_context *ctxt) ++{ ++ int status = pthread_mutex_unlock(&ctxt->uris_mutex); ++ if (status) ++ fatal(status); ++ return; ++} ++ + int bind_ldap_anonymous(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt) + { + int rv; +@@ -627,16 +643,20 @@ static LDAP *find_server(unsigned logopt + LIST_HEAD(tmp); + + /* Try each uri in list, add connect fails to tmp list */ ++ uris_mutex_lock(ctxt); + p = ctxt->uri->next; + while(p != ctxt->uri) { + this = list_entry(p, struct ldap_uri, list); +- p = p->next; ++ uris_mutex_unlock(ctxt); + debug(logopt, "trying server %s", this->uri); + ldap = connect_to_server(logopt, this->uri, ctxt); + if (ldap) { + info(logopt, "connected to uri %s", this->uri); ++ uris_mutex_lock(ctxt); + break; + } ++ uris_mutex_lock(ctxt); ++ p = p->next; + list_del_init(&this->list); + list_add_tail(&this->list, &tmp); + } +@@ -648,6 +668,7 @@ static LDAP *find_server(unsigned logopt + list_splice(ctxt->uri, &tmp); + INIT_LIST_HEAD(ctxt->uri); + list_splice(&tmp, ctxt->uri); ++ uris_mutex_unlock(ctxt); + + return ldap; + } +@@ -662,14 +683,18 @@ static LDAP *do_reconnect(unsigned logop + return ldap; + } + ++ uris_mutex_lock(ctxt); + this = list_entry(ctxt->uri->next, struct ldap_uri, list); ++ uris_mutex_unlock(ctxt); + ldap = do_connect(logopt, this->uri, ctxt); + if (ldap) + return ldap; + + /* Failed to connect, put at end of list */ ++ uris_mutex_lock(ctxt); + list_del_init(&this->list); + list_add_tail(&this->list, ctxt->uri); ++ uris_mutex_unlock(ctxt); + + #ifdef WITH_SASL + autofs_sasl_dispose(ctxt); +@@ -1203,6 +1228,8 @@ done: + + static void free_context(struct lookup_context *ctxt) + { ++ int ret; ++ + if (ctxt->schema) { + free(ctxt->schema->map_class); + free(ctxt->schema->map_attr); +@@ -1235,6 +1262,9 @@ static void free_context(struct lookup_c + free(ctxt->base); + if (ctxt->uri) + defaults_free_uris(ctxt->uri); ++ ret = pthread_mutex_destroy(&ctxt->uris_mutex); ++ if (ret) ++ fatal(ret); + if (ctxt->sdns) + defaults_free_searchdns(ctxt->sdns); + free(ctxt); +@@ -1286,6 +1316,13 @@ int lookup_init(const char *mapfmt, int + } + memset(ctxt, 0, sizeof(struct lookup_context)); + ++ ret = pthread_mutex_init(&ctxt->uris_mutex, NULL); ++ if (ret) { ++ error(LOGOPT_ANY, MODPREFIX "failed to init uris mutex"); ++ free(ctxt); ++ return 1; ++ } ++ + /* If a map type isn't explicitly given, parse it like sun entries. */ + if (mapfmt == NULL) + mapfmt = MAPFMT_DEFAULT; diff --git a/autofs-5.0.3-fix-rootless-direct-multi-mount-expire.patch b/autofs-5.0.3-fix-rootless-direct-multi-mount-expire.patch new file mode 100644 index 0000000..b50c2fb --- /dev/null +++ b/autofs-5.0.3-fix-rootless-direct-multi-mount-expire.patch @@ -0,0 +1,36 @@ +autofs-5.0.3 - don't close direct root + +From: Ian Kent + +For direct mount multi-mounts with no real mount at their base we +need to leave the file handle open so they will be expired. This +patch corrects the check done at mount completion to do this so +they will be expired. +--- + + daemon/direct.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + + +--- autofs-5.0.3.orig/daemon/direct.c ++++ autofs-5.0.3/daemon/direct.c +@@ -1311,8 +1311,17 @@ static void *do_mount_direct(void *arg) + !master_find_submount(ap, mt.name))) + close_fd = 1; + cache_writelock(mt.mc); +- if (!close_fd && (me = cache_lookup_distinct(mt.mc, mt.name))) +- me->ioctlfd = mt.ioctlfd; ++ if ((me = cache_lookup_distinct(mt.mc, mt.name))) { ++ /* ++ * Careful here, we need to leave the file handle open ++ * for direct mount multi-mounts with no real mount at ++ * their base so they will be expired. ++ */ ++ if (close_fd && me == me->multi) ++ close_fd = 0; ++ if (!close_fd) ++ me->ioctlfd = mt.ioctlfd; ++ } + send_ready(ap->logopt, mt.ioctlfd, mt.wait_queue_token); + cache_unlock(mt.mc); + if (close_fd) diff --git a/autofs-5.0.3-wait-submount-expire-complete.patch b/autofs-5.0.3-wait-submount-expire-complete.patch new file mode 100644 index 0000000..45d9684 --- /dev/null +++ b/autofs-5.0.3-wait-submount-expire-complete.patch @@ -0,0 +1,48 @@ +autofs-5.0.3 - wait submount expire complete + +From: Ian Kent + +When expiring a submount expires away and proceeds to shutdown we +can reach the end of the expire of the parent before the submount +goes away. This can cause an incomplete expire during shutdown in +some cases so, for the case the submount goes to state ST_SHUTDOWN, +we need to wait until the submount either goes away or fails to +shutdown before continuing. +--- + + lib/master.c | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + + +--- autofs-5.0.3.orig/lib/master.c ++++ autofs-5.0.3/lib/master.c +@@ -870,6 +870,29 @@ int master_notify_submount(struct autofs + + st_wait_task(this, state, 0); + ++ /* ++ * If our submount gets to state ST_SHUTDOWN we need to ++ * wait until it goes away or changes to ST_READY. ++ */ ++ mounts_mutex_lock(ap); ++ st_mutex_lock(); ++ while ((this = __master_find_submount(ap, path))) { ++ struct timespec t = { 0, 300000000 }; ++ struct timespec r; ++ ++ if (this->state != ST_SHUTDOWN) ++ break; ++ ++ st_mutex_unlock(); ++ mounts_mutex_unlock(ap); ++ while (nanosleep(&t, &r) == -1 && errno == EINTR) ++ memcpy(&t, &r, sizeof(struct timespec)); ++ mounts_mutex_lock(ap); ++ st_mutex_lock(); ++ } ++ st_mutex_unlock(); ++ mounts_mutex_unlock(ap); ++ + return ret; + + } diff --git a/autofs.spec b/autofs.spec index baf9931..2d9ee9b 100644 --- a/autofs.spec +++ b/autofs.spec @@ -4,7 +4,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.3 -Release: 26 +Release: 28 Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -62,6 +62,9 @@ Patch49: autofs-5.0.3-fix-incorrect-multi-mount-mountpoint.patch Patch50: autofs-5.0.3-map-type-in-map-name-fix.patch Patch51: autofs-5.0.3-dont-readmap-on-hup-for-new-mount.patch Patch52: autofs-5.0.3-nisplus-partial-and-free.patch +Patch53: autofs-5.0.3-fix-rootless-direct-multi-mount-expire.patch +Patch54: autofs-5.0.3-wait-submount-expire-complete.patch +Patch55: autofs-5.0.3-add-missing-uris-list-locking.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel module-init-tools util-linux nfs-utils e2fsprogs Requires: kernel >= 2.6.17 @@ -155,6 +158,9 @@ echo %{version}-%{release} > .version %patch50 -p1 %patch51 -p1 %patch52 -p1 +%patch53 -p1 +%patch54 -p1 +%patch55 -p1 %build #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir} @@ -207,6 +213,11 @@ fi %{_libdir}/autofs/ %changelog +* Thu Oct 23 2008 Ian Kent - 5.0.3-28 +- don't close file handle for rootless direct mounti-mount at mount. +- wait submount expire thread completion when expire successful. +- add inadvertantly ommitted server list locking in LDAP module. + * Fri Oct 10 2008 Ian Kent - 5.0.3-26 - add map-type-in-map-name fix patch to sync with upstream and RHEL. - don't readmap on HUP for new mount.