Whamcloud - gitweb
Branch HEAD
authoryangsheng <yangsheng>
Wed, 30 Sep 2009 04:06:35 +0000 (04:06 +0000)
committeryangsheng <yangsheng>
Wed, 30 Sep 2009 04:06:35 +0000 (04:06 +0000)
b=17153

i=johann, bobijam

Remove the BKL usage.

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

index 8193a8b..e1d253f 100644 (file)
@@ -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 <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
 #
@@ -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
index 83dd48a..04f138c 100644 (file)
@@ -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 */
index ce287c6..8619ae5 100644 (file)
@@ -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);
index 5151b73..14f6889 100644 (file)
@@ -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;