From 15e45e0a30bdb1d2836eb7f50dd3935fd63f2209 Mon Sep 17 00:00:00 2001 From: yangsheng Date: Wed, 23 Sep 2009 04:10:14 +0000 Subject: [PATCH] Branch b1_8 b=17153 i=johann, bobijam Replace the BKL with sb rename_lock. --- lustre/autoconf/lustre-core.m4 | 18 ++++++++++++++++++ lustre/include/linux/lustre_compat25.h | 8 ++++++++ lustre/mds/mds_reint.c | 5 +++-- lustre/obdfilter/filter.c | 2 -- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f4527e6..f65eefd 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1663,6 +1663,23 @@ LB_LINUX_TRY_COMPILE([ ]) ]) +# 2.6.17 super_block use s_vfs_rename_mutex instead of s_vfs_rename_sem +AC_DEFUN([LC_VFS_RENAME_MUTEX], +[AC_MSG_CHECKING([super_block has s_vfs_rename_mutex]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + struct super_block sb; + mutex_lock(&sb.s_vfs_rename_mutex); +],[ + AC_DEFINE(HAVE_VFS_RENAME_MUTEX, 1, + [super_block has s_vfs_rename_mutex]) + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) +]) +]) + # # LC_PROG_LINUX # @@ -1733,6 +1750,7 @@ AC_DEFUN([LC_PROG_LINUX], # 2.6.17 LC_DQUOTOFF_MUTEX + LC_VFS_RENAME_MUTEX # 2.6.18 LC_NR_PAGECACHE diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index f4ea8a7..724c7cc 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -622,5 +622,13 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount) #define ll_update_time(file) inode_update_time(file->f_mapping->host, 1) #endif +#ifdef HAVE_VFS_RENAME_MUTEX +#define VFS_RENAME_LOCK(inode) mutex_lock(&((inode)->i_sb->s_vfs_rename_mutex)) +#define VFS_RENAME_UNLOCK(inode) mutex_unlock(&((inode)->i_sb->s_vfs_rename_mutex)) +#else +#define VFS_RENAME_LOCK(inode) down(&((inode)->i_sb->s_vfs_rename_sem)) +#define VFS_RENAME_UNLOCK(inode) up(&((inode)->i_sb->s_vfs_rename_sem)) +#endif + #endif /* __KERNEL__ */ #endif /* _COMPAT25_H */ diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index d64f5e9..6d23645 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -2657,13 +2657,14 @@ no_unlink: if (IS_ERR(handle)) GOTO(cleanup, rc = PTR_ERR(handle)); - lock_kernel(); + VFS_RENAME_LOCK(de_srcdir->d_inode); de_old->d_fsdata = req; de_new->d_fsdata = req; rc = ll_vfs_rename(de_srcdir->d_inode, de_old, mds->mds_vfsmnt, de_tgtdir->d_inode, de_new, mds->mds_vfsmnt); - unlock_kernel(); + + VFS_RENAME_UNLOCK(de_srcdir->d_inode); if (rc == 0) { struct iattr iattr; diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 1f1c63c..8a6c218 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -2950,7 +2950,6 @@ int filter_setattr(struct obd_export *exp, struct obd_info *oinfo, filter = &exp->exp_obd->u.filter; push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); - lock_kernel(); if (oinfo->oi_oa->o_valid & (OBD_MD_FLMTIME | OBD_MD_FLATIME | OBD_MD_FLCTIME)) { @@ -2981,7 +2980,6 @@ int filter_setattr(struct obd_export *exp, struct obd_info *oinfo, EXIT; out_unlock: - unlock_kernel(); f_dput(dentry); pop_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); return rc; -- 1.8.3.1