static void nfs_destroy_inode(struct inode *);
static void nfs_write_inode(struct inode *,int);
static void nfs_delete_inode(struct inode *);
-static void nfs_put_super(struct super_block *);
static void nfs_clear_inode(struct inode *);
static void nfs_umount_begin(struct super_block *);
static int nfs_statfs(struct super_block *, struct kstatfs *);
.destroy_inode = nfs_destroy_inode,
.write_inode = nfs_write_inode,
.delete_inode = nfs_delete_inode,
- .put_super = nfs_put_super,
.statfs = nfs_statfs,
.clear_inode = nfs_clear_inode,
.umount_begin = nfs_umount_begin,
BUG_ON(atomic_read(&nfsi->data_updates) != 0);
}
-void
-nfs_put_super(struct super_block *sb)
-{
- struct nfs_server *server = NFS_SB(sb);
-
- nfs4_renewd_prepare_shutdown(server);
-
- if (server->client != NULL)
- rpc_shutdown_client(server->client);
- if (server->client_sys != NULL)
- rpc_shutdown_client(server->client_sys);
-
- if (!(server->flags & NFS_MOUNT_NONLM))
- lockd_down(); /* release rpc.lockd */
- rpciod_down(); /* release rpciod */
-
- destroy_nfsv4_state(server);
-
- kfree(server->hostname);
-}
-
void
nfs_umount_begin(struct super_block *sb)
{
nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int silent)
{
struct nfs_server *server;
- int err = -EIO;
rpc_authflavor_t authflavor;
server = NFS_SB(sb);
server->acdirmin = data->acdirmin*HZ;
server->acdirmax = data->acdirmax*HZ;
+ /* Start lockd here, before we might error out */
+ if (!(server->flags & NFS_MOUNT_NONLM))
+ lockd_up();
+
server->namelen = data->namlen;
server->hostname = kmalloc(strlen(data->hostname) + 1, GFP_KERNEL);
if (!server->hostname)
- goto out_fail;
+ return -ENOMEM;
strcpy(server->hostname, data->hostname);
/* Check NFS protocol revision and initialize RPC op vector
server->caps |= NFS_CAP_READDIRPLUS;
if (data->version < 4) {
printk(KERN_NOTICE "NFS: NFSv3 not supported by mount program.\n");
- goto out_fail;
+ return -EIO;
}
#else
printk(KERN_NOTICE "NFS: NFSv3 not supported.\n");
- goto out_fail;
+ return -EIO;
#endif
} else {
server->rpc_ops = &nfs_v2_clientops;
/* Create RPC client handles */
server->client = nfs_create_client(server, data);
if (IS_ERR(server->client))
- goto out_fail;
+ return PTR_ERR(server->client);
/* RFC 2623, sec 2.3.2 */
if (authflavor != RPC_AUTH_UNIX) {
server->client_sys = rpc_clone_client(server->client);
- if (server->client_sys == NULL)
- goto out_shutdown;
+ if (IS_ERR(server->client_sys))
+ return PTR_ERR(server->client_sys);
if (!rpcauth_create(RPC_AUTH_UNIX, server->client_sys))
- goto out_shutdown;
+ return -ENOMEM;
} else {
atomic_inc(&server->client->cl_count);
server->client_sys = server->client;
}
- /* Fire up rpciod if not yet running */
- if (rpciod_up() != 0) {
- printk(KERN_WARNING "NFS: couldn't start rpciod!\n");
- goto out_shutdown;
- }
-
- sb->s_op = &nfs_sops;
- err = nfs_sb_init(sb, authflavor);
- if (err != 0)
- goto out_noinit;
-
if (server->flags & NFS_MOUNT_VER3) {
if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN)
server->namelen = NFS3_MAXNAMLEN;
server->namelen = NFS2_MAXNAMLEN;
}
- /* Check whether to start the lockd process */
- if (!(server->flags & NFS_MOUNT_NONLM))
- lockd_up();
- return 0;
-out_noinit:
- rpciod_down();
-out_shutdown:
- if (server->client)
- rpc_shutdown_client(server->client);
- if (server->client_sys)
- rpc_shutdown_client(server->client_sys);
-out_fail:
- if (server->hostname)
- kfree(server->hostname);
- return err;
+ sb->s_op = &nfs_sops;
+ return nfs_sb_init(sb, authflavor);
}
static int
s->s_flags = flags;
+ /* Fire up rpciod if not yet running */
+ if (rpciod_up() != 0) {
+ printk(KERN_WARNING "NFS: couldn't start rpciod!\n");
+ kfree(server);
+ return ERR_PTR(-EIO);
+ }
+
error = nfs_fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
if (error) {
up_write(&s->s_umount);
static void nfs_kill_super(struct super_block *s)
{
struct nfs_server *server = NFS_SB(s);
+
kill_anon_super(s);
+
+ nfs4_renewd_prepare_shutdown(server);
+
+ if (server->client != NULL && !IS_ERR(server->client))
+ rpc_shutdown_client(server->client);
+ if (server->client_sys != NULL && !IS_ERR(server->client_sys))
+ rpc_shutdown_client(server->client_sys);
+
+ if (!(server->flags & NFS_MOUNT_NONLM))
+ lockd_down(); /* release rpc.lockd */
+
+ rpciod_down(); /* release rpciod */
+
+ destroy_nfsv4_state(server);
+
+ if (server->hostname != NULL)
+ kfree(server->hostname);
kfree(server);
}
.destroy_inode = nfs_destroy_inode,
.write_inode = nfs_write_inode,
.delete_inode = nfs_delete_inode,
- .put_super = nfs_put_super,
.statfs = nfs_statfs,
.clear_inode = nfs4_clear_inode,
.umount_begin = nfs_umount_begin,
clp = nfs4_get_client(&server->addr.sin_addr);
if (!clp) {
printk(KERN_WARNING "NFS: failed to create NFS4 client.\n");
- goto out_fail;
+ return -EIO;
}
/* Now create transport and client */
if (IS_ERR(clnt)) {
printk(KERN_WARNING "NFS: cannot create RPC client.\n");
- err = PTR_ERR(clnt);
- goto out_remove_list;
+ return PTR_ERR(clnt);
}
clnt->cl_intr = (server->flags & NFS4_MOUNT_INTR) ? 1 : 0;
clnt->cl_softrtry = (server->flags & NFS4_MOUNT_SOFT) ? 1 : 0;
server->client = clnt;
- err = -ENOMEM;
if (server->nfs4_state->cl_idmap == NULL) {
printk(KERN_WARNING "NFS: failed to create idmapper.\n");
- goto out_shutdown;
+ return -ENOMEM;
}
if (clnt->cl_auth->au_flavor != authflavour) {
if (rpcauth_create(authflavour, clnt) == NULL) {
printk(KERN_WARNING "NFS: couldn't create credcache!\n");
- goto out_shutdown;
+ return -ENOMEM;
}
}
- /* Fire up rpciod if not yet running */
- if (rpciod_up() != 0) {
- printk(KERN_WARNING "NFS: couldn't start rpciod!\n");
- goto out_shutdown;
- }
-
sb->s_op = &nfs4_sops;
err = nfs_sb_init(sb, authflavour);
if (err == 0)
return 0;
- rpciod_down();
-out_shutdown:
- rpc_shutdown_client(server->client);
-out_remove_list:
- down_write(&server->nfs4_state->cl_sem);
- list_del_init(&server->nfs4_siblings);
- up_write(&server->nfs4_state->cl_sem);
- destroy_nfsv4_state(server);
out_fail:
if (clp)
nfs4_put_client(clp);
s->s_flags = flags;
+ /* Fire up rpciod if not yet running */
+ if (rpciod_up() != 0) {
+ printk(KERN_WARNING "NFS: couldn't start rpciod!\n");
+ s = ERR_PTR(-EIO);
+ goto out_free;
+ }
+
error = nfs4_fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
if (error) {
up_write(&s->s_umount);