diff options
author | Matthew Macy <[email protected]> | 2019-11-21 09:32:57 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-11-21 09:32:57 -0800 |
commit | da92d5cbb38cea3a860b8a6bb8ee21f9129e7d7c (patch) | |
tree | cc2d84b481a30b43d4097603e79a55a1975b0b64 /include/os/linux/spl | |
parent | 67a6c3bc9ff401fa04bc41354c5172b51aaed1c9 (diff) |
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 <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Igor Kozhukhov <[email protected]>
Reviewed-by: Jorgen Lundman <[email protected]>
Signed-off-by: Matt Macy <[email protected]>
Closes #9556
Diffstat (limited to 'include/os/linux/spl')
-rw-r--r-- | include/os/linux/spl/sys/Makefile.am | 2 | ||||
-rw-r--r-- | include/os/linux/spl/sys/kobj.h | 42 | ||||
-rw-r--r-- | include/os/linux/spl/sys/mode.h | 32 | ||||
-rw-r--r-- | include/os/linux/spl/sys/vnode.h | 95 |
4 files changed, 0 insertions, 171 deletions
diff --git a/include/os/linux/spl/sys/Makefile.am b/include/os/linux/spl/sys/Makefile.am index e3df4edae..63b5ba71b 100644 --- a/include/os/linux/spl/sys/Makefile.am +++ b/include/os/linux/spl/sys/Makefile.am @@ -19,11 +19,9 @@ KERNEL_H = \ $(top_srcdir)/include/os/linux/spl/sys/isa_defs.h \ $(top_srcdir)/include/os/linux/spl/sys/kmem_cache.h \ $(top_srcdir)/include/os/linux/spl/sys/kmem.h \ - $(top_srcdir)/include/os/linux/spl/sys/kobj.h \ $(top_srcdir)/include/os/linux/spl/sys/kstat.h \ $(top_srcdir)/include/os/linux/spl/sys/list.h \ $(top_srcdir)/include/os/linux/spl/sys/mod_os.h \ - $(top_srcdir)/include/os/linux/spl/sys/mode.h \ $(top_srcdir)/include/os/linux/spl/sys/mutex.h \ $(top_srcdir)/include/os/linux/spl/sys/param.h \ $(top_srcdir)/include/os/linux/spl/sys/processor.h \ diff --git a/include/os/linux/spl/sys/kobj.h b/include/os/linux/spl/sys/kobj.h deleted file mode 100644 index 558ec39a8..000000000 --- a/include/os/linux/spl/sys/kobj.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf <[email protected]>. - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see <http://zfsonlinux.org/>. - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef _SPL_KOBJ_H -#define _SPL_KOBJ_H - -#include <sys/vnode.h> - -typedef struct _buf { - vnode_t *vp; -} _buf_t; - -typedef struct _buf buf_t; - -extern struct _buf *kobj_open_file(const char *name); -extern void kobj_close_file(struct _buf *file); -extern int kobj_read_file(struct _buf *file, char *buf, unsigned size, - unsigned off); -extern int kobj_get_filesize(struct _buf *file, uint64_t *size); - -#endif /* SPL_KOBJ_H */ diff --git a/include/os/linux/spl/sys/mode.h b/include/os/linux/spl/sys/mode.h deleted file mode 100644 index 02802d0d4..000000000 --- a/include/os/linux/spl/sys/mode.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf <[email protected]>. - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see <http://zfsonlinux.org/>. - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef _SPL_MODE_H -#define _SPL_MODE_H - -#define IFTOVT(mode) vn_mode_to_vtype(mode) -#define VTTOIF(vtype) vn_vtype_to_mode(vtype) -#define MAKEIMODE(T, M) (VTTOIF(T) | ((M) & ~S_IFMT)) - -#endif /* SPL_MODE_H */ diff --git a/include/os/linux/spl/sys/vnode.h b/include/os/linux/spl/sys/vnode.h index 7bd278e4e..07eac8e44 100644 --- a/include/os/linux/spl/sys/vnode.h +++ b/include/os/linux/spl/sys/vnode.h @@ -51,23 +51,8 @@ #define O_DSYNC O_SYNC #endif -#define FREAD 1 -#define FWRITE 2 -#define FCREAT O_CREAT -#define FTRUNC O_TRUNC -#define FOFFMAX O_LARGEFILE -#define FSYNC O_SYNC -#define FDSYNC O_DSYNC -#define FEXCL O_EXCL -#define FDIRECT O_DIRECT -#define FAPPEND O_APPEND - -#define FNODSYNC 0x10000 /* fsync pseudo flag */ -#define FNOFOLLOW 0x20000 /* don't follow symlinks */ - #define F_FREESP 11 /* Free file space */ - /* * The vnode AT_ flags are mapped to the Linux ATTR_* flags. * This allows them to be used safely with an iattr structure. @@ -102,23 +87,7 @@ #define CREATE_XATTR_DIR 0x04 #define ATTR_NOACLCHECK 0x20 -typedef enum vtype { - VNON = 0, - VREG = 1, - VDIR = 2, - VBLK = 3, - VCHR = 4, - VLNK = 5, - VFIFO = 6, - VDOOR = 7, - VPROC = 8, - VSOCK = 9, - VPORT = 10, - VBAD = 11 -} vtype_t; - typedef struct vattr { - enum vtype va_type; /* vnode type */ uint32_t va_mask; /* attribute bit-mask */ ushort_t va_mode; /* acc mode */ uid_t va_uid; /* owner uid */ @@ -133,70 +102,6 @@ typedef struct vattr { dev_t va_rdev; /* dev */ uint64_t va_nblocks; /* space used */ uint32_t va_blksize; /* block size */ - uint32_t va_seq; /* sequence */ struct dentry *va_dentry; /* dentry to wire */ } vattr_t; - -typedef struct vnode { - struct file *v_file; - kmutex_t v_lock; /* protects vnode fields */ - uint_t v_flag; /* vnode flags (see below) */ - uint_t v_count; /* reference count */ - void *v_data; /* private data for fs */ - struct vfs *v_vfsp; /* ptr to containing VFS */ - struct stdata *v_stream; /* associated stream */ - enum vtype v_type; /* vnode type */ - dev_t v_rdev; /* device (VCHR, VBLK) */ - gfp_t v_gfp_mask; /* original mapping gfp mask */ -} vnode_t; - -typedef struct vn_file { - int f_fd; /* linux fd for lookup */ - struct task_struct *f_task; /* linux task this fd belongs to */ - struct file *f_file; /* linux file struct */ - atomic_t f_ref; /* ref count */ - kmutex_t f_lock; /* struct lock */ - loff_t f_offset; /* offset */ - vnode_t *f_vnode; /* vnode */ - struct list_head f_list; /* list referenced file_t's */ -} file_t; - -extern vnode_t *vn_alloc(int flag); -void vn_free(vnode_t *vp); -extern vtype_t vn_mode_to_vtype(mode_t); -extern mode_t vn_vtype_to_mode(vtype_t); -extern int vn_open(const char *path, uio_seg_t seg, int flags, int mode, - vnode_t **vpp, int x1, void *x2); -extern int vn_openat(const char *path, uio_seg_t seg, int flags, int mode, - vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd); -extern int vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len, - offset_t off, uio_seg_t seg, int x1, rlim64_t x2, - void *x3, ssize_t *residp); -extern int vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4); -extern int vn_seek(vnode_t *vp, offset_t o, offset_t *op, void *ct); - -extern int vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4); -extern int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4); -extern int vn_space(vnode_t *vp, int cmd, struct flock *bfp, int flag, - offset_t offset, void *x6, void *x7); -extern file_t *vn_getf(int fd); -extern void vn_releasef(int fd); -extern void vn_areleasef(int fd, uf_info_t *fip); - -int spl_vn_init(void); -void spl_vn_fini(void); - -#define VOP_CLOSE vn_close -#define VOP_SEEK vn_seek -#define VOP_GETATTR vn_getattr -#define VOP_FSYNC vn_fsync -#define VOP_SPACE vn_space -#define VOP_PUTPAGE(vp, o, s, f, x1, x2) ((void)0) -#define vn_is_readonly(vp) 0 -#define getf vn_getf -#define releasef vn_releasef -#define areleasef vn_areleasef - -extern vnode_t *rootdir; - #endif /* SPL_VNODE_H */ |