aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inline.c
diff options
context:
space:
mode:
authorTao Ma <boyu.mt@taobao.com>2012-12-10 14:06:02 -0500
committerTheodore Ts'o <tytso@mit.edu>2012-12-10 14:06:02 -0500
commit941919856c11d4dd11d4fcabb4dab58bd2b146bf (patch)
treedcb06b13ca094575d9f32e49371560c1c956c874 /fs/ext4/inline.c
parent32f7f22c0b52e8189fef83986b16dc7abe95f2c4 (diff)
ext4: let fiemap work with inline data
fiemap is used to find the disk layout of a file, as for inline data, let us just pretend like a file with just one extent. Signed-off-by: Tao Ma <boyu.mt@taobao.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inline.c')
-rw-r--r--fs/ext4/inline.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index fc3629980925..bf5f77803885 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -15,6 +15,7 @@
15#include "ext4.h" 15#include "ext4.h"
16#include "xattr.h" 16#include "xattr.h"
17#include "truncate.h" 17#include "truncate.h"
18#include <linux/fiemap.h>
18 19
19#define EXT4_XATTR_SYSTEM_DATA "data" 20#define EXT4_XATTR_SYSTEM_DATA "data"
20#define EXT4_MIN_INLINE_DATA_SIZE ((sizeof(__le32) * EXT4_N_BLOCKS)) 21#define EXT4_MIN_INLINE_DATA_SIZE ((sizeof(__le32) * EXT4_N_BLOCKS))
@@ -1680,3 +1681,37 @@ int ext4_destroy_inline_data(handle_t *handle, struct inode *inode)
1680 1681
1681 return ret; 1682 return ret;
1682} 1683}
1684
1685int ext4_inline_data_fiemap(struct inode *inode,
1686 struct fiemap_extent_info *fieinfo,
1687 int *has_inline)
1688{
1689 __u64 physical = 0;
1690 __u64 length;
1691 __u32 flags = FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_LAST;
1692 int error = 0;
1693 struct ext4_iloc iloc;
1694
1695 down_read(&EXT4_I(inode)->xattr_sem);
1696 if (!ext4_has_inline_data(inode)) {
1697 *has_inline = 0;
1698 goto out;
1699 }
1700
1701 error = ext4_get_inode_loc(inode, &iloc);
1702 if (error)
1703 goto out;
1704
1705 physical = iloc.bh->b_blocknr << inode->i_sb->s_blocksize_bits;
1706 physical += (char *)ext4_raw_inode(&iloc) - iloc.bh->b_data;
1707 physical += offsetof(struct ext4_inode, i_block);
1708 length = i_size_read(inode);
1709
1710 if (physical)
1711 error = fiemap_fill_next_extent(fieinfo, 0, physical,
1712 length, flags);
1713 brelse(iloc.bh);
1714out:
1715 up_read(&EXT4_I(inode)->xattr_sem);
1716 return (error < 0 ? error : 0);
1717}