这个问题很难回答。也许正确的答案在理论上可能是肯定的,但实际上不是。
ext2 / ext3
就 ext2 和 ext3 而言,超级块和 inode 结构旨在允许块被分段。 (参见:fs/ext2/ext2.h 和 fs/ext3/ext3.h)
fs/ext3/ext3.h 的短 sn-p 在这里给出:
struct ext3_super_block {
/*00*/ __le32 s_inodes_count; /* Inodes count */
__le32 s_blocks_count; /* Blocks count */
__le32 s_r_blocks_count; /* Reserved blocks count */
__le32 s_free_blocks_count; /* Free blocks count */
/*10*/ __le32 s_free_inodes_count; /* Free inodes count */
__le32 s_first_data_block; /* First Data Block */
__le32 s_log_block_size; /* Block size */
__le32 s_log_frag_size; /* Fragment size */
// ...
struct ext3_inode {
__le16 i_mode; /* File mode */
__le16 i_uid; /* Low 16 bits of Owner Uid */
// ...
__le32 i_faddr; /* Fragment address */
尽管做好了准备,但至少在 linux 内核(直到 3.13 版)中从未实现块碎片,强制碎片大小等于块大小。 (见:fs/ext3/super.c)
if (blocksize != sbi->s_frag_size) {
ext3_msg(sb, KERN_ERR,
"error: fragsize %lu != blocksize %u (unsupported)",
sbi->s_frag_size, blocksize);
goto failed_mount;
}
Afaik GNU/Hurd 也没有实现 ext2/3 文件系统的块分段。很可能不会有操作系统来实现它。
尽管如此,在开始块级操作之前检查超级块中的s_log_frag_size 可能不是一个坏主意,因为您会安全。
ext4
有了 ext4,整个故事变得不那么麻烦了,因为 ext4 不再允许块碎片。用于存储片段大小的 superblock 字段已被赋予新的工作,用于存储片段地址的 iode 字段(重命名为i_obso_faddr)已在源代码中标记为已过时。
struct ext4_inode {
__le16 i_mode; /* File mode */
__le16 i_uid; /* Low 16 bits of Owner Uid */
// ...
__le32 i_obso_faddr; /* Obsoleted fragment address */