Create the VM system backing object for this vnode */
| 145 | |
| 146 | /* Create the VM system backing object for this vnode */ |
| 147 | int |
| 148 | vnode_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 | |
| 190 | void |
| 191 | vnode_destroy_vobject(struct vnode *vp) |
no test coverage detected