74096c
From 5a110946b41619577b365cdceddc4da551ff49f0 Mon Sep 17 00:00:00 2001
74096c
From: kinsu <vpolakis@gmail.com>
74096c
Date: Thu, 19 Sep 2019 08:34:32 +0000
74096c
Subject: [PATCH 490/511] Segmentation fault occurs during truncate
74096c
74096c
Problem:
74096c
Segmentation fault occurs when bricks are nearly full 100% and in
74096c
parallel truncate of a file is attempted (No space left on device).
74096c
Prerequicite is that performance xlators are activated
74096c
(read-ahead, write-behind etc)
74096c
while stack unwind of the frames following an error responce
74096c
from brick (No space left on device) frame->local includes a memory
74096c
location that is not allocated via mem_get but via calloc.
74096c
The destroyed frame is always ra_truncate_cbk winded from ra_ftruncate
74096c
and the inode ptr is copied to the frame local in the wb_ftruncate.
74096c
74096c
Fix:
74096c
extra check is added for the pool ptr
74096c
74096c
>Change-Id: Ic5d3bd0ab7011e40b2811c6dece063b256e4d9d1
74096c
>Fixes: bz#1797882
74096c
>Signed-off-by: kinsu <vpolakis@gmail.com>
74096c
74096c
Upstream-patch: https://review.gluster.org/c/glusterfs/+/23445
74096c
74096c
BUG: 1842449
74096c
Change-Id: Ic5d3bd0ab7011e40b2811c6dece063b256e4d9d1
74096c
Signed-off-by: nik-redhat <nladha@redhat.com>
74096c
Reviewed-on: https://code.engineering.redhat.com/gerrit/220540
74096c
Tested-by: RHGS Build Bot <nigelb@redhat.com>
74096c
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
74096c
---
74096c
 libglusterfs/src/mem-pool.c | 8 ++++++++
74096c
 1 file changed, 8 insertions(+)
74096c
74096c
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
74096c
index 73503e0..1390747 100644
74096c
--- a/libglusterfs/src/mem-pool.c
74096c
+++ b/libglusterfs/src/mem-pool.c
74096c
@@ -857,6 +857,14 @@ mem_put(void *ptr)
74096c
         /* Not one of ours; don't touch it. */
74096c
         return;
74096c
     }
74096c
+
74096c
+    if (!hdr->pool_list) {
74096c
+        gf_msg_callingfn("mem-pool", GF_LOG_CRITICAL, EINVAL,
74096c
+                         LG_MSG_INVALID_ARG,
74096c
+                         "invalid argument hdr->pool_list NULL");
74096c
+        return;
74096c
+    }
74096c
+
74096c
     pool_list = hdr->pool_list;
74096c
     pt_pool = &pool_list->pools[hdr->power_of_two - POOL_SMALLEST];
74096c
 
74096c
-- 
74096c
1.8.3.1
74096c