ore: Support for partial component table
authorBoaz Harrosh <bharrosh@panasas.com>
Wed, 28 Sep 2011 09:04:23 +0000 (12:04 +0300)
committerBoaz Harrosh <bharrosh@panasas.com>
Fri, 14 Oct 2011 16:54:41 +0000 (18:54 +0200)
Users like the objlayout-driver would like to only pass
a partial device table that covers the IO in question.
For example exofs divides the file into raid-group-sized
chunks and only serves group_width number of devices at
a time.

The partiality is communicated by setting
ore_componets->first_dev and the array covers all logical
devices from oc->first_dev upto (oc->first_dev + oc->numdevs)

The ore_comp_dev() API receives a logical device index
and returns the actual present device in the table.
An out-of-range dev_index will BUG.

Logical device index is the theoretical device index as if
all the devices of a file are present. .i.e:
total_devs = group_width * mirror_p1 * group_count
0 <= dev_index < total_devs

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
fs/exofs/exofs.h
fs/exofs/ore.c
include/scsi/osd_ore.h

index 006fd6f33571cd8cc0352c9e84d633c2aad2c8b2..51f4b4c40f095aab0a429d899c880d2884bf6869 100644 (file)
@@ -217,6 +217,7 @@ static inline void exofs_init_comps(struct ore_components *oc,
        one_comp->obj.id = oid;
        exofs_make_credential(one_comp->cred, &one_comp->obj);
 
+       oc->first_dev = 0;
        oc->numdevs = sbi->layout.group_width * sbi->layout.mirrors_p1 *
                                                        sbi->layout.group_count;
        oc->single_comp = EC_SINGLE_COMP;
index 8354fe061d1ce87e9036666ad1a7ec5b836d6af0..f1b718028a1f181f32c49589d1ab136f2894e626 100644 (file)
@@ -62,6 +62,10 @@ static struct osd_obj_id *_ios_obj(struct ore_io_state *ios, unsigned index)
 
 static struct osd_dev *_ios_od(struct ore_io_state *ios, unsigned index)
 {
+       ORE_DBGMSG2("oc->first_dev=%d oc->numdevs=%d i=%d oc->ods=%p\n",
+                   ios->oc->first_dev, ios->oc->numdevs, index,
+                   ios->oc->ods);
+
        return ore_comp_dev(ios->oc, index);
 }
 
index baeef0200a1fe102e9f9739d0b19f3874be7d531..492b70d43bb6c11a22d71069addcb1d2f725264c 100644 (file)
@@ -49,6 +49,7 @@ struct ore_dev {
 };
 
 struct ore_components {
+       unsigned        first_dev;              /* First logical device no    */
        unsigned        numdevs;                /* Num of devices in array    */
        /* If @single_comp == EC_SINGLE_COMP, @comps points to a single
         * component. else there are @numdevs components
@@ -70,14 +71,14 @@ struct ore_components {
 static inline struct osd_dev *ore_comp_dev(
        const struct ore_components *oc, unsigned i)
 {
-       BUG_ON(oc->numdevs <= i);
-       return oc->ods[i]->od;
+       BUG_ON((i < oc->first_dev) || (oc->first_dev + oc->numdevs <= i));
+       return oc->ods[i - oc->first_dev]->od;
 }
 
 static inline void ore_comp_set_dev(
        struct ore_components *oc, unsigned i, struct osd_dev *od)
 {
-       oc->ods[i]->od = od;
+       oc->ods[i - oc->first_dev]->od = od;
 }
 
 struct ore_striping_info {