From patchwork Thu May 21 22:44:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Marshall X-Patchwork-Id: 6511551 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1BCF7C0433 for ; Fri, 29 May 2015 21:53:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3322F20652 for ; Fri, 29 May 2015 21:53:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C6AE2080B for ; Fri, 29 May 2015 21:53:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757218AbbE2Vw6 (ORCPT ); Fri, 29 May 2015 17:52:58 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:35063 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756906AbbE2Vw4 (ORCPT ); Fri, 29 May 2015 17:52:56 -0400 Received: by pacrp13 with SMTP id rp13so22593996pac.2 for ; Fri, 29 May 2015 14:52:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:date:subject; bh=a01x4LeVk3gfIh5mp0VC6whzFBk1+GgLELAVO2xCHNY=; b=irTZopl4WQXmno6nfaZRl2a+QSrfZXqLw1yPUTzI6TFVHHPuOEkhnyMoGY+2Q43BDF IzTdx8s5/n/HhYWaiK5xED3Noep9hZBkswG0vUxfO7u0+rT2FyATqrOPJ4jftyCTdbQ2 pJfO3kIjZ4kBwXAP+cJtEQ5O4M6scHuyNCVUg0ApSmQvcSTzSAp14Jzx+9qBHsQ7C83A fyZOgBhzKQkYfaxT0FFHhSaZzAeUlIl1I9HQ0epnKnL/Opi9i3bKa6prnUCPWZo/OYMZ pFxKhGIqQrDqiuzy/7+p7bI79GzaC4WUmpt+MBpdXheT1TTR9V0ze0oQySyelCqna4Zn gAAw== X-Gm-Message-State: ALoCoQk1h+9q8sR9ThfrN71s0PUgbFDKInEQ8xw+DayfdQkw9Mm9/9CS3jAregB/fjPwQlrdEo3g X-Received: by 10.66.221.193 with SMTP id qg1mr18120411pac.134.1432936375700; Fri, 29 May 2015 14:52:55 -0700 (PDT) Received: from localhost (70-90-190-81-WA.hfc.comcastbusiness.net. [70.90.190.81]) by mx.google.com with ESMTPSA id we8sm6604033pac.44.2015.05.29.14.52.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 May 2015 14:52:54 -0700 (PDT) Message-ID: <5568dfb6.08f1420a.392d.3fe2@mx.google.com> From: Tom Marshall X-Google-Original-From: Tom Marshall Date: Thu, 21 May 2015 15:44:52 -0700 Subject: [PATCH 3/3] fs: ext4: Support transparent compression To: unlisted-recipients:; (no To-header on input) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DATE_IN_PAST_96_XX, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Tom Marshall --- fs/ext4/Makefile | 4 ++++ fs/ext4/ext4.h | 4 ++++ fs/ext4/inode.c | 41 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile index 75285ea..b6e230a 100644 --- a/fs/ext4/Makefile +++ b/fs/ext4/Makefile @@ -14,3 +14,7 @@ ext4-$(CONFIG_EXT4_FS_POSIX_ACL) += acl.o ext4-$(CONFIG_EXT4_FS_SECURITY) += xattr_security.o ext4-$(CONFIG_EXT4_FS_ENCRYPTION) += crypto_policy.o crypto.o \ crypto_key.o crypto_fname.o + +ifdef CONFIG_FS_TRANSPARENT_COMPRESSION +ccflags-y += -DFS_IMPL +endif diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 9a83f14..88d14f6 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef __KERNEL__ #include #endif @@ -957,6 +958,9 @@ struct ext4_inode_info { /* Encryption params */ struct ext4_encryption_key i_encryption_key; #endif +#ifdef CONFIG_FS_TRANSPARENT_COMPRESSION + struct xcomp_inode_info i_xcomp_info; +#endif }; /* diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 0554b0b..9077415 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -46,6 +46,13 @@ #define MPAGE_DA_EXTENT_TAIL 0x01 +static int ext4_inode_is_compressed(struct inode *inode) +{ + if (!xcomp_enabled()) + return 0; + return (EXT4_I(inode)->i_flags & EXT4_COMPR_FL); +} + static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw, struct ext4_inode_info *ei) { @@ -250,6 +257,11 @@ void ext4_evict_inode(struct inode *inode) if (IS_SYNC(inode)) ext4_handle_sync(handle); + + if (ext4_inode_is_compressed(inode)) { + xcomp_inode_info_free(&EXT4_I(inode)->i_xcomp_info); + } + inode->i_size = 0; err = ext4_mark_inode_dirty(handle, inode); if (err) { @@ -2912,7 +2924,7 @@ static sector_t ext4_bmap(struct address_space *mapping, sector_t block) return generic_block_bmap(mapping, block, ext4_get_block); } -static int ext4_readpage(struct file *file, struct page *page) +static int __ext4_readpage(struct page *page) { int ret = -EAGAIN; struct inode *inode = page->mapping->host; @@ -2928,8 +2940,16 @@ static int ext4_readpage(struct file *file, struct page *page) return ret; } +static int ext4_readpage(struct file *file, struct page *page) +{ + if (ext4_inode_is_compressed(page->mapping->host)) + return xcomp_readpage(&EXT4_I(page->mapping->host)->i_xcomp_info, page); + + return __ext4_readpage(page); +} + static int -ext4_readpages(struct file *file, struct address_space *mapping, +__ext4_readpages(struct address_space *mapping, struct list_head *pages, unsigned nr_pages) { struct inode *inode = mapping->host; @@ -2941,6 +2961,16 @@ ext4_readpages(struct file *file, struct address_space *mapping, return ext4_mpage_readpages(mapping, pages, NULL, nr_pages); } +static int +ext4_readpages(struct file *file, struct address_space *mapping, + struct list_head *pages, unsigned nr_pages) +{ + if (ext4_inode_is_compressed(mapping->host)) + return xcomp_readpages(&EXT4_I(mapping->host)->i_xcomp_info, mapping, pages, nr_pages); + + return __ext4_readpages(mapping, pages, nr_pages); +} + static void ext4_invalidatepage(struct page *page, unsigned int offset, unsigned int length) { @@ -4117,6 +4147,9 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) ei->i_file_acl |= ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32; inode->i_size = ext4_isize(raw_inode); +#ifdef CONFIG_FS_TRANSPARENT_COMPRESSION + inode->i_compressed_size = inode->i_size; +#endif ei->i_disksize = inode->i_size; #ifdef CONFIG_QUOTA ei->i_reserved_quota = 0; @@ -4241,6 +4274,10 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) brelse(iloc.bh); ext4_set_inode_flags(inode); unlock_new_inode(inode); + + if (S_ISREG(inode->i_mode) && ext4_inode_is_compressed(inode)) + xcomp_inode_info_init(inode, &ei->i_xcomp_info, __ext4_readpage); + return inode; bad_inode: