From 4584f520e1f773082ef44ff4f8969a5d992b16ec Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 11 Dec 2007 19:01:45 -0500 Subject: NFS: Fix NFS mountpoint crossing... The check that was added to nfs_xdev_get_sb() to work around broken servers, works fine for NFSv2, but causes mountpoint crossing on NFSv3 to always return ESTALE. Signed-off-by: Trond Myklebust --- fs/nfs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs') diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 2426e71..ea92920 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -1475,7 +1475,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags, error = PTR_ERR(mntroot); goto error_splat_super; } - if (mntroot->d_inode->i_op != &nfs_dir_inode_operations) { + if (mntroot->d_inode->i_op != server->nfs_client->rpc_ops->dir_inode_ops) { dput(mntroot); error = -ESTALE; goto error_splat_super; -- cgit v1.1 From 5cef338b30c110daf547fb13d99f0c77f2a79fbc Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 11 Dec 2007 22:01:56 -0500 Subject: NFSv2/v3: Fix a memory leak when using -onolock Neil Brown said: > Hi Trond, > > We found that a machine which made moderately heavy use of > 'automount' was leaking some nfs data structures - particularly the > 4K allocated by rpc_alloc_iostats. > It turns out that this only happens with filesystems with -onolock > set. > The problem is that if NFS_MOUNT_NONLM is set, nfs_start_lockd doesn't > set server->destroy, so when the filesystem is unmounted, the > ->client_acl is not shutdown, and so several resources are still > held. Multiple mount/umount cycles will slowly eat away memory > several pages at a time. Signed-off-by: Trond Myklebust Acked-by: NeilBrown --- fs/nfs/client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fs') diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 70587f3..a6f6254 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -410,9 +410,6 @@ static int nfs_create_rpc_client(struct nfs_client *clp, int proto, */ static void nfs_destroy_server(struct nfs_server *server) { - if (!IS_ERR(server->client_acl)) - rpc_shutdown_client(server->client_acl); - if (!(server->flags & NFS_MOUNT_NONLM)) lockd_down(); /* release rpc.lockd */ } @@ -755,6 +752,9 @@ void nfs_free_server(struct nfs_server *server) if (server->destroy != NULL) server->destroy(server); + + if (!IS_ERR(server->client_acl)) + rpc_shutdown_client(server->client_acl); if (!IS_ERR(server->client)) rpc_shutdown_client(server->client); -- cgit v1.1 From a5576cfa5cd8d8aa874bd4ee500dc8a2e7cbad18 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Wed, 12 Dec 2007 11:08:33 -0500 Subject: Revert "NFS: Ensure we return zero if applications attempt to write zero bytes" This reverts commit b9148c6b80d802dbc2a7530b29915a80432e50c7. On Wed, 12 Dec 2007 10:57:30 -0500, Chuck Lever wrote > commit b9148c6b should be reverted. It was recently forward-ported > from some years-old patches, and is clearly not needed now. > > On Dec 11, 2007, at 5:21 PM, Adrian Bunk wrote: > >> This code became dead after commit >> b9148c6b80d802dbc2a7530b29915a80432e50c7 >> (which BTW doesn't seem to have changed any behaviour) and can >> therefore >> be removed. >> >> Spotted by the Coverity checker. >> >> Signed-off-by: Adrian Bunk >> >> --- >> --- linux-2.6/fs/nfs/direct.c.old 2007-12-02 21:54:53.000000000 +0100 >> +++ linux-2.6/fs/nfs/direct.c 2007-12-02 21:55:10.000000000 +0100 >> @@ -897,15 +897,12 @@ ssize_t nfs_file_direct_write(struct kio >> if (!count) >> goto out; /* return 0 */ >> >> retval = -EINVAL; >> if ((ssize_t) count < 0) >> goto out; >> - retval = 0; >> - if (!count) >> - goto out; >> >> retval = nfs_sync_mapping(mapping); >> if (retval) >> goto out; >> >> retval = nfs_direct_write(iocb, iov, nr_segs, pos, count); >> Signed-off-by: Trond Myklebust --- fs/nfs/direct.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'fs') diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 5e8d82f..3c9d16b 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -894,8 +894,6 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, const struct iovec *iov, retval = generic_write_checks(file, &pos, &count, 0); if (retval) goto out; - if (!count) - goto out; /* return 0 */ retval = -EINVAL; if ((ssize_t) count < 0) -- cgit v1.1 From a10db50a4ae813fcb2f431f2fb039933c109a925 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Wed, 12 Dec 2007 11:12:15 -0500 Subject: NFS: Fix an Oops in NFS unmount Ensure that the dummy 'root dentry' is invisible to d_find_alias(). If not, then it may be spliced into the tree if a parent directory from the same filesystem gets mounted at a later time. Signed-off-by: Trond Myklebust --- fs/nfs/getroot.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'fs') diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c index 0ee4384..e6242cd 100644 --- a/fs/nfs/getroot.c +++ b/fs/nfs/getroot.c @@ -57,6 +57,17 @@ static int nfs_superblock_set_dummy_root(struct super_block *sb, struct inode *i } /* Circumvent igrab(): we know the inode is not being freed */ atomic_inc(&inode->i_count); + /* + * Ensure that this dentry is invisible to d_find_alias(). + * Otherwise, it may be spliced into the tree by + * d_materialise_unique if a parent directory from the same + * filesystem gets mounted at a later time. + * This again causes shrink_dcache_for_umount_subtree() to + * Oops, since the test for IS_ROOT() will fail. + */ + spin_lock(&dcache_lock); + list_del_init(&sb->s_root->d_alias); + spin_unlock(&dcache_lock); } return 0; } -- cgit v1.1