Whamcloud - gitweb
LU-14513 osd: release o_guard before quota acquisition
[fs/lustre-release.git] / lustre / osd-zfs / osd_object.c
index 9817cc5..464e0d6 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lustre/osd-zfs/osd_object.c
  *
@@ -616,9 +615,12 @@ zget:
                GOTO(out, rc = 0);
 
        rc = osd_check_lma(env, obj);
-       if ((!rc && !remote) || (rc != -EREMCHG))
+       if (rc != -EREMCHG)
                GOTO(out, rc);
 
+       osd_scrub_refresh_mapping(env, osd, fid, oid, DTO_INDEX_DELETE, true,
+                                 NULL);
+
 trigger:
        /* We still have chance to get the valid dnode: for the object that is
         * referenced by remote name entry, the object on the local MDT will be
@@ -661,8 +663,9 @@ trigger:
        /* It is me to trigger the OI scrub. */
        rc1 = osd_scrub_start(env, osd, SS_CLEAR_DRYRUN |
                              SS_CLEAR_FAILOUT | SS_AUTO_FULL);
-       LCONSOLE_WARN("%s: trigger OI scrub by RPC for the "DFID": rc = %d\n",
-                     osd_name(osd), PFID(fid), rc1);
+       CDEBUG_LIMIT(D_LFSCK | D_CONSOLE | D_WARNING,
+                    "%s: trigger OI scrub by RPC for "DFID"/%#llx: rc = %d\n",
+                    osd_name(osd), PFID(fid), oid, rc1);
        if (!rc) {
                LASSERT(remote);
 
@@ -851,12 +854,12 @@ static int osd_destroy(const struct lu_env *env, struct dt_object *dt,
                LASSERT(obj->oo_attr.la_size <= osd_sync_destroy_max_size);
                rc = -dmu_object_free(osd->od_os, oid, oh->ot_tx);
                if (rc)
-                       CERROR("%s: failed to free %s %llu: rc = %d\n",
+                       CERROR("%s: failed to free %s/%#llx: rc = %d\n",
                               osd->od_svname, buf, oid, rc);
        } else if (obj->oo_destroy == OSD_DESTROY_SYNC) {
                rc = -dmu_object_free(osd->od_os, oid, oh->ot_tx);
                if (rc)
-                       CERROR("%s: failed to free %s %llu: rc = %d\n",
+                       CERROR("%s: failed to free %s/%#llx: rc = %d\n",
                               osd->od_svname, buf, oid, rc);
        } else { /* asynchronous destroy */
                char *key = info->oti_key;
@@ -869,7 +872,7 @@ static int osd_destroy(const struct lu_env *env, struct dt_object *dt,
                rc = osd_zap_add(osd, osd->od_unlinked->dn_object,
                                 osd->od_unlinked, key, 8, 1, &oid, oh->ot_tx);
                if (rc)
-                       CERROR("%s: zap_add_int() failed %s %llu: rc = %d\n",
+                       CERROR("%s: zap_add_int() failed %s/%#llx: rc = %d\n",
                               osd->od_svname, buf, oid, rc);
        }
 
@@ -1013,7 +1016,7 @@ static int osd_attr_get(const struct lu_env *env, struct dt_object *dt,
        }
        read_unlock(&obj->oo_attr_lock);
        if (attr->la_valid & LA_FLAGS && attr->la_flags & LUSTRE_ORPHAN_FL)
-               CDEBUG(D_INFO, "%s: set orphan flag on "DFID" (%llx/%x)\n",
+               CDEBUG(D_INFO, "%s: set orphan flag on "DFID" (%#llx/%#x)\n",
                       osd_obj2dev(obj)->od_svname,
                       PFID(lu_object_fid(&dt->do_lu)),
                       attr->la_valid, obj->oo_lma_flags);
@@ -1128,7 +1131,7 @@ static int osd_declare_attr_set(const struct lu_env *env,
 
        down_read(&obj->oo_guard);
        if (unlikely(!dt_object_exists(dt) || obj->oo_destroyed))
-               GOTO(out, rc = 0);
+               GOTO(out_sem, rc = 0);
 
        LASSERT(obj->oo_sa_hdl != NULL);
        LASSERT(oh->ot_tx != NULL);
@@ -1150,7 +1153,7 @@ static int osd_declare_attr_set(const struct lu_env *env,
        if (!found)
                dmu_tx_hold_bonus(oh->ot_tx, obj->oo_dn->dn_object);
        if (oh->ot_tx->tx_err != 0)
-               GOTO(out, rc = -oh->ot_tx->tx_err);
+               GOTO(out_sem, rc = -oh->ot_tx->tx_err);
 
        if (attr && attr->la_valid & LA_FLAGS) {
                /* LMA is usually a part of bonus, no need to declare
@@ -1166,6 +1169,9 @@ static int osd_declare_attr_set(const struct lu_env *env,
                       osd->od_svname,
                       attr->la_uid, attr->la_gid, bspace, blksize);
        }
+       /* to preserve locking order - qsd_transfer() may need to flush
+        * currently running transaction when we're out of quota. */
+       up_read(&obj->oo_guard);
 
        if (attr && attr->la_valid & LA_UID) {
                /* quota enforcement for user */
@@ -1226,6 +1232,8 @@ static int osd_declare_attr_set(const struct lu_env *env,
        }
 #endif
 out:
+       RETURN(rc);
+out_sem:
        up_read(&obj->oo_guard);
        RETURN(rc);
 }