Skip to contentSkip to conversation

virtiofs: fix return value of iomap_begin_upgrade_mapping

PATCH In review Liu Bo 4 participants 6 messages Aug 21, 2019 – Aug 23, 2019 FUSE filesystem core

lore
Share & tools
lore

Liu Bo

author
#0 lore raw

PATCH 1/1 virtiofs: fix return value of iomap_begin_upgrade_mapping

Set ret = 0 if everything runs fine.

---
 fs/fuse/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/fuse/file.c +1 -0
index eb7543a..d3c5e45 100644
@@ -1985,6 +1985,7 @@ static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos,
 
 out_fill_iomap:
 	fuse_fill_iomap(inode, pos, length, iomap, dmap, flags);
+	ret = 0;
 out_err:
 	up_write(&fi->i_dmap_sem);
 	return ret;
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Liu Bo

Set ret = 0 if everything runs fine.

FYI, this fixes generic/344 failure.

fs/fuse/file.c static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos, · line 1988

Quoted 13 lines
---
 fs/fuse/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/fuse/file.c +1 -0
index eb7543a..d3c5e45 100644
@@ -1985,6 +1985,7 @@ static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos,
 
 out_fill_iomap:
 	fuse_fill_iomap(inode, pos, length, iomap, dmap, flags);
+	ret = 0;

I'd prefer setting ret in the if (dmap->writable) case, which seems more clear to me. i.e.

	if (dmap->writable) {
		ret = 0;
		goto out_fill_iomap;
	}

Anyway,

Thanks!
Eryu

Quoted 10 lines
fs/fuse/file.c +0 -0
 out_err:
 	up_write(&fi->i_dmap_sem);
 	return ret;
Signature · 6 lines
1.8.3.1

_______________________________________________
Virtio-fs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virtio-fs
Reviewed-by
#2 lore raw
Quoted 24 lines · Eryu Guan
Quoted 3 lines · Liu Bo

Set ret = 0 if everything runs fine.

FYI, this fixes generic/344 failure.

fs/fuse/file.c static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos, · line 1988

Quoted 13 lines
---
 fs/fuse/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/fuse/file.c +1 -0
index eb7543a..d3c5e45 100644
@@ -1985,6 +1985,7 @@ static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos,
 
 out_fill_iomap:
 	fuse_fill_iomap(inode, pos, length, iomap, dmap, flags);
+	ret = 0;

I'd prefer setting ret in the if (dmap->writable) case, which seems more clear to me. i.e.

Quoted 4 lines
	if (dmap->writable) {
		ret = 0;
		goto out_fill_iomap;
	}

Agreed, and feel free to add:

Jun

#3 lore raw
In reply to Liu Bo
Quoted 12 lines · Liu Bo

Set ret = 0 if everything runs fine.

---
 fs/fuse/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/fuse/file.c +0 -0
index eb7543a..d3c5e45 100644

fs/fuse/file.c static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos, · line 1988

Quoted 4 lines
fs/fuse/file.c +1 -0
@@ -1985,6 +1985,7 @@ static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos,
 
 out_fill_iomap:
 	fuse_fill_iomap(inode, pos, length, iomap, dmap, flags);
+	ret = 0;

Thanks. I initialized ret = 0 in the beginning itself now.

Vivek

Quoted 10 lines
fs/fuse/file.c +0 -0
 out_err:
 	up_write(&fi->i_dmap_sem);
 	return ret;
Signature · 6 lines
1.8.3.1

_______________________________________________
Virtio-fs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virtio-fs
#4 lore raw
Quoted 14 lines · Vivek Goyal
Quoted 13 lines · Liu Bo

Set ret = 0 if everything runs fine.

---
 fs/fuse/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/fuse/file.c +0 -0
index eb7543a..d3c5e45 100644
@@ -1985,6 +1985,7 @@ static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos,
 
Quoted 5 lines

fs/fuse/file.c static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos, · line 1988

Quoted 3 lines
fs/fuse/file.c +1 -0
 out_fill_iomap:
 	fuse_fill_iomap(inode, pos, length, iomap, dmap, flags);
+	ret = 0;

Thanks. I initialized ret = 0 in the beginning itself now.

This probably would not work as ret will be set -EIO again immediately.

Jun

#5 lore raw
Quoted 17 lines · piaojun
Quoted 14 lines · Vivek Goyal
Quoted 13 lines · Liu Bo

Set ret = 0 if everything runs fine.

---
 fs/fuse/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/fuse/file.c +0 -0
index eb7543a..d3c5e45 100644
@@ -1985,6 +1985,7 @@ static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos,
 
Quoted 7 lines
Quoted 5 lines

fs/fuse/file.c static int iomap_begin_upgrade_mapping(struct inode *inode, loff_t pos, · line 1988

Quoted 3 lines
fs/fuse/file.c +1 -0
 out_fill_iomap:
 	fuse_fill_iomap(inode, pos, length, iomap, dmap, flags);
+	ret = 0;

Thanks. I initialized ret = 0 in the beginning itself now.

This probably would not work as ret will be set -EIO again immediately.

I changed that ret = -EIO as well. I now set it only when error happens.

Vivek