Skip to content

Commit

Permalink
Merge branch 'btrfs-3.0' of git://github.com/chrismason/linux
Browse files Browse the repository at this point in the history
* 'btrfs-3.0' of git://github.com/chrismason/linux:
  Btrfs: make sure not to defrag extents past i_size
  Btrfs: fix recursive auto-defrag
  • Loading branch information
Linus Torvalds committed Oct 13, 2011
2 parents 65112dc + f7f43cc commit b2f9452
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,16 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
if (!max_to_defrag)
max_to_defrag = last_index - 1;

while (i <= last_index && defrag_count < max_to_defrag) {
/*
* make writeback starts from i, so the defrag range can be
* written sequentially.
*/
if (i < inode->i_mapping->writeback_index)
inode->i_mapping->writeback_index = i;

while (i <= last_index && defrag_count < max_to_defrag &&
(i < (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >>
PAGE_CACHE_SHIFT)) {
/*
* make sure we stop running if someone unmounts
* the FS
Expand Down

0 comments on commit b2f9452

Please sign in to comment.