Commit 387c149b54b4321cbc790dadbd4f8eedb5a90468

Authored by Trond Myklebust
1 parent 9f557cd807

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

Showing 1 changed file with 14 additions and 1 deletions Side-by-side Diff

... ... @@ -243,6 +243,7 @@
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  
... ... @@ -266,6 +267,7 @@
266 267 .alloc_inode = nfs_alloc_inode,
267 268 .destroy_inode = nfs_destroy_inode,
268 269 .write_inode = nfs_write_inode,
  270 + .put_super = nfs_put_super,
269 271 .statfs = nfs_statfs,
270 272 .clear_inode = nfs_clear_inode,
271 273 .umount_begin = nfs_umount_begin,
... ... @@ -335,6 +337,7 @@
335 337 .alloc_inode = nfs_alloc_inode,
336 338 .destroy_inode = nfs_destroy_inode,
337 339 .write_inode = nfs_write_inode,
  340 + .put_super = nfs_put_super,
338 341 .statfs = nfs_statfs,
339 342 .clear_inode = nfs4_clear_inode,
340 343 .umount_begin = nfs_umount_begin,
... ... @@ -2258,6 +2261,17 @@
2258 2261 }
2259 2262  
2260 2263 /*
  2264 + * Ensure that we unregister the bdi before kill_anon_super
  2265 + * releases the device name
  2266 + */
  2267 +static void nfs_put_super(struct super_block *s)
  2268 +{
  2269 + struct nfs_server *server = NFS_SB(s);
  2270 +
  2271 + bdi_unregister(&server->backing_dev_info);
  2272 +}
  2273 +
  2274 +/*
2261 2275 * Destroy an NFS2/3 superblock
2262 2276 */
2263 2277 static void nfs_kill_super(struct super_block *s)
... ... @@ -2265,7 +2279,6 @@
2265 2279 struct nfs_server *server = NFS_SB(s);
2266 2280  
2267 2281 kill_anon_super(s);
2268   - bdi_unregister(&server->backing_dev_info);
2269 2282 nfs_fscache_release_super_cookie(s);
2270 2283 nfs_free_server(server);
2271 2284 }