From: David Sterba Date: Mon, 24 Oct 2011 12:47:58 +0000 (+0200) Subject: Merge branch 'hotfixes-20111024/josef/for-chris' into btrfs-next-stable X-Git-Tag: firefly_0821_release~3680^2~3894^2~77 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a81d3b1ba2f5faae28ba7a092c7598673fa02ac2;p=firefly-linux-kernel-4.4.55.git Merge branch 'hotfixes-20111024/josef/for-chris' into btrfs-next-stable --- a81d3b1ba2f5faae28ba7a092c7598673fa02ac2 diff --cc fs/btrfs/ioctl.c index 877727b28d88,136a2f980e21..33aae13cc74b --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@@ -1051,18 -1055,9 +1055,18 @@@ int btrfs_defrag_file(struct inode *ino i = range->start >> PAGE_CACHE_SHIFT; } if (!max_to_defrag) - max_to_defrag = last_index - 1; + max_to_defrag = last_index; - 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