Whamcloud - gitweb
LU-6719 osd-zfs: Ignore EEXIST during object init
[fs/lustre-release.git] / lustre / osd-zfs / osd_object.c
index 5c2d1f5..9884333 100644 (file)
@@ -399,6 +399,11 @@ static int osd_object_init(const struct lu_env *env, struct lu_object *l,
        if (rc == 0) {
                LASSERT(obj->oo_db == NULL);
                rc = __osd_obj2dbuf(env, osd->od_os, oid, &obj->oo_db);
+               /* EEXIST will be returned if object is being deleted in ZFS */
+               if (rc == -EEXIST) {
+                       rc = 0;
+                       GOTO(out, rc);
+               }
                if (rc != 0) {
                        CERROR("%s: lookup "DFID"/"LPX64" failed: rc = %d\n",
                               osd->od_svname, PFID(lu_object_fid(l)), oid, rc);
@@ -660,7 +665,7 @@ static void osd_object_read_lock(const struct lu_env *env,
 
        LASSERT(osd_invariant(obj));
 
-       down_read(&obj->oo_sem);
+       down_read_nested(&obj->oo_sem, role);
 }
 
 static void osd_object_write_lock(const struct lu_env *env,
@@ -670,7 +675,7 @@ static void osd_object_write_lock(const struct lu_env *env,
 
        LASSERT(osd_invariant(obj));
 
-       down_write(&obj->oo_sem);
+       down_write_nested(&obj->oo_sem, role);
 }
 
 static void osd_object_read_unlock(const struct lu_env *env,
@@ -1525,8 +1530,10 @@ static int osd_object_ref_add(const struct lu_env *env,
 
        ENTRY;
 
+       if (!dt_object_exists(dt))
+               RETURN(-ENOENT);
+
        LASSERT(osd_invariant(obj));
-       LASSERT(dt_object_exists(dt));
        LASSERT(obj->oo_sa_hdl != NULL);
 
        oh = container_of0(handle, struct osd_thandle, ot_super);
@@ -1573,7 +1580,7 @@ static int osd_object_ref_del(const struct lu_env *env,
        write_unlock(&obj->oo_attr_lock);
 
        rc = osd_object_sa_update(obj, SA_ZPL_LINKS(osd), &nlink, 8, oh);
-       return rc;
+       RETURN(rc);
 }
 
 static int osd_object_sync(const struct lu_env *env, struct dt_object *dt,