diff options
author | Brian Behlendorf <[email protected]> | 2012-11-29 16:10:03 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-12-03 12:10:46 -0800 |
commit | e89260a1c8851ce05ea04b23606ba438b271d890 (patch) | |
tree | 599a29ba4468cec0231809ba0defa4ccc7876024 /module/zfs/zpl_inode.c | |
parent | 645fb9cc214c79c77378dd1e1fd2e3ef668bc848 (diff) |
Directory xattr znodes hold a reference on their parent
Unlike normal file or directory znodes, an xattr znode is
guaranteed to only have a single parent. Therefore, we can
take a refernce on that parent if it is provided at create
time and cache it. Additionally, we take care to cache it
on any subsequent zfs_zaccess() where the parent is provided
as an optimization.
This allows us to avoid needing to do a zfs_zget() when
setting up the SELinux security xattr in the create path.
This is critical because a hash lookup on the directory
will deadlock since it is locked.
The zpl_xattr_security_init() call has also been moved up
to the zpl layer to ensure TXs to create the required
xattrs are performed after the create TX. Otherwise we
run the risk of deadlocking on the open create TX.
Ideally the security xattr should be fully constructed
before the new inode is unlocked. However, doing so would
require far more extensive changes to ZFS.
This change may also have the benefitial side effect of
ensuring xattr directory znodes are evicted from the cache
before normal file or directory znodes due to the extra
reference.
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #671
Diffstat (limited to 'module/zfs/zpl_inode.c')
-rw-r--r-- | module/zfs/zpl_inode.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c index bb389f837..6175c2e93 100644 --- a/module/zfs/zpl_inode.c +++ b/module/zfs/zpl_inode.c @@ -92,8 +92,12 @@ zpl_create(struct inode *dir, struct dentry *dentry, zpl_umode_t mode, vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP); zpl_vap_init(vap, dir, dentry, mode, cr); - error = -zfs_create(dir, (char *)dentry->d_name.name, - vap, 0, mode, &ip, cr, 0, NULL); + error = -zfs_create(dir, dname(dentry), vap, 0, mode, &ip, cr, 0, NULL); + if (error == 0) { + error = zpl_xattr_security_init(ip, dir, &dentry->d_name); + VERIFY3S(error, ==, 0); + } + kmem_free(vap, sizeof(vattr_t)); crfree(cr); ASSERT3S(error, <=, 0); |