diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c index b7cac07fe0c804e1d162ccc1be3afb87603b2394..30a230fde3315c93aacde6dfd8d3bd4e5b71baa0 100644 --- a/fs/nfs/namespace.c +++ b/fs/nfs/namespace.c @@ -146,6 +146,7 @@ struct vfsmount *nfs_d_automount(struct path *path) struct nfs_server *server = NFS_SERVER(d_inode(path->dentry)); struct nfs_fh *fh = NULL; struct nfs_fattr *fattr = NULL; + int timeout = READ_ONCE(nfs_mountpoint_expiry_timeout); if (IS_ROOT(path->dentry)) return ERR_PTR(-ESTALE); @@ -160,12 +161,12 @@ struct vfsmount *nfs_d_automount(struct path *path) if (IS_ERR(mnt)) goto out; - if (nfs_mountpoint_expiry_timeout < 0) + mntget(mnt); /* prevent immediate expiration */ + if (timeout <= 0) goto out; - mntget(mnt); /* prevent immediate expiration */ mnt_set_expiry(mnt, &nfs_automount_list); - schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); + schedule_delayed_work(&nfs_automount_task, timeout); out: nfs_free_fattr(fattr); @@ -204,10 +205,11 @@ const struct inode_operations nfs_referral_inode_operations = { static void nfs_expire_automounts(struct work_struct *work) { struct list_head *list = &nfs_automount_list; + int timeout = READ_ONCE(nfs_mountpoint_expiry_timeout); mark_mounts_for_expiry(list); - if (!list_empty(list)) - schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); + if (!list_empty(list) && timeout > 0) + schedule_delayed_work(&nfs_automount_task, timeout); } void nfs_release_automount_timer(void)