mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-17 10:26:15 +00:00
zfs: add dmu_write_pages variant for freebsd
The freebsd variant of dmu_write_pages is hidden under _KERNEL to avoid needlessly pulling in vm_page_t declaration. Besides, this function seems to be useless for ZFS userland counterpart. MFC after: 15 days
This commit is contained in:
parent
fdbcc95a47
commit
6c5b7fffce
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=258745
@ -45,6 +45,7 @@
|
||||
#include <sys/zio_compress.h>
|
||||
#include <sys/sa.h>
|
||||
#ifdef _KERNEL
|
||||
#include <sys/vm.h>
|
||||
#include <sys/zfs_znode.h>
|
||||
#endif
|
||||
|
||||
@ -1184,6 +1185,64 @@ dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
|
||||
dmu_buf_rele_array(dbp, numbufs, FTAG);
|
||||
return (err);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
|
||||
vm_page_t *ma, dmu_tx_t *tx)
|
||||
{
|
||||
dmu_buf_t **dbp;
|
||||
struct sf_buf *sf;
|
||||
int numbufs, i;
|
||||
int err;
|
||||
|
||||
if (size == 0)
|
||||
return (0);
|
||||
|
||||
err = dmu_buf_hold_array(os, object, offset, size,
|
||||
FALSE, FTAG, &numbufs, &dbp);
|
||||
if (err)
|
||||
return (err);
|
||||
|
||||
for (i = 0; i < numbufs; i++) {
|
||||
int tocpy, copied, thiscpy;
|
||||
int bufoff;
|
||||
dmu_buf_t *db = dbp[i];
|
||||
caddr_t va;
|
||||
|
||||
ASSERT(size > 0);
|
||||
ASSERT3U(db->db_size, >=, PAGESIZE);
|
||||
|
||||
bufoff = offset - db->db_offset;
|
||||
tocpy = (int)MIN(db->db_size - bufoff, size);
|
||||
|
||||
ASSERT(i == 0 || i == numbufs-1 || tocpy == db->db_size);
|
||||
|
||||
if (tocpy == db->db_size)
|
||||
dmu_buf_will_fill(db, tx);
|
||||
else
|
||||
dmu_buf_will_dirty(db, tx);
|
||||
|
||||
for (copied = 0; copied < tocpy; copied += PAGESIZE) {
|
||||
ASSERT3U(ptoa((*ma)->pindex), ==, db->db_offset + bufoff);
|
||||
thiscpy = MIN(PAGESIZE, tocpy - copied);
|
||||
va = zfs_map_page(*ma, &sf);
|
||||
bcopy(va, (char *)db->db_data + bufoff, thiscpy);
|
||||
zfs_unmap_page(sf);
|
||||
ma += 1;
|
||||
bufoff += PAGESIZE;
|
||||
}
|
||||
|
||||
if (tocpy == db->db_size)
|
||||
dmu_buf_fill_done(db, tx);
|
||||
|
||||
offset += tocpy;
|
||||
size -= tocpy;
|
||||
}
|
||||
dmu_buf_rele_array(dbp, numbufs, FTAG);
|
||||
return (err);
|
||||
}
|
||||
#endif /* sun */
|
||||
#endif
|
||||
|
||||
|
@ -606,8 +606,15 @@ int dmu_write_uio(objset_t *os, uint64_t object, struct uio *uio, uint64_t size,
|
||||
dmu_tx_t *tx);
|
||||
int dmu_write_uio_dbuf(dmu_buf_t *zdb, struct uio *uio, uint64_t size,
|
||||
dmu_tx_t *tx);
|
||||
#ifdef _KERNEL
|
||||
#ifdef sun
|
||||
int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset,
|
||||
uint64_t size, struct page *pp, dmu_tx_t *tx);
|
||||
#else
|
||||
int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset,
|
||||
uint64_t size, struct vm_page **ppa, dmu_tx_t *tx);
|
||||
#endif
|
||||
#endif
|
||||
struct arc_buf *dmu_request_arcbuf(dmu_buf_t *handle, int size);
|
||||
void dmu_return_arcbuf(struct arc_buf *buf);
|
||||
void dmu_assign_arcbuf(dmu_buf_t *handle, uint64_t offset, struct arc_buf *buf,
|
||||
|
Loading…
Reference in New Issue
Block a user