diff options
author | Tao Ma <boyu.mt@taobao.com> | 2012-12-10 14:06:03 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-12-10 14:06:03 -0500 |
commit | 0c8d414f163f5d35e43a4de7a6e5ee8c253fcccf (patch) | |
tree | 7db57d3b2926408bda5bad880896ee4ec384f398 /fs/ext4/inline.c | |
parent | aef1c8513c1f8ae076e22ea2a57eff5835578e75 (diff) |
ext4: let fallocate handle inline data correctly
If we are punching hole in a file, we will return ENOTSUPP.
As for the fallocation of some extents, we will convert the
inline data to a normal extent based file first.
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.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index 727edb8d57e0..53b2f65091dd 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c | |||
@@ -1843,3 +1843,42 @@ out: | |||
1843 | ext4_journal_stop(handle); | 1843 | ext4_journal_stop(handle); |
1844 | return; | 1844 | return; |
1845 | } | 1845 | } |
1846 | |||
1847 | int ext4_convert_inline_data(struct inode *inode) | ||
1848 | { | ||
1849 | int error, needed_blocks; | ||
1850 | handle_t *handle; | ||
1851 | struct ext4_iloc iloc; | ||
1852 | |||
1853 | if (!ext4_has_inline_data(inode)) { | ||
1854 | ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); | ||
1855 | return 0; | ||
1856 | } | ||
1857 | |||
1858 | needed_blocks = ext4_writepage_trans_blocks(inode); | ||
1859 | |||
1860 | iloc.bh = NULL; | ||
1861 | error = ext4_get_inode_loc(inode, &iloc); | ||
1862 | if (error) | ||
1863 | return error; | ||
1864 | |||
1865 | handle = ext4_journal_start(inode, needed_blocks); | ||
1866 | if (IS_ERR(handle)) { | ||
1867 | error = PTR_ERR(handle); | ||
1868 | goto out_free; | ||
1869 | } | ||
1870 | |||
1871 | down_write(&EXT4_I(inode)->xattr_sem); | ||
1872 | if (!ext4_has_inline_data(inode)) { | ||
1873 | up_write(&EXT4_I(inode)->xattr_sem); | ||
1874 | goto out; | ||
1875 | } | ||
1876 | |||
1877 | error = ext4_convert_inline_data_nolock(handle, inode, &iloc); | ||
1878 | up_write(&EXT4_I(inode)->xattr_sem); | ||
1879 | out: | ||
1880 | ext4_journal_stop(handle); | ||
1881 | out_free: | ||
1882 | brelse(iloc.bh); | ||
1883 | return error; | ||
1884 | } | ||