summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-07-17 20:01:59 +0200
committerDavid Sterba <dsterba@suse.com>2017-08-16 16:12:05 +0200
commit1e2ef46d89ee41c0c5387563491493029c77cdd2 (patch)
treeec7776be192922d26e87daa549facf2b3279b2b7 /fs/btrfs/ioctl.c
parenteec63c65dcbeb14b59c95159eb225b1fc2310806 (diff)
downloadlinux-stable-1e2ef46d89ee41c0c5387563491493029c77cdd2.tar.gz
linux-stable-1e2ef46d89ee41c0c5387563491493029c77cdd2.tar.bz2
linux-stable-1e2ef46d89ee41c0c5387563491493029c77cdd2.zip
btrfs: defrag: cleanup checking for compression status
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 1d6603dc1d59..7a3c56c17e00 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1255,6 +1255,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
unsigned long cluster = max_cluster;
u64 new_align = ~((u64)SZ_128K - 1);
struct page **pages = NULL;
+ bool do_compress = range->flags & BTRFS_DEFRAG_RANGE_COMPRESS;
if (isize == 0)
return 0;
@@ -1262,7 +1263,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
if (range->start >= isize)
return -EINVAL;
- if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) {
+ if (do_compress) {
if (range->compress_type > BTRFS_COMPRESS_TYPES)
return -EINVAL;
if (range->compress_type)
@@ -1341,8 +1342,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
if (!should_defrag_range(inode, (u64)i << PAGE_SHIFT,
extent_thresh, &last_len, &skip,
- &defrag_end, range->flags &
- BTRFS_DEFRAG_RANGE_COMPRESS)) {
+ &defrag_end, do_compress)){
unsigned long next;
/*
* the should_defrag function tells us how much to skip
@@ -1370,7 +1370,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
}
inode_lock(inode);
- if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)
+ if (do_compress)
BTRFS_I(inode)->defrag_compress = compress_type;
ret = cluster_pages_for_defrag(inode, pages, i, cluster);
if (ret < 0) {
@@ -1418,7 +1418,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
filemap_flush(inode->i_mapping);
}
- if ((range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)) {
+ if (do_compress) {
/* the filemap_flush will queue IO into the worker threads, but
* we have to make sure the IO is actually started and that
* ordered extents get created before we return
@@ -1440,7 +1440,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
ret = defrag_count;
out_ra:
- if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) {
+ if (do_compress) {
inode_lock(inode);
BTRFS_I(inode)->defrag_compress = BTRFS_COMPRESS_NONE;
inode_unlock(inode);