* This is now called from local media FS's to operate against their * own vnodes if they fail to implement VOP_PUTPAGES. * * This is typically called indirectly via the pageout daemon and * clustering has already typically occurred, so in general we ask the * underlying filesystem to write the data out asynchronously rather * then delayed. */
| 1268 | * then delayed. |
| 1269 | */ |
| 1270 | int |
| 1271 | vnode_pager_generic_putpages(struct vnode *vp, vm_page_t *ma, int bytecount, |
| 1272 | int flags, int *rtvals) |
| 1273 | { |
| 1274 | vm_object_t object; |
| 1275 | vm_page_t m; |
| 1276 | vm_ooffset_t maxblksz, next_offset, poffset, prev_offset; |
| 1277 | struct uio auio; |
| 1278 | struct iovec aiov; |
| 1279 | off_t prev_resid, wrsz; |
| 1280 | int count, error, i, maxsize, ncount, pgoff, ppscheck; |
| 1281 | bool in_hole; |
| 1282 | static struct timeval lastfail; |
| 1283 | static int curfail; |
| 1284 | |
| 1285 | object = vp->v_object; |
| 1286 | count = bytecount / PAGE_SIZE; |
| 1287 | |
| 1288 | for (i = 0; i < count; i++) |
| 1289 | rtvals[i] = VM_PAGER_ERROR; |
| 1290 | |
| 1291 | if ((int64_t)ma[0]->pindex < 0) { |
| 1292 | printf("vnode_pager_generic_putpages: " |
| 1293 | "attempt to write meta-data 0x%jx(%lx)\n", |
| 1294 | (uintmax_t)ma[0]->pindex, (u_long)ma[0]->dirty); |
| 1295 | rtvals[0] = VM_PAGER_BAD; |
| 1296 | return (VM_PAGER_BAD); |
| 1297 | } |
| 1298 | |
| 1299 | maxsize = count * PAGE_SIZE; |
| 1300 | ncount = count; |
| 1301 | |
| 1302 | poffset = IDX_TO_OFF(ma[0]->pindex); |
| 1303 | |
| 1304 | /* |
| 1305 | * If the page-aligned write is larger then the actual file we |
| 1306 | * have to invalidate pages occurring beyond the file EOF. However, |
| 1307 | * there is an edge case where a file may not be page-aligned where |
| 1308 | * the last page is partially invalid. In this case the filesystem |
| 1309 | * may not properly clear the dirty bits for the entire page (which |
| 1310 | * could be VM_PAGE_BITS_ALL due to the page having been mmap()d). |
| 1311 | * With the page busied we are free to fix up the dirty bits here. |
| 1312 | * |
| 1313 | * We do not under any circumstances truncate the valid bits, as |
| 1314 | * this will screw up bogus page replacement. |
| 1315 | */ |
| 1316 | VM_OBJECT_RLOCK(object); |
| 1317 | if (maxsize + poffset > object->un_pager.vnp.vnp_size) { |
| 1318 | if (object->un_pager.vnp.vnp_size > poffset) { |
| 1319 | maxsize = object->un_pager.vnp.vnp_size - poffset; |
| 1320 | ncount = btoc(maxsize); |
| 1321 | if ((pgoff = (int)maxsize & PAGE_MASK) != 0) { |
| 1322 | pgoff = roundup2(pgoff, DEV_BSIZE); |
| 1323 | |
| 1324 | /* |
| 1325 | * If the page is busy and the following |
| 1326 | * conditions hold, then the page's dirty |
| 1327 | * field cannot be concurrently changed by a |
no test coverage detected