Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148116950
D55665.id173324.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D55665.id173324.diff
View Options
diff --git a/sys/fs/p9fs/p9fs_vnops.c b/sys/fs/p9fs/p9fs_vnops.c
--- a/sys/fs/p9fs/p9fs_vnops.c
+++ b/sys/fs/p9fs/p9fs_vnops.c
@@ -951,16 +951,36 @@
{
struct p9fs_node *np;
struct p9fs_inode *inode;
+ bool excl_locked;
np = P9FS_VTON(vp);
inode = &np->inode;
+ /*
+ * This function might be called with the vnode only shared
+ * locked. Then, interlock the vnode to ensure the exclusive
+ * access to the inode fields: the thread either owns
+ * exclusive vnode lock, or shared vnode lock plus interlock.
+ *
+ * If the vnode is locked exclusive, do not take the
+ * interlock. We directly call vnode_pager_setsize(), which
+ * needs the vm_object lock, and that lock is before vnode
+ * interlock in the lock order.
+ */
ASSERT_VOP_LOCKED(vp, __func__);
+ excl_locked = VOP_ISLOCKED(vp) == LK_EXCLUSIVE;
+ if (!excl_locked)
+ VI_LOCK(vp);
+
/* Update the pager size if file size changes on host */
if (inode->i_size != stat->st_size) {
inode->i_size = stat->st_size;
- if (vp->v_type == VREG)
- vnode_pager_setsize(vp, inode->i_size);
+ if (vp->v_type == VREG) {
+ if (excl_locked)
+ vnode_pager_setsize(vp, inode->i_size);
+ else
+ vn_delayed_setsize_locked(vp);
+ }
}
inode->i_mtime = stat->st_mtime_sec;
@@ -979,11 +999,12 @@
inode->gen = stat->st_gen;
inode->data_version = stat->st_data_version;
- ASSERT_VOP_LOCKED(vp, __func__);
/* Setting a flag if file changes based on qid version */
if (np->vqid.qid_version != stat->qid.version)
np->flags |= P9FS_NODE_MODIFIED;
memcpy(&np->vqid, &stat->qid, sizeof(stat->qid));
+ if (!excl_locked)
+ VI_UNLOCK(vp);
return (0);
}
@@ -2213,12 +2234,25 @@
return (rtvals[0]);
}
+static int
+p9fs_delayed_setsize(struct vop_delayed_setsize_args *ap)
+{
+ struct vnode *vp;
+ struct p9fs_node *np;
+
+ vp = ap->a_vp;
+ np = P9FS_VTON(vp);
+ vnode_pager_setsize(vp, np->inode.i_size);
+ return (0);
+}
+
struct vop_vector p9fs_vnops = {
.vop_default = &default_vnodeops,
.vop_lookup = p9fs_lookup,
.vop_open = p9fs_open,
.vop_close = p9fs_close,
.vop_access = p9fs_access,
+ .vop_delayed_setsize = p9fs_delayed_setsize,
.vop_getattr = p9fs_getattr_dotl,
.vop_setattr = p9fs_setattr_dotl,
.vop_reclaim = p9fs_reclaim,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 16, 9:56 PM (18 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29426877
Default Alt Text
D55665.id173324.diff (2 KB)
Attached To
Mode
D55665: p9fs: locking improvements for p9fs_stat_vnode_dotl()
Attached
Detach File
Event Timeline
Log In to Comment