get rid of is_mounted checks in cache_clean
Subsystems (2)
PATCH 1/1 get rid of is_mounted checks in cache_clean
Hi, Ian,
I'm not sure what purpose the following check serves in the cache_clean function:
if (is_mounted(_PATH_MOUNTED, path)) {
free(path);
continue;
}In the event that the map was updated, we signal the daemon to do a re-read of the entire map. If the mount finishes before the daemon is able to process this signal, we end up not pruning the old entry for the given path. Now, because we append entries to the cache, we end up with the stale entry first, followed by the updated entry. This means that subsequent lookups will give the old entry.
As I don't see the cache information being used aside from during mount, I think we can safely get rid of this check. Do you agree?
(Note that if you don't remove this check, there is a memory leak in the second check for is_mounted; we don't free path in that case)
-Jeff
Index: lib/cache.c
===================================================================
RCS file: /root/autofs/lib/cache.c,v
retrieving revision 1.14
lib/cache.c +0 -8
@@ -312,11 +312,6 @@ void cache_clean(const char *root, time_if (!path)return ; -if (is_mounted (_PATH_MOUNTED, path)) { -free (path); -continue ; - } -if (me->age < age) { pred->next = me->next;free (me->key);
@@ -336,9 +331,6 @@ void cache_clean(const char *root, time_ path =cache_fullpath (root, me->key);if (!path)return ; - -if (is_mounted (_PATH_MOUNTED, path)) -continue ;if (me->age < age) { mapent_hash[i] = me->next;
Ian Kent
maintainerQuoted 10 lines · Jeff Moyer
Hi, Ian,
I'm not sure what purpose the following check serves in the
cache_cleanfunction:if (is_mounted(_PATH_MOUNTED, path)) { free(path); continue; }
Quoted 6 lines
In the event that the map was updated, we signal the daemon to do a re-read of the entire map. If the mount finishes before the daemon is able to process this signal, we end up not pruning the old entry for the given path. Now, because we append entries to the cache, we end up with the stale entry first, followed by the updated entry. This means that subsequent lookups will give the old entry.
This was originally meant to stop busy (currently mounted) entries from disappearing from the cache.
I'll check whether this is actually needed and get back.
One thing that comes to mind is that the direct mount rework design might need this.
Quoted 6 lines
As I don't see the cache information being used aside from during mount, I think we can safely get rid of this check. Do you agree?
(Note that if you don't remove this check, there is a memory leak in the second check for
is_mounted; we don't free path in that case)
OK.
I'll check that to.
Thanks
Ian
Quoted 33 lines
-Jeff
Index:
lib/cache.c
===================================================================
RCS file:/root/autofs/lib/cache.c,v
retrieving revision 1.14
diff -u -p -r1.14cache.clib/cache.c +0
-8@@ -312,11 +312,6 @@ void cache_clean(const char *root, time_if (!path)return ; -if (is_mounted (_PATH_MOUNTED, path)) { -free (path); -continue ; - } -if (me->age < age) { pred->next = me->next;free (me->key);@@ -336,9 +331,6 @@ void cache_clean(const char *root, time_ path =cache_fullpath (root, me->key);if (!path)return ; - -if (is_mounted (_PATH_MOUNTED, path)) -continue ;if (me->age < age) { mapent_hash[i] = me->next;
==> Regarding Re: [patch] get rid of is_mounted checks in cache_clean; Ian Kent <[email protected]> adds:
Quoted 5 lines · Jeff Moyer
Quoted 5 lines
Hi, Ian,
I'm not sure what purpose the following check serves in the
cache_cleanfunction:
Quoted 8 lines
Quoted 8 lines
if (
is_mounted(_PATH_MOUNTED, path)) { free(path); continue; }In the event that the map was updated, we signal the daemon to do a re-read of the entire map. If the mount finishes before the daemon is able to process this signal, we end up not pruning the old entry for the given path. Now, because we append entries to the cache, we end up with the stale entry first, followed by the updated entry. This means that subsequent lookups will give the old entry.
raven> This was originally meant to stop busy (currently mounted) entries raven> from disappearing from the cache.
raven> I'll check whether this is actually needed and get back.
raven> One thing that comes to mind is that the direct mount rework design raven> might need this.
Well, unfortunately I cannot comment on that. We had have a very precise definite of what it means to be in the cache, then, if there are to be side-effects of removing entries.
Anyway, the patch I sent was somewhat incomplete. Look at this:
if (me->age < age) {
pred->next = me->next;
free(me->key);
free(me->mapent);
free(me);
me = pred;
rmdir_path(path);
}The rmdir_path is unneeded, and I would argue has no business being here. It is the job of the umount_multi code to clean up the directory tree, not the cache code. Lucky for us, the umount_multi path doesn't error out if a directory is removed for it (thinking of odd races, here). Anyway, the attached patch (diffed against current cvs) is more complete in this respect. It gets rid of these rmdir_path calls.
-Jeff
Index: lib/cache.c
===================================================================
RCS file: /root/autofs/lib/cache.c,v
retrieving revision 1.14
lib/cache.c +0 -10
@@ -312,18 +312,12 @@ void cache_clean(const char *root, time_if (!path)return ; -if (is_mounted (_PATH_MOUNTED, path)) { -free (path); -continue ; - } -if (me->age < age) { pred->next = me->next;free (me->key);free (me->mapent);free (me); me = pred; -rmdir_path (path); }free (path);
@@ -337,12 +331,8 @@ void cache_clean(const char *root, time_if (!path)return ; -if (is_mounted (_PATH_MOUNTED, path)) -continue ; -if (me->age < age) { mapent_hash[i] = me->next; -rmdir_path (path);free (me->key);free (me->mapent);free (me);
Ian Kent
maintainerQuoted 16 lines · Jeff Moyer
==> Regarding Re: [patch] get rid of
is_mountedchecks incache_clean; Ian Kent <[email protected]> adds:Quoted 13 lines · Jeff Moyer
Quoted 13 lines
Hi, Ian,
I'm not sure what purpose the following check serves in the
cache_cleanfunction:if (
is_mounted(_PATH_MOUNTED, path)) { free(path); continue; }In the event that the map was updated, we signal the daemon to do a re-read of the entire map. If the mount finishes before the daemon is able to process this signal, we end up not pruning the old entry for the given path. Now, because we append entries to the cache, we end up with the stale entry first, followed by the updated entry. This means that subsequent lookups will give the old entry.
I see the problem.
Side affect from a previous bug fix.
Quoted 4 lines
raven> This was originally meant to stop busy (currently mounted) entries raven> from disappearing from the cache.
Quoted 8 lines
raven> I'll check whether this is actually needed and get back.
raven> One thing that comes to mind is that the direct mount rework design raven> might need this.
Well, unfortunately I cannot comment on that. We had have a very precise definite of what it means to be in the cache, then, if there are to be side-effects of removing entries.
That's a bit unclear?
Quoted 12 lines
Anyway, the patch I sent was somewhat incomplete. Look at this:
if (me->age < age) { pred->next = me->next; free(me->key); free(me->mapent); free(me); me = pred; rmdir_path(path); }
Quoted 6 lines
The
rmdir_pathis unneeded, and I would argue has no business being here. It is the job of theumount_multicode to clean up the directory tree, not the cache code. Lucky for us, theumount_multipath doesn't error out if a directory is removed for it (thinking of odd races, here). Anyway, the attached patch (diffed against current cvs) is more complete in this respect. It gets rid of thesermdir_pathcalls.
Agreed.
But I remember I put that in there to fix an obsucure problem I was having. Removing it may cause undesirable side effects. Unfortuneatly, I can't remember what the symptoms were.
It's probably better to fix the problem as you suggest above though. I'll spend some time to see if I can work out why I thought I had to have it there. A lot has changed since then so maybe removing it will work fine.
The direct mount rework is driven by the cache. If it's mounted then it needs to stay in the cache. To fix the problem above we could mark the entry as stale and skip it on lookup. We could do this by adding a field, stale, to the cache struct or by simply setting age to zero and adding the needed tests.
Ian
Ian Kent
maintainerQuoted 40 lines · Jeff Moyer
==> Regarding Re: [patch] get rid of
is_mountedchecks incache_clean; Ian Kent <[email protected]> adds:Quoted 5 lines · Jeff Moyer
Quoted 5 lines
Hi, Ian,
I'm not sure what purpose the following check serves in the
cache_cleanfunction:Quoted 8 lines
Quoted 8 lines
if (
is_mounted(_PATH_MOUNTED, path)) { free(path); continue; }In the event that the map was updated, we signal the daemon to do a re-read of the entire map. If the mount finishes before the daemon is able to process this signal, we end up not pruning the old entry for the given path. Now, because we append entries to the cache, we end up with the stale entry first, followed by the updated entry. This means that subsequent lookups will give the old entry.
raven> This was originally meant to stop busy (currently mounted) entries raven> from disappearing from the cache.
raven> I'll check whether this is actually needed and get back.
raven> One thing that comes to mind is that the direct mount rework design raven> might need this.
Well, unfortunately I cannot comment on that. We had have a very precise definite of what it means to be in the cache, then, if there are to be side-effects of removing entries.
Anyway, the patch I sent was somewhat incomplete. Look at this:
if (me->age < age) { pred->next = me->next; free(me->key); free(me->mapent); free(me); me = pred; rmdir_path(path); }
Quoted 6 lines
The
rmdir_pathis unneeded, and I would argue has no business being here. It is the job of theumount_multicode to clean up the directory tree, not the cache code. Lucky for us, theumount_multipath doesn't error out if a directory is removed for it (thinking of odd races, here). Anyway, the attached patch (diffed against current cvs) is more complete in this respect. It gets rid of thesermdir_pathcalls.
I remember now why this is needed.
The directory creation/removal isn't done at mount/umount for browsable maps. It's done when the map is updated.
Ian
==> Regarding Re: [patch] get rid of is_mounted checks in cache_clean; Ian Kent <[email protected]> adds:
Quoted 3 lines · Jeff Moyer
Quoted 3 lines
==> Regarding Re: [patch] get rid of
is_mountedchecks incache_clean; Ian Kent <[email protected]> adds:
Quoted 7 lines · Jeff Moyer
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Hi, Ian,
I'm not sure what purpose the following check serves in the
cache_clean>> function:Quoted 3 lines
Quoted 3 lines
if (
is_mounted(_PATH_MOUNTED, path)) { free(path); continue; }
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
In the event that the map was updated, we signal the daemon to do a re-read of the entire map. If the mount finishes before the daemon
is >> able to process this signal, we end up not pruning the old entry for the >> given path. Now, because we append entries to the cache, we end up with >> the stale entry first, followed by the updated entry. This means that >> subsequent lookups will give the old entry.
raven> This was originally meant to stop busy (currently mounted) entries raven> from disappearing from the cache.
Quoted 1 line
Quoted 1 line
raven> I'll check whether this is actually needed and get back.
Quoted 1 line
Quoted 1 line
raven> One thing that comes to mind is that the direct mount rework design raven> might need this.
Quoted 7 lines
Quoted 7 lines
Well, unfortunately I cannot comment on that. We had have a very precise definite of what it means to be in the cache, then, if there are to be side-effects of removing entries.
Anyway, the patch I sent was somewhat incomplete. Look at this:
if (
me->age< age) {
pred-> next = me->next;
Quoted 9 lines
Quoted 9 lines
free(me->key);free(me->mapent); free(me); me = pred;rmdir_path(path); }The
rmdir_pathis unneeded, and I would argue has no business being here. It is the job of theumount_multicode to clean up the directory tree, not the cache code. Lucky for us, theumount_multipath doesn't error out if a directory is removed for it (thinking of odd races, here). Anyway, the attached patch (diffed against current cvs) is more complete in this respect. It gets rid of thesermdir_pathcalls.
raven> I remember now why this is needed.
raven> The directory creation/removal isn't done at mount/umount for raven> browsable maps. It's done when the map is updated.
A ha! That makes sense, so I guess we should do:
if (!is_mounted(path))
rmdir_path(path);At least that is what I'm going with for now, since we have to get a release out the door. I understand your concerns with the direct mount rework, and so I definitely view this as a temporary fix.
Thanks,
Jeff