Blob Blame History Raw
From 7a578ddf23794d8a95000ce950807c88de74dfce Mon Sep 17 00:00:00 2001
From: Gaurav Kumar Garg <ggarg@redhat.com>
Date: Wed, 12 Aug 2015 15:00:29 +0530
Subject: [PATCH 276/279] libglusterfs: write error handling when filesystem have no space left

This is a backport of: http://review.gluster.org/#/c/11029/

When no space left on filesystem and user want to perform any operation
which result to change in /var/lib/glusterd/* files then glusterd is
failing to write on temporary file.

Fix is to handle error when write failed on temporary files due to no
space left on file system.

>Change-Id: I79d595776b42580da35e1282b4a3cd7fe3d14afe
>BUG: 1226829
>Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com>

Change-Id: Ifae5d27698025bb3b5cf7235449565575e762451
BUG: 1226665
Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/54977
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Niels de Vos <ndevos@redhat.com>
---
 libglusterfs/src/store.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c
index 7c8b29d..8442b31 100644
--- a/libglusterfs/src/store.c
+++ b/libglusterfs/src/store.c
@@ -345,15 +345,15 @@ gf_store_save_value (int fd, char *key, char *value)
 
         fp = fdopen (dup_fd, "a+");
         if (fp == NULL) {
-                gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
-                        "fdopen failed.");
+                gf_msg (THIS->name, GF_LOG_WARNING, errno,
+                        LG_MSG_FILE_OP_FAILED, "fdopen failed.");
                 ret = -1;
                 goto out;
         }
 
         ret = fprintf (fp, "%s=%s\n", key, value);
         if (ret < 0) {
-                gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
+                gf_msg (THIS->name, GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
                         "Unable to store key: %s, value: %s.",
                         key, value);
                 ret = -1;
@@ -361,8 +361,8 @@ gf_store_save_value (int fd, char *key, char *value)
         }
 
         ret = fflush (fp);
-        if (feof (fp)) {
-                gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
+        if (ret) {
+                gf_msg (THIS->name, GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
                         "fflush failed.");
                 ret = -1;
                 goto out;
@@ -373,7 +373,7 @@ out:
         if (fp)
                 fclose (fp);
 
-        gf_msg_debug ("", 0, "returning: %d", ret);
+        gf_msg_debug (THIS->name, 0, "returning: %d", ret);
         return ret;
 }
 
-- 
1.7.1