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