[Devel] [PATCH RHEL7 COMMIT] ext4: fix seek_data soft lookup on sparse files

Konstantin Khorenko khorenko at virtuozzo.com
Mon Feb 27 06:16:06 PST 2017


The commit is pushed to "branch-rh7-3.10.0-514.6.1.vz7.28.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.6.1.vz7.28.7
------>
commit 780346f14210fba056968e6ed743449d4e8ebf68
Author: Dmitry Monakhov <dmonakhov at openvz.org>
Date:   Mon Feb 27 18:16:06 2017 +0400

    ext4: fix seek_data soft lookup on sparse files
    
    Good fix requires optimal implementation of next_extent like it was done in
    
    14516bb ("ext4: fix suboptimal seek_{data,hole} extents traversial") or
    2d90c160 ("ext4: more efficient SEEK_DATA implementation"),
    
    but this makes patch huge, let's just break the loop when necessery.
    
    https://jira.sw.ru/browse/PSBM-55818
    
    Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
 fs/ext4/file.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index c63d937..167e262 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -612,7 +612,17 @@ static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
 			if (unwritten)
 				break;
 		}
-
+		if (signal_pending(current)) {
+			mutex_unlock(&inode->i_mutex);
+			return -EINTR;
+		}
+		if (need_resched()) {
+			mutex_unlock(&inode->i_mutex);
+			cond_resched();
+			mutex_lock(&inode->i_mutex);
+			isize = inode->i_size;
+			end = isize >> blkbits;
+		}
 		last++;
 		dataoff = (loff_t)last << blkbits;
 	} while (last <= end);


More information about the Devel mailing list