aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2013-02-09 18:38:06 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-02-20 12:59:51 -0500
commit210549ebe9047ae5a8cc47487203d3ee16a7749b (patch)
tree57c9c8123a46a1170abba0fc476ded82eac442ed /fs/btrfs/ioctl.c
parentb069e0c3450ae388d7a9c94ded6d938a465de262 (diff)
btrfs: add cancellation points to defrag
The defrag operation can take very long, we want to have a way how to cancel it. The code checks for a pending signal at safe points in the defrag loops and returns EAGAIN. This means a user can press ^C after running 'btrfs fi defrag', woks for both defrag modes, files and root. Returning from the command was instant in my light tests, but may take longer depending on the aging factor of the filesystem. Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 6d6314406e27..d02ec577f70f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1202,6 +1202,12 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
1202 if (!(inode->i_sb->s_flags & MS_ACTIVE)) 1202 if (!(inode->i_sb->s_flags & MS_ACTIVE))
1203 break; 1203 break;
1204 1204
1205 if (btrfs_defrag_cancelled(root->fs_info)) {
1206 printk(KERN_DEBUG "btrfs: defrag_file cancelled\n");
1207 ret = -EAGAIN;
1208 break;
1209 }
1210
1205 if (!should_defrag_range(inode, (u64)i << PAGE_CACHE_SHIFT, 1211 if (!should_defrag_range(inode, (u64)i << PAGE_CACHE_SHIFT,
1206 extent_thresh, &last_len, &skip, 1212 extent_thresh, &last_len, &skip,
1207 &defrag_end, range->flags & 1213 &defrag_end, range->flags &