libnvdimm/namespace: Differentiate between probe mapping and runtime mapping
[linux-2.6-microblaze.git] / drivers / nvdimm / btt.c
index a8d5688..8cb890a 100644 (file)
@@ -392,9 +392,9 @@ static int btt_flog_write(struct arena_info *arena, u32 lane, u32 sub,
        arena->freelist[lane].sub = 1 - arena->freelist[lane].sub;
        if (++(arena->freelist[lane].seq) == 4)
                arena->freelist[lane].seq = 1;
-       if (ent_e_flag(ent->old_map))
+       if (ent_e_flag(le32_to_cpu(ent->old_map)))
                arena->freelist[lane].has_err = 1;
-       arena->freelist[lane].block = le32_to_cpu(ent_lba(ent->old_map));
+       arena->freelist[lane].block = ent_lba(le32_to_cpu(ent->old_map));
 
        return ret;
 }
@@ -560,8 +560,8 @@ static int btt_freelist_init(struct arena_info *arena)
                 * FIXME: if error clearing fails during init, we want to make
                 * the BTT read-only
                 */
-               if (ent_e_flag(log_new.old_map) &&
-                               !ent_normal(log_new.old_map)) {
+               if (ent_e_flag(le32_to_cpu(log_new.old_map)) &&
+                   !ent_normal(le32_to_cpu(log_new.old_map))) {
                        arena->freelist[i].has_err = 1;
                        ret = arena_clear_freelist_error(arena, i);
                        if (ret)
@@ -1674,7 +1674,8 @@ int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns)
        struct nd_region *nd_region;
        struct btt_sb *btt_sb;
        struct btt *btt;
-       size_t rawsize;
+       size_t size, rawsize;
+       int rc;
 
        if (!nd_btt->uuid || !nd_btt->ndns || !nd_btt->lbasize) {
                dev_dbg(&nd_btt->dev, "incomplete btt configuration\n");
@@ -1685,6 +1686,11 @@ int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns)
        if (!btt_sb)
                return -ENOMEM;
 
+       size = nvdimm_namespace_capacity(ndns);
+       rc = devm_namespace_enable(&nd_btt->dev, ndns, size);
+       if (rc)
+               return rc;
+
        /*
         * If this returns < 0, that is ok as it just means there wasn't
         * an existing BTT, and we're creating a new one. We still need to
@@ -1693,7 +1699,7 @@ int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns)
         */
        nd_btt_version(nd_btt, ndns, btt_sb);
 
-       rawsize = nvdimm_namespace_capacity(ndns) - nd_btt->initial_offset;
+       rawsize = size - nd_btt->initial_offset;
        if (rawsize < ARENA_MIN_SIZE) {
                dev_dbg(&nd_btt->dev, "%s must be at least %ld bytes\n",
                                dev_name(&ndns->dev),