aboutsummaryrefslogtreecommitdiffstats
path: root/include/sys/zfs_znode.h
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2011-02-08 11:16:06 -0800
committerBrian Behlendorf <[email protected]>2011-02-10 09:27:21 -0800
commit3558fd73b5d863304102f6745c26e0b592aca60a (patch)
treeb22e26afbf6c494d34032876fb9be4d21d4e8ed7 /include/sys/zfs_znode.h
parent6149f4c45fc905761a6f636ea9e14ff76ce6c842 (diff)
Prototype/structure update for Linux
I appologize in advance why to many things ended up in this commit. When it could be seperated in to a whole series of commits teasing that all apart now would take considerable time and I'm not sure there's much merrit in it. As such I'll just summerize the intent of the changes which are all (or partly) in this commit. Broadly the intent is to remove as much Solaris specific code as possible and replace it with native Linux equivilants. More specifically: 1) Replace all instances of zfsvfs_t with zfs_sb_t. While the type is largely the same calling it private super block data rather than a zfsvfs is more consistent with how Linux names this. While non critical it makes the code easier to read when your thinking in Linux friendly VFS terms. 2) Replace vnode_t with struct inode. The Linux VFS doesn't have the notion of a vnode and there's absolutely no good reason to create one. There are in fact several good reasons to remove it. It just adds overhead on Linux if we were to manage one, it conplicates the code, and it likely will lead to bugs so there's a good change it will be out of date. The code has been updated to remove all need for this type. 3) Replace all vtype_t's with umode types. Along with this shift all uses of types to mode bits. The Solaris code would pass a vtype which is redundant with the Linux mode. Just update all the code to use the Linux mode macros and remove this redundancy. 4) Remove using of vn_* helpers and replace where needed with inode helpers. The big example here is creating iput_aync to replace vn_rele_async. Other vn helpers will be addressed as needed but they should be be emulated. They are a Solaris VFS'ism and should simply be replaced with Linux equivilants. 5) Update znode alloc/free code. Under Linux it's common to embed the inode specific data with the inode itself. This removes the need for an extra memory allocation. In zfs this information is called a znode and it now embeds the inode with it. Allocators have been updated accordingly. 6) Minimal integration with the vfs flags for setting up the super block and handling mount options has been added this code will need to be refined but functionally it's all there. This will be the first and last of these to large to review commits.
Diffstat (limited to 'include/sys/zfs_znode.h')
-rw-r--r--include/sys/zfs_znode.h76
1 files changed, 40 insertions, 36 deletions
diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h
index 4dbecb4b5..2f25cc7fe 100644
--- a/include/sys/zfs_znode.h
+++ b/include/sys/zfs_znode.h
@@ -69,7 +69,7 @@ extern "C" {
pflags |= attr; \
else \
pflags &= ~attr; \
- VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_FLAGS(zp->z_zfsvfs), \
+ VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_FLAGS(zp->z_sb), \
&pflags, sizeof (pflags), tx)); \
}
@@ -181,8 +181,6 @@ typedef struct zfs_dirlock {
} zfs_dirlock_t;
typedef struct znode {
- struct zfsvfs *z_zfsvfs;
- vnode_t *z_vnode;
uint64_t z_id; /* object ID for this znode */
kmutex_t z_lock; /* znode modification lock */
krwlock_t z_parent_lock; /* parent lock for directories */
@@ -235,48 +233,52 @@ typedef struct znode {
/*
* Convert between znode pointers and inode pointers
*/
-#define ZTOI(ZP) (&((ZP)->z_inode))
-#define ITOZ(IP) (container_of((IP), znode_t, z_inode))
-
-/* XXX - REMOVE ME ONCE THE OTHER BUILD ISSUES ARE RESOLVED */
-#define ZTOV(ZP) ((ZP)->z_vnode)
-#define VTOZ(VP) ((znode_t *)(VP)->v_data)
+#define ZTOI(znode) (&((znode)->z_inode))
+#define ITOZ(inode) (container_of((inode), znode_t, z_inode))
+#define VTOZSB(vfs) ((zfs_sb_t *)((vfs)->mnt_sb->s_fs_info))
+#define ZTOZSB(znode) ((zfs_sb_t *)(ZTOI(znode)->i_sb->s_fs_info))
+#define ITOZSB(inode) ((zfs_sb_t *)((inode)->i_sb->s_fs_info))
+#define S_ISDEV(mode) (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode))
/*
* ZFS_ENTER() is called on entry to each ZFS inode and vfs operation.
* ZFS_EXIT() must be called before exitting the vop.
* ZFS_VERIFY_ZP() verifies the znode is valid.
*/
-#define ZFS_ENTER(zfsvfs) \
+#define ZFS_ENTER(zsb) \
{ \
- rrw_enter(&(zfsvfs)->z_teardown_lock, RW_READER, FTAG); \
- if ((zfsvfs)->z_unmounted) { \
- ZFS_EXIT(zfsvfs); \
+ rrw_enter(&(zsb)->z_teardown_lock, RW_READER, FTAG); \
+ if ((zsb)->z_unmounted) { \
+ ZFS_EXIT(zsb); \
return (EIO); \
} \
}
-#define ZFS_EXIT(zfsvfs) rrw_exit(&(zfsvfs)->z_teardown_lock, FTAG)
+#define ZFS_EXIT(zsb) \
+ { \
+ rrw_exit(&(zsb)->z_teardown_lock, FTAG); \
+ tsd_exit(); \
+ }
#define ZFS_VERIFY_ZP(zp) \
if ((zp)->z_sa_hdl == NULL) { \
- ZFS_EXIT((zp)->z_zfsvfs); \
+ ZFS_EXIT(ZTOZSB(zp)); \
return (EIO); \
- } \
+ }
/*
* Macros for dealing with dmu_buf_hold
*/
#define ZFS_OBJ_HASH(obj_num) ((obj_num) & (ZFS_OBJ_MTX_SZ - 1))
-#define ZFS_OBJ_MUTEX(zfsvfs, obj_num) \
- (&(zfsvfs)->z_hold_mtx[ZFS_OBJ_HASH(obj_num)])
-#define ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num) \
- mutex_enter(ZFS_OBJ_MUTEX((zfsvfs), (obj_num)))
-#define ZFS_OBJ_HOLD_TRYENTER(zfsvfs, obj_num) \
- mutex_tryenter(ZFS_OBJ_MUTEX((zfsvfs), (obj_num)))
-#define ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num) \
- mutex_exit(ZFS_OBJ_MUTEX((zfsvfs), (obj_num)))
+#define ZFS_OBJ_MUTEX(zsb, obj_num) \
+ (&(zsb)->z_hold_mtx[ZFS_OBJ_HASH(obj_num)])
+#define ZFS_OBJ_HOLD_ENTER(zsb, obj_num) \
+ mutex_enter(ZFS_OBJ_MUTEX((zsb), (obj_num)))
+#define ZFS_OBJ_HOLD_TRYENTER(zsb, obj_num) \
+ mutex_tryenter(ZFS_OBJ_MUTEX((zsb), (obj_num)))
+#define ZFS_OBJ_HOLD_EXIT(zsb, obj_num) \
+ mutex_exit(ZFS_OBJ_MUTEX((zsb), (obj_num)))
/*
* Macros to encode/decode ZFS stored time values from/to struct timespec
@@ -296,15 +298,15 @@ typedef struct znode {
/*
* Timestamp defines
*/
-#define ACCESSED (AT_ATIME)
-#define STATE_CHANGED (AT_CTIME)
-#define CONTENT_MODIFIED (AT_MTIME | AT_CTIME)
+#define ACCESSED (ATTR_ATIME)
+#define STATE_CHANGED (ATTR_CTIME)
+#define CONTENT_MODIFIED (ATTR_MTIME | ATTR_CTIME)
-#define ZFS_ACCESSTIME_STAMP(zfsvfs, zp) \
- if ((zfsvfs)->z_atime && !((zfsvfs)->z_vfs->vfs_flag & VFS_RDONLY)) \
+#define ZFS_ACCESSTIME_STAMP(zsb, zp) \
+ if ((zsb)->z_atime && !((zsb)->z_vfs->mnt_flags & MNT_READONLY)) \
zfs_tstamp_update_setup(zp, ACCESSED, NULL, NULL, B_FALSE);
-extern int zfs_init_fs(zfsvfs_t *, znode_t **);
+extern int zfs_init_fs(zfs_sb_t *, znode_t **);
extern void zfs_set_dataprop(objset_t *);
extern void zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *,
dmu_tx_t *tx);
@@ -314,18 +316,19 @@ extern void zfs_grow_blocksize(znode_t *, uint64_t, dmu_tx_t *);
extern int zfs_freesp(znode_t *, uint64_t, uint64_t, int, boolean_t);
extern void zfs_znode_init(void);
extern void zfs_znode_fini(void);
-extern int zfs_zget(zfsvfs_t *, uint64_t, znode_t **);
+extern int zfs_zget(zfs_sb_t *, uint64_t, znode_t **);
extern int zfs_rezget(znode_t *);
extern void zfs_zinactive(znode_t *);
extern void zfs_znode_delete(znode_t *, dmu_tx_t *);
-extern void zfs_znode_free(znode_t *);
extern void zfs_remove_op_tables(void);
extern int zfs_create_op_tables(void);
-extern int zfs_sync(vfs_t *vfsp, short flag, cred_t *cr);
+extern int zfs_sync(zfs_sb_t *, short, cred_t *);
extern dev_t zfs_cmpldev(uint64_t);
extern int zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value);
extern int zfs_get_stats(objset_t *os, nvlist_t *nv);
extern void zfs_znode_dmu_fini(znode_t *);
+extern int zfs_inode_alloc(struct super_block *, struct inode **ip);
+extern void zfs_inode_destroy(struct inode *);
extern void zfs_inode_update(znode_t *);
extern void zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
@@ -347,12 +350,13 @@ extern void zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
extern void zfs_log_truncate(zilog_t *zilog, dmu_tx_t *tx, int txtype,
znode_t *zp, uint64_t off, uint64_t len);
extern void zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype,
- znode_t *zp, vattr_t *vap, uint_t mask_applied, zfs_fuid_info_t *fuidp);
+ znode_t *zp, struct iattr *attr, uint_t mask_applied,
+ zfs_fuid_info_t *fuidp);
extern void zfs_log_acl(zilog_t *zilog, dmu_tx_t *tx, znode_t *zp,
vsecattr_t *vsecp, zfs_fuid_info_t *fuidp);
extern void zfs_xvattr_set(znode_t *zp, xvattr_t *xvap, dmu_tx_t *tx);
-extern void zfs_upgrade(zfsvfs_t *zfsvfs, dmu_tx_t *tx);
-extern int zfs_create_share_dir(zfsvfs_t *zfsvfs, dmu_tx_t *tx);
+extern void zfs_upgrade(zfs_sb_t *zsb, dmu_tx_t *tx);
+extern int zfs_create_share_dir(zfs_sb_t *zsb, dmu_tx_t *tx);
#if defined(HAVE_UIO_RW)
extern caddr_t zfs_map_page(page_t *, enum seg_rw);