From patchwork Thu Jul 12 17:05:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1190021 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 27401DFFFE for ; Thu, 12 Jul 2012 17:05:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934096Ab2GLRFX (ORCPT ); Thu, 12 Jul 2012 13:05:23 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:37636 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932521Ab2GLRFW (ORCPT ); Thu, 12 Jul 2012 13:05:22 -0400 Received: by mail-yx0-f174.google.com with SMTP id l2so2639200yen.19 for ; Thu, 12 Jul 2012 10:05:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=OOnySPM9flOUOu5XNiTl67BTACP+QjmOnniQviYIHcc=; b=laQIRuP65FS7lXtRRlsO2pAU2mrqZ/lKUou7C6QNStQdO7uYXCN3s4PV5rkb0USRxR TSJgjYI5yBnTVo73qEPf3CXrpCuTv8/+NnWuCJO7k4aYnTqJiOsGr0mxr9Ruo/HtOxXe WA75LpgzXL9xIIrGXwVPKcoccbNn6sB2zXWUesAOoZS7BugzlEHbQnS4jJBJhEGCmW5X 2caaa2omShOZTiOU0tO1sMnyWygml5yD6BvPV3pc786G+eXKdbs4VjEj4R7fP+H6g7xK Y6m/2h9neDNy/SyDUpdqDtRHh/k6yzPotslj1P6ix7AbHpfY9qioIeCn6bPIh1xd6zso bSXA== Received: by 10.101.90.12 with SMTP id s12mr17484882anl.18.1342112722070; Thu, 12 Jul 2012 10:05:22 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id r25sm9736124yhi.13.2012.07.12.10.05.21 (version=SSLv3 cipher=OTHER); Thu, 12 Jul 2012 10:05:21 -0700 (PDT) Message-ID: <4FFF03D0.2010604@inktank.com> Date: Thu, 12 Jul 2012 12:05:20 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH] rbd: create pool_id device attribute References: <4FFD847C.7070205@inktank.com> <4FFD875B.3060608@inktank.com> In-Reply-To: <4FFD875B.3060608@inktank.com> X-Gm-Message-State: ALoCoQmLVMM3kpiCnEKJ17BSKrmBJQ46F5flgR1+es1OtaGS3KfitPgLzxQ5NKnaJBeRBxgV0hWZ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Add an entry under /sys/bus/rbd/devices// named "pool_id" that provides the id for the pool the rbd image is assocatied with. This is in addition to the pool name already provided. Rename the "poolid" field in struct rbd_device to be "pool_id". Signed-off-by: Alex Elder --- drivers/block/rbd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/drivers/block/rbd.c =================================================================== --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -167,7 +167,7 @@ struct rbd_device { int obj_len; char obj_md_name[RBD_MAX_MD_NAME_LEN]; /* hdr nm. */ char pool_name[RBD_MAX_POOL_NAME_LEN]; - int poolid; + int pool_id; struct ceph_osd_event *watch_event; struct ceph_osd_request *watch_request; @@ -920,7 +920,7 @@ static int rbd_do_request(struct request layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); layout->fl_stripe_count = cpu_to_le32(1); layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); - layout->fl_pg_pool = cpu_to_le32(dev->poolid); + layout->fl_pg_pool = cpu_to_le32(dev->pool_id); ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno, req, ops); @@ -1643,7 +1643,7 @@ static int rbd_header_add_snap(struct rb return -EINVAL; monc = &dev->rbd_client->client->monc; - ret = ceph_monc_create_snapid(monc, dev->poolid, &new_snapid); + ret = ceph_monc_create_snapid(monc, dev->pool_id, &new_snapid); dout("created snapid=%lld\n", new_snapid); if (ret < 0) return ret; @@ -1847,6 +1847,14 @@ static ssize_t rbd_pool_show(struct devi return sprintf(buf, "%s\n", rbd_dev->pool_name); } +static ssize_t rbd_pool_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); + + return sprintf(buf, "%d\n", rbd_dev->pool_id); +} + static ssize_t rbd_name_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -1887,6 +1895,7 @@ static DEVICE_ATTR(size, S_IRUGO, rbd_si static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL); static DEVICE_ATTR(client_id, S_IRUGO, rbd_client_id_show, NULL); static DEVICE_ATTR(pool, S_IRUGO, rbd_pool_show, NULL); +static DEVICE_ATTR(pool_id, S_IRUGO, rbd_pool_id_show, NULL); static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL); static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh); static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL); @@ -1897,6 +1906,7 @@ static struct attribute *rbd_attrs[] = { &dev_attr_major.attr, &dev_attr_client_id.attr, &dev_attr_pool.attr, + &dev_attr_pool_id.attr, &dev_attr_name.attr, &dev_attr_current_snap.attr, &dev_attr_refresh.attr, @@ -2430,7 +2440,7 @@ static ssize_t rbd_add(struct bus_type * rc = ceph_pg_poolid_by_name(osdc->osdmap, rbd_dev->pool_name); if (rc < 0) goto err_out_client; - rbd_dev->poolid = rc; + rbd_dev->pool_id = rc; /* register our block device */ rc = register_blkdev(0, rbd_dev->name);