Skip to content

Commit

Permalink
mount: Make use of MNT_DOOMED
Browse files Browse the repository at this point in the history
Make use of MNT_DOOMED and add a corresponding smp_mb() barrier in
attempt_disconnect().

Signed-off-by: Pedro Falcato <[email protected]>
  • Loading branch information
heatd committed Aug 5, 2024
1 parent cbb4a86 commit 280039c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/kernel/fs/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ struct mount *mnt_traverse(struct dentry *mountpoint)
break;
mnt_get(mnt);

/* TODO: Will pair with something on the umount side */
smp_mb();
if (mnt->mnt_flags & MNT_DOOMED)
{
Expand Down Expand Up @@ -332,6 +331,7 @@ static bool attempt_disconnect(struct mount *mount)
/* No one can grab a reference to a mount while we hold mount_lock. As such, checking the refs
* here is mostly safe. Note that we can spuriouly see a ref-up here, but that's not _really_ a
* problem. We expect a mnt_count of 1 for the struct path we hold. */
smp_mb();
if (mount->mnt_count == 1)
{
struct dentry *mp = mount->mnt_point;
Expand All @@ -343,6 +343,7 @@ static bool attempt_disconnect(struct mount *mount)
* There's no race because MOUNTPOINT is only set while holding mount_lock in write mode. */
if (!mnt_find_by_mp(mp))
__atomic_and_fetch(&mp->d_flags, ~DENTRY_FLAG_MOUNTPOINT, __ATOMIC_RELEASE);
mount->mnt_flags |= MNT_DOOMED;
}

write_sequnlock(&mount_lock);
Expand Down

0 comments on commit 280039c

Please sign in to comment.