Whamcloud - gitweb
LU-7345 obdclass: annotate locks in __local_file_create 57/16957/4
authorOlaf Faaland <faaland1@llnl.gov>
Tue, 27 Oct 2015 00:51:46 +0000 (17:51 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 15 Nov 2015 15:39:27 +0000 (15:39 +0000)
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 <faaland1@llnl.gov>
Change-Id: Iab79feadfbd7d1a5a06749ecb9f6888b55a78d73
Reviewed-on: http://review.whamcloud.com/16957
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/obdclass/local_storage.c
lustre/obdclass/local_storage.h
lustre/osd-zfs/osd_object.c

index d124690..317c776 100644 (file)
@@ -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)
index 7ff6faa..caf26bf 100644 (file)
@@ -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
index 5c2d1f5..2dc0370 100644 (file)
@@ -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,