Lines 488-493
Link Here
|
488 |
struct tmpfs_node *node; |
488 |
struct tmpfs_node *node; |
489 |
off_t oldsize; |
489 |
off_t oldsize; |
490 |
int error, ioflag; |
490 |
int error, ioflag; |
|
|
491 |
vm_pindex_t oldresident, newresident; |
492 |
struct tmpfs_mount *tmp; |
491 |
|
493 |
|
492 |
vp = v->a_vp; |
494 |
vp = v->a_vp; |
493 |
uio = v->a_uio; |
495 |
uio = v->a_uio; |
Lines 494-500
Link Here
|
494 |
ioflag = v->a_ioflag; |
496 |
ioflag = v->a_ioflag; |
495 |
error = 0; |
497 |
error = 0; |
496 |
node = VP_TO_TMPFS_NODE(vp); |
498 |
node = VP_TO_TMPFS_NODE(vp); |
|
|
499 |
oldresident = node->tn_reg.tn_aobj->resident_page_count; |
497 |
oldsize = node->tn_size; |
500 |
oldsize = node->tn_size; |
|
|
501 |
tmp = VFS_TO_TMPFS(vp->v_mount); |
498 |
|
502 |
|
499 |
if (uio->uio_offset < 0 || vp->v_type != VREG) |
503 |
if (uio->uio_offset < 0 || vp->v_type != VREG) |
500 |
return (EINVAL); |
504 |
return (EINVAL); |
Lines 502-512
Link Here
|
502 |
return (0); |
506 |
return (0); |
503 |
if (ioflag & IO_APPEND) |
507 |
if (ioflag & IO_APPEND) |
504 |
uio->uio_offset = node->tn_size; |
508 |
uio->uio_offset = node->tn_size; |
505 |
if (uio->uio_offset + uio->uio_resid > |
509 |
if (uio->uio_offset + uio->uio_resid > tmp->tm_maxfilesize) |
506 |
VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize) |
|
|
507 |
return (EFBIG); |
510 |
return (EFBIG); |
508 |
if (vn_rlimit_fsize(vp, uio, uio->uio_td)) |
511 |
if (vn_rlimit_fsize(vp, uio, uio->uio_td)) |
509 |
return (EFBIG); |
512 |
return (EFBIG); |
|
|
513 |
/* XXX need to check for vm_object with holes, this test is simplistic XXX */ |
514 |
if (tmp->tm_pages_used + howmany(uio->uio_resid, PAGE_SIZE) >= tmp->tm_pages_max) |
515 |
return(ENOSPC); |
510 |
if (uio->uio_offset + uio->uio_resid > node->tn_size) { |
516 |
if (uio->uio_offset + uio->uio_resid > node->tn_size) { |
511 |
error = tmpfs_reg_resize(vp, uio->uio_offset + uio->uio_resid, |
517 |
error = tmpfs_reg_resize(vp, uio->uio_offset + uio->uio_resid, |
512 |
FALSE); |
518 |
FALSE); |
Lines 524-529
Link Here
|
524 |
if (error != 0) |
530 |
if (error != 0) |
525 |
(void)tmpfs_reg_resize(vp, oldsize, TRUE); |
531 |
(void)tmpfs_reg_resize(vp, oldsize, TRUE); |
526 |
|
532 |
|
|
|
533 |
newresident = node->tn_reg.tn_aobj->resident_page_count; |
534 |
if (newresident != oldresident) |
535 |
atomic_add_long(&tmp->tm_pages_used, newresident - oldresident); |
527 |
out: |
536 |
out: |
528 |
MPASS(IMPLIES(error == 0, uio->uio_resid == 0)); |
537 |
MPASS(IMPLIES(error == 0, uio->uio_resid == 0)); |
529 |
MPASS(IMPLIES(error != 0, oldsize == node->tn_size)); |
538 |
MPASS(IMPLIES(error != 0, oldsize == node->tn_size)); |