]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Btrfs: honor extent thresh during defragmentation
authorLi Zefan <lizf@cn.fujitsu.com>
Fri, 2 Sep 2011 07:57:07 +0000 (15:57 +0800)
committerChris Mason <chris.mason@oracle.com>
Wed, 16 Nov 2011 02:20:39 +0000 (21:20 -0500)
commite223b090e2250090a5c227ca0ea876f0b8c5a5d2
tree114cddf2fd55b06e8cf67e6eeaef2b367ba6ebf8
parent25684a7e82024e37f1c2ffbbcaf4ba02336f80b8
Btrfs: honor extent thresh during defragmentation

We won't defrag an extent, if it's bigger than the threshold we
specified and there's no small extent before it, but actually
the code doesn't work this way.

There are three bugs:

- When should_defrag_range() decides we should keep on defragmenting
  an extent, last_len is not incremented. (old bug)

- The length that passes to should_defrag_range() is not the length
  we're going to defrag. (new bug)

- We always defrag 256K bytes data, and a big extent can be part of
  this range. (new bug)

For a file with 4 extents:

        | 4K | 4K | 256K | 256K |

The result of defrag with (the default) 256K extent thresh should be:

        | 264K | 256K |

but with those bugs, we'll get:

        | 520K |

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
(cherry picked from commit 008873eafbc77deb1702aedece33756c58486c6a)
fs/btrfs/ioctl.c