Merge branch 'linux-ioctl' into refs/top-bases/linux-zfs-branch

This commit is contained in:
Brian Behlendorf 2008-12-16 16:10:16 -08:00
commit 4ee4891d66
3 changed files with 1 additions and 66 deletions

View File

@ -40,8 +40,6 @@
#include <sys/mnttab.h> #include <sys/mnttab.h>
#include <sys/mntent.h> #include <sys/mntent.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/dmu_ctl.h>
#include <sys/fs/zfs.h>
#include <libzfs.h> #include <libzfs.h>
@ -563,21 +561,15 @@ libzfs_init(void)
return (NULL); return (NULL);
} }
#ifdef HAVE_SPL #if defined(HAVE_SPL) && !defined(HAVE_GPL_ONLY_SYMBOLS)
#ifndef HAVE_GPL_ONLY_SYMBOLS
/* If we don't have access to GPL-only symbols then we may not use /* If we don't have access to GPL-only symbols then we may not use
* the udev APIs, therefore we must mknod the device ourselves. */ * the udev APIs, therefore we must mknod the device ourselves. */
(void)mknod(ZFS_DEV, S_IFCHR | 0600, makedev(ZFS_MAJOR, 0)); (void)mknod(ZFS_DEV, S_IFCHR | 0600, makedev(ZFS_MAJOR, 0));
#endif #endif
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) { if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
free(hdl); free(hdl);
return (NULL); return (NULL);
} }
#else
if ((hdl->libzfs_fd = dctlc_connect(DMU_CTL_DEFAULT_DIR, B_TRUE)) < 0)
hdl->libzfs_fd = -1;
#endif
#ifdef HAVE_SETMNTENT #ifdef HAVE_SETMNTENT
if ((hdl->libzfs_mnttab = setmntent(MNTTAB, "r")) == NULL) { if ((hdl->libzfs_mnttab = setmntent(MNTTAB, "r")) == NULL) {
@ -600,12 +592,7 @@ libzfs_init(void)
void void
libzfs_fini(libzfs_handle_t *hdl) libzfs_fini(libzfs_handle_t *hdl)
{ {
#ifdef HAVE_SPL
(void) close(hdl->libzfs_fd); (void) close(hdl->libzfs_fd);
#else
if (hdl->libzfs_fd != -1)
dctlc_disconnect(hdl->libzfs_fd);
#endif
if (hdl->libzfs_mnttab) if (hdl->libzfs_mnttab)
#ifdef HAVE_SETMNTENT #ifdef HAVE_SETMNTENT
(void) endmntent(hdl->libzfs_mnttab); (void) endmntent(hdl->libzfs_mnttab);

View File

@ -38,17 +38,12 @@
#include <sys/zfs_ioctl.h> #include <sys/zfs_ioctl.h>
#include <sys/zap.h> #include <sys/zap.h>
#include <sys/zio_checksum.h> #include <sys/zio_checksum.h>
#include <sys/dmu_ctl.h>
static char *dmu_recv_tag = "dmu_recv_tag"; static char *dmu_recv_tag = "dmu_recv_tag";
struct backuparg { struct backuparg {
dmu_replay_record_t *drr; dmu_replay_record_t *drr;
#ifdef _KERNEL
vnode_t *vp; vnode_t *vp;
#else
int fd;
#endif
offset_t *off; offset_t *off;
objset_t *os; objset_t *os;
zio_cksum_t zc; zio_cksum_t zc;
@ -58,7 +53,6 @@ struct backuparg {
static int static int
dump_bytes(struct backuparg *ba, void *buf, int len) dump_bytes(struct backuparg *ba, void *buf, int len)
{ {
#ifdef _KERNEL
ssize_t resid; /* have to get resid to get detailed errno */ ssize_t resid; /* have to get resid to get detailed errno */
ASSERT3U(len % 8, ==, 0); ASSERT3U(len % 8, ==, 0);
@ -66,12 +60,6 @@ dump_bytes(struct backuparg *ba, void *buf, int len)
ba->err = vn_rdwr(UIO_WRITE, ba->vp, ba->err = vn_rdwr(UIO_WRITE, ba->vp,
(caddr_t)buf, len, (caddr_t)buf, len,
0, UIO_SYSSPACE, FAPPEND, RLIM64_INFINITY, CRED(), &resid); 0, UIO_SYSSPACE, FAPPEND, RLIM64_INFINITY, CRED(), &resid);
#else
ASSERT3U(len % 8, ==, 0);
fletcher_4_incremental_native(buf, len, &ba->zc);
ba->err = dctls_fd_write(ba->fd, buf, len);
#endif
*ba->off += len; *ba->off += len;
return (ba->err); return (ba->err);
} }
@ -222,15 +210,9 @@ backup_cb(spa_t *spa, blkptr_t *bp, const zbookmark_t *zb,
return (err); return (err);
} }
#ifdef _KERNEL
int int
dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin, dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
vnode_t *vp, offset_t *off) vnode_t *vp, offset_t *off)
#else
int
dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
int fd, offset_t *off)
#endif
{ {
dsl_dataset_t *ds = tosnap->os->os_dsl_dataset; dsl_dataset_t *ds = tosnap->os->os_dsl_dataset;
dsl_dataset_t *fromds = fromsnap ? fromsnap->os->os_dsl_dataset : NULL; dsl_dataset_t *fromds = fromsnap ? fromsnap->os->os_dsl_dataset : NULL;
@ -290,11 +272,7 @@ dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
dsl_dataset_rele(fromds, FTAG); dsl_dataset_rele(fromds, FTAG);
ba.drr = drr; ba.drr = drr;
#ifdef _KERNEL
ba.vp = vp; ba.vp = vp;
#else
ba.fd = fd;
#endif
ba.os = tosnap; ba.os = tosnap;
ba.off = off; ba.off = off;
ZIO_SET_CHECKSUM(&ba.zc, 0, 0, 0, 0); ZIO_SET_CHECKSUM(&ba.zc, 0, 0, 0, 0);
@ -698,11 +676,7 @@ dmu_recv_begin(char *tofs, char *tosnap, struct drr_begin *drrb,
struct restorearg { struct restorearg {
int err; int err;
int byteswap; int byteswap;
#ifdef _KERNEL
vnode_t *vp; vnode_t *vp;
#else
int fd;
#endif
char *buf; char *buf;
uint64_t voff; uint64_t voff;
int bufsize; /* amount of memory allocated for buf */ int bufsize; /* amount of memory allocated for buf */
@ -721,7 +695,6 @@ restore_read(struct restorearg *ra, int len)
while (done < len) { while (done < len) {
ssize_t resid; ssize_t resid;
#ifdef _KERNEL
ra->err = vn_rdwr(UIO_READ, ra->vp, ra->err = vn_rdwr(UIO_READ, ra->vp,
(caddr_t)ra->buf + done, len - done, (caddr_t)ra->buf + done, len - done,
ra->voff, UIO_SYSSPACE, FAPPEND, ra->voff, UIO_SYSSPACE, FAPPEND,
@ -729,13 +702,6 @@ restore_read(struct restorearg *ra, int len)
if (resid == len - done) if (resid == len - done)
ra->err = EINVAL; ra->err = EINVAL;
#else
ra->err = dctls_fd_read(ra->fd, (caddr_t) ra->buf + done,
len - done, &resid);
if (ra->err == 0 && resid == len - done)
ra->err = EINVAL;
#endif
ra->voff += len - done - resid; ra->voff += len - done - resid;
done = len - resid; done = len - resid;
if (ra->err) if (ra->err)
@ -993,13 +959,8 @@ dmu_recv_abort_cleanup(dmu_recv_cookie_t *drc)
/* /*
* NB: callers *must* call dmu_recv_end() if this succeeds. * NB: callers *must* call dmu_recv_end() if this succeeds.
*/ */
#ifdef _KERNEL
int int
dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp) dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp)
#else
int
dmu_recv_stream(dmu_recv_cookie_t *drc, int fd, offset_t *voffp)
#endif
{ {
struct restorearg ra = { 0 }; struct restorearg ra = { 0 };
dmu_replay_record_t *drr; dmu_replay_record_t *drr;
@ -1036,11 +997,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, int fd, offset_t *voffp)
drrb->drr_fromguid = BSWAP_64(drrb->drr_fromguid); drrb->drr_fromguid = BSWAP_64(drrb->drr_fromguid);
} }
#ifdef _KERNEL
ra.vp = vp; ra.vp = vp;
#else
ra.fd = fd;
#endif
ra.voff = *voffp; ra.voff = *voffp;
ra.bufsize = 1<<20; ra.bufsize = 1<<20;
ra.buf = vmem_alloc(ra.bufsize, KM_SLEEP); ra.buf = vmem_alloc(ra.bufsize, KM_SLEEP);

View File

@ -637,13 +637,8 @@ typedef void (*dmu_traverse_cb_t)(objset_t *os, void *arg, struct blkptr *bp,
void dmu_traverse_objset(objset_t *os, uint64_t txg_start, void dmu_traverse_objset(objset_t *os, uint64_t txg_start,
dmu_traverse_cb_t cb, void *arg); dmu_traverse_cb_t cb, void *arg);
#ifdef _KERNEL
int dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin, int dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
struct vnode *vp, offset_t *off); struct vnode *vp, offset_t *off);
#else
int dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
int fd, offset_t *off);
#endif
typedef struct dmu_recv_cookie { typedef struct dmu_recv_cookie {
/* /*
@ -663,11 +658,7 @@ typedef struct dmu_recv_cookie {
int dmu_recv_begin(char *tofs, char *tosnap, struct drr_begin *, int dmu_recv_begin(char *tofs, char *tosnap, struct drr_begin *,
boolean_t force, objset_t *origin, boolean_t online, dmu_recv_cookie_t *); boolean_t force, objset_t *origin, boolean_t online, dmu_recv_cookie_t *);
#ifdef _KERNEL
int dmu_recv_stream(dmu_recv_cookie_t *drc, struct vnode *vp, offset_t *voffp); int dmu_recv_stream(dmu_recv_cookie_t *drc, struct vnode *vp, offset_t *voffp);
#else
int dmu_recv_stream(dmu_recv_cookie_t *drc, int fd, offset_t *voffp);
#endif
int dmu_recv_end(dmu_recv_cookie_t *drc); int dmu_recv_end(dmu_recv_cookie_t *drc);
void dmu_recv_abort_cleanup(dmu_recv_cookie_t *drc); void dmu_recv_abort_cleanup(dmu_recv_cookie_t *drc);