From: Olaf Faaland Date: Tue, 27 Oct 2015 00:51:46 +0000 (-0700) Subject: LU-7345 obdclass: annotate locks in __local_file_create X-Git-Tag: 2.7.63~2 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=953e9e5e75ca12a5ef72bfe844c1216341af12c9 LU-7345 obdclass: annotate locks in __local_file_create dt_write_lock() is called for both the child and the parent dt_objects when a directory is created. This triggers a false positive in lockdep when running with CONFIG_LOCKDEP=y, as the structure containing the lock and the name of the lock is the same, and so it appears to be a recursive lock attempt based on lock class. This gives the two locks different subclasses so lockdep can differentiate between them. Also, osd-zfs osd_object_{read,write}_lock() functions currently ignore the subclass (role) provided by the caller, calling down_read() instead of down_read_nested() for example. Make osd_zfs use the _nested variants so the role takes effect. Signed-off-by: Olaf Faaland Change-Id: Iab79feadfbd7d1a5a06749ecb9f6888b55a78d73 Reviewed-on: http://review.whamcloud.com/16957 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/local_storage.c b/lustre/obdclass/local_storage.c index d124690..317c776 100644 --- a/lustre/obdclass/local_storage.c +++ b/lustre/obdclass/local_storage.c @@ -368,7 +368,7 @@ static struct dt_object *__local_file_create(const struct lu_env *env, if (rc) GOTO(trans_stop, rc); - dt_write_lock(env, dto, 0); + dt_write_lock(env, dto, LOS_CHILD); if (dt_object_exists(dto)) GOTO(unlock, rc = 0); @@ -399,7 +399,7 @@ static struct dt_object *__local_file_create(const struct lu_env *env, rec->rec_fid = fid; rec->rec_type = dto->do_lu.lo_header->loh_attr; - dt_write_lock(env, parent, 0); + dt_write_lock(env, parent, LOS_PARENT); rc = dt_insert(env, parent, (const struct dt_rec *)rec, (const struct dt_key *)name, th, 1); if (dti->dti_dof.dof_type == DFT_DIR) diff --git a/lustre/obdclass/local_storage.h b/lustre/obdclass/local_storage.h index 7ff6faa..caf26bf 100644 --- a/lustre/obdclass/local_storage.h +++ b/lustre/obdclass/local_storage.h @@ -91,4 +91,12 @@ struct los_ondisk { #define LOS_MAGIC 0xdecafbee +/** + * Used in __local_file_create() for object lock role + **/ +enum los_object_role { + LOS_PARENT, + LOS_CHILD, +}; + #endif diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 5c2d1f5..2dc0370 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -660,7 +660,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 +670,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,