[Devel] [PATCH RHEL7 COMMIT] ext4: Use initial count in ext4_ind_direct_IO()

Vasily Averin vvs at virtuozzo.com
Tue Jun 22 21:51:28 MSK 2021


The commit is pushed to "branch-rh7-3.10.0-1160.31.1.vz7.181.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.31.1.vz7.181.8
------>
commit ddc33f38cc64fcef425fb489a3cb90df4d9c1ec4
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Tue Jun 22 21:51:28 2021 +0300

    ext4: Use initial count in ext4_ind_direct_IO()
    
    We can't use iov_iter_count() here, since iter is advanced in:
    
    __blockdev_direct_IO()->do_direct_IO()->dio_refill_pages().
    
    In case of iter is completely advanced and direct IO failed
    on last page, iov_iter_count(iter) returns 0 here. Then,
    we have end == isize, and ext4_truncate_failed_write()
    is not called (this function cancels partially completed
    writes). In further, we have a written extent after
    inode size, since ext4_update_i_disksize() is not called
    in this function.
    
    Note, that BUG actually becomes visible after 884dd390d7a0
    "new helper: iov_iter_npages()", while it's introduced earlier.
    
    https://jira.sw.ru/browse/PSBM-129846
    
    Fixes: 6072179f278a "ext4: Use iov_iter argument in direct_IO functions"
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 fs/ext4/indirect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index b598607..513d05d 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -730,7 +730,7 @@ locked:
 
 		if (unlikely((rw & WRITE) && ret < 0)) {
 			loff_t isize = i_size_read(inode);
-			loff_t end = offset + iov_iter_count(iter);
+			loff_t end = offset + count;
 
 			if (end > isize)
 				ext4_truncate_failed_write(inode);


More information about the Devel mailing list