Whamcloud - gitweb
LU-11914 build: add a configure check for l_getsepol
[fs/lustre-release.git] / lustre / osd-zfs / osd_oi.c
index c8d1fcc..a2532c4 100644 (file)
@@ -538,7 +538,7 @@ osd_get_name_n_idx_compat(const struct lu_env *env, struct osd_device *osd,
        if (zdn != NULL)
                *zdn = NULL;
 
-       if (fid_is_on_ost(env, osd, fid) == 1 || fid_seq(fid) == FID_SEQ_ECHO) {
+       if (fid_is_echo(fid) || fid_is_on_ost(env, osd, fid)) {
                zapid = osd_get_idx_for_ost_obj_compat(env, osd, fid,
                                                       buf, bufsize);
        } else if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE)) {
@@ -572,8 +572,8 @@ uint64_t osd_get_name_n_idx(const struct lu_env *env, struct osd_device *osd,
        if (zdn != NULL)
                *zdn = NULL;
 
-       if (fid_is_on_ost(env, osd, fid) == 1 || fid_seq(fid) == FID_SEQ_ECHO ||
-           fid_is_last_id(fid)) {
+       if (fid_is_echo(fid) || fid_is_last_id(fid) ||
+           fid_is_on_ost(env, osd, fid)) {
                zapid = osd_get_idx_for_ost_obj(env, osd, fid, buf, bufsize);
        } else if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE)) {
                /* special objects with fixed known fids get their name */
@@ -752,7 +752,8 @@ static int osd_oi_probe(const struct lu_env *env, struct osd_device *o)
         * power of two and this is checked for basic sanity.
         */
        for (count = 0; count < max; count++) {
-               snprintf(name, 15, "%s.%d", DMU_OSD_OI_NAME_BASE, count);
+               snprintf(name, sizeof(name) - 1, "%s.%d",
+                        DMU_OSD_OI_NAME_BASE, count);
                rc = osd_oi_lookup(env, o, o->od_root, name, &oi);
                if (!rc)
                        continue;
@@ -807,6 +808,20 @@ osd_oi_init_compat(const struct lu_env *env, struct osd_device *o)
        RETURN(rc);
 }
 
+static int
+osd_oi_init_index_backup(const struct lu_env *env, struct osd_device *o)
+{
+       struct lu_fid *fid = &osd_oti_get(env)->oti_fid;
+       int rc;
+       ENTRY;
+
+       lu_local_obj_fid(fid, INDEX_BACKUP_OID);
+       rc = osd_obj_find_or_create(env, o, o->od_root, INDEX_BACKUP_DIR,
+                                   &o->od_index_backup_id, fid, true);
+
+       RETURN(rc);
+}
+
 static void
 osd_oi_init_remote_parent(const struct lu_env *env, struct osd_device *o)
 {
@@ -844,6 +859,10 @@ int osd_oi_init(const struct lu_env *env, struct osd_device *o)
        LASSERTF((sf->sf_oi_count & (sf->sf_oi_count - 1)) == 0,
                 "Invalid OI count in scrub file %d\n", sf->sf_oi_count);
 
+       rc = osd_oi_init_index_backup(env, o);
+       if (rc)
+               RETURN(rc);
+
        osd_oi_init_remote_parent(env, o);
 
        rc = osd_oi_init_compat(env, o);
@@ -1040,10 +1059,16 @@ struct osd_idmap_cache *osd_idc_find_or_init(const struct lu_env *env,
        if (idc != NULL)
                return idc;
 
+       CDEBUG(D_INODE, "%s: FID "DFID" not in the id map cache\n",
+              osd->od_svname, PFID(fid));
+
        /* new mapping is needed */
        idc = osd_idc_add(env, osd, fid);
-       if (IS_ERR(idc))
+       if (IS_ERR(idc)) {
+               CERROR("%s: FID "DFID" add id map cache failed: %ld\n",
+                      osd->od_svname, PFID(fid), PTR_ERR(idc));
                return idc;
+       }
 
        /* initialize it */
        rc = osd_remote_fid(env, osd, fid);
@@ -1088,10 +1113,16 @@ int osd_idc_find_and_init(const struct lu_env *env, struct osd_device *osd,
                return 0;
        }
 
+       CDEBUG(D_INODE, "%s: FID "DFID" not in the id map cache\n",
+              osd->od_svname, PFID(fid));
+
        /* new mapping is needed */
        idc = osd_idc_add(env, osd, fid);
-       if (IS_ERR(idc))
+       if (IS_ERR(idc)) {
+               CERROR("%s: FID "DFID" add id map cache failed: %ld\n",
+                      osd->od_svname, PFID(fid), PTR_ERR(idc));
                return PTR_ERR(idc);
+       }
 
        if (obj->oo_dn)
                idc->oic_dnode = obj->oo_dn->dn_object;