Skip to contentSkip to conversation

f2fs: fix to cover f2fs_fiemap with inode_lock

PATCH Superseded Chao Yu 2 participants 2 messages Jan 10, 2018 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 f2fs: fix to cover f2fs_fiemap with inode_lock

This patch fix to cover f2fs_fiemap with inode_lock in order to make the whole interface avoiding race with mapping change.

---
 fs/f2fs/data.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/f2fs/data.c +4 -4
index d6302051a65d..330085d3adfc 100644
@@ -1146,18 +1146,18 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 	u32 flags = 0;
 	int ret = 0;
 
+	inode_lock(inode);
+
 	ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC);
 	if (ret)
-		return ret;
+		goto out;
 
 	if (f2fs_has_inline_data(inode)) {
 		ret = f2fs_inline_data_fiemap(inode, fieinfo, start, len);
 		if (ret != -EAGAIN)
-			return ret;
+			goto out;
 	}
 
-	inode_lock(inode);
-
 	if (logical_to_blk(inode, len) == 0)
 		len = blk_to_logical(inode, 1);
 
Signature · 1 line
2.15.0.55.gc2ece9dc4de6
maintainer
#1 lore raw
Quoted 13 lines · Chao Yu

This patch fix to cover f2fs_fiemap with inode_lock in order to make the whole interface avoiding race with mapping change.

---
 fs/f2fs/data.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/f2fs/data.c +0 -0
index d6302051a65d..330085d3adfc 100644

fs/f2fs/data.c int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, · line 1153

Quoted 9 lines
fs/f2fs/data.c +3 -1
@@ -1146,18 +1146,18 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 	u32 flags = 0;
 	int ret = 0;
 
+	inode_lock(inode);
+
 	ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC);
 	if (ret)
-		return ret;
+		goto out;

Uh? We don't need to cover fiemap_check_flags() by inode_lock().

Quoted 15 lines
fs/f2fs/data.c +1 -3
 	if (f2fs_has_inline_data(inode)) {
 		ret = f2fs_inline_data_fiemap(inode, fieinfo, start, len);
 		if (ret != -EAGAIN)
-			return ret;
+			goto out;
 	}
 
-	inode_lock(inode);
-
 	if (logical_to_blk(inode, len) == 0)
 		len = blk_to_logical(inode, 1);
 
Signature · 1 line
2.15.0.55.gc2ece9dc4de6