diff options
author | Matthew Macy <[email protected]> | 2019-12-13 07:54:10 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-12-13 07:54:10 -0800 |
commit | 13a9a6f5e872fe45684f9ba12d1e322ced577849 (patch) | |
tree | 0fedd1c5ffb8fcb48b4139af7937cf4238e7b0de /module/os | |
parent | 9bb0d89c5c7f1bbf16ab410c25a087b691d428ac (diff) |
Make zfs_replay.c work on FreeBSD
FreeBSD's vfs currently doesn't permit file systems
to do their own locking. To avoid having to have
duplicate zfs functions with and without locking add
locking here. With luck these changes can be removed
in the future.
Reviewed-by: Sean Eric Fagan <[email protected]>
Reviewed-by: Jorgen Lundman <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Matt Macy <[email protected]>
Closes #9715
Diffstat (limited to 'module/os')
-rw-r--r-- | module/os/linux/zfs/zfs_vnops.c | 36 | ||||
-rw-r--r-- | module/os/linux/zfs/zfs_znode.c | 6 |
2 files changed, 42 insertions, 0 deletions
diff --git a/module/os/linux/zfs/zfs_vnops.c b/module/os/linux/zfs/zfs_vnops.c index b1fa89167..ec63dbdeb 100644 --- a/module/os/linux/zfs/zfs_vnops.c +++ b/module/os/linux/zfs/zfs_vnops.c @@ -974,6 +974,42 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr) } /* + * Write the bytes to a file. + * + * IN: zp - znode of file to be written to + * data - bytes to write + * len - number of bytes to write + * pos - offset to start writing at + * + * OUT: resid - remaining bytes to write + * + * RETURN: 0 if success + * positive error code if failure + * + * Timestamps: + * zp - ctime|mtime updated if byte count > 0 + */ +int +zfs_write_simple(znode_t *zp, const void *data, size_t len, + loff_t pos, size_t *resid) +{ + ssize_t written; + int error = 0; + + written = zpl_write_common(ZTOI(zp), data, len, &pos, + UIO_SYSSPACE, 0, kcred); + if (written < 0) { + error = -written; + } else if (resid == NULL) { + if (written < len) + error = SET_ERROR(EIO); /* short write */ + } else { + *resid = len - written; + } + return (error); +} + +/* * Drop a reference on the passed inode asynchronously. This ensures * that the caller will never drop the last reference on an inode in * the current context. Doing so while holding open a tx could result diff --git a/module/os/linux/zfs/zfs_znode.c b/module/os/linux/zfs/zfs_znode.c index a476e58dd..45f19785d 100644 --- a/module/os/linux/zfs/zfs_znode.c +++ b/module/os/linux/zfs/zfs_znode.c @@ -320,6 +320,12 @@ zfs_znode_hold_exit(zfsvfs_t *zfsvfs, znode_hold_t *zh) kmem_cache_free(znode_hold_cache, zh); } +dev_t +zfs_cmpldev(uint64_t dev) +{ + return (dev); +} + static void zfs_znode_sa_init(zfsvfs_t *zfsvfs, znode_t *zp, dmu_buf_t *db, dmu_object_type_t obj_type, sa_handle_t *sa_hdl) |