--- Begin Message --- We need to ensure that nobody adds anything to nfs_automount_list while we
are killing off the work queue entry, or else nfs_expire_automounts will
simply rearm it, and we hang.
Signed-off-by: Trond Myklebust <Trond.Myklebust@xxxxxxxxxx>
---
fs/nfs/namespace.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index aea76d0..bcd0777 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -22,6 +22,11 @@ static void nfs_expire_automounts(struct work_struct *work);
LIST_HEAD(nfs_automount_list);
static DECLARE_DELAYED_WORK(nfs_automount_task, nfs_expire_automounts);
+/*
+ * The following mutex prevents nfs_follow_mountpoint from adding new
+ * entries to nfs_automount_list
+ */
+static DEFINE_MUTEX(nfs_automount_mutex);
int nfs_mountpoint_expiry_timeout = 500 * HZ;
static struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent,
@@ -128,18 +133,21 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
goto out_err;
mntget(mnt);
+ mutex_lock(&nfs_automount_mutex);
err = do_add_mount(mnt, nd, nd->mnt->mnt_flags|MNT_SHRINKABLE, &nfs_automount_list);
if (err < 0) {
+ mutex_unlock(&nfs_automount_mutex);
mntput(mnt);
if (err == -EBUSY)
goto out_follow;
goto out_err;
}
+ schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout);
+ mutex_unlock(&nfs_automount_mutex);
mntput(nd->mnt);
dput(nd->dentry);
nd->mnt = mnt;
nd->dentry = dget(mnt->mnt_root);
- schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout);
out:
dprintk("%s: done, returned %d\n", __FUNCTION__, err);
@@ -175,8 +183,12 @@ static void nfs_expire_automounts(struct work_struct *work)
void nfs_release_automount_timer(void)
{
+ if (!list_empty(&nfs_automount_list))
+ return;
+ mutex_lock(&nfs_automount_mutex);
if (list_empty(&nfs_automount_list))
cancel_delayed_work_sync(&nfs_automount_task);
+ mutex_unlock(&nfs_automount_mutex);
}
/*
--- End Message ---