From: Jason Dillaman Date: Tue, 21 Oct 2014 07:42:13 +0000 (-0400) Subject: rbd: Correct readahead divide by zero exception X-Git-Tag: v0.88~49^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fbf89f50dd15d7b5093af72cf3c391c0f525fc55;p=ceph.git rbd: Correct readahead divide by zero exception When readahead is used on old-format RBD images, a divide by zero signal will be thrown. This was caused by initializing the readahead alignments prior to initializing the stripe layout of old-format RBD images. Fixes: 9857 Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index ee757d9464a..c9b74f232a8 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -162,17 +162,11 @@ namespace librbd { } md_config_t *conf = cct->_conf; - vector alignments; - alignments.push_back(stripe_count << order); // object set (in file striping terminology) - alignments.push_back(stripe_unit * stripe_count); // stripe - alignments.push_back(stripe_unit); // stripe unit readahead.set_trigger_requests(conf->rbd_readahead_trigger_requests); readahead.set_max_readahead_size(conf->rbd_readahead_max_bytes); - readahead.set_alignments(alignments); - return 0; } - + void ImageCtx::init_layout() { if (stripe_unit == 0 || stripe_count == 0) { @@ -180,6 +174,12 @@ namespace librbd { stripe_count = 1; } + vector alignments; + alignments.push_back(stripe_count << order); // object set (in file striping terminology) + alignments.push_back(stripe_unit * stripe_count); // stripe + alignments.push_back(stripe_unit); // stripe unit + readahead.set_alignments(alignments); + memset(&layout, 0, sizeof(layout)); layout.fl_stripe_unit = stripe_unit; layout.fl_stripe_count = stripe_count;