MFp4: Reduce diff against vendor code:

- Move FreeBSD-specific code to zfs_freebsd_*() functions in zfs_vnops.c
  and keep original functions as similar to vendor's code as possible.
- Add various includes back, now that we have them.
This commit is contained in:
Pawel Jakub Dawidek 2007-04-23 00:52:07 +00:00
parent ee7f985774
commit cc7cd831b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=168962
24 changed files with 1718 additions and 954 deletions

View File

@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/libkern.h>
#include <sys/misc.h>
#include <sys/sunddi.h>
char hw_serial[11] = "0";

View File

@ -29,12 +29,17 @@
#ifndef _OPENSOLARIS_SYS_MISC_H_
#define _OPENSOLARIS_SYS_MISC_H_
#define _FIOFFS (INT_MIN)
#define _FIOGDIO (INT_MIN+1)
#define _FIOSDIO (INT_MIN+2)
#define _FIO_SEEK_DATA FIOSEEKDATA
#define _FIO_SEEK_HOLE FIOSEEKHOLE
struct opensolaris_utsname {
char *nodename;
};
extern char hw_serial[11];
extern struct opensolaris_utsname utsname;
int ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result);
#endif /* _OPENSOLARIS_SYS_MISC_H_ */

View File

@ -0,0 +1,36 @@
/*-
* Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _OPENSOLARIS_SYS_SUNDDI_H_
#define _OPENSOLARIS_SYS_SUNDDI_H_
#define ddi_copyin(from, to, size, flag) (bcopy((from), (to), (size)), 0)
#define ddi_copyout(from, to, size, flag) (bcopy((from), (to), (size)), 0)
int ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result);
#endif /* _OPENSOLARIS_SYS_SUNDDI_H_ */

View File

@ -49,6 +49,7 @@ typedef short index_t;
typedef off_t offset_t;
typedef long ptrdiff_t; /* pointer difference */
typedef void pathname_t;
typedef int64_t rlim64_t;
#else

View File

@ -40,6 +40,7 @@
typedef struct vnode vnode_t;
typedef struct vattr vattr_t;
typedef void caller_context_t;
typedef struct vop_vector vnodeops_t;
#define vop_fid vop_vptofh
@ -63,11 +64,25 @@ vn_is_readonly(vnode_t *vp)
#define VN_RELE(v) vrele(v)
#define VN_URELE(v) vput(v)
#define VOP_REALVP(vp, vpp) (*(vpp) = (vp), 0)
#define vnevent_remove(vp) do { } while (0)
#define vnevent_rmdir(vp) do { } while (0)
#define vnevent_rename_src(vp) do { } while (0)
#define vnevent_rename_dest(vp) do { } while (0)
#define IS_DEVVP(vp) \
((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO)
#define MODEMASK ALLPERMS
#define specvp(vp, rdev, type, cr) (VN_HOLD(vp), (vp))
#define MANDMODE(mode) (0)
#define chklock(vp, op, offset, size, mode, ct) (0)
#define cleanlocks(vp, pid, foo) do { } while (0)
#define cleanshares(vp, pid) do { } while (0)
/*
* We will use va_spare is place of Solaris' va_mask.
* This field is initialized in zfs_setattr().
@ -80,6 +95,9 @@ vn_is_readonly(vnode_t *vp)
#define va_blksize va_blocksize
#define va_seq va_gen
#define MAXOFFSET_T OFF_MAX
#define EXCL 0
#define AT_TYPE 0x0001
#define AT_MODE 0x0002
#define AT_UID 0x0004
@ -95,6 +113,8 @@ vn_is_readonly(vnode_t *vp)
#define AT_BLKSIZE 0x1000
#define AT_NBLOCKS 0x2000
#define AT_SEQ 0x4000
#define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
#define ACCESSED (AT_ATIME)
#define STATE_CHANGED (AT_CTIME)
@ -122,10 +142,15 @@ vattr_init_mask(vattr_t *vap)
vap->va_mask |= AT_MODE;
}
enum create { CRCREAT };
#define FCREAT O_CREAT
#define FTRUNC O_TRUNC
#define FDSYNC FFSYNC
#define FRSYNC FFSYNC
#define FSYNC FFSYNC
#define FOFFMAX 0x00
enum create { CRCREAT };
static __inline int
zfs_vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode,
vnode_t **vpp, enum create crwhy, mode_t umask)
@ -185,7 +210,6 @@ zfs_vn_rdwr(enum uio_rw rw, vnode_t *vp, caddr_t base, ssize_t len,
#define vn_rdwr(rw, vp, base, len, offset, seg, ioflag, ulimit, cr, residp) \
zfs_vn_rdwr((rw), (vp), (base), (len), (offset), (seg), (ioflag), (ulimit), (cr), (residp))
#define FSYNC MNT_WAIT
static __inline int
zfs_vop_fsync(vnode_t *vp, int flag, cred_t *cr)
{
@ -199,7 +223,7 @@ zfs_vop_fsync(vnode_t *vp, int flag, cred_t *cr)
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
goto drop;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
error = VOP_FSYNC(vp, flag, td);
error = VOP_FSYNC(vp, MNT_WAIT, td);
VOP_UNLOCK(vp, 0, td);
vn_finished_write(mp);
drop:

View File

@ -57,6 +57,7 @@
#include <sys/dsl_synctask.h>
#include <sys/fs/zfs.h>
#include <sys/callb.h>
#include <sys/sunddi.h>
int zio_taskq_threads = 0;
SYSCTL_DECL(_vfs_zfs);

View File

@ -35,6 +35,7 @@
#include <sys/vdev_impl.h>
#include <sys/zfs_ioctl.h>
#include <sys/utsname.h>
#include <sys/sunddi.h>
#ifdef _KERNEL
#include <sys/kobj.h>
#endif

View File

@ -25,6 +25,7 @@
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
@ -35,6 +36,7 @@
#include <sys/proc.h>
#include <sys/errno.h>
#include <sys/uio.h>
#include <sys/buf.h>
#include <sys/file.h>
#include <sys/kmem.h>
#include <sys/conf.h>
@ -50,6 +52,9 @@
#include <sys/dsl_dir.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_prop.h>
#include <sys/sunddi.h>
#include <sys/policy.h>
#include <sys/zone.h>
#include <sys/nvpair.h>
#include <sys/mount.h>
#include <sys/taskqueue.h>

View File

@ -37,6 +37,7 @@
#include <sys/zfs_dir.h>
#include <sys/zil.h>
#include <sys/byteorder.h>
#include <sys/policy.h>
#include <sys/stat.h>
#include <sys/acl.h>
#include <sys/dmu.h>
@ -234,7 +235,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
*/
if (len > zfs_immediate_write_sz)
write_state = WR_INDIRECT;
else if (ioflag & IO_SYNC)
else if (ioflag & FDSYNC)
write_state = WR_COPIED;
else
write_state = WR_NEED_COPY;

View File

@ -47,9 +47,11 @@
#include <sys/spa.h>
#include <sys/zap.h>
#include <sys/varargs.h>
#include <sys/policy.h>
#include <sys/atomic.h>
#include <sys/zfs_ioctl.h>
#include <sys/zfs_ctldir.h>
#include <sys/sunddi.h>
#include <sys/dnlc.h>
struct mtx atomic_mtx;

File diff suppressed because it is too large Load Diff

View File

@ -43,11 +43,13 @@
* run before opening and using a device.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/errno.h>
#include <sys/uio.h>
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/kmem.h>
#include <sys/conf.h>
#include <sys/cmn_err.h>
@ -56,8 +58,11 @@
#include <sys/spa.h>
#include <sys/zio.h>
#include <sys/dsl_prop.h>
#include <sys/dkio.h>
#include <sys/byteorder.h>
#include <sys/sunddi.h>
#include <sys/dirent.h>
#include <sys/policy.h>
#include <sys/fs/zfs.h>
#include <sys/zfs_ioctl.h>
#include <sys/zil.h>

View File

@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/libkern.h>
#include <sys/misc.h>
#include <sys/sunddi.h>
char hw_serial[11] = "0";

View File

@ -29,12 +29,17 @@
#ifndef _OPENSOLARIS_SYS_MISC_H_
#define _OPENSOLARIS_SYS_MISC_H_
#define _FIOFFS (INT_MIN)
#define _FIOGDIO (INT_MIN+1)
#define _FIOSDIO (INT_MIN+2)
#define _FIO_SEEK_DATA FIOSEEKDATA
#define _FIO_SEEK_HOLE FIOSEEKHOLE
struct opensolaris_utsname {
char *nodename;
};
extern char hw_serial[11];
extern struct opensolaris_utsname utsname;
int ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result);
#endif /* _OPENSOLARIS_SYS_MISC_H_ */

View File

@ -0,0 +1,36 @@
/*-
* Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _OPENSOLARIS_SYS_SUNDDI_H_
#define _OPENSOLARIS_SYS_SUNDDI_H_
#define ddi_copyin(from, to, size, flag) (bcopy((from), (to), (size)), 0)
#define ddi_copyout(from, to, size, flag) (bcopy((from), (to), (size)), 0)
int ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result);
#endif /* _OPENSOLARIS_SYS_SUNDDI_H_ */

View File

@ -49,6 +49,7 @@ typedef short index_t;
typedef off_t offset_t;
typedef long ptrdiff_t; /* pointer difference */
typedef void pathname_t;
typedef int64_t rlim64_t;
#else

View File

@ -40,6 +40,7 @@
typedef struct vnode vnode_t;
typedef struct vattr vattr_t;
typedef void caller_context_t;
typedef struct vop_vector vnodeops_t;
#define vop_fid vop_vptofh
@ -63,11 +64,25 @@ vn_is_readonly(vnode_t *vp)
#define VN_RELE(v) vrele(v)
#define VN_URELE(v) vput(v)
#define VOP_REALVP(vp, vpp) (*(vpp) = (vp), 0)
#define vnevent_remove(vp) do { } while (0)
#define vnevent_rmdir(vp) do { } while (0)
#define vnevent_rename_src(vp) do { } while (0)
#define vnevent_rename_dest(vp) do { } while (0)
#define IS_DEVVP(vp) \
((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO)
#define MODEMASK ALLPERMS
#define specvp(vp, rdev, type, cr) (VN_HOLD(vp), (vp))
#define MANDMODE(mode) (0)
#define chklock(vp, op, offset, size, mode, ct) (0)
#define cleanlocks(vp, pid, foo) do { } while (0)
#define cleanshares(vp, pid) do { } while (0)
/*
* We will use va_spare is place of Solaris' va_mask.
* This field is initialized in zfs_setattr().
@ -80,6 +95,9 @@ vn_is_readonly(vnode_t *vp)
#define va_blksize va_blocksize
#define va_seq va_gen
#define MAXOFFSET_T OFF_MAX
#define EXCL 0
#define AT_TYPE 0x0001
#define AT_MODE 0x0002
#define AT_UID 0x0004
@ -95,6 +113,8 @@ vn_is_readonly(vnode_t *vp)
#define AT_BLKSIZE 0x1000
#define AT_NBLOCKS 0x2000
#define AT_SEQ 0x4000
#define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
#define ACCESSED (AT_ATIME)
#define STATE_CHANGED (AT_CTIME)
@ -122,10 +142,15 @@ vattr_init_mask(vattr_t *vap)
vap->va_mask |= AT_MODE;
}
enum create { CRCREAT };
#define FCREAT O_CREAT
#define FTRUNC O_TRUNC
#define FDSYNC FFSYNC
#define FRSYNC FFSYNC
#define FSYNC FFSYNC
#define FOFFMAX 0x00
enum create { CRCREAT };
static __inline int
zfs_vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode,
vnode_t **vpp, enum create crwhy, mode_t umask)
@ -185,7 +210,6 @@ zfs_vn_rdwr(enum uio_rw rw, vnode_t *vp, caddr_t base, ssize_t len,
#define vn_rdwr(rw, vp, base, len, offset, seg, ioflag, ulimit, cr, residp) \
zfs_vn_rdwr((rw), (vp), (base), (len), (offset), (seg), (ioflag), (ulimit), (cr), (residp))
#define FSYNC MNT_WAIT
static __inline int
zfs_vop_fsync(vnode_t *vp, int flag, cred_t *cr)
{
@ -199,7 +223,7 @@ zfs_vop_fsync(vnode_t *vp, int flag, cred_t *cr)
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
goto drop;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
error = VOP_FSYNC(vp, flag, td);
error = VOP_FSYNC(vp, MNT_WAIT, td);
VOP_UNLOCK(vp, 0, td);
vn_finished_write(mp);
drop:

View File

@ -57,6 +57,7 @@
#include <sys/dsl_synctask.h>
#include <sys/fs/zfs.h>
#include <sys/callb.h>
#include <sys/sunddi.h>
int zio_taskq_threads = 0;
SYSCTL_DECL(_vfs_zfs);

View File

@ -35,6 +35,7 @@
#include <sys/vdev_impl.h>
#include <sys/zfs_ioctl.h>
#include <sys/utsname.h>
#include <sys/sunddi.h>
#ifdef _KERNEL
#include <sys/kobj.h>
#endif

View File

@ -25,6 +25,7 @@
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
@ -35,6 +36,7 @@
#include <sys/proc.h>
#include <sys/errno.h>
#include <sys/uio.h>
#include <sys/buf.h>
#include <sys/file.h>
#include <sys/kmem.h>
#include <sys/conf.h>
@ -50,6 +52,9 @@
#include <sys/dsl_dir.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_prop.h>
#include <sys/sunddi.h>
#include <sys/policy.h>
#include <sys/zone.h>
#include <sys/nvpair.h>
#include <sys/mount.h>
#include <sys/taskqueue.h>

View File

@ -37,6 +37,7 @@
#include <sys/zfs_dir.h>
#include <sys/zil.h>
#include <sys/byteorder.h>
#include <sys/policy.h>
#include <sys/stat.h>
#include <sys/acl.h>
#include <sys/dmu.h>
@ -234,7 +235,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
*/
if (len > zfs_immediate_write_sz)
write_state = WR_INDIRECT;
else if (ioflag & IO_SYNC)
else if (ioflag & FDSYNC)
write_state = WR_COPIED;
else
write_state = WR_NEED_COPY;

View File

@ -47,9 +47,11 @@
#include <sys/spa.h>
#include <sys/zap.h>
#include <sys/varargs.h>
#include <sys/policy.h>
#include <sys/atomic.h>
#include <sys/zfs_ioctl.h>
#include <sys/zfs_ctldir.h>
#include <sys/sunddi.h>
#include <sys/dnlc.h>
struct mtx atomic_mtx;

File diff suppressed because it is too large Load Diff

View File

@ -43,11 +43,13 @@
* run before opening and using a device.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/errno.h>
#include <sys/uio.h>
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/kmem.h>
#include <sys/conf.h>
#include <sys/cmn_err.h>
@ -56,8 +58,11 @@
#include <sys/spa.h>
#include <sys/zio.h>
#include <sys/dsl_prop.h>
#include <sys/dkio.h>
#include <sys/byteorder.h>
#include <sys/sunddi.h>
#include <sys/dirent.h>
#include <sys/policy.h>
#include <sys/fs/zfs.h>
#include <sys/zfs_ioctl.h>
#include <sys/zil.h>