zfs
zfs copied to clipboard
zfs_zaccess_trivial() causes deadlock for xattr attributes
zfs_zaccess_trivial() calls the generic_permission() to read xattr attributes. This may cause deadlock if the xattr and dent locks were already held. This commit adds ZSHARED flag in zfs_get_xattrdir() to allow concurrent access and skips acquiring xattr lock in zpl_xattr_get() if already held.
How Has This Been Tested?
Without this patch, setfacl would be deadlocked:
USER_NON_ROOT=$USER
truncate -s 1G /tmp/f1
zpool create tank /tmp/f1 -f
zfs create -o xattr=dir -o acltype=posix -o mountpoint=/data tank/data
echo "TEMP" > /data/file1
chown $USER_NON_ROOT:$USER_NON_ROOT /data/file1
setfacl -m u:$USER_NON_ROOT:rwx /data/file1
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Performance enhancement (non-breaking change which improves efficiency)
- [ ] Code cleanup (non-breaking change which makes code smaller or more readable)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
- [ ] Documentation (a change to man pages or other documentation)
Checklist:
- [ ] My code follows the OpenZFS code style requirements.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the contributing document.
- [ ] I have added tests to cover my changes.
- [ ] I have run the ZFS Test Suite with this change applied.
- [x] All commit messages are properly formatted and contain
Signed-off-by.
@amotin, @freqlabs, @anodos325.
Thanks, @youzhongyang. @amotin suggested some modifications internally, I am testing those and will also add the test case.