From 5a37bc9577d4c871cd468ca67b2c2d04aed9921f Mon Sep 17 00:00:00 2001 From: James Simmons Date: Sun, 22 Aug 2021 18:40:49 -0400 Subject: [PATCH] LU-15014 obdclass: lu_ref_add() called in atomic context For the native Linux client testing I turn on lu_ref debugging. When turned on the following errors occur: [ 2885.946815] Call Trace: [ 2885.951240] dump_stack+0x68/0x9b [ 2885.956523] ___might_sleep+0x205/0x260 [ 2885.962245] lu_ref_add+0x25/0x40 [obdclass] [ 2885.968442] vvp_pgcache_current+0x101/0x1a0 [lustre] [ 2885.975370] seq_read+0x1ab/0x3c0 and [ 7042.102529] dump_stack+0x68/0x9b [ 7042.107328] ___might_sleep+0x205/0x260 [ 7042.112647] lu_ref_add+0x25/0x40 [obdclass] [ 7042.118385] mdc_lock_upcall+0x154/0x4d0 [mdc] [ 7042.124275] mdc_enqueue_send+0x508/0x580 [mdc] [ 7042.130225] ? mdc_lock_lvb_update+0x280/0x280 [mdc] This is easily fixed with introducing a lu_object_ref_add_atomic() function. Test-Parameters: trivial Change-Id: Ife7d255079a836570661f669c1e9c7c0ce6de4aa Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/44969 Reviewed-by: Patrick Farrell Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/include/lu_object.h | 7 +++++++ lustre/llite/vvp_dev.c | 2 +- lustre/mdc/mdc_dev.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index fe35671..ae6b91b 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -885,6 +885,13 @@ static inline __u32 lu_object_attr(const struct lu_object *o) return o->lo_header->loh_attr & S_IFMT; } +static inline void lu_object_ref_add_atomic(struct lu_object *o, + const char *scope, + const void *source) +{ + lu_ref_add_atomic(&o->lo_header->loh_reference, scope, source); +} + static inline void lu_object_ref_add(struct lu_object *o, const char *scope, const void *source) diff --git a/lustre/llite/vvp_dev.c b/lustre/llite/vvp_dev.c index 05ce3c8..274c6679 100644 --- a/lustre/llite/vvp_dev.c +++ b/lustre/llite/vvp_dev.c @@ -425,7 +425,7 @@ static struct page *vvp_pgcache_current(struct vvp_seq_private *priv) continue; priv->vsp_clob = lu2cl(lu_obj); - lu_object_ref_add(lu_obj, "dump", current); + lu_object_ref_add_atomic(lu_obj, "dump", current); priv->vsp_page_index = 0; } diff --git a/lustre/mdc/mdc_dev.c b/lustre/mdc/mdc_dev.c index 9767b74..d7719e1 100644 --- a/lustre/mdc/mdc_dev.c +++ b/lustre/mdc/mdc_dev.c @@ -476,7 +476,7 @@ static void mdc_lock_granted(const struct lu_env *env, struct osc_lock *oscl, /* lock reference taken by ldlm_handle2lock_long() is * owned by osc_lock and released in osc_lock_detach() */ - lu_ref_add(&dlmlock->l_reference, "osc_lock", oscl); + lu_ref_add_atomic(&dlmlock->l_reference, "osc_lock", oscl); oscl->ols_has_ref = 1; LASSERT(oscl->ols_dlmlock == NULL); -- 1.8.3.1