Whamcloud - gitweb
Introduce and use new LOCK_INODE_MUTEX_PARENT() macro to be used in the
authornikita <nikita>
Sat, 18 Oct 2008 15:30:01 +0000 (15:30 +0000)
committernikita <nikita>
Sat, 18 Oct 2008 15:30:01 +0000 (15:30 +0000)
situations where Lustre has to lock more than one inode mutex at a time.
b=16450

lustre/ChangeLog
lustre/include/linux/lustre_compat25.h
lustre/lvfs/quotafmt_test.c
lustre/mds/mds_fs.c
lustre/obdfilter/filter.c

index 8afb64c..34944b4 100644 (file)
@@ -1478,6 +1478,13 @@ Details    : Add two new failloc constants to test lockless IO. Only one of
             them in implemented---another is checked in yet to be landed
             core CLIO code.
 
+Severity   : normal
+Bugzilla   : 16450
+Description: Add lockdep support for inode mutex.
+Details    : Introduce and use new LOCK_INODE_MUTEX_PARENT() macro to be used
+            in the situations where Lustre has to lock more than one inode
+            mutex at a time.
+
 --------------------------------------------------------------------------------
 
 2007-08-10         Cluster File Systems, Inc. <info@clusterfs.com>
index 9a57ebd..1e59fe7 100644 (file)
@@ -88,11 +88,14 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
 #if HAVE_INODE_I_MUTEX
 #define UNLOCK_INODE_MUTEX(inode) do {mutex_unlock(&(inode)->i_mutex); } while(0)
 #define LOCK_INODE_MUTEX(inode) do {mutex_lock(&(inode)->i_mutex); } while(0)
+#define LOCK_INODE_MUTEX_PARENT(inode) \
+do {mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0)
 #define TRYLOCK_INODE_MUTEX(inode) mutex_trylock(&(inode)->i_mutex)
 #else
 #define UNLOCK_INODE_MUTEX(inode) do {up(&(inode)->i_sem); } while(0)
 #define LOCK_INODE_MUTEX(inode) do {down(&(inode)->i_sem); } while(0)
 #define TRYLOCK_INODE_MUTEX(inode) (!down_trylock(&(inode)->i_sem))
+#define LOCK_INODE_MUTEX_PARENT(inode) LOCK_INODE_MUTEX(inode)
 #endif /* HAVE_INODE_I_MUTEX */
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
index b5e0a4b..2b37387 100644 (file)
@@ -81,7 +81,7 @@ static int quotfmt_initialize(struct lustre_quota_info *lqi,
                 int namelen = strlen(name);
 
                 /* remove the stale test quotafile */
-                LOCK_INODE_MUTEX(parent_inode);
+                LOCK_INODE_MUTEX_PARENT(parent_inode);
                 de = lookup_one_len(name, tgt->obd_lvfs_ctxt.pwd, namelen);
                 if (!IS_ERR(de) && de->d_inode)
                         ll_vfs_unlink(parent_inode, de, 
@@ -136,7 +136,7 @@ static int quotfmt_finalize(struct lustre_quota_info *lqi,
                 filp_close(lqi->qi_files[i], 0);
 
                 /* unlink quota file */
-                LOCK_INODE_MUTEX(parent_inode);
+                LOCK_INODE_MUTEX_PARENT(parent_inode);
 
                 de = lookup_one_len(name, tgt->obd_lvfs_ctxt.pwd, namelen);
                 if (IS_ERR(de) || de->d_inode == NULL) {
index 97feafb..ec83e30 100644 (file)
@@ -106,7 +106,7 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa,
         oa->o_generation = filp->f_dentry->d_inode->i_generation;
         namelen = ll_fid2str(fidname, oa->o_id, oa->o_generation);
 
-        LOCK_INODE_MUTEX(parent_inode);
+        LOCK_INODE_MUTEX_PARENT(parent_inode);
         new_child = lookup_one_len(fidname, mds->mds_objects_dir, namelen);
 
         if (IS_ERR(new_child)) {
@@ -176,7 +176,7 @@ int mds_obd_destroy(struct obd_export *exp, struct obdo *oa,
 
         namelen = ll_fid2str(fidname, oa->o_id, oa->o_generation);
 
-        LOCK_INODE_MUTEX(parent_inode);
+        LOCK_INODE_MUTEX_PARENT(parent_inode);
         de = lookup_one_len(fidname, mds->mds_objects_dir, namelen);
         if (IS_ERR(de)) {
                 rc = IS_ERR(de);
index 4c8d301..d66bb93 100644 (file)
@@ -1406,7 +1406,7 @@ obd_id filter_last_id(struct filter_obd *filter, obd_gr group)
 
 static int filter_lock_dentry(struct obd_device *obd, struct dentry *dparent)
 {
-        LOCK_INODE_MUTEX(dparent->d_inode);
+        LOCK_INODE_MUTEX_PARENT(dparent->d_inode);
         return 0;
 }