From 356248c8a14571049d0ae9eb09c5107397b92d65 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Fri, 12 Mar 2021 09:17:11 +0300 Subject: [PATCH] LU-14513 osd: release o_guard before quota acquisition to avoid deadlocks as regular transactions (like write) start a transaction, then grab o_guard. Signed-off-by: Alex Zhuravlev Change-Id: I2678677ed6c213e4bed30cc1218e48b8f2900dc4 Reviewed-on: https://review.whamcloud.com/42018 Reviewed-by: Andreas Dilger Reviewed-by: Wang Shilong Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/osd-zfs/osd_object.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 49f887e..464e0d6 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -1131,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); @@ -1153,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 @@ -1169,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 */ @@ -1229,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); } -- 1.8.3.1