From 7bdade4102f8fde236344f1c78bb2534cbb766bf Mon Sep 17 00:00:00 2001 From: yangsheng Date: Wed, 30 Sep 2009 04:06:35 +0000 Subject: [PATCH] Branch HEAD b=17153 i=johann, bobijam Remove the BKL usage. --- lustre/autoconf/lustre-core.m4 | 18 ++++++++++++++++++ lustre/include/linux/lustre_compat25.h | 8 ++++++++ lustre/mds/mds_fs.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 8193a8b..e1d253f 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1395,6 +1395,23 @@ AC_DEFUN([LC_LINUX_FIEMAP_H], []) ]) +# 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 # @@ -1471,6 +1488,7 @@ AC_DEFUN([LC_PROG_LINUX], # 2.6.17 LC_INODE_IPRIVATE 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 83dd48a..04f138c 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -656,5 +656,13 @@ static inline long labs(long x) #define SLAB_DESTROY_BY_RCU 0 #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_fs.c b/lustre/mds/mds_fs.c index ce287c6..8619ae5 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -123,11 +123,12 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, if (IS_ERR(handle)) GOTO(out_dput, rc = PTR_ERR(handle)); - lock_kernel(); + VFS_RENAME_LOCK(mds->mds_objects_dir->d_inode); rc = ll_vfs_rename(mds->mds_objects_dir->d_inode, filp->f_dentry, filp->f_vfsmnt, mds->mds_objects_dir->d_inode, new_child, filp->f_vfsmnt); - unlock_kernel(); + + VFS_RENAME_UNLOCK(mds->mds_objects_dir->d_inode); if (rc) CERROR("error renaming new object "LPU64":%u: rc %d\n", oa->o_id, oa->o_generation, rc); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 5151b73..14f6889 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -3415,7 +3415,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 (oa->o_valid & (OBD_MD_FLMTIME | OBD_MD_FLATIME | OBD_MD_FLCTIME)) { @@ -3448,7 +3447,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