tmpfs - Use atomic_fetchadd_long() to allocate inode numbers
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 31 Oct 2018 01:50:03 +0000 (18:50 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 31 Oct 2018 01:50:03 +0000 (18:50 -0700)
* Since DFly inode numbers are 64 bits wide, tmpfs just increments a
  per-mount counter to allocate a new inode.

* We had some old code in tmpfs to allocate inode numbers which wrapped
  a tmpfs mount lock around the increment.  This is totally unnecessary.
  Use atomic_fetchadd_long() instead.

Reported-by: mjg
sys/vfs/tmpfs/tmpfs_subr.c

index 60319e7..38a652e 100644 (file)
@@ -1358,9 +1358,7 @@ tmpfs_fetch_ino(struct tmpfs_mount *tmp)
 {
        ino_t ret;
 
-       TMPFS_LOCK(tmp);
-       ret = tmp->tm_ino++;
-       TMPFS_UNLOCK(tmp);
+       ret = atomic_fetchadd_64(&tmp->tm_ino, 1);
 
        return (ret);
 }