Whamcloud - gitweb
Branch HEAD
authoryangsheng <yangsheng>
Tue, 10 Jun 2008 04:22:50 +0000 (04:22 +0000)
committeryangsheng <yangsheng>
Tue, 10 Jun 2008 04:22:50 +0000 (04:22 +0000)
b=15592
i=oleg, shadow

Correctly handle the FS_RENAME_DOES_D_MOVE flag in Lustre.

lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_compat25.h
lustre/llite/llite_lib.c
lustre/llite/namei.c
lustre/obdclass/obd_mount.c

index 9068b9d..0c49a0f 100644 (file)
@@ -1432,6 +1432,22 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
 ])
 ])
 
+#
+# check for FS_RENAME_DOES_D_MOVE flag
+#
+AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
+[AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        int v = FS_RENAME_DOES_D_MOVE;
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
+],[
+        AC_MSG_RESULT([no])
+])
+])
 
 #
 # LC_PROG_LINUX
 
 #
 # LC_PROG_LINUX
@@ -1536,6 +1552,7 @@ AC_DEFUN([LC_PROG_LINUX],
         # 2.6.22
          LC_INVALIDATE_BDEV_2ARG
          LC_ASYNC_BLOCK_CIPHER
         # 2.6.22
          LC_INVALIDATE_BDEV_2ARG
          LC_ASYNC_BLOCK_CIPHER
+         LC_FS_RENAME_DOES_D_MOVE
          # 2.6.23
          LC_UNREGISTER_BLKDEV_RETURN_INT
          LC_KERNEL_SPLICE_READ
          # 2.6.23
          LC_UNREGISTER_BLKDEV_RETURN_INT
          LC_KERNEL_SPLICE_READ
index 5bbac96..975ef22 100644 (file)
@@ -395,8 +395,10 @@ static inline unsigned int ll_nr_free_buffer_pages(void)
 #define ll_nr_free_buffer_pages()      nr_free_buffer_pages()
 #endif
 
 #define ll_nr_free_buffer_pages()      nr_free_buffer_pages()
 #endif
 
-#ifdef FS_ODD_RENAME
-#define FS_RENAME_DOES_D_MOVE FS_ODD_RENAME
+#ifdef HAVE_FS_RENAME_DOES_D_MOVE
+#define LL_RENAME_DOES_D_MOVE  FS_RENAME_DOES_D_MOVE
+#else
+#define LL_RENAME_DOES_D_MOVE  FS_ODD_RENAME
 #endif
 
 /* add a lustre compatible layer for crypto API */
 #endif
 
 /* add a lustre compatible layer for crypto API */
index 04eee3e..1a82ddf 100644 (file)
@@ -942,7 +942,6 @@ int ll_fill_super(struct super_block *sb)
 
         cfs_module_get();
 
 
         cfs_module_get();
 
-        sb->s_type->fs_flags |= FS_RENAME_DOES_D_MOVE;
         /* client additional sb info */
         lsi->lsi_llsbi = sbi = ll_init_sbi();
         if (!sbi) {
         /* client additional sb info */
         lsi->lsi_llsbi = sbi = ll_init_sbi();
         if (!sbi) {
index 2631bda..a40e7db 100644 (file)
@@ -1253,10 +1253,18 @@ static int ll_link(struct dentry *old_dentry, struct inode *dir,
 static int ll_rename(struct inode *old_dir, struct dentry *old_dentry,
                      struct inode *new_dir, struct dentry *new_dentry)
 {
 static int ll_rename(struct inode *old_dir, struct dentry *old_dentry,
                      struct inode *new_dir, struct dentry *new_dentry)
 {
-        return ll_rename_generic(old_dir, NULL,
+        int err;
+        err = ll_rename_generic(old_dir, NULL,
                                  old_dentry, &old_dentry->d_name,
                                  new_dir, NULL, new_dentry,
                                  &new_dentry->d_name);
                                  old_dentry, &old_dentry->d_name,
                                  new_dir, NULL, new_dentry,
                                  &new_dentry->d_name);
+        if (!err) {
+#ifndef HAVE_FS_RENAME_DOES_D_MOVE
+                if (!S_ISDIR(old_dentry->d_inode->i_mode))
+#endif
+                        d_move(old_dentry, new_dentry);
+        }
+        return err;
 }
 
 struct inode_operations ll_dir_inode_operations = {
 }
 
 struct inode_operations ll_dir_inode_operations = {
index 8ed47c9..ee12d1d 100644 (file)
@@ -2000,7 +2000,8 @@ struct file_system_type lustre_fs_type = {
         .name         = "lustre",
         .get_sb       = lustre_get_sb,
         .kill_sb      = lustre_kill_super,
         .name         = "lustre",
         .get_sb       = lustre_get_sb,
         .kill_sb      = lustre_kill_super,
-        .fs_flags     = FS_BINARY_MOUNTDATA | FS_REQUIRES_DEV,
+        .fs_flags     = FS_BINARY_MOUNTDATA | FS_REQUIRES_DEV |
+                        LL_RENAME_DOES_D_MOVE,
 };
 
 int lustre_register_fs(void)
 };
 
 int lustre_register_fs(void)