gpt4 book ai didi

filesystems - 如何将 "extended attributes"存储在 ext4 inode block 中,因为我们有 inode 额外大小 "i_extra_isize"

转载 作者:行者123 更新时间:2023-12-02 01:42:57 24 4
gpt4 key购买 nike

根据

struct ext4_inode {
.....
__le16 i_extra_isize;
.....
}

鉴于我使用的 inode 大小 = 256 字节,我看到这可以用于存储扩展属性。几个问题:

  1. 我如何知道我的 FS inode 大小是 256 字节还是 128 字节?
  2. 如何设置小扩展属性(<10 字节)并将其存储在额外区域中? (原因:性能很重要),因为我相信不会有额外的 IO block 读取为连续的。 Fileystem/C lib 对此有何要求?典型的系统调用“setattr”会这样做吗?我一直在使用命令行“setfattr”进行设置,但不确定它是否会转到 inode 128 字节之后分配的额外区域。
  3. 在 128 字节 inode 之后映射额外字节的内存结构是什么,这是我要存储我的小扩展属性的地方。

最佳答案

How do I know if my FS inode size is 256 or 128 bytes ?

$ sudo tune2fs -l /dev/sda2  | egrep -i 'inode size'
Inode size: 256

How do I set the small extended attributes

Ext3/4 支持可配置的 inode 大小(来自 -I 选项 mkfs.ext{3,4} cmd 参数),但默认 inode 大小为 128 字节。 Ext4 将默认为 256 字节。这是容纳一些额外字段(如纳秒时间戳或 inode 版本控制)所必需的,inode 的剩余空间将用于存储足够小以适应该空间的扩展属性。此外,您可能还想查看实现的函数 fs/ext4/file.c:struct inode_operations{.setattr,.getattr}。

What's the Fileystem/C lib call for that?

引用 API 的 setxattr(), lsetxattr(), fsetxattr()用于以编程方式设置扩展属性。使用命令 attr、lsattr、chattr 测试设置文件的扩展属性。你也可能想要 look into

Whats the in-memory structure for mapping the extra bytes after 128 bytes of inode, the place where I want to store my small extended attributes.

引用fs/ext4/xattr.c

* Extended attributes are stored directly in inodes (on file systems with
18 * inodes bigger than 128 bytes) and on additional disk blocks. The i_file_acl
19 * field contains the block number if an inode uses an additional block. All
20 * attributes must fit in the inode and one additional block. Blocks that
21 * contain the identical set of attributes may be shared among several inodes.
22 * Identical blocks are detected by keeping a cache of blocks that have
23 * recently been accessed.
24 *
25 * The attributes in inodes and on blocks have a different header; the entries
26 * are stored in the same format:
27 *
28 * +------------------+
29 * | header |
30 * | entry 1 | |
31 * | entry 2 | | growing downwards
32 * | entry 3 | v
33 * | four null bytes |
34 * | . . . |
35 * | value 1 | ^
36 * | value 3 | | growing upwards
37 * | value 2 | |
38 * +------------------+
39 *
40 * The header is followed by multiple entry descriptors. In disk blocks, the
41 * entry descriptors are kept sorted. In inodes, they are unsorted. The
42 * attribute values are aligned to the end of the block in no specific order.

关于filesystems - 如何将 "extended attributes"存储在 ext4 inode block 中,因为我们有 inode 额外大小 "i_extra_isize",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27393692/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com