From c9704328461ec22fed2400e60707ac633453551f Mon Sep 17 00:00:00 2001 From: yangsheng Date: Tue, 10 Jun 2008 04:22:50 +0000 Subject: [PATCH] Branch HEAD b=15592 i=oleg, shadow Correctly handle the FS_RENAME_DOES_D_MOVE flag in Lustre. --- lustre/autoconf/lustre-core.m4 | 17 +++++++++++++++++ lustre/include/linux/lustre_compat25.h | 6 ++++-- lustre/llite/llite_lib.c | 1 - lustre/llite/namei.c | 10 +++++++++- lustre/obdclass/obd_mount.c | 3 ++- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 9068b9d..0c49a0f 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 +],[ + 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 @@ -1536,6 +1552,7 @@ AC_DEFUN([LC_PROG_LINUX], # 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 diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index 5bbac96..975ef22 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -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 -#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 */ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 04eee3e..1a82ddf 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -942,7 +942,6 @@ int ll_fill_super(struct super_block *sb) 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) { diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 2631bda..a40e7db 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -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) { - 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); + 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 = { diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 8ed47c9..ee12d1d 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -2000,7 +2000,8 @@ struct file_system_type lustre_fs_type = { .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) -- 1.8.3.1