vfs: Use std::atomic for ->m_count

Use std::atomic for ->m_count to avoid MOUNT_LOCK under vn_lock().

Spotted by lockdep:

  Thread 1:
  B:
  lockfree::mutex::lock() at core/lfmutex.cc:39
  mutex_lock at include/osv/mutex.h:35
  sys_mount at fs/vfs/vfs_mount.cc:119
  mount_rootfs() at fs/vfs/main.cc:1478
  vfs_init at fs/vfs/main.cc:1551
  main_cont(int, char**) at loader.cc:284

  A:
  mutex_lock at include/osv/mutex.h:66
  vget at fs/vfs/vfs_vnode.c:195
  sys_mount at fs/vfs/vfs_mount.cc:165
  mount_rootfs() at fs/vfs/main.cc:1478
  vfs_init at fs/vfs/main.cc:1551
  main_cont(int, char**) at loader.cc:284

  Thread 2:
  A
  lockfree::mutex::lock() at core/lfmutex.cc:39
  lockfree_mutex_lock at core/lfmutex.cc:277
  mutex_lock at include/osv/mutex.h:66
  vn_lock at fs/vfs/vfs_vnode.c:135 (discriminator 1)
  namei at fs/vfs/vfs_lookup.c:211
  sys_mkdir at fs/vfs/vfs_syscalls.c:455
  mkdir at fs/vfs/main.cc:573
  mount_rootfs() at fs/vfs/main.cc:1482
  vfs_init at fs/vfs/main.cc:1551
  main_cont(int, char**) at loader.cc:284

  B
  lockfree::mutex::lock() at core/lfmutex.cc:30
  mutex_lock at include/osv/mutex.h:35
  vfs_unbusy at fs/vfs/vfs_mount.cc:357
  vput at fs/vfs/vfs_vnode.c:240 (discriminator 1)
  namei at fs/vfs/vfs_lookup.c:216
  sys_mkdir at fs/vfs/vfs_syscalls.c:455
  mkdir at fs/vfs/main.cc:573
  mount_rootfs() at fs/vfs/main.cc:1482
  vfs_init at fs/vfs/main.cc:1551
  main_cont(int, char**) at loader.cc:284

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: Fix lock inversion in drele()

The drele() function attempts to take vn_lock() while holding the
dentry_hash_lock which can deadlock because sys_mount() takes the locks
in the opposite order.

Spotted by lockdep:

Thread 0xb8be68:
  acquired A at:
    0x32fd1e
    0x35e2c5
    0x35e627 # fs/vfs/vfs_lookup.c:218 # dentry_hash_lock
    0x36086b
    0x3555e7
    0x35c73b
    0x35c846
    0x20a8d9
    0x340a4a
    0x327b25
    ...

  and now tries to acquire B at:
    0x32fbee
    0x35fb30
    0x360561
    0x35e2ee # fs/vfs/vfs_vnode.c:518
    0x35e627
    0x36086b
    0x3555e7
    0x35c73b
    0x35c846
    0x20a8d9
    0x340a4a
    0x327b25
    ...

Previously, thread 0xb8be68:
  acquired B at:
    0x32fd1e
    0x35fccd
    0x35e98e # fs/vfs/vfs_mount.cc:165 # vn_lock
    0x35beec
    0x35c841
    0x20a8d9
    0x340a4a
    0x327b25
    ...

  and then tried to acquire A at:
    0x32fbee
    0x35e0c4
    0x35e9bc # fs/vfs/vfs_mount.cc:173 # dentry_hash_lock
    0x35beec
    0x35c841
    0x20a8d9
    0x340a4a
    0x327b25

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: getblk() vs brelse() lock inversion...

Spotted by lockdep:

  lock A (attempted) : 0x23c
  lock B (held)      : 0x2

  Thread 0xffffc0002e1ce010:
    acquired A at:
      0x32fd1e
      0x35dbf8
      0x35dc62 # fs/vfs/vfs_bio.c:249
      0x362d56
      0x31e02d
      0x31e510
      0x31978c
      0x318083
      ...

    and now tries to acquire B at:
      0x32fbee
      0x35d96f
      0x362da3 # fs/devfs/device.c:141
      0x31e02d
      0x31e510
      0x31978c
      0x318083
      0x31950e
      0x209ae0
      ...

  Previously, thread 0xffffc0002e1ce010:
    acquired B at:
      0x32fd1e
      0x35dae6
      0x35dc62 # fs/vfs/vfs_bio.c:249
      0x362d56
      0x31e02d
      0x31e510
      0x31978c
      0x318083
      0x31950e
      0x209ae0
      ...

    and then tried to acquire A at:
      0x32fbee
      0x35dbf8
      0x35dc62 # fs/vfs/vfs_bio.c:249
      0x362d56
      0x31e02d
      0x31e510
      0x31978c
      0x318083
      0x31950e
      ...
  Aborted

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>