MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vfs_setdirty_range

Function vfs_setdirty_range

freebsd/kern/vfs_bio.c:3712–3762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3710}
3711
3712static void
3713vfs_setdirty_range(struct buf *bp)
3714{
3715 vm_offset_t boffset;
3716 vm_offset_t eoffset;
3717 int i;
3718
3719 /*
3720 * test the pages to see if they have been modified directly
3721 * by users through the VM system.
3722 */
3723 for (i = 0; i < bp->b_npages; i++)
3724 vm_page_test_dirty(bp->b_pages[i]);
3725
3726 /*
3727 * Calculate the encompassing dirty range, boffset and eoffset,
3728 * (eoffset - boffset) bytes.
3729 */
3730
3731 for (i = 0; i < bp->b_npages; i++) {
3732 if (bp->b_pages[i]->dirty)
3733 break;
3734 }
3735 boffset = (i << PAGE_SHIFT) - (bp->b_offset & PAGE_MASK);
3736
3737 for (i = bp->b_npages - 1; i >= 0; --i) {
3738 if (bp->b_pages[i]->dirty) {
3739 break;
3740 }
3741 }
3742 eoffset = ((i + 1) << PAGE_SHIFT) - (bp->b_offset & PAGE_MASK);
3743
3744 /*
3745 * Fit it to the buffer.
3746 */
3747
3748 if (eoffset > bp->b_bcount)
3749 eoffset = bp->b_bcount;
3750
3751 /*
3752 * If we have a good dirty range, merge with the existing
3753 * dirty range.
3754 */
3755
3756 if (boffset < eoffset) {
3757 if (bp->b_dirtyoff > boffset)
3758 bp->b_dirtyoff = boffset;
3759 if (bp->b_dirtyend < eoffset)
3760 bp->b_dirtyend = eoffset;
3761 }
3762}
3763
3764/*
3765 * Allocate the KVA mapping for an existing buffer.

Callers 2

vfs_busy_pagesFunction · 0.85

Calls 1

vm_page_test_dirtyFunction · 0.85

Tested by

no test coverage detected