Add zfs_file_* interface, remove vnodes

Provide a common zfs_file_* interface which can be implemented on all 
platforms to perform normal file access from either the kernel module
or the libzpool library.

This allows all non-portable vnode_t usage in the common code to be 
replaced by the new portable zfs_file_t.  The associated vnode and
kobj compatibility functions, types, and macros have been removed
from the SPL.  Moving forward, vnodes should only be used in platform
specific code when provided by the native operating system.

Reviewed-by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9556
This commit is contained in:
Matthew Macy
2019-11-21 09:32:57 -08:00
committed by Brian Behlendorf
parent 67a6c3bc9f
commit da92d5cbb3
53 changed files with 1169 additions and 1554 deletions
+18 -15
View File
@@ -40,33 +40,36 @@
#include <sys/zap.h>
#include <sys/zio_checksum.h>
#include <sys/zfs_znode.h>
#include <sys/zfs_file.h>
struct diffarg {
struct vnode *da_vp; /* file to which we are reporting */
typedef struct dmu_diffarg {
zfs_file_t *da_fp; /* file to which we are reporting */
offset_t *da_offp;
int da_err; /* error that stopped diff search */
dmu_diff_record_t da_ddr;
};
} dmu_diffarg_t;
static int
write_record(struct diffarg *da)
int
write_record(dmu_diffarg_t *da)
{
ssize_t resid; /* have to get resid to get detailed errno */
zfs_file_t *fp;
ssize_t resid;
if (da->da_ddr.ddr_type == DDR_NONE) {
da->da_err = 0;
return (0);
}
da->da_err = vn_rdwr(UIO_WRITE, da->da_vp, (caddr_t)&da->da_ddr,
sizeof (da->da_ddr), 0, UIO_SYSSPACE, FAPPEND,
RLIM64_INFINITY, CRED(), &resid);
fp = da->da_fp;
da->da_err = zfs_file_write(fp, (caddr_t)&da->da_ddr,
sizeof (da->da_ddr), &resid);
*da->da_offp += sizeof (da->da_ddr);
return (da->da_err);
}
static int
report_free_dnode_range(struct diffarg *da, uint64_t first, uint64_t last)
report_free_dnode_range(dmu_diffarg_t *da, uint64_t first, uint64_t last)
{
ASSERT(first <= last);
if (da->da_ddr.ddr_type != DDR_FREE ||
@@ -83,7 +86,7 @@ report_free_dnode_range(struct diffarg *da, uint64_t first, uint64_t last)
}
static int
report_dnode(struct diffarg *da, uint64_t object, dnode_phys_t *dnp)
report_dnode(dmu_diffarg_t *da, uint64_t object, dnode_phys_t *dnp)
{
ASSERT(dnp != NULL);
if (dnp->dn_type == DMU_OT_NONE)
@@ -110,7 +113,7 @@ static int
diff_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
const zbookmark_phys_t *zb, const dnode_phys_t *dnp, void *arg)
{
struct diffarg *da = arg;
dmu_diffarg_t *da = arg;
int err = 0;
if (issig(JUSTLOOKING) && issig(FORREAL))
@@ -162,9 +165,9 @@ diff_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
int
dmu_diff(const char *tosnap_name, const char *fromsnap_name,
struct vnode *vp, offset_t *offp)
zfs_file_t *fp, offset_t *offp)
{
struct diffarg da;
dmu_diffarg_t da;
dsl_dataset_t *fromsnap;
dsl_dataset_t *tosnap;
dsl_pool_t *dp;
@@ -205,7 +208,7 @@ dmu_diff(const char *tosnap_name, const char *fromsnap_name,
dsl_dataset_long_hold(tosnap, FTAG);
dsl_pool_rele(dp, FTAG);
da.da_vp = vp;
da.da_fp = fp;
da.da_offp = offp;
da.da_ddr.ddr_type = DDR_NONE;
da.da_ddr.ddr_first = da.da_ddr.ddr_last = 0;