Whamcloud - gitweb
LU-4101 mdt: protect internal xattrs
[fs/lustre-release.git] / lustre / obdclass / local_storage.c
index 26a3137..2799aba 100644 (file)
@@ -867,9 +867,12 @@ out_los:
                (*los)->los_seq = fid_seq(first_fid);
                (*los)->los_last_oid = le64_to_cpu(lastid);
                (*los)->los_obj = o;
-               /* read value should not be less than initial one */
-               LASSERTF((*los)->los_last_oid >= first_oid, "%u < %u\n",
-                        (*los)->los_last_oid, first_oid);
+               /* Read value should not be less than initial one
+                * but possible after upgrade from older fs.
+                * In this case just switch to the first_oid in memory and
+                * it will be updated on disk with first object generated */
+               if ((*los)->los_last_oid < first_oid)
+                       (*los)->los_last_oid = first_oid;
        }
 out:
        mutex_unlock(&ls->ls_los_mutex);
@@ -891,12 +894,15 @@ void local_oid_storage_fini(const struct lu_env *env,
        ls = dt2ls_dev(los->los_dev);
 
        mutex_lock(&ls->ls_los_mutex);
-       if (cfs_atomic_read(&los->los_refcount) == 0) {
-               if (los->los_obj)
-                       lu_object_put_nocache(env, &los->los_obj->do_lu);
-               cfs_list_del(&los->los_list);
-               OBD_FREE_PTR(los);
+       if (cfs_atomic_read(&los->los_refcount) > 0) {
+               mutex_unlock(&ls->ls_los_mutex);
+               return;
        }
+
+       if (los->los_obj)
+               lu_object_put_nocache(env, &los->los_obj->do_lu);
+       cfs_list_del(&los->los_list);
+       OBD_FREE_PTR(los);
        mutex_unlock(&ls->ls_los_mutex);
        ls_device_put(env, ls);
 }