From: Mike Waychison <michael.waychison@sun.com>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: raven@themaw.net
Subject: [PATCH 5/28] VFS: Make expiry timeout configurable
Date: Mon, 25 Oct 2004 10:41:01 -0400 [thread overview]
Message-ID: <10987152612887@sun.com> (raw)
In-Reply-To: <1098715230634@sun.com>
This patch modifies the expiry logic to make timeouts configurable. We do
this by using an atomic counter that ticks downwards every second of
non-usage. We also store a per vfsmount value of what this timer gets reset
to on every mntput.
Signed-off-by: Mike Waychison <michael.waychison@sun.com>
---
fs/namespace.c | 33 +++++++++++++++++++++++----------
include/linux/mount.h | 6 ++++--
2 files changed, 27 insertions(+), 12 deletions(-)
Index: linux-2.6.9-quilt/include/linux/mount.h
===================================================================
--- linux-2.6.9-quilt.orig/include/linux/mount.h 2004-10-22 17:17:34.147272968 -0400
+++ linux-2.6.9-quilt/include/linux/mount.h 2004-10-22 17:17:35.377086008 -0400
@@ -29,7 +29,9 @@ struct vfsmount
struct list_head mnt_child; /* and going through their mnt_child */
atomic_t mnt_count;
int mnt_flags;
- int mnt_expiry_mark; /* true if marked for expiry */
+ int mnt_active; /* flag set on mntput() */
+ int mnt_expiry_countdown; /* countdown of ticks until expiry */
+ int mnt_expiry_ticks; /* total ticks before expiry */
char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
struct list_head mnt_list;
struct list_head mnt_expire; /* link in fs-specific expiry list */
@@ -56,7 +58,7 @@ static inline void _mntput(struct vfsmou
static inline void mntput(struct vfsmount *mnt)
{
if (mnt) {
- mnt->mnt_expiry_mark = 0;
+ xchg(&mnt->mnt_active, 1);
_mntput(mnt);
}
}
Index: linux-2.6.9-quilt/fs/namespace.c
===================================================================
--- linux-2.6.9-quilt.orig/fs/namespace.c 2004-10-22 17:17:34.148272816 -0400
+++ linux-2.6.9-quilt/fs/namespace.c 2004-10-22 17:17:35.378085856 -0400
@@ -68,6 +68,8 @@ struct vfsmount *alloc_vfsmnt(const char
INIT_LIST_HEAD(&mnt->mnt_mounts);
INIT_LIST_HEAD(&mnt->mnt_list);
INIT_LIST_HEAD(&mnt->mnt_expire);
+ mnt->mnt_expiry_ticks = mnt->mnt_expiry_countdown = 0;
+ mnt->mnt_active = 1;
if (name) {
int size = strlen(name)+1;
char *newname = kmalloc(size, GFP_KERNEL);
@@ -365,9 +367,9 @@ static void umount_tree(struct vfsmount
struct nameidata old_nd;
detach_mnt(mnt, &old_nd);
spin_unlock(&vfsmount_lock);
- path_release(&old_nd);
+ path_release_on_umount(&old_nd);
}
- mntput(mnt);
+ _mntput(mnt);
spin_lock(&vfsmount_lock);
}
}
@@ -395,7 +397,7 @@ static int do_umount(struct vfsmount *mn
if (atomic_read(&mnt->mnt_count) != 2)
return -EBUSY;
- if (!xchg(&mnt->mnt_expiry_mark, 1))
+ if (--mnt->mnt_expiry_countdown != 0)
return -EAGAIN;
}
@@ -840,6 +842,8 @@ void mnt_expire(struct vfsmount *mnt, un
goto out;
list_del_init(&mnt->mnt_expire);
+ mnt->mnt_expiry_ticks = mnt->mnt_expiry_countdown = expire;
+ mnt->mnt_active = 1;
if (expire > 0)
list_add_tail(&mnt->mnt_expire, &expiry_list);
out:
@@ -847,7 +851,7 @@ out:
up(&expiry_sem);
}
EXPORT_SYMBOL_GPL(mnt_expire);
-
+
/*
* process a list of expirable mountpoints with the intent of discarding any
* mountpoints that aren't in use and haven't been touched since last we came
@@ -872,12 +876,21 @@ static void do_expiry_run(void *nothing)
* cleared by mntput())
*/
list_for_each_entry_safe(mnt, next, &expiry_list, mnt_expire) {
- if (!xchg(&mnt->mnt_expiry_mark, 1) ||
- atomic_read(&mnt->mnt_count) != 1)
+ /*
+ * Something might still hold a reference to this mount. If
+ * mnt_active is set, we can just move on. If it gets set
+ * after we xchg() here, we'll catch it on the graveyard list.
+ */
+ if (xchg(&mnt->mnt_active, 0)) {
+ mnt->mnt_expiry_countdown = mnt->mnt_expiry_ticks;
continue;
-
- mntget(mnt);
- list_move(&mnt->mnt_expire, &graveyard);
+ }
+ if (mnt->mnt_expiry_countdown >= 1)
+ mnt->mnt_expiry_countdown--;
+ if (atomic_read(&mnt->mnt_count) == 2 && mnt->mnt_expiry_countdown == 0) {
+ mntget(mnt);
+ list_move(&mnt->mnt_expire, &graveyard);
+ }
}
/*
@@ -903,7 +916,7 @@ static void do_expiry_run(void *nothing)
/* check that it is still dead: the count should now be 2 - as
* contributed by the vfsmount parent and the mntget above */
- if (atomic_read(&mnt->mnt_count) == 2) {
+ if (atomic_read(&mnt->mnt_count) == 2 && !mnt->mnt_active) {
struct vfsmount *xdmnt;
struct dentry *xdentry;
next prev parent reply other threads:[~2004-10-25 14:41 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-25 14:38 [PATCH 0/28] Autofs NG Patchset 0.2 Mike Waychison
2004-10-25 14:39 ` [PATCH 1/28] VFS: Unexport umount_tree Mike Waychison
2004-10-25 14:39 ` [PATCH 2/28] VFS: mnt_fslink -> mnt_expire Mike Waychison
2004-10-25 14:40 ` [PATCH 3/28] VFS: Move expiry into vfs Mike Waychison
2004-10-25 14:40 ` [PATCH 4/28] VFS: Stat shouldn't stop expire Mike Waychison
2004-10-25 14:41 ` Mike Waychison [this message]
2004-10-25 14:41 ` [PATCH 6/28] VFS: Make expiry recursive Mike Waychison
2004-10-25 14:42 ` [PATCH 7/28] AFS: Update AFS to use new expiry interface Mike Waychison
2004-10-25 14:42 ` [PATCH 8/28] VFS: Remove MNT_EXPIRE support Mike Waychison
2004-10-25 14:43 ` [PATCH 9/28] VFS: Give sane expiry semantics Mike Waychison
2004-10-25 14:43 ` [PATCH 10/28] VFS: Move next_mnt() Mike Waychison
2004-10-25 14:44 ` [PATCH 11/28] VFS: Allow for detachable subtrees Mike Waychison
2004-10-25 14:44 ` [PATCH 12/28] VFS: Remove (now bogus) check_mnt Mike Waychison
2004-10-25 14:45 ` [PATCH 13/28] VFS: Introduce soft reference counts Mike Waychison
2004-10-25 15:25 ` Christoph Hellwig
2004-10-25 15:35 ` [PATCH 14/28] VFS: Introduce Mountpoint file descriptors (resend) Mike Waychison
2004-10-25 17:20 ` [PATCH 13/28] VFS: Introduce soft reference counts Mika Penttilä
2004-10-25 17:25 ` Mike Waychison
2004-10-25 17:52 ` Mika Penttilä
2004-10-25 17:56 ` [PATCH 11/28] VFS: Allow for detachable subtrees (resend) Mike Waychison
2004-10-25 15:09 ` [PATCH 12/28] VFS: Remove (now bogus) check_mnt Christoph Hellwig
2004-10-25 15:15 ` Mike Waychison
2004-10-25 15:04 ` [PATCH 8/28] VFS: Remove MNT_EXPIRE support Christoph Hellwig
2004-10-25 15:12 ` Mike Waychison
2004-10-25 15:16 ` Christoph Hellwig
2004-10-25 15:30 ` Mike Waychison
2004-10-25 17:16 ` Mike Waychison
2004-10-25 17:29 ` Mike Waychison
2004-10-25 15:04 ` [PATCH 6/28] VFS: Make expiry recursive Christoph Hellwig
2004-10-26 10:27 ` [PATCH 4/28] VFS: Stat shouldn't stop expire Christoph Hellwig
2004-10-27 18:36 ` Mike Waychison
2004-10-25 14:59 ` [PATCH 3/28] VFS: Move expiry into vfs Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10987152612887@sun.com \
--to=michael.waychison@sun.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=raven@themaw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).