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

Submitted by Konstantin Khorenko on Feb. 27, 2017, 2:16 p.m.

Details

Message ID 201702271416.v1REG6vL027024@finist_cl7.x64_64.work.ct
State New
Series "ext4: fix seek_data soft lookup on sparse files"
Headers show

Commit Message

Konstantin Khorenko Feb. 27, 2017, 2:16 p.m.
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@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@openvz.org>
---
 fs/ext4/file.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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);