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