On 9/17/18 6:22 AM, Joshi wrote: > I've been doing some defrag related tests, and for that I needed to be > able to create file with same set of block numbers (i.e. extents), for > at least two times. Userspace cannot control that. > May I know if there is any randomness in Ext4 allocator, and if there > is any, can I disable it for the purpose of getting repeatable > block-allocation patterns. > > Here are experiment details - > For a 100K file (created using dd if=/dev/zero of=/mnt/f100k bs=4K > count=100, oflag=direct) I got extent info in one run as this - > > File size of /mnt/file400k is 409600 (100 blocks of 4096 bytes) > ext: logical_offset: physical_offset: length: expected: flags: > 0: 0.. 15: 34816.. 34831: 16: > 1: 16.. 99: 33824.. 33907: 84: 34832: last,eof > > while in the the second run I got somewhat different runs - > File size of /mnt/file400k is 409600 (100 blocks of 4096 bytes) > ext: logical_offset: physical_offset: length: expected: flags: > 0: 0.. 0: 34816.. 34816: 1: > 1: 1.. 15: 34320.. 34334: 15: 34817: > 2: 16.. 99: 33824.. 33907: 84: 34335: last,eof > > Each run beings with a mkfs.ext4 with lazy inode/journal > initialization disabled. Userspace doesn't get to pick physical locations for allocations, you cannot write a test which depends on doing so. -Eric