On Tue, Mar 03, 2020 at 12:57:15PM +0300, Kirill Tkhai wrote: > The practice shows it's not so. Your suggestion was the first thing we tried, > but it works bad and just doubles/triples IO. > > Let we have two files of 512Kb, and they are placed in separate 1Mb clusters: > > [[512Kb file][512Kb free]][[512Kb file][512Kb free]] > > We want to pack both of files in the same 1Mb cluster. Packed together on block device, > they will be in the same server of underlining distributed storage file system. > This gives a big performance improvement, and this is the price I aimed. > > In case of I fallocate a large hunk for both of them, I have to move them > both to this new hunk. So, instead of moving 512Kb of data, we will have to move > 1Mb of data, i.e. double size, which is counterproductive. > > Imaging another situation, when we have > [[1020Kb file]][4Kb free]][[4Kb file][1020Kb free]] > > Here we may just move [4Kb file] into [4Kb free]. But your suggestion again forces > us to move 1Mb instead of 4Kb, which makes IO 256 times worse! This is terrible! > And this is the thing I try prevent with finding a suitable new interface. OK, so you aren't trying to *defragment*. You want to have files placed "properly" ab initio. It sounds like what you *think* is the best way to go is to simply have files backed tightly together. So effectively what you want as a block allocation strategy is something which just finds the next free space big enough for the requested fallocate space, and just plop it down right there. OK, so what happens once you've allocated all of the free space, and the pattern of deletes leaves the file system with a lot of holes? I could imagine trying to implement this as a mount option which uses an alternate block allocation strategy, but it's not clear what your end game is after all of the "easy" spaces have been taken. It's much like proposals I've seen for a log-structured file system, where the garbage collector is left as a "we'll get to it later" TODO item. (If I had a dollar each time I've read a paper proposing a log structured file system which leaves out the garbage collector as an implementation detail....) > It's powerful, but it does not allow to create an effective defragmentation > tool for my usecase. See the examples above. I do not want to replace > EXT4_IOC_MOVE_EXTENT I just want an interface to be able to allocate > a space close to some existing file and reduce IO at defragmentation time. > This is just only thing I need in this patchset. "At defragmentation time"? So you do want to run a defragger? It might be helpful to see the full design of what you have in mind, and not just a request for interfaces.... > I can't climb into maintainers heads and find a thing, which will be suitable > for you. I did my try and suggested the interface. In case of it's not OK > for you, could you, please, suggest another one, which will work for my usecase? > The thesis "EXT4_IOC_MOVE_EXTENT is enough for everything" does not work for me :( > Are you OK with interface suggested by Andreas? Like you, I can't climb into your head and figure out exactly how your entire system design is going to work. And I'd really rather not proposal or bless an interface until I do, since it may be that it's better to make some minor changes to your system design, instead of trying to twist ext4 for your particular use case.... - Ted