[sheepdog] [PATCH 2/2] sheep: fix error handling in local_stat_cluster
Christoph Hellwig
hch at infradead.org
Tue Jun 5 13:53:45 CEST 2012
Error out and print a debug message if epoch_log_read_remote doesn't manage
to return a node list. Without this we touch possibly uninitialized memory
in get_max_nr_copies_from.
Signed-off-by: Christoph Hellwig <hch at lst.de>
diff --git a/sheep/ops.c b/sheep/ops.c
index a6f0670..27ca07d 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -351,10 +351,16 @@ static int local_stat_cluster(struct request *req)
log->ctime = get_cluster_ctime();
log->nr_nodes = epoch_log_read(epoch, (char *)log->nodes,
sizeof(log->nodes));
- if (log->nr_nodes == -1)
+ if (log->nr_nodes == -1) {
log->nr_nodes = epoch_log_read_remote(epoch,
(char *)log->nodes,
sizeof(log->nodes));
+ }
+ if (log->nr_nodes == -1) {
+ eprintf("Failed to read log for epoch %d\n", i);
+ break;
+ }
+
log->nr_copies = get_max_nr_copies_from(log->nodes, log->nr_nodes);
rsp->data_length += sizeof(*log);
More information about the sheepdog
mailing list