Skip to content

Commit

Permalink
NFS: ensure bdi_unregister is called on mount failure.
Browse files Browse the repository at this point in the history
bdi_unregister is called by nfs_put_super which is only called by
generic_shutdown_super if ->s_root is not NULL.  So if we error out
in a circumstance where we called nfs_bdi_register (i.e. server !=
NULL) but have not set s_root, then we need to call bdi_unregister
explicitly in nfs_get_sb and various other *_get_sb() functions.

Signed-off-by: NeilBrown <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
neilbrown authored and Trond Myklebust committed Mar 15, 2010
1 parent bb6fbc4 commit cfbc068
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2214,7 +2214,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
} else {
error = nfs_bdi_register(server);
if (error)
goto error_splat_super;
goto error_splat_bdi;
}

if (!s->s_root) {
Expand Down Expand Up @@ -2256,6 +2256,9 @@ static int nfs_get_sb(struct file_system_type *fs_type,
error_splat_root:
dput(mntroot);
error_splat_super:
if (server && !s->s_root)
bdi_unregister(&server->backing_dev_info);
error_splat_bdi:
deactivate_locked_super(s);
goto out;
}
Expand Down Expand Up @@ -2326,7 +2329,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
} else {
error = nfs_bdi_register(server);
if (error)
goto error_splat_super;
goto error_splat_bdi;
}

if (!s->s_root) {
Expand Down Expand Up @@ -2363,6 +2366,9 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
return error;

error_splat_super:
if (server && !s->s_root)
bdi_unregister(&server->backing_dev_info);
error_splat_bdi:
deactivate_locked_super(s);
dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error);
return error;
Expand Down Expand Up @@ -2578,7 +2584,7 @@ static int nfs4_remote_get_sb(struct file_system_type *fs_type,
} else {
error = nfs_bdi_register(server);
if (error)
goto error_splat_super;
goto error_splat_bdi;
}

if (!s->s_root) {
Expand Down Expand Up @@ -2616,6 +2622,9 @@ static int nfs4_remote_get_sb(struct file_system_type *fs_type,
error_splat_root:
dput(mntroot);
error_splat_super:
if (server && !s->s_root)
bdi_unregister(&server->backing_dev_info);
error_splat_bdi:
deactivate_locked_super(s);
goto out;
}
Expand Down Expand Up @@ -2811,7 +2820,7 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
} else {
error = nfs_bdi_register(server);
if (error)
goto error_splat_super;
goto error_splat_bdi;
}

if (!s->s_root) {
Expand Down Expand Up @@ -2847,6 +2856,9 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
return error;

error_splat_super:
if (server && !s->s_root)
bdi_unregister(&server->backing_dev_info);
error_splat_bdi:
deactivate_locked_super(s);
dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error);
return error;
Expand Down Expand Up @@ -2893,7 +2905,7 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type,
} else {
error = nfs_bdi_register(server);
if (error)
goto error_splat_super;
goto error_splat_bdi;
}

if (!s->s_root) {
Expand Down Expand Up @@ -2929,6 +2941,9 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type,
return error;

error_splat_super:
if (server && !s->s_root)
bdi_unregister(&server->backing_dev_info);
error_splat_bdi:
deactivate_locked_super(s);
dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error);
return error;
Expand Down

0 comments on commit cfbc068

Please sign in to comment.