[Devel] [PATCH RH7 1/3] ext4: Extract logic from ext4_overwrite_io() to underlining function
Kirill Tkhai
ktkhai at virtuozzo.com
Wed Jun 17 19:09:25 MSK 2020
Introduce __ext4_overwrite_io() with more arguments,
and make ext4_overwrite_io() calling it.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
fs/ext4/file.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 83f8aaaeda9d..b187b9bbe5fc 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -95,27 +95,34 @@ ext4_unaligned_aio(struct inode *inode, size_t count, loff_t pos)
}
/* Is IO overwriting allocated and initialized blocks? */
-static bool ext4_overwrite_io(struct inode *inode, loff_t pos, loff_t len)
+static bool __ext4_overwrite_io(struct inode *inode, loff_t pos, loff_t len,
+ struct ext4_map_blocks *map, int flags)
{
- struct ext4_map_blocks map;
unsigned int blkbits = inode->i_blkbits;
int err, blklen;
if (pos + len > i_size_read(inode))
return false;
- map.m_lblk = pos >> blkbits;
- map.m_len = (EXT4_BLOCK_ALIGN(pos + len, blkbits) >> blkbits)
- - map.m_lblk;
- blklen = map.m_len;
+ map->m_lblk = pos >> blkbits;
+ map->m_len = (EXT4_BLOCK_ALIGN(pos + len, blkbits) >> blkbits)
+ - map->m_lblk;
+ blklen = map->m_len;
- err = ext4_map_blocks(NULL, inode, &map, 0);
+ err = ext4_map_blocks(NULL, inode, map, flags);
/*
* 'err==len' means that all of the blocks have been preallocated,
* regardless of whether they have been initialized or not. To exclude
* unwritten extents, we need to check m_flags.
*/
- return err == blklen && (map.m_flags & EXT4_MAP_MAPPED);
+ return err == blklen && (map->m_flags & EXT4_MAP_MAPPED);
+}
+
+static bool ext4_overwrite_io(struct inode *inode, loff_t pos, loff_t len)
+{
+ struct ext4_map_blocks map;
+
+ return __ext4_overwrite_io(inode, pos, len, &map, 0);
}
static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *iter, loff_t *pos)
More information about the Devel
mailing list