xfs
[Top] [All Lists]

[PATCH 3/7] iomap: fiemap should honor the FIEMAP_FLAG_SYNC flag

To: xfs@xxxxxxxxxxx
Subject: [PATCH 3/7] iomap: fiemap should honor the FIEMAP_FLAG_SYNC flag
From: Christoph Hellwig <hch@xxxxxx>
Date: Sat, 13 Aug 2016 16:42:57 -0700
Cc: Dave Chinner <dchinner@xxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1471131781-14107-1-git-send-email-hch@xxxxxx>
References: <1471131781-14107-1-git-send-email-hch@xxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

The flag is checked as supported, but then we do an unconditional
sync of the file, regardless of whether the flag is set or not. Make
the sync conditional on having the FIEMAP_FLAG_SYNC flag set.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 fs/iomap.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index 74712e2..56c19e6 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -467,9 +467,11 @@ int iomap_fiemap(struct inode *inode, struct 
fiemap_extent_info *fi,
        if (ret)
                return ret;
 
-       ret = filemap_write_and_wait(inode->i_mapping);
-       if (ret)
-               return ret;
+       if (fi->fi_flags & FIEMAP_FLAG_SYNC) {
+               ret = filemap_write_and_wait(inode->i_mapping);
+               if (ret)
+                       return ret;
+       }
 
        while (len > 0) {
                ret = iomap_apply(inode, start, len, 0, ops, &ctx,
-- 
2.1.4

<Prev in Thread] Current Thread [Next in Thread>