Hi all, I come up with the new fragmentation score based on your comments. The interface of new libe2p function will be as follows: int e2p_get_fragscore(int fd, __u32 threshold, __u32 max_chunk_blks) This function returns the fragmentation score that shows how badly fragmented the file might be. The score is extents per @threshold, so the higher score means the worse fragmentation. Fragmentation score treats extents, whose file offset continues and whose status is the same, as one chunk. If the number of extents in chunk is equal to the ideal number of extents, the chunk is not used for the fragmentation score because there is no fragment in the chunk. The ideal number of extents is calculated based on @max_chunk_blks. In case of ext4, @max_chunk_blks is 32768 blocks. If you have 128MB file with two extents, these two extents are used for the calculation of the fragmentation score because the ideal number of extents in this file is one. e4defrag will judge the necessity of calling EXT4_IOC_MOVE_EXT ioctl by fragmentation score. If the fragmentation score of defrag target file is more than one, and the score of the file created by fallocate is zero, e4defrag will call the ioctl. I'll decide the better value of threshold during some tests. If you must do e4defrag to the specified file, you will be able to force defrag by using new option of e4defrag. Two examples (@threshold=256, @max_chunk_blks=32768): # filefrag -v fragment Filesystem type is: ef53 File size of fragment is 409600 (100 blocks, blocksize 4096) ext logical physical expected length flags 0 0 33807 16 1 16 32848 33822 84 eof fragment: 2 extents found This small file has two extents, so it is fragmented. The calculation is as follows: fragmentation score = 2 / (100 / 256) = 5 extents / MB. # filefrag -v not_fragment Filesystem type is: ef53 File size of not_fragment is 125829120 (30720 blocks, blocksize 4096) ext logical physical expected length flags 0 0 33823 16 1 16 32944 33838 48 2 64 33152 32991 64 3 128 34304 33215 30592 eof not_fragment: 4 extents found This file has four extents included one large extent. So the score is zero in this case. fragmentation score = 4 / (30720 / 256) = 0 extents / MB. Regards, Kazuya Mio -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html