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

Function swapgeom_strategy

freebsd/vm/swap_pager.c:2810–2861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2808}
2809
2810static void
2811swapgeom_strategy(struct buf *bp, struct swdevt *sp)
2812{
2813 struct bio *bio;
2814 struct g_consumer *cp;
2815
2816 mtx_lock(&sw_dev_mtx);
2817 cp = sp->sw_id;
2818 if (cp == NULL) {
2819 mtx_unlock(&sw_dev_mtx);
2820 bp->b_error = ENXIO;
2821 bp->b_ioflags |= BIO_ERROR;
2822 bufdone(bp);
2823 return;
2824 }
2825 swapgeom_acquire(cp);
2826 mtx_unlock(&sw_dev_mtx);
2827 if (bp->b_iocmd == BIO_WRITE)
2828 bio = g_new_bio();
2829 else
2830 bio = g_alloc_bio();
2831 if (bio == NULL) {
2832 mtx_lock(&sw_dev_mtx);
2833 swapgeom_release(cp, sp);
2834 mtx_unlock(&sw_dev_mtx);
2835 bp->b_error = ENOMEM;
2836 bp->b_ioflags |= BIO_ERROR;
2837 printf("swap_pager: cannot allocate bio\n");
2838 bufdone(bp);
2839 return;
2840 }
2841
2842 bp->b_caller1 = bio;
2843 bio->bio_caller1 = sp;
2844 bio->bio_caller2 = bp;
2845 bio->bio_cmd = bp->b_iocmd;
2846 bio->bio_offset = (bp->b_blkno - sp->sw_first) * PAGE_SIZE;
2847 bio->bio_length = bp->b_bcount;
2848 bio->bio_done = swapgeom_done;
2849 if (!buf_mapped(bp)) {
2850 bio->bio_ma = bp->b_pages;
2851 bio->bio_data = unmapped_buf;
2852 bio->bio_ma_offset = (vm_offset_t)bp->b_offset & PAGE_MASK;
2853 bio->bio_ma_n = bp->b_npages;
2854 bio->bio_flags |= BIO_UNMAPPED;
2855 } else {
2856 bio->bio_data = bp->b_data;
2857 bio->bio_ma = NULL;
2858 }
2859 g_io_request(bio, cp);
2860 return;
2861}
2862
2863static void
2864swapgeom_orphan(struct g_consumer *cp)

Callers

nothing calls this directly

Calls 7

bufdoneFunction · 0.85
swapgeom_acquireFunction · 0.85
swapgeom_releaseFunction · 0.85
buf_mappedFunction · 0.85
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected