From patchwork Mon Oct 25 07:12:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zefan X-Patchwork-Id: 266262 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9P7C6FX018791 for ; Mon, 25 Oct 2010 07:12:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753413Ab0JYHMC (ORCPT ); Mon, 25 Oct 2010 03:12:02 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:58956 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752757Ab0JYHMB (ORCPT ); Mon, 25 Oct 2010 03:12:01 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 30526170EE9 for ; Mon, 25 Oct 2010 15:11:54 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o9P77k79016497 for ; Mon, 25 Oct 2010 15:07:47 +0800 Received: from lizf.localdomain (unknown [10.167.225.51]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 143C314C06D for ; Mon, 25 Oct 2010 15:13:34 +0800 (CST) Message-ID: <4CC52DF2.2040803@cn.fujitsu.com> Date: Mon, 25 Oct 2010 15:12:50 +0800 From: Li Zefan User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Thunderbird/3.0b2 MIME-Version: 1.0 To: linux-btrfs@vger.kernel.org Subject: [PATCH 4/5] btrfs: Allow to specify compress method when defrag References: <4CC52D9A.3030709@cn.fujitsu.com> In-Reply-To: <4CC52D9A.3030709@cn.fujitsu.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 25 Oct 2010 07:12:06 +0000 (UTC) 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 {