Whamcloud - gitweb
Branch b1_8
authoryangsheng <yangsheng>
Wed, 23 Sep 2009 04:10:14 +0000 (04:10 +0000)
committeryangsheng <yangsheng>
Wed, 23 Sep 2009 04:10:14 +0000 (04:10 +0000)
b=17153

i=johann, bobijam

Replace the BKL with sb rename_lock.

lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_compat25.h
lustre/mds/mds_reint.c
lustre/obdfilter/filter.c

index f4527e6..f65eefd 100644 (file)
@@ -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 <linux/fs.h>
+],[
+        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
index f4ea8a7..724c7cc 100644 (file)
@@ -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 */
index d64f5e9..6d23645 100644 (file)
@@ -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;
index 1f1c63c..8a6c218 100644 (file)
@@ -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;