[PATCH 4/5] btrfs: Allow to specify compress method when defrag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Update defrag ioctl, so one can choose lzo or zlib when turning
on compression in defrag operation.

Signed-off-by: Li Zefan <lizf@xxxxxxxxxxxxxx>
---
 fs/btrfs/ioctl.c |    6 +++++-
 fs/btrfs/ioctl.h |    9 ++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index ecc49ee..2ea05df 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -584,8 +584,12 @@ static int btrfs_defrag_file(struct file *file,
 		}
 		total_read++;
 		mutex_lock(&inode->i_mutex);
-		if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)
+		if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) {
 			BTRFS_I(inode)->force_compress = BTRFS_COMPRESS_ZLIB;
+			if (range->compress_type)
+				BTRFS_I(inode)->force_compress =
+					range->compress_type;
+		}
 
 		ret  = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE);
 		if (ret)
diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h
index 424694a..776a2b4 100644
--- a/fs/btrfs/ioctl.h
+++ b/fs/btrfs/ioctl.h
@@ -122,8 +122,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 {
-- 
1.7.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux