git: 3a3450eda6d4 - main - tmpfs_rename(): use tmpfs_access_locked instead of VOP_ACCESS()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 13 Feb 2023 23:16:48 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=3a3450eda6d4616df51a30f84a872d9d43669d78
commit 3a3450eda6d4616df51a30f84a872d9d43669d78
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-02-12 23:20:25 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-02-13 23:16:38 +0000
tmpfs_rename(): use tmpfs_access_locked instead of VOP_ACCESS()
Protect the call with the node lock. We cannot lock the fvp vnode
sleepable there, because we already own other participating vnode's
locks. Taking it without sleeping require unwinding the whole locking
state in one more place.
Note that the liveness of the node is guaranteed by the lock on the
parent directory vnode.
Reported and tested by: pho
Fixes: cbac1f3464956185cf95955344b6009e2cc3ae40ESC
Reviewed by: markj, mjg
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D38557
---
sys/fs/tmpfs/tmpfs_vnops.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
index cd460636b647..b1d6bce6754f 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -1129,7 +1129,10 @@ tmpfs_rename(struct vop_rename_args *v)
if (de->td_node->tn_type == VDIR) {
struct tmpfs_node *n;
- error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, curthread);
+ TMPFS_NODE_LOCK(fnode);
+ error = tmpfs_access_locked(fvp, fnode, VWRITE,
+ tcnp->cn_cred);
+ TMPFS_NODE_UNLOCK(fnode);
if (error) {
if (newname != NULL)
free(newname, M_TMPFSNAME);