aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2011-03-29 23:04:39 -0700
committerBrian Behlendorf <[email protected]>2011-04-07 09:51:57 -0700
commitc85b224fafacafa49817101f26f0a9760a8d05d1 (patch)
tree4e08918675d6590cd332e51162c9ecccb9794091 /module/zfs
parentd433c206515e567c52ce09589033405a0ae3716e (diff)
Call d_instantiate before unlocking inode
Under Linux a dentry referencing an inode must be instantiated before the inode is unlocked. To accomplish this without overly modifing the core ZFS code the dentry it passed via the vattr_t. There are cases such as replay when a dentry is not available. In which case it is obviously not initialized at inode creation time, if a dentry is needed it will be spliced as when required via d_lookup().
Diffstat (limited to 'module/zfs')
-rw-r--r--module/zfs/zfs_dir.c4
-rw-r--r--module/zfs/zfs_znode.c11
-rw-r--r--module/zfs/zpl_inode.c24
3 files changed, 12 insertions, 27 deletions
diff --git a/module/zfs/zfs_dir.c b/module/zfs/zfs_dir.c
index f54ed1912..355b0ef0a 100644
--- a/module/zfs/zfs_dir.c
+++ b/module/zfs/zfs_dir.c
@@ -774,10 +774,6 @@ zfs_link_create(zfs_dirlock_t *dl, znode_t *zp, dmu_tx_t *tx, int flag)
8, 1, &value, tx);
ASSERT(error == 0);
-#ifdef HAVE_DNLC
- dnlc_update(ZTOI(dzp), dl->dl_name, vp);
-#endif /* HAVE_DNLC */
-
return (0);
}
diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c
index 1fe88499b..f9ea2a0eb 100644
--- a/module/zfs/zfs_znode.c
+++ b/module/zfs/zfs_znode.c
@@ -322,7 +322,8 @@ zfs_inode_set_ops(zfs_sb_t *zsb, struct inode *ip)
*/
static znode_t *
zfs_znode_alloc(zfs_sb_t *zsb, dmu_buf_t *db, int blksz,
- dmu_object_type_t obj_type, uint64_t obj, sa_handle_t *hdl)
+ dmu_object_type_t obj_type, uint64_t obj, sa_handle_t *hdl,
+ struct dentry *dentry)
{
znode_t *zp;
struct inode *ip;
@@ -379,6 +380,9 @@ zfs_znode_alloc(zfs_sb_t *zsb, dmu_buf_t *db, int blksz,
if (insert_inode_locked(ip))
goto error;
+ if (dentry)
+ d_instantiate(dentry, ip);
+
mutex_enter(&zsb->z_znodes_lock);
list_insert_tail(&zsb->z_all_znodes, zp);
membar_producer();
@@ -675,7 +679,8 @@ zfs_mknode(znode_t *dzp, vattr_t *vap, dmu_tx_t *tx, cred_t *cr,
VERIFY(sa_replace_all_by_template(sa_hdl, sa_attrs, cnt, tx) == 0);
if (!(flag & IS_ROOT_NODE)) {
- *zpp = zfs_znode_alloc(zsb, db, 0, obj_type, obj, sa_hdl);
+ *zpp = zfs_znode_alloc(zsb, db, 0, obj_type, obj, sa_hdl,
+ vap->va_dentry);
ASSERT(*zpp != NULL);
ASSERT(dzp != NULL);
err = zpl_xattr_security_init(ZTOI(*zpp), ZTOI(dzp));
@@ -866,7 +871,7 @@ zfs_zget(zfs_sb_t *zsb, uint64_t obj_num, znode_t **zpp)
* bonus buffer.
*/
zp = zfs_znode_alloc(zsb, db, doi.doi_data_block_size,
- doi.doi_bonus_type, obj_num, NULL);
+ doi.doi_bonus_type, obj_num, NULL, NULL);
if (zp == NULL) {
err = ENOENT;
} else {
diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
index fcc19b004..029a4038b 100644
--- a/module/zfs/zpl_inode.c
+++ b/module/zfs/zpl_inode.c
@@ -66,14 +66,10 @@ zpl_create(struct inode *dir, struct dentry *dentry, int mode,
vap->va_mask = ATTR_MODE;
vap->va_uid = crgetfsuid(cr);
vap->va_gid = crgetfsgid(cr);
+ vap->va_dentry = dentry;
error = -zfs_create(dir, (char *)dentry->d_name.name,
vap, 0, mode, &ip, cr, 0, NULL);
- if (error)
- goto out;
-
- d_instantiate(dentry, ip);
-out:
kmem_free(vap, sizeof(vattr_t));
crfree(cr);
ASSERT3S(error, <=, 0);
@@ -96,14 +92,10 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
vap->va_rdev = rdev;
vap->va_uid = crgetfsuid(cr);
vap->va_gid = crgetfsgid(cr);
+ vap->va_dentry = dentry;
error = -zfs_create(dir, (char *)dentry->d_name.name,
vap, 0, mode, &ip, cr, 0, NULL);
- if (error)
- goto out;
-
- d_instantiate(dentry, ip);
-out:
kmem_free(vap, sizeof(vattr_t));
crfree(cr);
ASSERT3S(error, <=, 0);
@@ -139,13 +131,9 @@ zpl_mkdir(struct inode *dir, struct dentry *dentry, int mode)
vap->va_mask = ATTR_MODE;
vap->va_uid = crgetfsuid(cr);
vap->va_gid = crgetfsgid(cr);
+ vap->va_dentry = dentry;
error = -zfs_mkdir(dir, dname(dentry), vap, &ip, cr, 0, NULL);
- if (error)
- goto out;
-
- d_instantiate(dentry, ip);
-out:
kmem_free(vap, sizeof(vattr_t));
crfree(cr);
ASSERT3S(error, <=, 0);
@@ -264,13 +252,9 @@ zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
vap->va_mask = ATTR_MODE;
vap->va_uid = crgetfsuid(cr);
vap->va_gid = crgetfsgid(cr);
+ vap->va_dentry = dentry;
error = -zfs_symlink(dir, dname(dentry), vap, (char *)name, &ip, cr, 0);
- if (error)
- goto out;
-
- d_instantiate(dentry, ip);
-out:
kmem_free(vap, sizeof(vattr_t));
crfree(cr);
ASSERT3S(error, <=, 0);