| 1078 | } |
| 1079 | |
| 1080 | int |
| 1081 | vop_stdadvise(struct vop_advise_args *ap) |
| 1082 | { |
| 1083 | struct vnode *vp; |
| 1084 | struct bufobj *bo; |
| 1085 | daddr_t startn, endn; |
| 1086 | off_t bstart, bend, start, end; |
| 1087 | int bsize, error; |
| 1088 | |
| 1089 | vp = ap->a_vp; |
| 1090 | switch (ap->a_advice) { |
| 1091 | case POSIX_FADV_WILLNEED: |
| 1092 | /* |
| 1093 | * Do nothing for now. Filesystems should provide a |
| 1094 | * custom method which starts an asynchronous read of |
| 1095 | * the requested region. |
| 1096 | */ |
| 1097 | error = 0; |
| 1098 | break; |
| 1099 | case POSIX_FADV_DONTNEED: |
| 1100 | error = 0; |
| 1101 | vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); |
| 1102 | if (VN_IS_DOOMED(vp)) { |
| 1103 | VOP_UNLOCK(vp); |
| 1104 | break; |
| 1105 | } |
| 1106 | |
| 1107 | /* |
| 1108 | * Round to block boundaries (and later possibly further to |
| 1109 | * page boundaries). Applications cannot reasonably be aware |
| 1110 | * of the boundaries, and the rounding must be to expand at |
| 1111 | * both extremities to cover enough. It still doesn't cover |
| 1112 | * read-ahead. For partial blocks, this gives unnecessary |
| 1113 | * discarding of buffers but is efficient enough since the |
| 1114 | * pages usually remain in VMIO for some time. |
| 1115 | */ |
| 1116 | bsize = vp->v_bufobj.bo_bsize; |
| 1117 | bstart = rounddown(ap->a_start, bsize); |
| 1118 | bend = roundup(ap->a_end, bsize); |
| 1119 | |
| 1120 | /* |
| 1121 | * Deactivate pages in the specified range from the backing VM |
| 1122 | * object. Pages that are resident in the buffer cache will |
| 1123 | * remain wired until their corresponding buffers are released |
| 1124 | * below. |
| 1125 | */ |
| 1126 | if (vp->v_object != NULL) { |
| 1127 | start = trunc_page(bstart); |
| 1128 | end = round_page(bend); |
| 1129 | VM_OBJECT_RLOCK(vp->v_object); |
| 1130 | vm_object_page_noreuse(vp->v_object, OFF_TO_IDX(start), |
| 1131 | OFF_TO_IDX(end)); |
| 1132 | VM_OBJECT_RUNLOCK(vp->v_object); |
| 1133 | } |
| 1134 | |
| 1135 | bo = &vp->v_bufobj; |
| 1136 | BO_RLOCK(bo); |
| 1137 | startn = bstart / bsize; |
nothing calls this directly
no test coverage detected