From 16fb69c519b3d61bf57065587439b4260b40291a Mon Sep 17 00:00:00 2001 From: Sunny Kumar Date: Wed, 17 Oct 2018 15:40:04 +0530 Subject: shard: prevent segfault in shard_unlink_block_inode() gluster-blockd sometimes segfaults with the following backtrace: Core was generated by `/usr/sbin/gluster-blockd --glfs-lru-count 5 --log-level INFO'. Program terminated with signal 11, Segmentation fault. #0 0x00007fbb9cd639b9 in shard_unlink_block_inode (local=local@entry=0x7fbb80000a78, shard_block_num=) at shard.c:2929 2929 base_ictx->fsync_count--; (gdb) bt #0 0x00007fbb9cd639b9 in shard_unlink_block_inode (local=local@entry=0x7fbb80000a78, shard_block_num=) at shard.c:2929 #1 0x00007fbb9cd64311 in shard_unlink_shards_do_cbk (frame=frame@entry=0x7fbb9010a768, cookie=, this=, op_ret=, op_errno=, preparent=preparent@entry=0x7fbb7470dcf8, postparent=postparent@entry=0x7fbb7470dd90, xdata=xdata@entry=0x0) at shard.c:2987 A fix for this has already been provided through a Converity report. Backport of: > Change-Id: Ic5d302a5e32d375acf8adc412763ab94e6dabc3d > Signed-off-by: Sunny Kumar > (cherry picked from commit 145e180517054626d07892219fdee689b703c218) Change-Id: I699a039e9c5115eb3376190dd8014427d12a293b Updates: bz#1659563 Signed-off-by: Niels de Vos --- xlators/features/shard/src/shard.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 365147a3a95..ca91d4af65e 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -2926,7 +2926,8 @@ shard_unlink_block_inode(shard_local_t *local, int shard_block_num) list_del_init(&ctx->to_fsync_list); if (base_inode) __shard_inode_ctx_get(base_inode, this, &base_ictx); - base_ictx->fsync_count--; + if (base_ictx) + base_ictx->fsync_count--; } } UNLOCK(&inode->lock); -- cgit