tmpfs_vnops.c (1a0fda2b547365c9453523592a445dfe21266d4b) tmpfs_vnops.c (b88b6c9d80ed2e1ad85a6b928e2c9346a41aced6)
1/* $NetBSD: tmpfs_vnops.c,v 1.39 2007/07/23 15:41:01 jmmv Exp $ */
2
3/*-
4 * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code

--- 502 unchanged lines hidden (view full) ---

511 if ((vobj == NULL) ||
512 (vobj->resident_page_count == 0 && vobj->cache == NULL))
513 goto nocache;
514
515 VM_OBJECT_LOCK(vobj);
516lookupvpg:
517 if (((m = vm_page_lookup(vobj, idx)) != NULL) &&
518 vm_page_is_valid(m, offset, tlen)) {
1/* $NetBSD: tmpfs_vnops.c,v 1.39 2007/07/23 15:41:01 jmmv Exp $ */
2
3/*-
4 * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code

--- 502 unchanged lines hidden (view full) ---

511 if ((vobj == NULL) ||
512 (vobj->resident_page_count == 0 && vobj->cache == NULL))
513 goto nocache;
514
515 VM_OBJECT_LOCK(vobj);
516lookupvpg:
517 if (((m = vm_page_lookup(vobj, idx)) != NULL) &&
518 vm_page_is_valid(m, offset, tlen)) {
519 if (vm_page_sleep_if_busy(m, FALSE, "tmfsmr"))
519 if ((m->oflags & VPO_BUSY) != 0) {
520 /*
521 * Reference the page before unlocking and sleeping so
522 * that the page daemon is less likely to reclaim it.
523 */
524 vm_page_lock_queues();
525 vm_page_flag_set(m, PG_REFERENCED);
526 vm_page_sleep(m, "tmfsmr");
520 goto lookupvpg;
527 goto lookupvpg;
528 }
521 vm_page_busy(m);
522 VM_OBJECT_UNLOCK(vobj);
523 error = uiomove_fromphys(&m, offset, tlen, uio);
524 VM_OBJECT_LOCK(vobj);
525 vm_page_wakeup(m);
526 VM_OBJECT_UNLOCK(vobj);
527 return (error);
528 } else if (m != NULL && uio->uio_segflg == UIO_NOCOPY) {
529 vm_page_busy(m);
530 VM_OBJECT_UNLOCK(vobj);
531 error = uiomove_fromphys(&m, offset, tlen, uio);
532 VM_OBJECT_LOCK(vobj);
533 vm_page_wakeup(m);
534 VM_OBJECT_UNLOCK(vobj);
535 return (error);
536 } else if (m != NULL && uio->uio_segflg == UIO_NOCOPY) {
529 if (vm_page_sleep_if_busy(m, FALSE, "tmfsmr"))
537 if ((m->oflags & VPO_BUSY) != 0) {
538 /*
539 * Reference the page before unlocking and sleeping so
540 * that the page daemon is less likely to reclaim it.
541 */
542 vm_page_lock_queues();
543 vm_page_flag_set(m, PG_REFERENCED);
544 vm_page_sleep(m, "tmfsmr");
530 goto lookupvpg;
545 goto lookupvpg;
546 }
531 vm_page_busy(m);
532 VM_OBJECT_UNLOCK(vobj);
533 sched_pin();
534 sf = sf_buf_alloc(m, SFB_CPUPRIVATE);
535 ma = (char *)sf_buf_kva(sf);
536 error = tmpfs_nocacheread_buf(tobj, idx, offset, tlen,
537 ma + offset);
538 if (error == 0) {

--- 83 unchanged lines hidden (view full) ---

622 vpg = NULL;
623 goto nocache;
624 }
625
626 VM_OBJECT_LOCK(vobj);
627lookupvpg:
628 if (((vpg = vm_page_lookup(vobj, idx)) != NULL) &&
629 vm_page_is_valid(vpg, offset, tlen)) {
547 vm_page_busy(m);
548 VM_OBJECT_UNLOCK(vobj);
549 sched_pin();
550 sf = sf_buf_alloc(m, SFB_CPUPRIVATE);
551 ma = (char *)sf_buf_kva(sf);
552 error = tmpfs_nocacheread_buf(tobj, idx, offset, tlen,
553 ma + offset);
554 if (error == 0) {

--- 83 unchanged lines hidden (view full) ---

638 vpg = NULL;
639 goto nocache;
640 }
641
642 VM_OBJECT_LOCK(vobj);
643lookupvpg:
644 if (((vpg = vm_page_lookup(vobj, idx)) != NULL) &&
645 vm_page_is_valid(vpg, offset, tlen)) {
630 if (vm_page_sleep_if_busy(vpg, FALSE, "tmfsmw"))
646 if ((vpg->oflags & VPO_BUSY) != 0) {
647 /*
648 * Reference the page before unlocking and sleeping so
649 * that the page daemon is less likely to reclaim it.
650 */
651 vm_page_lock_queues();
652 vm_page_flag_set(vpg, PG_REFERENCED);
653 vm_page_sleep(vpg, "tmfsmw");
631 goto lookupvpg;
654 goto lookupvpg;
655 }
632 vm_page_busy(vpg);
633 vm_page_lock_queues();
634 vm_page_undirty(vpg);
635 vm_page_unlock_queues();
636 VM_OBJECT_UNLOCK(vobj);
637 error = uiomove_fromphys(&vpg, offset, tlen, uio);
638 } else {
639 if (__predict_false(vobj->cache != NULL))

--- 927 unchanged lines hidden ---
656 vm_page_busy(vpg);
657 vm_page_lock_queues();
658 vm_page_undirty(vpg);
659 vm_page_unlock_queues();
660 VM_OBJECT_UNLOCK(vobj);
661 error = uiomove_fromphys(&vpg, offset, tlen, uio);
662 } else {
663 if (__predict_false(vobj->cache != NULL))

--- 927 unchanged lines hidden ---