diff options
Diffstat (limited to 'include/sys')
-rw-r--r-- | include/sys/Makefile.am | 1 | ||||
-rw-r--r-- | include/sys/dmu.h | 3 | ||||
-rw-r--r-- | include/sys/dmu_recv.h | 4 | ||||
-rw-r--r-- | include/sys/spa.h | 12 | ||||
-rw-r--r-- | include/sys/spa_impl.h | 2 | ||||
-rw-r--r-- | include/sys/vdev_file.h | 2 | ||||
-rw-r--r-- | include/sys/vdev_impl.h | 2 | ||||
-rw-r--r-- | include/sys/zfs_context.h | 53 | ||||
-rw-r--r-- | include/sys/zfs_file.h | 61 | ||||
-rw-r--r-- | include/sys/zil.h | 2 |
10 files changed, 80 insertions, 62 deletions
diff --git a/include/sys/Makefile.am b/include/sys/Makefile.am index 21e85431c..75f7d93e7 100644 --- a/include/sys/Makefile.am +++ b/include/sys/Makefile.am @@ -104,6 +104,7 @@ COMMON_H = \ $(top_srcdir)/include/sys/zfs_context.h \ $(top_srcdir)/include/sys/zfs_debug.h \ $(top_srcdir)/include/sys/zfs_delay.h \ + $(top_srcdir)/include/sys/zfs_file.h \ $(top_srcdir)/include/sys/zfs_fuid.h \ $(top_srcdir)/include/sys/zfs_project.h \ $(top_srcdir)/include/sys/zfs_ratelimit.h \ diff --git a/include/sys/dmu.h b/include/sys/dmu.h index 44889bb10..24cbb2f7a 100644 --- a/include/sys/dmu.h +++ b/include/sys/dmu.h @@ -49,6 +49,7 @@ #include <sys/zio_compress.h> #include <sys/zio_priority.h> #include <sys/uio.h> +#include <sys/zfs_file.h> #ifdef __cplusplus extern "C" { @@ -1071,7 +1072,7 @@ void dmu_traverse_objset(objset_t *os, uint64_t txg_start, dmu_traverse_cb_t cb, void *arg); int dmu_diff(const char *tosnap_name, const char *fromsnap_name, - struct vnode *vp, offset_t *offp); + zfs_file_t *fp, offset_t *offp); /* CRC64 table */ #define ZFS_CRC64_POLY 0xC96C5795D7870F42ULL /* ECMA-182, reflected form */ diff --git a/include/sys/dmu_recv.h b/include/sys/dmu_recv.h index 1a7347d66..2cbe49c49 100644 --- a/include/sys/dmu_recv.h +++ b/include/sys/dmu_recv.h @@ -62,7 +62,7 @@ typedef struct dmu_recv_cookie { nvlist_t *drc_begin_nvl; objset_t *drc_os; - vnode_t *drc_vp; /* The vnode to read the stream from */ + zfs_file_t *drc_fp; /* The file to read the stream from */ uint64_t drc_voff; /* The current offset in the stream */ uint64_t drc_bytes_read; /* @@ -82,7 +82,7 @@ typedef struct dmu_recv_cookie { int dmu_recv_begin(char *tofs, char *tosnap, dmu_replay_record_t *drr_begin, boolean_t force, boolean_t resumable, nvlist_t *localprops, nvlist_t *hidden_args, char *origin, dmu_recv_cookie_t *drc, - vnode_t *vp, offset_t *voffp); + zfs_file_t *fp, offset_t *voffp); int dmu_recv_stream(dmu_recv_cookie_t *drc, int cleanup_fd, uint64_t *action_handlep, offset_t *voffp); int dmu_recv_end(dmu_recv_cookie_t *drc, void *owner); diff --git a/include/sys/spa.h b/include/sys/spa.h index cb9157738..cae29a4f4 100644 --- a/include/sys/spa.h +++ b/include/sys/spa.h @@ -723,6 +723,12 @@ typedef enum spa_import_type { SPA_IMPORT_ASSEMBLE } spa_import_type_t; +typedef enum spa_mode { + SPA_MODE_UNINIT = 0, + SPA_MODE_READ = 1, + SPA_MODE_WRITE = 2, +} spa_mode_t; + /* * Send TRIM commands in-line during normal pool operation while deleting. * OFF: no @@ -1099,7 +1105,7 @@ extern uint32_t spa_get_hostid(spa_t *spa); extern void spa_activate_allocation_classes(spa_t *, dmu_tx_t *); extern boolean_t spa_livelist_delete_check(spa_t *spa); -extern int spa_mode(spa_t *spa); +extern spa_mode_t spa_mode(spa_t *spa); extern uint64_t zfs_strtonum(const char *str, char **nptr); extern char *spa_his_ievent_table[]; @@ -1149,7 +1155,7 @@ extern void vdev_mirror_stat_init(void); extern void vdev_mirror_stat_fini(void); /* Initialization and termination */ -extern void spa_init(int flags); +extern void spa_init(spa_mode_t mode); extern void spa_fini(void); extern void spa_boot_init(void); @@ -1189,7 +1195,7 @@ _NOTE(CONSTCOND) } while (0) #define dprintf_bp(bp, fmt, ...) #endif -extern int spa_mode_global; /* mode, e.g. FREAD | FWRITE */ +extern spa_mode_t spa_mode_global; extern int zfs_deadman_enabled; extern unsigned long zfs_deadman_synctime_ms; extern unsigned long zfs_deadman_ziotime_ms; diff --git a/include/sys/spa_impl.h b/include/sys/spa_impl.h index c83252bca..5a581214d 100644 --- a/include/sys/spa_impl.h +++ b/include/sys/spa_impl.h @@ -362,7 +362,7 @@ struct spa { uint8_t spa_claiming; /* pool is doing zil_claim() */ boolean_t spa_is_root; /* pool is root */ int spa_minref; /* num refs when first opened */ - int spa_mode; /* FREAD | FWRITE */ + spa_mode_t spa_mode; /* SPA_MODE_{READ|WRITE} */ spa_log_state_t spa_log_state; /* log state */ uint64_t spa_autoexpand; /* lun expansion on/off */ ddt_t *spa_ddt[ZIO_CHECKSUM_FUNCTIONS]; /* in-core DDTs */ diff --git a/include/sys/vdev_file.h b/include/sys/vdev_file.h index 9a398c583..1514a44fc 100644 --- a/include/sys/vdev_file.h +++ b/include/sys/vdev_file.h @@ -34,7 +34,7 @@ extern "C" { #endif typedef struct vdev_file { - vnode_t *vf_vnode; + zfs_file_t *vf_file; } vdev_file_t; extern void vdev_file_init(void); diff --git a/include/sys/vdev_impl.h b/include/sys/vdev_impl.h index ae82b75c0..4f63e1ae5 100644 --- a/include/sys/vdev_impl.h +++ b/include/sys/vdev_impl.h @@ -220,8 +220,6 @@ struct vdev { vdev_ops_t *vdev_ops; /* vdev operations */ spa_t *vdev_spa; /* spa for this vdev */ void *vdev_tsd; /* type-specific data */ - vnode_t *vdev_name_vp; /* vnode for pathname */ - vnode_t *vdev_devid_vp; /* vnode for devid */ vdev_t *vdev_top; /* top-level vdev */ vdev_t *vdev_parent; /* parent vdev */ vdev_t **vdev_child; /* array of children */ diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index f221091d8..c14d92a2c 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -42,7 +42,6 @@ #include <sys/vmem.h> #include <sys/taskq.h> #include <sys/param.h> -#include <sys/kobj.h> #include <sys/disp.h> #include <sys/debug.h> #include <sys/random.h> @@ -515,16 +514,6 @@ extern void system_taskq_fini(void); #define XVA_MAPSIZE 3 #define XVA_MAGIC 0x78766174 -/* - * vnodes - */ -typedef struct vnode { - uint64_t v_size; - int v_fd; - char *v_path; - int v_dump_fd; -} vnode_t; - extern char *vn_dumpdir; #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */ @@ -593,40 +582,7 @@ typedef struct vsecattr { #define CRCREAT 0 #define F_FREESP 11 - -extern int fop_getattr(vnode_t *vp, vattr_t *vap); - -#define VOP_CLOSE(vp, f, c, o, cr, ct) vn_close(vp) -#define VOP_PUTPAGE(vp, of, sz, fl, cr, ct) 0 -#define VOP_GETATTR(vp, vap, fl, cr, ct) fop_getattr((vp), (vap)); - -#define VOP_FSYNC(vp, f, cr, ct) fsync((vp)->v_fd) - -#if defined(FALLOC_FL_PUNCH_HOLE) && defined(FALLOC_FL_KEEP_SIZE) -#define VOP_SPACE(vp, cmd, flck, fl, off, cr, ct) \ - fallocate((vp)->v_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, \ - (flck)->l_start, (flck)->l_len) -#else -#define VOP_SPACE(vp, cmd, flck, fl, off, cr, ct) (0) -#endif - -#define VN_RELE(vp) vn_close(vp) - -extern int vn_open(char *path, int x1, int oflags, int mode, vnode_t **vpp, - int x2, int x3); -extern int vn_openat(char *path, int x1, int oflags, int mode, vnode_t **vpp, - int x2, int x3, vnode_t *vp, int fd); -extern int vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, - offset_t offset, int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp); -extern void vn_close(vnode_t *vp); - -#define vn_remove(path, x1, x2) remove(path) -#define vn_rename(from, to, seg) rename((from), (to)) -#define vn_is_readonly(vp) B_FALSE - -extern vnode_t *rootdir; - -#include <sys/file.h> /* for FREAD, FWRITE, etc */ +#define FIGNORECASE 0x80000 /* request case-insensitive lookups */ /* * Random stuff @@ -681,7 +637,7 @@ extern int lowbit64(uint64_t i); extern int random_get_bytes(uint8_t *ptr, size_t len); extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len); -extern void kernel_init(int); +extern void kernel_init(int mode); extern void kernel_fini(void); extern void random_init(void); extern void random_fini(void); @@ -758,11 +714,6 @@ typedef struct ace_object { #define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07 #define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08 -extern struct _buf *kobj_open_file(char *name); -extern int kobj_read_file(struct _buf *file, char *buf, unsigned size, - unsigned off); -extern void kobj_close_file(struct _buf *file); -extern int kobj_get_filesize(struct _buf *file, uint64_t *size); extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr); extern int zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr); diff --git a/include/sys/zfs_file.h b/include/sys/zfs_file.h new file mode 100644 index 000000000..6b33420e3 --- /dev/null +++ b/include/sys/zfs_file.h @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +#ifndef _SYS_ZFS_FILE_H +#define _SYS_ZFS_FILE_H + +#ifndef _KERNEL +typedef struct zfs_file { + int f_fd; + int f_dump_fd; +} zfs_file_t; +#elif defined(__linux__) || defined(__FreeBSD__) +typedef struct file zfs_file_t; +#else +#error "unknown OS" +#endif + +typedef struct zfs_file_attr { + uint64_t zfa_size; /* file size */ + mode_t zfa_mode; /* file type */ +} zfs_file_attr_t; + +int zfs_file_open(const char *path, int flags, int mode, zfs_file_t **fp); +void zfs_file_close(zfs_file_t *fp); + +int zfs_file_write(zfs_file_t *fp, const void *buf, size_t len, ssize_t *resid); +int zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t len, loff_t off, + ssize_t *resid); +int zfs_file_read(zfs_file_t *fp, void *buf, size_t len, ssize_t *resid); +int zfs_file_pread(zfs_file_t *fp, void *buf, size_t len, loff_t off, + ssize_t *resid); + +int zfs_file_seek(zfs_file_t *fp, loff_t *offp, int whence); +int zfs_file_getattr(zfs_file_t *fp, zfs_file_attr_t *zfattr); +int zfs_file_fsync(zfs_file_t *fp, int flags); +int zfs_file_fallocate(zfs_file_t *fp, int mode, loff_t offset, loff_t len); +loff_t zfs_file_off(zfs_file_t *fp); +int zfs_file_unlink(const char *); + +int zfs_file_get(int fd, zfs_file_t **fp); +void zfs_file_put(int fd); + +#endif /* _SYS_ZFS_FILE_H */ diff --git a/include/sys/zil.h b/include/sys/zil.h index e84fb864a..716b19e56 100644 --- a/include/sys/zil.h +++ b/include/sys/zil.h @@ -373,7 +373,7 @@ typedef struct { * - the write occupies only one block * WR_COPIED: * If we know we'll immediately be committing the - * transaction (FSYNC or FDSYNC), then we allocate a larger + * transaction (O_SYNC or O_DSYNC), then we allocate a larger * log record here for the data and copy the data in. * WR_NEED_COPY: * Otherwise we don't allocate a buffer, and *if* we need to |