From: Tom Marshall <tom@cyngn.com>
To: unlisted-recipients:; (no To-header on input)
Subject: [PATCH 3/3] fs: ext4: Support transparent compression
Date: Thu, 21 May 2015 15:44:52 -0700 [thread overview]
Message-ID: <5568dfb6.08f1420a.392d.3fe2@mx.google.com> (raw)
Signed-off-by: Tom Marshall <tdm@cyngn.com>
---
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 <linux/ratelimit.h>
#include <crypto/hash.h>
#include <linux/falloc.h>
+#include <linux/fs-xcomp.h>
#ifdef __KERNEL__
#include <linux/compat.h>
#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:
--
2.1.4
reply other threads:[~2015-05-29 21:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5568dfb6.08f1420a.392d.3fe2@mx.google.com \
--to=tom@cyngn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).