MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vnode_create_vobject

Function vnode_create_vobject

freebsd/vm/vnode_pager.c:147–188  ·  view source on GitHub ↗

Create the VM system backing object for this vnode */

Source from the content-addressed store, hash-verified

145
146/* Create the VM system backing object for this vnode */
147int
148vnode_create_vobject(struct vnode *vp, off_t isize, struct thread *td)
149{
150 vm_object_t object;
151 vm_ooffset_t size = isize;
152 struct vattr va;
153 bool last;
154
155 if (!vn_isdisk(vp) && vn_canvmio(vp) == FALSE)
156 return (0);
157
158 object = vp->v_object;
159 if (object != NULL)
160 return (0);
161
162 if (size == 0) {
163 if (vn_isdisk(vp)) {
164 size = IDX_TO_OFF(INT_MAX);
165 } else {
166 if (VOP_GETATTR(vp, &va, td->td_ucred))
167 return (0);
168 size = va.va_size;
169 }
170 }
171
172 object = vnode_pager_alloc(vp, size, 0, 0, td->td_ucred);
173 /*
174 * Dereference the reference we just created. This assumes
175 * that the object is associated with the vp. We still have
176 * to serialize with vnode_pager_dealloc() for the last
177 * potential reference.
178 */
179 VM_OBJECT_RLOCK(object);
180 last = refcount_release(&object->ref_count);
181 VM_OBJECT_RUNLOCK(object);
182 if (last)
183 vrele(vp);
184
185 KASSERT(vp->v_object != NULL, ("vnode_create_vobject: NULL object"));
186
187 return (0);
188}
189
190void
191vnode_destroy_vobject(struct vnode *vp)

Callers 2

zfs_freebsd_openFunction · 0.85
zfs_fhtovpFunction · 0.85

Calls 6

vn_isdiskFunction · 0.85
vn_canvmioFunction · 0.85
VOP_GETATTRFunction · 0.85
vnode_pager_allocFunction · 0.85
refcount_releaseFunction · 0.85
vreleFunction · 0.50

Tested by

no test coverage detected