buf_map
Get virtual mappings for buffer data.
Declaration
errno_t buf_map(buf_t bp, caddr_t *io_addr);Parameters
- bp:
Buffer whose mapping to find or create.
- io_addr:
Destination for mapping address.
Return Value
0 for success, ENOMEM if unable to map the buffer.
Discussion
For buffers created through buf_getblk() (i.e. traditional buffer cache usage), buf_map() just returns the address at which data was mapped by but_getblk(). For a B_CLUSTER buffer, i.e. an iobuf whose upl state is managed manually, there are two possibilities. If the buffer was created with an underlying "real" buffer through cluster_bp(), the mapping of the "real" buffer is returned. Otherwise, the buffer was created with buf_alloc() and buf_setupl() was subsequently called; buf_map() will call ubc_upl_map() to get a mapping for the buffer's upl and return the start of that mapping plus the buffer's upl offset (set in buf_setupl()). In the last case, buf_unmap() must later be called to tear down the mapping. NOTE: buf_map() does not set the buffer data pointer; this must be done with buf_setdataptr().
See Also
Buffers
buf_allocbuf_attrbuf_bawritebuf_bdwritebuf_biodonebuf_biowaitbuf_blknobuf_breadbuf_breadnbuf_brelsebuf_bwritebuf_callbackbuf_clearbuf_clear_redundancy_flagsbuf_clearflagsbuf_clonebuf_countbuf_create_shadowbuf_dataptrbuf_devicebuf_dirtyendbuf_dirtyoffbuf_drvdatabuf_errorbuf_flagsbuf_flushdirtyblksbuf_freebuf_fromcachebuf_fsprivatebuf_fuabuf_getblkbuf_geteblkbuf_invalblknobuf_invalidateblksbuf_iteratebuf_lblknobuf_markagedbuf_markcleanbuf_markdelayedbuf_markeintrbuf_markfuabuf_markinvalidbuf_markstaticbuf_meta_breadbuf_meta_breadnbuf_procbuf_rcredbuf_redundancy_flagsbuf_resetbuf_residbuf_set_redundancy_flagsbuf_setblknobuf_setcallbackbuf_setcountbuf_setdataptrbuf_setdevicebuf_setdirtyendbuf_setdirtyoffbuf_setdrvdatabuf_seterrorbuf_setflagsbuf_setfsprivatebuf_setlblknobuf_setresidbuf_setsizebuf_setuplbuf_setvnodebuf_shadowbuf_sizebuf_staticbuf_strategybuf_unmapbuf_uplbuf_uploffsetbuf_validbuf_vnodebuf_wcredbufattr_ioscheduledbufattr_markioscheduled