From patchwork Fri Jan 21 16:53:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Rees X-Patchwork-Id: 495951 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0LGrHcK021711 for ; Fri, 21 Jan 2011 16:53:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754503Ab1AUQx5 (ORCPT ); Fri, 21 Jan 2011 11:53:57 -0500 Received: from magus.merit.edu ([198.108.1.13]:52024 "EHLO magus.merit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754486Ab1AUQx5 (ORCPT ); Fri, 21 Jan 2011 11:53:57 -0500 Received: from localhost (localhost [127.0.0.1]) by magus.merit.edu (Postfix) with ESMTP id D0F792259F0; Fri, 21 Jan 2011 11:53:56 -0500 (EST) X-Virus-Scanned: amavisd-new at magus.merit.edu Received: from magus.merit.edu ([127.0.0.1]) by localhost (magus.merit.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KYRnSe83i090; Fri, 21 Jan 2011 11:53:54 -0500 (EST) Received: from merit.edu (pietrapertosa.merit.edu [198.108.62.155]) by magus.merit.edu (Postfix) with ESMTPSA id 016572259DC; Fri, 21 Jan 2011 11:53:54 -0500 (EST) Date: Fri, 21 Jan 2011 11:53:53 -0500 From: Jim Rees To: Benny Halevy Cc: linux-nfs@vger.kernel.org, peter honeyman Subject: [PATCH 2/3] Fix calculation of stripe device and unit sizes Message-ID: <6eae3b83b619dc3965e1c0fd1110df2db76b9183.1295627825.git.rees@umich.edu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 21 Jan 2011 16:53:58 +0000 (UTC) diff --git a/utils/blkmapd/dm-device.c b/utils/blkmapd/dm-device.c index d720086..ee7d787 100644 --- a/utils/blkmapd/dm-device.c +++ b/utils/blkmapd/dm-device.c @@ -371,7 +371,7 @@ static int dm_device_exists(char *dev_name) /* TODO: check the value for DM_DEV_NAME_LEN, DM_TYPE_LEN, DM_PARAMS_LEN */ uint64_t dm_device_create(struct bl_volume *vols, int num_vols) { - uint64_t size, dev = 0; + uint64_t size, stripe_unit, stripe_size, nstripes, dev = 0; unsigned int count = dev_count; int volnum, i, pos; struct bl_volume *node; @@ -416,11 +416,25 @@ uint64_t dm_device_create(struct bl_volume *vols, int num_vols) if (!table) goto out; table->offset = 0; - table->size = node->bv_size; + stripe_unit = node->param.bv_stripe_unit << 9; + stripe_size = stripe_unit * node->bv_vol_n; + nstripes = node->bv_size * node->bv_vol_n / stripe_size; + /* Make sure total size is a multiple of stripe size */ + size = node->bv_size * node->bv_vol_n; + if (size % stripe_size != 0) { + /* XXX Should this be an error? */ + BL_LOG_WARNING( + "%s: %d units of %llu bytes is not a multiple of %lld stripe size\n", + __func__, node->bv_vol_n, + (long long unsigned) node->bv_size, + (long long unsigned) stripe_size); + size = nstripes * stripe_size; + } + table->size = size; strcpy(table->target_type, "striped"); - sprintf(table->params, "%d %lu %n", node->bv_vol_n, - node->param.bv_stripe_unit, &pos); - /* Repeatedly copy subdev to params */ + sprintf(table->params, "%d %llu %n", node->bv_vol_n, + (long long unsigned) stripe_unit, &pos); + /* Copy subdev major:minor to params */ tmp = table->params + pos; len = DM_PARAMS_LEN - pos; for (i = 0; i < node->bv_vol_n; i++) {