From: Gou Hao gouhao@uniontech.com
Patch series "Add extended attributes support for EulerFS".
I refer to the extended attribute implementation code of ext2 file system. At first, I implemented it completely according to the extended attribute of ext file system. But later, I changed the disk layout of entries.
About layout of entry: The layout of ext2's extended attribute is that name and value are stored separately,with name growing from top to bottom and value growing from bottom to top. I think the layout of ext2 wastes space, because, Name and value are aligned with 4 bytes, In the worst case, the name and value of entry need 3 bytes of padding respectively, and a total of 6 bytes are wasted.
I store the name and value together. In the worst case, only need 3 bytes of padding.Use xattr-test.c selftests, with the same block size, my method can store 112 entries, while using ext2 layout can only store 102 entries.
In ext4 file system, value can be stored in different blocks, which increases the scalability. In my method, it can add a pointer to the next block in the header to achieve the same function, and it is simpler.
The performance of my method is the same as that of ext2, or even better.
About block share: In ext2, if the extended attributes of two files are exactly the same, they can share the same disk block. Its implementation process is: 1. When accessing the extended attribute of a file, add this extended attribute block to a specific cache.
2. When setting the extended attribute of a file, if there is a block with exactly the same content as this extended attribute in the cache, share that block directly.
There is a problem here. If the block of a file is not added to the cache, the extended attribute block will not be shared.So in this patch set, I didn't realize the shared disk block. I'll implement it later when there is a good method or when there is a need.
At present, only user. prefix xattr is implemented. Trusted, ACL and security will be implemented later.
Gou Hao (7): eulerfs: add EULER_FS_XATTR config eulerfs: add related fields of extended attributes eulerfs: add alloc xattr block interface eulerfs: implement extended attribute core functions eulerfs: add callback interface of extended attribute eulerfs: add implementation of user. prefix extended attribute eulerfs: add selftests for eulerfs extended attribute
fs/eulerfs/Kconfig | 9 + fs/eulerfs/Makefile | 1 + fs/eulerfs/alloc_interface.h | 4 + fs/eulerfs/const.h | 1 + fs/eulerfs/euler.h | 1 + fs/eulerfs/euler_def.h | 3 + fs/eulerfs/file.c | 1 + fs/eulerfs/inode.c | 3 + fs/eulerfs/namei.c | 2 + fs/eulerfs/nvalloc.c | 1 + fs/eulerfs/nvalloc.h | 1 + fs/eulerfs/nvm_struct.h | 12 + fs/eulerfs/super.c | 36 +- fs/eulerfs/symlink.c | 1 + fs/eulerfs/xattr.c | 422 ++++++++++++++ fs/eulerfs/xattr.h | 99 ++++ fs/eulerfs/xattr_user.c | 43 ++ tools/testing/selftests/eulerfs/Makefile | 6 + tools/testing/selftests/eulerfs/xattr-test.c | 565 +++++++++++++++++++ 19 files changed, 1209 insertions(+), 2 deletions(-) create mode 100644 fs/eulerfs/xattr.c create mode 100644 fs/eulerfs/xattr.h create mode 100644 fs/eulerfs/xattr_user.c create mode 100644 tools/testing/selftests/eulerfs/Makefile create mode 100644 tools/testing/selftests/eulerfs/xattr-test.c