Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 231750
b: refs/heads/master
c: 1a419d8
h: refs/heads/master
v: v3
  • Loading branch information
Li Zefan committed Dec 22, 2010
1 parent 5e62aad commit 95f582f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a6fa6fae40ec336c7df6155255ae64ebef43a8bc
refs/heads/master: 1a419d85a76853d7d04e9b6280a80e96770bf3e3
19 changes: 18 additions & 1 deletion trunk/fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,16 +638,26 @@ static int btrfs_defrag_file(struct file *file,
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
struct btrfs_ordered_extent *ordered;
struct page *page;
struct btrfs_super_block *disk_super;
unsigned long last_index;
unsigned long ra_pages = root->fs_info->bdi.ra_pages;
unsigned long total_read = 0;
u64 features;
u64 page_start;
u64 page_end;
u64 last_len = 0;
u64 skip = 0;
u64 defrag_end = 0;
unsigned long i;
int ret;
int compress_type = BTRFS_COMPRESS_ZLIB;

if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) {
if (range->compress_type > BTRFS_COMPRESS_TYPES)
return -EINVAL;
if (range->compress_type)
compress_type = range->compress_type;
}

if (inode->i_size == 0)
return 0;
Expand Down Expand Up @@ -683,7 +693,7 @@ static int btrfs_defrag_file(struct file *file,
total_read++;
mutex_lock(&inode->i_mutex);
if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)
BTRFS_I(inode)->force_compress = BTRFS_COMPRESS_ZLIB;
BTRFS_I(inode)->force_compress = compress_type;

ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE);
if (ret)
Expand Down Expand Up @@ -785,6 +795,13 @@ static int btrfs_defrag_file(struct file *file,
mutex_unlock(&inode->i_mutex);
}

disk_super = &root->fs_info->super_copy;
features = btrfs_super_incompat_flags(disk_super);
if (range->compress_type == BTRFS_COMPRESS_LZO) {
features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO;
btrfs_set_super_incompat_flags(disk_super, features);
}

return 0;

err_reservations:
Expand Down
9 changes: 8 additions & 1 deletion trunk/fs/btrfs/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,15 @@ struct btrfs_ioctl_defrag_range_args {
*/
__u32 extent_thresh;

/*
* which compression method to use if turning on compression
* for this defrag operation. If unspecified, zlib will
* be used
*/
__u32 compress_type;

/* spare for later */
__u32 unused[5];
__u32 unused[4];
};

struct btrfs_ioctl_space_info {
Expand Down

0 comments on commit 95f582f

Please sign in to comment.