Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd
[linux-3.10.git] / fs / exofs / super.c
index 65fe5de..735ca06 100644 (file)
 #include <linux/parser.h>
 #include <linux/vfs.h>
 #include <linux/random.h>
+#include <linux/module.h>
 #include <linux/exportfs.h>
 #include <linux/slab.h>
 
 #include "exofs.h"
 
+#define EXOFS_DBGMSG2(M...) do {} while (0)
+
 /******************************************************************************
  * MOUNT OPTIONS
  *****************************************************************************/
@@ -163,7 +166,6 @@ static struct inode *exofs_alloc_inode(struct super_block *sb)
 static void exofs_i_callback(struct rcu_head *head)
 {
        struct inode *inode = container_of(head, struct inode, i_rcu);
-       INIT_LIST_HEAD(&inode->i_dentry);
        kmem_cache_free(exofs_inode_cachep, exofs_i(inode));
 }
 
@@ -208,10 +210,48 @@ static void destroy_inodecache(void)
 }
 
 /******************************************************************************
- * SUPERBLOCK FUNCTIONS
+ * Some osd helpers
  *****************************************************************************/
-static const struct super_operations exofs_sops;
-static const struct export_operations exofs_export_ops;
+void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], const struct osd_obj_id *obj)
+{
+       osd_sec_init_nosec_doall_caps(cred_a, obj, false, true);
+}
+
+static int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj,
+                   u64 offset, void *p, unsigned length)
+{
+       struct osd_request *or = osd_start_request(od, GFP_KERNEL);
+/*     struct osd_sense_info osi = {.key = 0};*/
+       int ret;
+
+       if (unlikely(!or)) {
+               EXOFS_DBGMSG("%s: osd_start_request failed.\n", __func__);
+               return -ENOMEM;
+       }
+       ret = osd_req_read_kern(or, obj, offset, p, length);
+       if (unlikely(ret)) {
+               EXOFS_DBGMSG("%s: osd_req_read_kern failed.\n", __func__);
+               goto out;
+       }
+
+       ret = osd_finalize_request(or, 0, cred, NULL);
+       if (unlikely(ret)) {
+               EXOFS_DBGMSG("Failed to osd_finalize_request() => %d\n", ret);
+               goto out;
+       }
+
+       ret = osd_execute_request(or);
+       if (unlikely(ret))
+               EXOFS_DBGMSG("osd_execute_request() => %d\n", ret);
+       /* osd_req_decode_sense(or, ret); */
+
+out:
+       osd_end_request(or);
+       EXOFS_DBGMSG2("read_kern(0x%llx) offset=0x%llx "
+                     "length=0x%llx dev=%p ret=>%d\n",
+                     _LLU(obj->id), _LLU(offset), _LLU(length), od, ret);
+       return ret;
+}
 
 static const struct osd_attr g_attr_sb_stats = ATTR_DEF(
        EXOFS_APAGE_SB_DATA,
@@ -223,21 +263,19 @@ static int __sbi_read_stats(struct exofs_sb_info *sbi)
        struct osd_attr attrs[] = {
                [0] = g_attr_sb_stats,
        };
-       struct exofs_io_state *ios;
+       struct ore_io_state *ios;
        int ret;
 
-       ret = exofs_get_io_state(&sbi->layout, &ios);
+       ret = ore_get_io_state(&sbi->layout, &sbi->oc, &ios);
        if (unlikely(ret)) {
-               EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__);
+               EXOFS_ERR("%s: ore_get_io_state failed.\n", __func__);
                return ret;
        }
 
-       ios->cred = sbi->s_cred;
-
        ios->in_attr = attrs;
        ios->in_attr_len = ARRAY_SIZE(attrs);
 
-       ret = exofs_sbi_read(ios);
+       ret = ore_read(ios);
        if (unlikely(ret)) {
                EXOFS_ERR("Error reading super_block stats => %d\n", ret);
                goto out;
@@ -264,13 +302,13 @@ static int __sbi_read_stats(struct exofs_sb_info *sbi)
        }
 
 out:
-       exofs_put_io_state(ios);
+       ore_put_io_state(ios);
        return ret;
 }
 
-static void stats_done(struct exofs_io_state *ios, void *p)
+static void stats_done(struct ore_io_state *ios, void *p)
 {
-       exofs_put_io_state(ios);
+       ore_put_io_state(ios);
        /* Good thanks nothing to do anymore */
 }
 
@@ -280,12 +318,12 @@ int exofs_sbi_write_stats(struct exofs_sb_info *sbi)
        struct osd_attr attrs[] = {
                [0] = g_attr_sb_stats,
        };
-       struct exofs_io_state *ios;
+       struct ore_io_state *ios;
        int ret;
 
-       ret = exofs_get_io_state(&sbi->layout, &ios);
+       ret = ore_get_io_state(&sbi->layout, &sbi->oc, &ios);
        if (unlikely(ret)) {
-               EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__);
+               EXOFS_ERR("%s: ore_get_io_state failed.\n", __func__);
                return ret;
        }
 
@@ -293,29 +331,37 @@ int exofs_sbi_write_stats(struct exofs_sb_info *sbi)
        sbi->s_ess.s_numfiles = cpu_to_le64(sbi->s_numfiles);
        attrs[0].val_ptr = &sbi->s_ess;
 
-       ios->cred = sbi->s_cred;
+
        ios->done = stats_done;
        ios->private = sbi;
        ios->out_attr = attrs;
        ios->out_attr_len = ARRAY_SIZE(attrs);
 
-       ret = exofs_sbi_write(ios);
+       ret = ore_write(ios);
        if (unlikely(ret)) {
-               EXOFS_ERR("%s: exofs_sbi_write failed.\n", __func__);
-               exofs_put_io_state(ios);
+               EXOFS_ERR("%s: ore_write failed.\n", __func__);
+               ore_put_io_state(ios);
        }
 
        return ret;
 }
 
+/******************************************************************************
+ * SUPERBLOCK FUNCTIONS
+ *****************************************************************************/
+static const struct super_operations exofs_sops;
+static const struct export_operations exofs_export_ops;
+
 /*
  * Write the superblock to the OSD
  */
-int exofs_sync_fs(struct super_block *sb, int wait)
+static int exofs_sync_fs(struct super_block *sb, int wait)
 {
        struct exofs_sb_info *sbi;
        struct exofs_fscb *fscb;
-       struct exofs_io_state *ios;
+       struct ore_comp one_comp;
+       struct ore_components oc;
+       struct ore_io_state *ios;
        int ret = -ENOMEM;
 
        fscb = kmalloc(sizeof(*fscb), GFP_KERNEL);
@@ -331,7 +377,10 @@ int exofs_sync_fs(struct super_block *sb, int wait)
         * version). Otherwise the exofs_fscb is read-only from mkfs time. All
         * the writeable info is set in exofs_sbi_write_stats() above.
         */
-       ret = exofs_get_io_state(&sbi->layout, &ios);
+
+       exofs_init_comps(&oc, &one_comp, sbi, EXOFS_SUPER_ID);
+
+       ret = ore_get_io_state(&sbi->layout, &oc, &ios);
        if (unlikely(ret))
                goto out;
 
@@ -340,19 +389,17 @@ int exofs_sync_fs(struct super_block *sb, int wait)
        ios->length = offsetof(struct exofs_fscb, s_dev_table_oid);
        memset(fscb, 0, ios->length);
        fscb->s_nextid = cpu_to_le64(sbi->s_nextid);
-       fscb->s_numfiles = cpu_to_le32(sbi->s_numfiles);
+       fscb->s_numfiles = cpu_to_le64(sbi->s_numfiles);
        fscb->s_magic = cpu_to_le16(sb->s_magic);
        fscb->s_newfs = 0;
        fscb->s_version = EXOFS_FSCB_VER;
 
-       ios->obj.id = EXOFS_SUPER_ID;
        ios->offset = 0;
        ios->kern_buff = fscb;
-       ios->cred = sbi->s_cred;
 
-       ret = exofs_sbi_write(ios);
+       ret = ore_write(ios);
        if (unlikely(ret))
-               EXOFS_ERR("%s: exofs_sbi_write failed.\n", __func__);
+               EXOFS_ERR("%s: ore_write failed.\n", __func__);
        else
                sb->s_dirt = 0;
 
@@ -360,7 +407,7 @@ int exofs_sync_fs(struct super_block *sb, int wait)
        unlock_super(sb);
 out:
        EXOFS_DBGMSG("s_nextid=0x%llx ret=%d\n", _LLU(sbi->s_nextid), ret);
-       exofs_put_io_state(ios);
+       ore_put_io_state(ios);
        kfree(fscb);
        return ret;
 }
@@ -382,19 +429,20 @@ static void _exofs_print_device(const char *msg, const char *dev_path,
                msg, dev_path ?: "", odi->osdname, _LLU(pid));
 }
 
-void exofs_free_sbi(struct exofs_sb_info *sbi)
+static void exofs_free_sbi(struct exofs_sb_info *sbi)
 {
-       while (sbi->layout.s_numdevs) {
-               int i = --sbi->layout.s_numdevs;
-               struct osd_dev *od = sbi->layout.s_ods[i];
+       unsigned numdevs = sbi->oc.numdevs;
+
+       while (numdevs) {
+               unsigned i = --numdevs;
+               struct osd_dev *od = ore_comp_dev(&sbi->oc, i);
 
                if (od) {
-                       sbi->layout.s_ods[i] = NULL;
+                       ore_comp_set_dev(&sbi->oc, i, NULL);
                        osduld_put_device(od);
                }
        }
-       if (sbi->layout.s_ods != sbi->_min_one_dev)
-               kfree(sbi->layout.s_ods);
+       kfree(sbi->oc.ods);
        kfree(sbi);
 }
 
@@ -421,8 +469,8 @@ static void exofs_put_super(struct super_block *sb)
                                  msecs_to_jiffies(100));
        }
 
-       _exofs_print_device("Unmounting", NULL, sbi->layout.s_ods[0],
-                           sbi->layout.s_pid);
+       _exofs_print_device("Unmounting", NULL, ore_comp_dev(&sbi->oc, 0),
+                           sbi->one_comp.obj.partition);
 
        bdi_destroy(&sbi->bdi);
        exofs_free_sbi(sbi);
@@ -432,76 +480,20 @@ static void exofs_put_super(struct super_block *sb)
 static int _read_and_match_data_map(struct exofs_sb_info *sbi, unsigned numdevs,
                                    struct exofs_device_table *dt)
 {
-       u64 stripe_length;
+       int ret;
 
-       sbi->data_map.odm_num_comps   =
-                               le32_to_cpu(dt->dt_data_map.cb_num_comps);
-       sbi->data_map.odm_stripe_unit =
+       sbi->layout.stripe_unit =
                                le64_to_cpu(dt->dt_data_map.cb_stripe_unit);
-       sbi->data_map.odm_group_width =
+       sbi->layout.group_width =
                                le32_to_cpu(dt->dt_data_map.cb_group_width);
-       sbi->data_map.odm_group_depth =
+       sbi->layout.group_depth =
                                le32_to_cpu(dt->dt_data_map.cb_group_depth);
-       sbi->data_map.odm_mirror_cnt  =
-                               le32_to_cpu(dt->dt_data_map.cb_mirror_cnt);
-       sbi->data_map.odm_raid_algorithm  =
+       sbi->layout.mirrors_p1  =
+                               le32_to_cpu(dt->dt_data_map.cb_mirror_cnt) + 1;
+       sbi->layout.raid_algorithm  =
                                le32_to_cpu(dt->dt_data_map.cb_raid_algorithm);
 
-/* FIXME: Only raid0 for now. if not so, do not mount */
-       if (sbi->data_map.odm_num_comps != numdevs) {
-               EXOFS_ERR("odm_num_comps(%u) != numdevs(%u)\n",
-                         sbi->data_map.odm_num_comps, numdevs);
-               return -EINVAL;
-       }
-       if (sbi->data_map.odm_raid_algorithm != PNFS_OSD_RAID_0) {
-               EXOFS_ERR("Only RAID_0 for now\n");
-               return -EINVAL;
-       }
-       if (0 != (numdevs % (sbi->data_map.odm_mirror_cnt + 1))) {
-               EXOFS_ERR("Data Map wrong, numdevs=%d mirrors=%d\n",
-                         numdevs, sbi->data_map.odm_mirror_cnt);
-               return -EINVAL;
-       }
-
-       if (0 != (sbi->data_map.odm_stripe_unit & ~PAGE_MASK)) {
-               EXOFS_ERR("Stripe Unit(0x%llx)"
-                         " must be Multples of PAGE_SIZE(0x%lx)\n",
-                         _LLU(sbi->data_map.odm_stripe_unit), PAGE_SIZE);
-               return -EINVAL;
-       }
-
-       sbi->layout.stripe_unit = sbi->data_map.odm_stripe_unit;
-       sbi->layout.mirrors_p1 = sbi->data_map.odm_mirror_cnt + 1;
-
-       if (sbi->data_map.odm_group_width) {
-               sbi->layout.group_width = sbi->data_map.odm_group_width;
-               sbi->layout.group_depth = sbi->data_map.odm_group_depth;
-               if (!sbi->layout.group_depth) {
-                       EXOFS_ERR("group_depth == 0 && group_width != 0\n");
-                       return -EINVAL;
-               }
-               sbi->layout.group_count = sbi->data_map.odm_num_comps /
-                                               sbi->layout.mirrors_p1 /
-                                               sbi->data_map.odm_group_width;
-       } else {
-               if (sbi->data_map.odm_group_depth) {
-                       printk(KERN_NOTICE "Warning: group_depth ignored "
-                               "group_width == 0 && group_depth == %d\n",
-                               sbi->data_map.odm_group_depth);
-                       sbi->data_map.odm_group_depth = 0;
-               }
-               sbi->layout.group_width = sbi->data_map.odm_num_comps /
-                                                       sbi->layout.mirrors_p1;
-               sbi->layout.group_depth = -1;
-               sbi->layout.group_count = 1;
-       }
-
-       stripe_length = (u64)sbi->layout.group_width * sbi->layout.stripe_unit;
-       if (stripe_length >= (1ULL << 32)) {
-               EXOFS_ERR("Total Stripe length(0x%llx)"
-                         " >= 32bit is not supported\n", _LLU(stripe_length));
-               return -EINVAL;
-       }
+       ret = ore_verify_layout(numdevs, &sbi->layout);
 
        EXOFS_DBGMSG("exofs: layout: "
                "num_comps=%u stripe_unit=0x%x group_width=%u "
@@ -511,11 +503,11 @@ static int _read_and_match_data_map(struct exofs_sb_info *sbi, unsigned numdevs,
                sbi->layout.group_width,
                _LLU(sbi->layout.group_depth),
                sbi->layout.mirrors_p1,
-               sbi->data_map.odm_raid_algorithm);
-       return 0;
+               sbi->layout.raid_algorithm);
+       return ret;
 }
 
-static unsigned __ra_pages(struct exofs_layout *layout)
+static unsigned __ra_pages(struct ore_layout *layout)
 {
        const unsigned _MIN_RA = 32; /* min 128K read-ahead */
        unsigned ra_pages = layout->group_width * layout->stripe_unit /
@@ -537,7 +529,8 @@ static int exofs_devs_2_odi(struct exofs_dt_device_info *dt_dev,
                             struct osd_dev_info *odi)
 {
        odi->systemid_len = le32_to_cpu(dt_dev->systemid_len);
-       memcpy(odi->systemid, dt_dev->systemid, odi->systemid_len);
+       if (likely(odi->systemid_len))
+               memcpy(odi->systemid, dt_dev->systemid, OSD_SYSTEMID_LEN);
 
        odi->osdname_len = le32_to_cpu(dt_dev->osdname_len);
        odi->osdname = dt_dev->osdname;
@@ -558,13 +551,40 @@ static int exofs_devs_2_odi(struct exofs_dt_device_info *dt_dev,
        return !(odi->systemid_len || odi->osdname_len);
 }
 
+int __alloc_dev_table(struct exofs_sb_info *sbi, unsigned numdevs,
+                     struct exofs_dev **peds)
+{
+       struct __alloc_ore_devs_and_exofs_devs {
+               /* Twice bigger table: See exofs_init_comps() and comment at
+                * exofs_read_lookup_dev_table()
+                */
+               struct ore_dev *oreds[numdevs * 2 - 1];
+               struct exofs_dev eds[numdevs];
+       } *aoded;
+       struct exofs_dev *eds;
+       unsigned i;
+
+       aoded = kzalloc(sizeof(*aoded), GFP_KERNEL);
+       if (unlikely(!aoded)) {
+               EXOFS_ERR("ERROR: failed allocating Device array[%d]\n",
+                         numdevs);
+               return -ENOMEM;
+       }
+
+       sbi->oc.ods = aoded->oreds;
+       *peds = eds = aoded->eds;
+       for (i = 0; i < numdevs; ++i)
+               aoded->oreds[i] = &eds[i].ored;
+       return 0;
+}
+
 static int exofs_read_lookup_dev_table(struct exofs_sb_info *sbi,
                                       struct osd_dev *fscb_od,
                                       unsigned table_count)
 {
-       struct osd_obj_id obj = {.partition = sbi->layout.s_pid,
-                                .id = EXOFS_DEVTABLE_ID};
+       struct ore_comp comp;
        struct exofs_device_table *dt;
+       struct exofs_dev *eds;
        unsigned table_bytes = table_count * sizeof(dt->dt_dev_table[0]) +
                                             sizeof(*dt);
        unsigned numdevs, i;
@@ -577,8 +597,14 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info *sbi,
                return -ENOMEM;
        }
 
-       sbi->layout.s_numdevs = 0;
-       ret = exofs_read_kern(fscb_od, sbi->s_cred, &obj, 0, dt, table_bytes);
+       sbi->oc.numdevs = 0;
+
+       comp.obj.partition = sbi->one_comp.obj.partition;
+       comp.obj.id = EXOFS_DEVTABLE_ID;
+       exofs_make_credential(comp.cred, &comp.obj);
+
+       ret = exofs_read_kern(fscb_od, comp.cred, &comp.obj, 0, dt,
+                             table_bytes);
        if (unlikely(ret)) {
                EXOFS_ERR("ERROR: reading device table\n");
                goto out;
@@ -595,17 +621,16 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info *sbi,
        if (unlikely(ret))
                goto out;
 
-       if (likely(numdevs > 1)) {
-               unsigned size = numdevs * sizeof(sbi->layout.s_ods[0]);
-
-               sbi->layout.s_ods = kzalloc(size, GFP_KERNEL);
-               if (unlikely(!sbi->layout.s_ods)) {
-                       EXOFS_ERR("ERROR: faild allocating Device array[%d]\n",
-                                 numdevs);
-                       ret = -ENOMEM;
-                       goto out;
-               }
-       }
+       ret = __alloc_dev_table(sbi, numdevs, &eds);
+       if (unlikely(ret))
+               goto out;
+       /* exofs round-robins the device table view according to inode
+        * number. We hold a: twice bigger table hence inodes can point
+        * to any device and have a sequential view of the table
+        * starting at this device. See exofs_init_comps()
+        */
+       memcpy(&sbi->oc.ods[numdevs], &sbi->oc.ods[0],
+               (numdevs - 1) * sizeof(sbi->oc.ods[0]));
 
        for (i = 0; i < numdevs; i++) {
                struct exofs_fscb fscb;
@@ -621,13 +646,16 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info *sbi,
                printk(KERN_NOTICE "Add device[%d]: osd_name-%s\n",
                       i, odi.osdname);
 
+               /* the exofs id is currently the table index */
+               eds[i].did = i;
+
                /* On all devices the device table is identical. The user can
                 * specify any one of the participating devices on the command
                 * line. We always keep them in device-table order.
                 */
                if (fscb_od && osduld_device_same(fscb_od, &odi)) {
-                       sbi->layout.s_ods[i] = fscb_od;
-                       ++sbi->layout.s_numdevs;
+                       eds[i].ored.od = fscb_od;
+                       ++sbi->oc.numdevs;
                        fscb_od = NULL;
                        continue;
                }
@@ -640,13 +668,13 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info *sbi,
                        goto out;
                }
 
-               sbi->layout.s_ods[i] = od;
-               ++sbi->layout.s_numdevs;
+               eds[i].ored.od = od;
+               ++sbi->oc.numdevs;
 
                /* Read the fscb of the other devices to make sure the FS
                 * partition is there.
                 */
-               ret = exofs_read_kern(od, sbi->s_cred, &obj, 0, &fscb,
+               ret = exofs_read_kern(od, comp.cred, &comp.obj, 0, &fscb,
                                      sizeof(fscb));
                if (unlikely(ret)) {
                        EXOFS_ERR("ERROR: Malformed participating device "
@@ -663,13 +691,11 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info *sbi,
 
 out:
        kfree(dt);
-       if (unlikely(!ret && fscb_od)) {
-               EXOFS_ERR(
-                     "ERROR: Bad device-table container device not present\n");
-               osduld_put_device(fscb_od);
-               ret = -EINVAL;
+       if (unlikely(fscb_od && !ret)) {
+                       EXOFS_ERR("ERROR: Bad device-table container device not present\n");
+                       osduld_put_device(fscb_od);
+                       return -EINVAL;
        }
-
        return ret;
 }
 
@@ -683,7 +709,7 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
        struct exofs_sb_info *sbi;      /*extended info                  */
        struct osd_dev *od;             /* Master device                 */
        struct exofs_fscb fscb;         /*on-disk superblock info        */
-       struct osd_obj_id obj;
+       struct ore_comp comp;
        unsigned table_count;
        int ret;
 
@@ -714,26 +740,31 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
        sbi->layout.group_width = 1;
        sbi->layout.group_depth = -1;
        sbi->layout.group_count = 1;
-       sbi->layout.s_ods = sbi->_min_one_dev;
-       sbi->layout.s_numdevs = 1;
-       sbi->layout.s_pid = opts->pid;
        sbi->s_timeout = opts->timeout;
 
+       sbi->one_comp.obj.partition = opts->pid;
+       sbi->one_comp.obj.id = 0;
+       exofs_make_credential(sbi->one_comp.cred, &sbi->one_comp.obj);
+       sbi->oc.numdevs = 1;
+       sbi->oc.single_comp = EC_SINGLE_COMP;
+       sbi->oc.comps = &sbi->one_comp;
+
        /* fill in some other data by hand */
        memset(sb->s_id, 0, sizeof(sb->s_id));
        strcpy(sb->s_id, "exofs");
        sb->s_blocksize = EXOFS_BLKSIZE;
        sb->s_blocksize_bits = EXOFS_BLKSHIFT;
        sb->s_maxbytes = MAX_LFS_FILESIZE;
+       sb->s_max_links = EXOFS_LINK_MAX;
        atomic_set(&sbi->s_curr_pending, 0);
        sb->s_bdev = NULL;
        sb->s_dev = 0;
 
-       obj.partition = sbi->layout.s_pid;
-       obj.id = EXOFS_SUPER_ID;
-       exofs_make_credential(sbi->s_cred, &obj);
+       comp.obj.partition = sbi->one_comp.obj.partition;
+       comp.obj.id = EXOFS_SUPER_ID;
+       exofs_make_credential(comp.cred, &comp.obj);
 
-       ret = exofs_read_kern(od, sbi->s_cred, &obj, 0, &fscb, sizeof(fscb));
+       ret = exofs_read_kern(od, comp.cred, &comp.obj, 0, &fscb, sizeof(fscb));
        if (unlikely(ret))
                goto free_sbi;
 
@@ -766,7 +797,13 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
                if (unlikely(ret))
                        goto free_sbi;
        } else {
-               sbi->layout.s_ods[0] = od;
+               struct exofs_dev *eds;
+
+               ret = __alloc_dev_table(sbi, 1, &eds);
+               if (unlikely(ret))
+                       goto free_sbi;
+
+               ore_comp_set_dev(&sbi->oc, 0, od);
        }
 
        __sbi_read_stats(sbi);
@@ -783,9 +820,8 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
                ret = PTR_ERR(root);
                goto free_sbi;
        }
-       sb->s_root = d_alloc_root(root);
+       sb->s_root = d_make_root(root);
        if (!sb->s_root) {
-               iput(root);
                EXOFS_ERR("ERROR: get root inode failed\n");
                ret = -ENOMEM;
                goto free_sbi;
@@ -803,16 +839,19 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
        ret = bdi_setup_and_register(&sbi->bdi, "exofs", BDI_CAP_MAP_COPY);
        if (ret) {
                EXOFS_DBGMSG("Failed to bdi_setup_and_register\n");
+               dput(sb->s_root);
+               sb->s_root = NULL;
                goto free_sbi;
        }
 
-       _exofs_print_device("Mounting", opts->dev_name, sbi->layout.s_ods[0],
-                           sbi->layout.s_pid);
+       _exofs_print_device("Mounting", opts->dev_name,
+                           ore_comp_dev(&sbi->oc, 0),
+                           sbi->one_comp.obj.partition);
        return 0;
 
 free_sbi:
        EXOFS_ERR("Unable to mount exofs on %s pid=0x%llx err=%d\n",
-                 opts->dev_name, sbi->layout.s_pid, ret);
+                 opts->dev_name, sbi->one_comp.obj.partition, ret);
        exofs_free_sbi(sbi);
        return ret;
 }
@@ -844,7 +883,7 @@ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
        struct super_block *sb = dentry->d_sb;
        struct exofs_sb_info *sbi = sb->s_fs_info;
-       struct exofs_io_state *ios;
+       struct ore_io_state *ios;
        struct osd_attr attrs[] = {
                ATTR_DEF(OSD_APAGE_PARTITION_QUOTAS,
                        OSD_ATTR_PQ_CAPACITY_QUOTA, sizeof(__be64)),
@@ -853,21 +892,18 @@ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf)
        };
        uint64_t capacity = ULLONG_MAX;
        uint64_t used = ULLONG_MAX;
-       uint8_t cred_a[OSD_CAP_LEN];
        int ret;
 
-       ret = exofs_get_io_state(&sbi->layout, &ios);
+       ret = ore_get_io_state(&sbi->layout, &sbi->oc, &ios);
        if (ret) {
-               EXOFS_DBGMSG("exofs_get_io_state failed.\n");
+               EXOFS_DBGMSG("ore_get_io_state failed.\n");
                return ret;
        }
 
-       exofs_make_credential(cred_a, &ios->obj);
-       ios->cred = sbi->s_cred;
        ios->in_attr = attrs;
        ios->in_attr_len = ARRAY_SIZE(attrs);
 
-       ret = exofs_sbi_read(ios);
+       ret = ore_read(ios);
        if (unlikely(ret))
                goto out;
 
@@ -896,7 +932,7 @@ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf)
        buf->f_namelen = EXOFS_NAME_LEN;
 
 out:
-       exofs_put_io_state(ios);
+       ore_put_io_state(ios);
        return ret;
 }
 
@@ -915,7 +951,7 @@ static const struct super_operations exofs_sops = {
  * EXPORT OPERATIONS
  *****************************************************************************/
 
-struct dentry *exofs_get_parent(struct dentry *child)
+static struct dentry *exofs_get_parent(struct dentry *child)
 {
        unsigned long ino = exofs_parent_ino(child);