summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/fs/zfs/sys
diff options
context:
space:
mode:
authorahrens <none@none>2007-08-02 21:23:46 -0700
committerahrens <none@none>2007-08-02 21:23:46 -0700
commit91ebeef555ce7f899b6270a3c2df47b51f7ad59a (patch)
tree7c2ea33b8ecbb85fdd82366244cb0850dbba3287 /usr/src/uts/common/fs/zfs/sys
parent03509b53a806cb39ca94c9a1c00f1c6405321554 (diff)
downloadillumos-joyent-91ebeef555ce7f899b6270a3c2df47b51f7ad59a.tar.gz
6393351 unique_* could be improved
6553348 assertion failed: ab->b_flags & (1 << 3) at line 2572 of arc.c 6582408 ::arc should accept -k/-m/-g to print in kilo/mega/giga-bytes 6582438 should have generic reader-priority rwlock for spa_config locks 6582441 zfs_cmd_t should only be used to pass arguments to/from userland 6582456 property code is overdue for some spring cleaning 6588564 zpl unmount lock should use regular rwlock
Diffstat (limited to 'usr/src/uts/common/fs/zfs/sys')
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dmu.h2
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dmu_objset.h2
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dnode.h2
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dsl_dataset.h4
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dsl_deleg.h35
-rw-r--r--usr/src/uts/common/fs/zfs/sys/refcount.h4
-rw-r--r--usr/src/uts/common/fs/zfs/sys/rprwlock.h61
-rw-r--r--usr/src/uts/common/fs/zfs/sys/spa_impl.h17
-rw-r--r--usr/src/uts/common/fs/zfs/sys/unique.h13
-rw-r--r--usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h2
-rw-r--r--usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h7
-rw-r--r--usr/src/uts/common/fs/zfs/sys/zfs_znode.h8
-rw-r--r--usr/src/uts/common/fs/zfs/sys/zvol.h4
13 files changed, 103 insertions, 58 deletions
diff --git a/usr/src/uts/common/fs/zfs/sys/dmu.h b/usr/src/uts/common/fs/zfs/sys/dmu.h
index eba1e64dc4..121152632d 100644
--- a/usr/src/uts/common/fs/zfs/sys/dmu.h
+++ b/usr/src/uts/common/fs/zfs/sys/dmu.h
@@ -157,7 +157,7 @@ void zfs_znode_byteswap(void *buf, size_t size);
int dmu_objset_open(const char *name, dmu_objset_type_t type, int mode,
objset_t **osp);
void dmu_objset_close(objset_t *os);
-int dmu_objset_evict_dbufs(objset_t *os, int try);
+int dmu_objset_evict_dbufs(objset_t *os, boolean_t try);
int dmu_objset_create(const char *name, dmu_objset_type_t type,
objset_t *clone_parent,
void (*func)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx), void *arg);
diff --git a/usr/src/uts/common/fs/zfs/sys/dmu_objset.h b/usr/src/uts/common/fs/zfs/sys/dmu_objset.h
index a401930af8..fbc1450b47 100644
--- a/usr/src/uts/common/fs/zfs/sys/dmu_objset.h
+++ b/usr/src/uts/common/fs/zfs/sys/dmu_objset.h
@@ -108,7 +108,7 @@ uint64_t dmu_objset_fsid_guid(objset_t *os);
int dmu_objset_find(char *name, int func(char *, void *), void *arg,
int flags);
void dmu_objset_byteswap(void *buf, size_t size);
-int dmu_objset_evict_dbufs(objset_t *os, int try);
+int dmu_objset_evict_dbufs(objset_t *os, boolean_t try);
/* called from dsl */
void dmu_objset_sync(objset_impl_t *os, zio_t *zio, dmu_tx_t *tx);
diff --git a/usr/src/uts/common/fs/zfs/sys/dnode.h b/usr/src/uts/common/fs/zfs/sys/dnode.h
index 327e538cf8..02f9de3f06 100644
--- a/usr/src/uts/common/fs/zfs/sys/dnode.h
+++ b/usr/src/uts/common/fs/zfs/sys/dnode.h
@@ -226,7 +226,7 @@ void dnode_init(void);
void dnode_fini(void);
int dnode_next_offset(dnode_t *dn, boolean_t hole, uint64_t *off, int minlvl,
uint64_t blkfill, uint64_t txg);
-int dnode_evict_dbufs(dnode_t *dn, int try);
+int dnode_evict_dbufs(dnode_t *dn, boolean_t try);
#ifdef ZFS_DEBUG
diff --git a/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h b/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h
index 8cfc1dcc98..2a8d354be4 100644
--- a/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h
+++ b/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h
@@ -87,6 +87,7 @@ typedef struct dsl_dataset {
dsl_dataset_phys_t *ds_phys;
dmu_buf_t *ds_dbuf;
uint64_t ds_object;
+ uint64_t ds_fsid_guid;
/* only used in syncing context: */
struct dsl_dataset *ds_prev; /* only valid for non-snapshots */
@@ -110,6 +111,9 @@ typedef struct dsl_dataset {
/* no locking; only for making guesses */
uint64_t ds_trysnap_txg;
+ /* for objset_open() */
+ kmutex_t ds_opening_lock;
+
/* Protected by ds_lock; keep at end of struct for better locality */
char ds_snapname[MAXNAMELEN];
} dsl_dataset_t;
diff --git a/usr/src/uts/common/fs/zfs/sys/dsl_deleg.h b/usr/src/uts/common/fs/zfs/sys/dsl_deleg.h
index 1cc22b3dc8..1d01123c77 100644
--- a/usr/src/uts/common/fs/zfs/sys/dsl_deleg.h
+++ b/usr/src/uts/common/fs/zfs/sys/dsl_deleg.h
@@ -23,8 +23,8 @@
* Use is subject to license terms.
*/
-#ifndef _SYS_DSL_PERMS_H
-#define _SYS_DSL_PERMS_H
+#ifndef _SYS_DSL_DELEG_H
+#define _SYS_DSL_DELEG_H
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -48,30 +48,13 @@ extern "C" {
#define ZFS_DELEG_PERM_SHARE "share"
#define ZFS_DELEG_PERM_SEND "send"
#define ZFS_DELEG_PERM_RECEIVE "receive"
-#define ZFS_DELEG_PERM_QUOTA "quota"
-#define ZFS_DELEG_PERM_RESERVATION "reservation"
-#define ZFS_DELEG_PERM_VOLSIZE "volsize"
-#define ZFS_DELEG_PERM_RECORDSIZE "recordsize"
-#define ZFS_DELEG_PERM_MOUNTPOINT "mountpoint"
-#define ZFS_DELEG_PERM_SHARENFS "sharenfs"
-#define ZFS_DELEG_PERM_CHECKSUM "checksum"
-#define ZFS_DELEG_PERM_COMPRESSION "compression"
-#define ZFS_DELEG_PERM_ATIME "atime"
-#define ZFS_DELEG_PERM_DEVICES "devices"
-#define ZFS_DELEG_PERM_EXEC "exec"
-#define ZFS_DELEG_PERM_SETUID "setuid"
-#define ZFS_DELEG_PERM_READONLY "readonly"
-#define ZFS_DELEG_PERM_ZONED "zoned"
-#define ZFS_DELEG_PERM_SNAPDIR "snapdir"
-#define ZFS_DELEG_PERM_ACLMODE "aclmode"
-#define ZFS_DELEG_PERM_ACLINHERIT "aclinherit"
#define ZFS_DELEG_PERM_ALLOW "allow"
-#define ZFS_DELEG_PERM_CANMOUNT "canmount"
#define ZFS_DELEG_PERM_USERPROP "userprop"
-#define ZFS_DELEG_PERM_SHAREISCSI "shareiscsi"
-#define ZFS_DELEG_PERM_XATTR "xattr"
-#define ZFS_DELEG_PERM_COPIES "copies"
-#define ZFS_DELEG_PERM_VERSION "version"
+
+/*
+ * Note: the names of properties that are marked delegatable are also
+ * valid delegated permissions
+ */
int dsl_deleg_get(const char *ddname, nvlist_t **nvp);
int dsl_deleg_set(const char *ddname, nvlist_t *nvp, boolean_t unset);
@@ -80,10 +63,10 @@ void dsl_deleg_set_create_perms(dsl_dir_t *dd, dmu_tx_t *tx, cred_t *cr);
int dsl_deleg_can_allow(char *ddname, nvlist_t *nvp, cred_t *cr);
int dsl_deleg_can_unallow(char *ddname, nvlist_t *nvp, cred_t *cr);
int dsl_deleg_destroy(objset_t *os, uint64_t zapobj, dmu_tx_t *tx);
-boolean_t dsl_delegation_on(objset_t *os);
+boolean_t dsl_delegation_on(objset_t *os);
#ifdef __cplusplus
}
#endif
-#endif /* _SYS_DSL_PERMS_H */
+#endif /* _SYS_DSL_DELEG_H */
diff --git a/usr/src/uts/common/fs/zfs/sys/refcount.h b/usr/src/uts/common/fs/zfs/sys/refcount.h
index 0b7e12f2cb..d3fe7b1f89 100644
--- a/usr/src/uts/common/fs/zfs/sys/refcount.h
+++ b/usr/src/uts/common/fs/zfs/sys/refcount.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -59,7 +59,7 @@ typedef struct refcount {
int64_t rc_removed_count;
} refcount_t;
-/* Note: refcount_t should be initialized to zero before use. */
+/* Note: refcount_t must be initialized with refcount_create() */
void refcount_create(refcount_t *rc);
void refcount_destroy(refcount_t *rc);
diff --git a/usr/src/uts/common/fs/zfs/sys/rprwlock.h b/usr/src/uts/common/fs/zfs/sys/rprwlock.h
new file mode 100644
index 0000000000..ba23799c9d
--- /dev/null
+++ b/usr/src/uts/common/fs/zfs/sys/rprwlock.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
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_RPRWLOCK_H
+#define _SYS_RPRWLOCK_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/inttypes.h>
+#include <sys/list.h>
+#include <sys/zfs_context.h>
+#include <sys/refcount.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct rprwlock {
+ kmutex_t rw_lock;
+ kthread_t *rw_writer;
+ kcondvar_t rw_cv;
+ refcount_t rw_count;
+} rprwlock_t;
+
+void rprw_init(rprwlock_t *rwl);
+void rprw_destroy(rprwlock_t *rwl);
+void rprw_enter_read(rprwlock_t *rwl, void *tag);
+void rprw_enter_write(rprwlock_t *rwl, void *tag);
+void rprw_enter(rprwlock_t *rwl, krw_t rw, void *tag);
+void rprw_exit(rprwlock_t *rwl, void *tag);
+boolean_t rprw_held(rprwlock_t *rwl, krw_t rw);
+#define RPRW_READ_HELD(x) rprw_held(x, RW_READER)
+#define RPRW_WRITE_HELD(x) rprw_held(x, RW_WRITER)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_RPRWLOCK_H */
diff --git a/usr/src/uts/common/fs/zfs/sys/spa_impl.h b/usr/src/uts/common/fs/zfs/sys/spa_impl.h
index 0d155d7c0c..c313c696a4 100644
--- a/usr/src/uts/common/fs/zfs/sys/spa_impl.h
+++ b/usr/src/uts/common/fs/zfs/sys/spa_impl.h
@@ -37,19 +37,13 @@
#include <sys/zfs_context.h>
#include <sys/avl.h>
#include <sys/refcount.h>
+#include <sys/rprwlock.h>
#include <sys/bplist.h>
#ifdef __cplusplus
extern "C" {
#endif
-typedef struct spa_config_lock {
- kmutex_t scl_lock;
- refcount_t scl_count;
- kthread_t *scl_writer;
- kcondvar_t scl_cv;
-} spa_config_lock_t;
-
typedef struct spa_error_entry {
zbookmark_t se_bookmark;
char *se_name;
@@ -152,11 +146,12 @@ struct spa {
uint64_t spa_bootfs; /* default boot filesystem */
boolean_t spa_delegation; /* delegation on/off */
/*
- * spa_refcnt must be the last element because it changes size based on
- * compilation options. In order for the MDB module to function
- * correctly, the other fields must remain in the same location.
+ * spa_refcnt & spa_config_lock must be the last elements
+ * because refcount_t changes size based on compilation options.
+ * In order for the MDB module to function correctly, the other
+ * fields must remain in the same location.
*/
- spa_config_lock_t spa_config_lock; /* configuration changes */
+ rprwlock_t spa_config_lock; /* configuration changes */
refcount_t spa_refcount; /* number of opens */
};
diff --git a/usr/src/uts/common/fs/zfs/sys/unique.h b/usr/src/uts/common/fs/zfs/sys/unique.h
index c8c177e3ca..2ef3093edf 100644
--- a/usr/src/uts/common/fs/zfs/sys/unique.h
+++ b/usr/src/uts/common/fs/zfs/sys/unique.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * 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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -39,8 +38,12 @@ extern "C" {
#define UNIQUE_BITS 56
void unique_init(void);
+void unique_fini(void);
-/* Return a new unique value. */
+/*
+ * Return a new unique value (which will not be uniquified against until
+ * it is unique_insert()-ed.
+ */
uint64_t unique_create(void);
/* Return a unique value, which equals the one passed in if possible. */
diff --git a/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h b/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h
index 8228fe4709..663e8ac64b 100644
--- a/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h
+++ b/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h
@@ -133,8 +133,6 @@ typedef struct zfs_cmd {
uint64_t zc_nvlist_dst; /* really (char *) */
uint64_t zc_nvlist_dst_size;
uint64_t zc_cookie;
- uint64_t zc_cred;
- uint64_t zc_dev;
uint64_t zc_objset_type;
uint64_t zc_perm_action;
uint64_t zc_history; /* really (char *) */
diff --git a/usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h b/usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h
index 7a9d578d6e..e76ccc3ce5 100644
--- a/usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h
+++ b/usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h
@@ -52,10 +52,9 @@ struct zfsvfs {
uint_t z_acl_mode; /* acl chmod/mode behavior */
uint_t z_acl_inherit; /* acl inheritance behavior */
boolean_t z_atime; /* enable atimes mount option */
- boolean_t z_unmounted1; /* unmounted phase 1 */
- boolean_t z_unmounted2; /* unmounted phase 2 */
- uint32_t z_op_cnt; /* vnode/vfs operations ref count */
- krwlock_t z_um_lock; /* rw lock for umount phase 2 */
+ boolean_t z_unmounted; /* unmounted */
+ krwlock_t z_unmount_lock;
+ krwlock_t z_unmount_inactive_lock;
list_t z_all_znodes; /* all vnodes in the fs */
kmutex_t z_znodes_lock; /* lock for z_all_znodes */
vnode_t *z_ctldir; /* .zfs directory pointer */
diff --git a/usr/src/uts/common/fs/zfs/sys/zfs_znode.h b/usr/src/uts/common/fs/zfs/sys/zfs_znode.h
index 4b731ba320..54f9c39619 100644
--- a/usr/src/uts/common/fs/zfs/sys/zfs_znode.h
+++ b/usr/src/uts/common/fs/zfs/sys/zfs_znode.h
@@ -192,13 +192,15 @@ typedef struct znode {
*/
#define ZFS_ENTER(zfsvfs) \
{ \
- atomic_add_32(&(zfsvfs)->z_op_cnt, 1); \
- if ((zfsvfs)->z_unmounted1) { \
+ if (rw_tryenter(&(zfsvfs)->z_unmount_lock, RW_READER) == 0) \
+ return (EIO); \
+ if ((zfsvfs)->z_unmounted) { \
ZFS_EXIT(zfsvfs); \
return (EIO); \
} \
}
-#define ZFS_EXIT(zfsvfs) atomic_add_32(&(zfsvfs)->z_op_cnt, -1)
+
+#define ZFS_EXIT(zfsvfs) rw_exit(&(zfsvfs)->z_unmount_lock)
/*
* Macros for dealing with dmu_buf_hold
diff --git a/usr/src/uts/common/fs/zfs/sys/zvol.h b/usr/src/uts/common/fs/zfs/sys/zvol.h
index 34f1ca1c31..f7a0f8fd4e 100644
--- a/usr/src/uts/common/fs/zfs/sys/zvol.h
+++ b/usr/src/uts/common/fs/zfs/sys/zvol.h
@@ -40,9 +40,9 @@ extern int zvol_check_volsize(uint64_t volsize, uint64_t blocksize);
extern int zvol_check_volblocksize(uint64_t volblocksize);
extern int zvol_get_stats(objset_t *os, nvlist_t *nv);
extern void zvol_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx);
-extern int zvol_create_minor(const char *, dev_t);
+extern int zvol_create_minor(const char *, major_t);
extern int zvol_remove_minor(const char *);
-extern int zvol_set_volsize(const char *, dev_t, uint64_t);
+extern int zvol_set_volsize(const char *, major_t, uint64_t);
extern int zvol_set_volblocksize(const char *, uint64_t);
extern int zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr);