|
@@ -403,8 +403,7 @@ static void ext4_map_blocks_es_recheck(handle_t *handle,
|
|
|
* out taking i_data_sem. So at the time the unwritten extent
|
|
|
* could be converted.
|
|
|
*/
|
|
|
- if (!(flags & EXT4_GET_BLOCKS_NO_LOCK))
|
|
|
- down_read(&EXT4_I(inode)->i_data_sem);
|
|
|
+ down_read(&EXT4_I(inode)->i_data_sem);
|
|
|
if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
|
|
|
retval = ext4_ext_map_blocks(handle, inode, map, flags &
|
|
|
EXT4_GET_BLOCKS_KEEP_SIZE);
|
|
@@ -412,8 +411,7 @@ static void ext4_map_blocks_es_recheck(handle_t *handle,
|
|
|
retval = ext4_ind_map_blocks(handle, inode, map, flags &
|
|
|
EXT4_GET_BLOCKS_KEEP_SIZE);
|
|
|
}
|
|
|
- if (!(flags & EXT4_GET_BLOCKS_NO_LOCK))
|
|
|
- up_read((&EXT4_I(inode)->i_data_sem));
|
|
|
+ up_read((&EXT4_I(inode)->i_data_sem));
|
|
|
|
|
|
/*
|
|
|
* We don't check m_len because extent will be collpased in status
|
|
@@ -509,8 +507,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
|
|
|
* Try to see if we can get the block without requesting a new
|
|
|
* file system block.
|
|
|
*/
|
|
|
- if (!(flags & EXT4_GET_BLOCKS_NO_LOCK))
|
|
|
- down_read(&EXT4_I(inode)->i_data_sem);
|
|
|
+ down_read(&EXT4_I(inode)->i_data_sem);
|
|
|
if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
|
|
|
retval = ext4_ext_map_blocks(handle, inode, map, flags &
|
|
|
EXT4_GET_BLOCKS_KEEP_SIZE);
|
|
@@ -541,8 +538,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
|
|
|
if (ret < 0)
|
|
|
retval = ret;
|
|
|
}
|
|
|
- if (!(flags & EXT4_GET_BLOCKS_NO_LOCK))
|
|
|
- up_read((&EXT4_I(inode)->i_data_sem));
|
|
|
+ up_read((&EXT4_I(inode)->i_data_sem));
|
|
|
|
|
|
found:
|
|
|
if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
|
|
@@ -674,7 +670,7 @@ static int _ext4_get_block(struct inode *inode, sector_t iblock,
|
|
|
map.m_lblk = iblock;
|
|
|
map.m_len = bh->b_size >> inode->i_blkbits;
|
|
|
|
|
|
- if (flags && !(flags & EXT4_GET_BLOCKS_NO_LOCK) && !handle) {
|
|
|
+ if (flags && !handle) {
|
|
|
/* Direct IO write... */
|
|
|
if (map.m_len > DIO_MAX_BLOCKS)
|
|
|
map.m_len = DIO_MAX_BLOCKS;
|
|
@@ -879,9 +875,6 @@ int do_journal_get_write_access(handle_t *handle,
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-static int ext4_get_block_write_nolock(struct inode *inode, sector_t iblock,
|
|
|
- struct buffer_head *bh_result, int create);
|
|
|
-
|
|
|
#ifdef CONFIG_EXT4_FS_ENCRYPTION
|
|
|
static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len,
|
|
|
get_block_t *get_block)
|
|
@@ -3054,13 +3047,21 @@ int ext4_get_block_write(struct inode *inode, sector_t iblock,
|
|
|
EXT4_GET_BLOCKS_IO_CREATE_EXT);
|
|
|
}
|
|
|
|
|
|
-static int ext4_get_block_write_nolock(struct inode *inode, sector_t iblock,
|
|
|
+static int ext4_get_block_overwrite(struct inode *inode, sector_t iblock,
|
|
|
struct buffer_head *bh_result, int create)
|
|
|
{
|
|
|
- ext4_debug("ext4_get_block_write_nolock: inode %lu, create flag %d\n",
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ ext4_debug("ext4_get_block_overwrite: inode %lu, create flag %d\n",
|
|
|
inode->i_ino, create);
|
|
|
- return _ext4_get_block(inode, iblock, bh_result,
|
|
|
- EXT4_GET_BLOCKS_NO_LOCK);
|
|
|
+ ret = _ext4_get_block(inode, iblock, bh_result, 0);
|
|
|
+ /*
|
|
|
+ * Blocks should have been preallocated! ext4_file_write_iter() checks
|
|
|
+ * that.
|
|
|
+ */
|
|
|
+ WARN_ON_ONCE(!buffer_mapped(bh_result));
|
|
|
+
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int ext4_get_block_dax(struct inode *inode, sector_t iblock,
|
|
@@ -3143,10 +3144,8 @@ static ssize_t ext4_ext_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
|
|
|
/* If we do a overwrite dio, i_mutex locking can be released */
|
|
|
overwrite = *((int *)iocb->private);
|
|
|
|
|
|
- if (overwrite) {
|
|
|
- down_read(&EXT4_I(inode)->i_data_sem);
|
|
|
+ if (overwrite)
|
|
|
mutex_unlock(&inode->i_mutex);
|
|
|
- }
|
|
|
|
|
|
/*
|
|
|
* We could direct write to holes and fallocate.
|
|
@@ -3189,7 +3188,7 @@ static ssize_t ext4_ext_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
|
|
|
}
|
|
|
|
|
|
if (overwrite) {
|
|
|
- get_block_func = ext4_get_block_write_nolock;
|
|
|
+ get_block_func = ext4_get_block_overwrite;
|
|
|
} else {
|
|
|
get_block_func = ext4_get_block_write;
|
|
|
dio_flags = DIO_LOCKING;
|
|
@@ -3245,10 +3244,8 @@ retake_lock:
|
|
|
if (iov_iter_rw(iter) == WRITE)
|
|
|
inode_dio_end(inode);
|
|
|
/* take i_mutex locking again if we do a ovewrite dio */
|
|
|
- if (overwrite) {
|
|
|
- up_read(&EXT4_I(inode)->i_data_sem);
|
|
|
+ if (overwrite)
|
|
|
mutex_lock(&inode->i_mutex);
|
|
|
- }
|
|
|
|
|
|
return ret;
|
|
|
}
|