[Devel] [PATCH RHEL7 COMMIT] ext4: Extract logic from ext4_overwrite_io() to underlining function

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jun 18 20:09:12 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1127.10.1.vz7.162.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.10.1.vz7.162.4
------>
commit af054a9321d39928d1f7e8aa10a76ec30a30d2ef
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Thu Jun 18 20:09:11 2020 +0300

    ext4: Extract logic from ext4_overwrite_io() to underlining function
    
    Introduce __ext4_overwrite_io() with more arguments,
    and make ext4_overwrite_io() calling it.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =====================
    Patchset description:
    ploop: Add direct queuing support for io_kaio
    
    This introduces a possibility to dispath incomming request directly
    from ploop_make_request() without waking ploop thread up. We queue
    bio in case of it fits in a single extent (like fastpath for io_direct).
    To get the target bio location, ext4 extent tree is used.
    
    Currently, some sanity checks are missed, so that makes ploop file
    unsafe for touching by side software (like we have in io_direct).
    But this patchset is mostly for a view of testing improvements,
    and one else will go on top of this.
    
    Kirill Tkhai (3):
          ext4: Extract logic from ext4_overwrite_io() to underlining function
          ext4: Introduce ext4_fastmap()
          ploop: Introduce fastpath for io_kaio
---
 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 83f8aaaeda9d9..b187b9bbe5fc2 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