|
@@ -3432,14 +3432,8 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
|
|
|
|
|
|
/* buffered write, writepage time, convert*/
|
|
/* buffered write, writepage time, convert*/
|
|
ret = ext4_ext_convert_to_initialized(handle, inode, map, path);
|
|
ret = ext4_ext_convert_to_initialized(handle, inode, map, path);
|
|
- if (ret >= 0) {
|
|
|
|
|
|
+ if (ret >= 0)
|
|
ext4_update_inode_fsync_trans(handle, inode, 1);
|
|
ext4_update_inode_fsync_trans(handle, inode, 1);
|
|
- err = check_eofblocks_fl(handle, inode, map->m_lblk, path,
|
|
|
|
- map->m_len);
|
|
|
|
- if (err < 0)
|
|
|
|
- goto out2;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
out:
|
|
out:
|
|
if (ret <= 0) {
|
|
if (ret <= 0) {
|
|
err = ret;
|
|
err = ret;
|
|
@@ -3480,6 +3474,12 @@ out:
|
|
|
|
|
|
map_out:
|
|
map_out:
|
|
map->m_flags |= EXT4_MAP_MAPPED;
|
|
map->m_flags |= EXT4_MAP_MAPPED;
|
|
|
|
+ if ((flags & EXT4_GET_BLOCKS_KEEP_SIZE) == 0) {
|
|
|
|
+ err = check_eofblocks_fl(handle, inode, map->m_lblk, path,
|
|
|
|
+ map->m_len);
|
|
|
|
+ if (err < 0)
|
|
|
|
+ goto out2;
|
|
|
|
+ }
|
|
out1:
|
|
out1:
|
|
if (allocated > map->m_len)
|
|
if (allocated > map->m_len)
|
|
allocated = map->m_len;
|
|
allocated = map->m_len;
|
|
@@ -3955,7 +3955,10 @@ got_allocated_blocks:
|
|
map->m_flags |= EXT4_MAP_UNINIT;
|
|
map->m_flags |= EXT4_MAP_UNINIT;
|
|
}
|
|
}
|
|
|
|
|
|
- err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len);
|
|
|
|
|
|
+ err = 0;
|
|
|
|
+ if ((flags & EXT4_GET_BLOCKS_KEEP_SIZE) == 0)
|
|
|
|
+ err = check_eofblocks_fl(handle, inode, map->m_lblk,
|
|
|
|
+ path, ar.len);
|
|
if (!err)
|
|
if (!err)
|
|
err = ext4_ext_insert_extent(handle, inode, path,
|
|
err = ext4_ext_insert_extent(handle, inode, path,
|
|
&newex, flags);
|
|
&newex, flags);
|
|
@@ -4214,6 +4217,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
|
|
int ret = 0;
|
|
int ret = 0;
|
|
int ret2 = 0;
|
|
int ret2 = 0;
|
|
int retries = 0;
|
|
int retries = 0;
|
|
|
|
+ int flags;
|
|
struct ext4_map_blocks map;
|
|
struct ext4_map_blocks map;
|
|
unsigned int credits, blkbits = inode->i_blkbits;
|
|
unsigned int credits, blkbits = inode->i_blkbits;
|
|
|
|
|
|
@@ -4250,6 +4254,10 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
|
|
trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
|
|
trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
+ flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT |
|
|
|
|
+ EXT4_GET_BLOCKS_NO_NORMALIZE;
|
|
|
|
+ if (mode & FALLOC_FL_KEEP_SIZE)
|
|
|
|
+ flags |= EXT4_GET_BLOCKS_KEEP_SIZE;
|
|
retry:
|
|
retry:
|
|
while (ret >= 0 && ret < max_blocks) {
|
|
while (ret >= 0 && ret < max_blocks) {
|
|
map.m_lblk = map.m_lblk + ret;
|
|
map.m_lblk = map.m_lblk + ret;
|
|
@@ -4259,9 +4267,7 @@ retry:
|
|
ret = PTR_ERR(handle);
|
|
ret = PTR_ERR(handle);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- ret = ext4_map_blocks(handle, inode, &map,
|
|
|
|
- EXT4_GET_BLOCKS_CREATE_UNINIT_EXT |
|
|
|
|
- EXT4_GET_BLOCKS_NO_NORMALIZE);
|
|
|
|
|
|
+ ret = ext4_map_blocks(handle, inode, &map, flags);
|
|
if (ret <= 0) {
|
|
if (ret <= 0) {
|
|
#ifdef EXT4FS_DEBUG
|
|
#ifdef EXT4FS_DEBUG
|
|
WARN_ON(ret <= 0);
|
|
WARN_ON(ret <= 0);
|