[Devel] [PATCH 11/13] fs: FIEMAP should sync only required range with FIEMAP_FLAG_SYNC

Alexander Mikhalitsyn alexander.mikhalitsyn at virtuozzo.com
Wed Apr 14 10:44:56 MSK 2021


From: Maxim Patlasov <mpatlasov at virtuozzo.com>

https://jira.sw.ru/browse/PSBM-68226

== combined with:

fs: ioctl_fiemap must check what filemap_write_and_wait_range returns

It's safer to check if filemap_write_and_wait_range succeeded or not.

https://jira.sw.ru/browse/PSBM-68454

Signed-off-by: Alexey Kuznetsov <kuznet at virtuozzo.com>
Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>

VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127782

Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
 fs/ioctl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index df792d63bced..920dd71d8827 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -210,8 +210,12 @@ static int ioctl_fiemap(struct file *filp, struct fiemap __user *ufiemap)
 		       fieinfo.fi_extents_max * sizeof(struct fiemap_extent)))
 		return -EFAULT;
 
-	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
-		filemap_write_and_wait(inode->i_mapping);
+	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC) {
+		error = filemap_write_and_wait_range(inode->i_mapping,
+				fiemap.fm_start, fiemap.fm_start + len - 1);
+		if (error)
+			return error;
+	}
 
 	error = inode->i_op->fiemap(inode, &fieinfo, fiemap.fm_start, len);
 	fiemap.fm_flags = fieinfo.fi_flags;
-- 
2.28.0



More information about the Devel mailing list