You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Btrfs: fix wrong max_to_defrag in btrfs_defrag_file()
It's off-by-one, and thus we may skip the last page while defragmenting. An example case: # create /mnt/file with 2 4K file extents # btrfs fi defrag /mnt/file # sync # filefrag /mnt/file /mnt/file: 2 extents found So it's not defragmented. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
This commit is contained in:
+1
-1
@@ -1052,7 +1052,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
|
|||||||
i = range->start >> PAGE_CACHE_SHIFT;
|
i = range->start >> PAGE_CACHE_SHIFT;
|
||||||
}
|
}
|
||||||
if (!max_to_defrag)
|
if (!max_to_defrag)
|
||||||
max_to_defrag = last_index - 1;
|
max_to_defrag = last_index;
|
||||||
|
|
||||||
while (i <= last_index && defrag_count < max_to_defrag) {
|
while (i <= last_index && defrag_count < max_to_defrag) {
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user