NFS: Fix a umount race

Ensure that we unregister the bdi before kill_anon_super() calls
ida_remove() on our device name.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org

+14 -1
+14 -1
fs/nfs/super.c
··· 243 static int nfs_get_sb(struct file_system_type *, int, const char *, void *, struct vfsmount *); 244 static int nfs_xdev_get_sb(struct file_system_type *fs_type, 245 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); 246 static void nfs_kill_super(struct super_block *); 247 static int nfs_remount(struct super_block *sb, int *flags, char *raw_data); 248 ··· 267 .alloc_inode = nfs_alloc_inode, 268 .destroy_inode = nfs_destroy_inode, 269 .write_inode = nfs_write_inode, 270 .statfs = nfs_statfs, 271 .clear_inode = nfs_clear_inode, 272 .umount_begin = nfs_umount_begin, ··· 337 .alloc_inode = nfs_alloc_inode, 338 .destroy_inode = nfs_destroy_inode, 339 .write_inode = nfs_write_inode, 340 .statfs = nfs_statfs, 341 .clear_inode = nfs4_clear_inode, 342 .umount_begin = nfs_umount_begin, ··· 2261 } 2262 2263 /* 2264 * Destroy an NFS2/3 superblock 2265 */ 2266 static void nfs_kill_super(struct super_block *s) ··· 2279 struct nfs_server *server = NFS_SB(s); 2280 2281 kill_anon_super(s); 2282 - bdi_unregister(&server->backing_dev_info); 2283 nfs_fscache_release_super_cookie(s); 2284 nfs_free_server(server); 2285 }
··· 243 static int nfs_get_sb(struct file_system_type *, int, const char *, void *, struct vfsmount *); 244 static int nfs_xdev_get_sb(struct file_system_type *fs_type, 245 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); 246 + static void nfs_put_super(struct super_block *); 247 static void nfs_kill_super(struct super_block *); 248 static int nfs_remount(struct super_block *sb, int *flags, char *raw_data); 249 ··· 266 .alloc_inode = nfs_alloc_inode, 267 .destroy_inode = nfs_destroy_inode, 268 .write_inode = nfs_write_inode, 269 + .put_super = nfs_put_super, 270 .statfs = nfs_statfs, 271 .clear_inode = nfs_clear_inode, 272 .umount_begin = nfs_umount_begin, ··· 335 .alloc_inode = nfs_alloc_inode, 336 .destroy_inode = nfs_destroy_inode, 337 .write_inode = nfs_write_inode, 338 + .put_super = nfs_put_super, 339 .statfs = nfs_statfs, 340 .clear_inode = nfs4_clear_inode, 341 .umount_begin = nfs_umount_begin, ··· 2258 } 2259 2260 /* 2261 + * Ensure that we unregister the bdi before kill_anon_super 2262 + * releases the device name 2263 + */ 2264 + static void nfs_put_super(struct super_block *s) 2265 + { 2266 + struct nfs_server *server = NFS_SB(s); 2267 + 2268 + bdi_unregister(&server->backing_dev_info); 2269 + } 2270 + 2271 + /* 2272 * Destroy an NFS2/3 superblock 2273 */ 2274 static void nfs_kill_super(struct super_block *s) ··· 2265 struct nfs_server *server = NFS_SB(s); 2266 2267 kill_anon_super(s); 2268 nfs_fscache_release_super_cookie(s); 2269 nfs_free_server(server); 2270 }