diff options
author | Christian Brauner <brauner@kernel.org> | 2022-02-03 16:14:09 +0300 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2022-02-14 10:37:40 +0300 |
commit | 03b6abee9ba67c20c4e5253e1a347d8c26edc511 (patch) | |
tree | dda5e0d50bbb9c0c7cbff556c31883932cdb1f2e /fs/namespace.c | |
parent | a26f788b6e7a10d193c4cc6889818e4d625e9461 (diff) | |
download | linux-03b6abee9ba67c20c4e5253e1a347d8c26edc511.tar.xz |
fs: simplify check in mount_setattr_commit()
In order to determine whether we need to call mnt_unhold_writers() in
mount_setattr_commit() we currently do not just check whether
MNT_WRITE_HOLD is set but also if a read-only mount was requested.
However, checking whether MNT_WRITE_HOLD is set is enough. Setting
MNT_WRITE_HOLD requires lock_mount_hash() to be held and it must be
unset before calling unlock_mount_hash(). This guarantees that if we see
MNT_WRITE_HOLD we know that we were the ones who set it earlier. We
don't need to care about why we set it. Plus, leaving this additional
read-only check in makes the code more confusing because it implies that
MNT_WRITE_HOLD could've been set by another thread when it really can't.
Remove it and update the associated comment.
Link: https://lore.kernel.org/r/20220203131411.3093040-6-brauner@kernel.org
Cc: Seth Forshee <seth.forshee@digitalocean.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r-- | fs/namespace.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 7e5535ed155d..ddae5c08ea8c 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4096,13 +4096,8 @@ static void mount_setattr_commit(struct mount_kattr *kattr, WRITE_ONCE(m->mnt.mnt_flags, flags); } - /* - * We either set MNT_READONLY above so make it visible - * before ~MNT_WRITE_HOLD or we failed to recursively - * apply mount options. - */ - if ((kattr->attr_set & MNT_READONLY) && - (m->mnt.mnt_flags & MNT_WRITE_HOLD)) + /* If we had to hold writers unblock them. */ + if (m->mnt.mnt_flags & MNT_WRITE_HOLD) mnt_unhold_writers(m); if (!err && kattr->propagation) |