|
|
49b67f |
autofs-5.1.7 - eliminate count_mounts() from expire_proc_indirect()
|
|
|
49b67f |
|
|
|
49b67f |
From: Ian Kent <raven@themaw.net>
|
|
|
49b67f |
|
|
|
49b67f |
The count_mounts() function traverses the directory tree under a given
|
|
|
49b67f |
automount in order to count the number of mounts.
|
|
|
49b67f |
|
|
|
49b67f |
If there are many directories (such as when there is a very large
|
|
|
49b67f |
number of offset trigger mounts) this can take a long time.
|
|
|
49b67f |
|
|
|
49b67f |
Eliminate the call in expire_proc_indirect() by changing the expire
|
|
|
49b67f |
ioctl function to better use the expire return from the kernel.
|
|
|
49b67f |
|
|
|
49b67f |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
49b67f |
---
|
|
|
49b67f |
CHANGELOG | 1 +
|
|
|
49b67f |
daemon/direct.c | 4 ++--
|
|
|
49b67f |
daemon/indirect.c | 10 +++++-----
|
|
|
49b67f |
lib/dev-ioctl-lib.c | 21 +++++++++++++--------
|
|
|
49b67f |
4 files changed, 21 insertions(+), 15 deletions(-)
|
|
|
49b67f |
|
|
|
49b67f |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
49b67f |
+++ autofs-5.1.4/CHANGELOG
|
|
|
49b67f |
@@ -19,6 +19,7 @@
|
|
|
49b67f |
- pass mapent_cache to update_offset_entry().
|
|
|
49b67f |
- fix inconsistent locking in parse_mount().
|
|
|
49b67f |
- remove unused mount offset list lock functions.
|
|
|
49b67f |
+- eliminate count_mounts() from expire_proc_indirect().
|
|
|
49b67f |
|
|
|
49b67f |
xx/xx/2018 autofs-5.1.5
|
|
|
49b67f |
- fix flag file permission.
|
|
|
49b67f |
--- autofs-5.1.4.orig/daemon/direct.c
|
|
|
49b67f |
+++ autofs-5.1.4/daemon/direct.c
|
|
|
49b67f |
@@ -884,7 +884,7 @@ cont:
|
|
|
49b67f |
ioctlfd = me->ioctlfd;
|
|
|
49b67f |
|
|
|
49b67f |
ret = ops->expire(ap->logopt, ioctlfd, mnt->mp, how);
|
|
|
49b67f |
- if (ret) {
|
|
|
49b67f |
+ if (ret == 1) {
|
|
|
49b67f |
left++;
|
|
|
49b67f |
pthread_setcancelstate(cur_state, NULL);
|
|
|
49b67f |
continue;
|
|
|
49b67f |
@@ -910,7 +910,7 @@ cont:
|
|
|
49b67f |
|
|
|
49b67f |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
|
|
|
49b67f |
ret = ops->expire(ap->logopt, ioctlfd, mnt->mp, how);
|
|
|
49b67f |
- if (ret)
|
|
|
49b67f |
+ if (ret == 1)
|
|
|
49b67f |
left++;
|
|
|
49b67f |
pthread_setcancelstate(cur_state, NULL);
|
|
|
49b67f |
}
|
|
|
49b67f |
--- autofs-5.1.4.orig/daemon/indirect.c
|
|
|
49b67f |
+++ autofs-5.1.4/daemon/indirect.c
|
|
|
49b67f |
@@ -358,7 +358,6 @@ void *expire_proc_indirect(void *arg)
|
|
|
49b67f |
struct expire_args ec;
|
|
|
49b67f |
unsigned int how;
|
|
|
49b67f |
int offsets, submnts, count;
|
|
|
49b67f |
- int retries;
|
|
|
49b67f |
int ioctlfd, cur_state;
|
|
|
49b67f |
int status, ret, left;
|
|
|
49b67f |
|
|
|
49b67f |
@@ -496,7 +495,7 @@ void *expire_proc_indirect(void *arg)
|
|
|
49b67f |
|
|
|
49b67f |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
|
|
|
49b67f |
ret = ops->expire(ap->logopt, ioctlfd, mnt->mp, how);
|
|
|
49b67f |
- if (ret)
|
|
|
49b67f |
+ if (ret == 1)
|
|
|
49b67f |
left++;
|
|
|
49b67f |
pthread_setcancelstate(cur_state, NULL);
|
|
|
49b67f |
}
|
|
|
49b67f |
@@ -507,10 +506,11 @@ void *expire_proc_indirect(void *arg)
|
|
|
49b67f |
* so we need to umount or unlink them here.
|
|
|
49b67f |
*/
|
|
|
49b67f |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
|
|
|
49b67f |
- retries = (count_mounts(ap, ap->path, ap->dev) + 1);
|
|
|
49b67f |
- while (retries--) {
|
|
|
49b67f |
+ while (1) {
|
|
|
49b67f |
ret = ops->expire(ap->logopt, ap->ioctlfd, ap->path, how);
|
|
|
49b67f |
- if (ret)
|
|
|
49b67f |
+ if (ret != 0 && errno == EAGAIN)
|
|
|
49b67f |
+ break;
|
|
|
49b67f |
+ if (ret == 1)
|
|
|
49b67f |
left++;
|
|
|
49b67f |
}
|
|
|
49b67f |
pthread_setcancelstate(cur_state, NULL);
|
|
|
49b67f |
--- autofs-5.1.4.orig/lib/dev-ioctl-lib.c
|
|
|
49b67f |
+++ autofs-5.1.4/lib/dev-ioctl-lib.c
|
|
|
49b67f |
@@ -650,6 +650,7 @@ static int expire(unsigned int logopt,
|
|
|
49b67f |
{
|
|
|
49b67f |
int ret, retries = EXPIRE_RETRIES;
|
|
|
49b67f |
unsigned int may_umount;
|
|
|
49b67f |
+ int save_errno = 0;
|
|
|
49b67f |
|
|
|
49b67f |
while (retries--) {
|
|
|
49b67f |
struct timespec tm = {0, 100000000};
|
|
|
49b67f |
@@ -657,9 +658,11 @@ static int expire(unsigned int logopt,
|
|
|
49b67f |
/* Ggenerate expire message for the mount. */
|
|
|
49b67f |
ret = ioctl(fd, cmd, arg);
|
|
|
49b67f |
if (ret == -1) {
|
|
|
49b67f |
+ save_errno = errno;
|
|
|
49b67f |
+
|
|
|
49b67f |
/* Mount has gone away */
|
|
|
49b67f |
if (errno == EBADF || errno == EINVAL)
|
|
|
49b67f |
- return 0;
|
|
|
49b67f |
+ break;
|
|
|
49b67f |
|
|
|
49b67f |
/*
|
|
|
49b67f |
* Other than EAGAIN is an expire error so continue.
|
|
|
49b67f |
@@ -673,14 +676,16 @@ static int expire(unsigned int logopt,
|
|
|
49b67f |
nanosleep(&tm, NULL);
|
|
|
49b67f |
}
|
|
|
49b67f |
|
|
|
49b67f |
- may_umount = 0;
|
|
|
49b67f |
- if (ctl.ops->askumount(logopt, ioctlfd, &may_umount))
|
|
|
49b67f |
- return -1;
|
|
|
49b67f |
-
|
|
|
49b67f |
- if (!may_umount)
|
|
|
49b67f |
- return 1;
|
|
|
49b67f |
+ if (!ret || save_errno == EAGAIN) {
|
|
|
49b67f |
+ may_umount = 0;
|
|
|
49b67f |
+ if (!ctl.ops->askumount(logopt, ioctlfd, &may_umount)) {
|
|
|
49b67f |
+ if (!may_umount)
|
|
|
49b67f |
+ ret = 1;
|
|
|
49b67f |
+ }
|
|
|
49b67f |
+ }
|
|
|
49b67f |
+ errno = save_errno;
|
|
|
49b67f |
|
|
|
49b67f |
- return 0;
|
|
|
49b67f |
+ return ret;
|
|
|
49b67f |
}
|
|
|
49b67f |
|
|
|
49b67f |
static int dev_ioctl_expire(unsigned int logopt,
|