From 6af8d45f9501933c812b7bb90ad49c75997f851c Mon Sep 17 00:00:00 2001 From: nikita Date: Sat, 18 Oct 2008 15:30:01 +0000 Subject: [PATCH] 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. b=16450 --- lustre/ChangeLog | 7 +++++++ lustre/include/linux/lustre_compat25.h | 3 +++ lustre/lvfs/quotafmt_test.c | 4 ++-- lustre/mds/mds_fs.c | 4 ++-- lustre/obdfilter/filter.c | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 8afb64c..34944b4 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -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. diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index 9a57ebd..1e59fe7 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -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) diff --git a/lustre/lvfs/quotafmt_test.c b/lustre/lvfs/quotafmt_test.c index b5e0a4b..2b37387 100644 --- a/lustre/lvfs/quotafmt_test.c +++ b/lustre/lvfs/quotafmt_test.c @@ -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) { diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index 97feafb..ec83e30 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -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); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 4c8d301..d66bb93 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -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; } -- 1.8.3.1