[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 1/7] gluster: Move glfs_close() to create's clean-up
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH 1/7] gluster: Move glfs_close() to create's clean-up |
Date: |
Tue, 13 Feb 2018 14:03:50 +0100 |
glfs_close() is a classical clean-up operation, as can be seen by the
fact that it is executed even if the truncation before it failed.
Also, moving it to clean-up makes it more clear that if it fails, we do
not want it to overwrite the current ret value if that signifies an
error already.
Signed-off-by: Max Reitz <address@hidden>
---
block/gluster.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/block/gluster.c b/block/gluster.c
index d8decc41ad..7fab2dfa12 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -970,7 +970,7 @@ static int qemu_gluster_create(const char *filename,
{
BlockdevOptionsGluster *gconf;
struct glfs *glfs;
- struct glfs_fd *fd;
+ struct glfs_fd *fd = NULL;
int ret = 0;
PreallocMode prealloc;
int64_t total_size = 0;
@@ -1054,10 +1054,12 @@ static int qemu_gluster_create(const char *filename,
break;
}
- if (glfs_close(fd) != 0) {
- ret = -errno;
- }
out:
+ if (fd) {
+ if (glfs_close(fd) != 0 && ret == 0) {
+ ret = -errno;
+ }
+ }
qapi_free_BlockdevOptionsGluster(gconf);
glfs_clear_preopened(glfs);
return ret;
--
2.14.3
- [Qemu-block] [PATCH 0/7] block: Preallocated truncation for gluster and sheepdog, Max Reitz, 2018/02/13
- [Qemu-block] [PATCH 2/7] gluster: Pull truncation from qemu_gluster_create, Max Reitz, 2018/02/13
- [Qemu-block] [PATCH 4/7] gluster: Add preallocated truncation, Max Reitz, 2018/02/13
- [Qemu-block] [PATCH 1/7] gluster: Move glfs_close() to create's clean-up,
Max Reitz <=
- [Qemu-block] [PATCH 5/7] sheepdog: Make sd_prealloc() take a BDS, Max Reitz, 2018/02/13
- [Qemu-block] [PATCH 7/7] sheepdog: Allow fully preallocated truncation, Max Reitz, 2018/02/13
- [Qemu-block] [PATCH 3/7] gluster: Query current size in do_truncate(), Max Reitz, 2018/02/13
- [Qemu-block] [PATCH 6/7] sheepdog: Pass old and new size to sd_prealloc(), Max Reitz, 2018/02/13
- Re: [Qemu-block] [PATCH 0/7] block: Preallocated truncation for gluster and sheepdog, Kevin Wolf, 2018/02/13