From 422e102b8effaa14e0247591a53f8730a4f37b7d Mon Sep 17 00:00:00 2001 From: yangsheng Date: Sun, 22 Sep 2013 01:24:35 +0800 Subject: [PATCH] LU-3373 misc: small changes for 3.10 server support --quota use struct kqid as parameter --export ext4_dec/inc_count for nlink count --ext4_find_entry & ext4_journal_start_sb changes --iop->truncate removed --other trival changes to calm compiler warning Lustre-commit: 9bd7e40d2934cd0162eeff5388f054444a982ac9 Lustre-change: http://review.whamcloud.com/7794 Signed-off-by: yang sheng Signed-off-by: Bob Glossman Signed-off-by: Bobi Jam Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Change-Id: Ia2670d925ecbbfcc1ed3abb1a15a8d91fa27bd32 Reviewed-on: http://review.whamcloud.com/9013 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- .../patches/rhel6.3/export-ext4-2.6.patch | 38 ++++--- .../patches/rhel6.3/ext4-nlink-2.6.patch | 26 ++++- .../patches/sles11sp2/export-ext4-3.0.patch | 110 +++++++++++++-------- lustre/autoconf/lustre-core.m4 | 37 ++++++- lustre/osd-ldiskfs/osd_compat.c | 33 +++---- lustre/osd-ldiskfs/osd_handler.c | 72 +++++--------- lustre/osd-ldiskfs/osd_iam.c | 2 +- lustre/osd-ldiskfs/osd_iam.h | 2 - lustre/osd-ldiskfs/osd_iam_lfix.c | 6 +- lustre/osd-ldiskfs/osd_iam_lvar.c | 6 +- lustre/osd-ldiskfs/osd_internal.h | 27 ++++- lustre/osd-ldiskfs/osd_io.c | 13 ++- lustre/osd-ldiskfs/osd_oi.c | 4 +- lustre/osd-ldiskfs/osd_quota.c | 8 ++ lustre/osd-ldiskfs/osd_scrub.c | 4 +- 15 files changed, 247 insertions(+), 141 deletions(-) diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/export-ext4-2.6.patch b/ldiskfs/kernel_patches/patches/rhel6.3/export-ext4-2.6.patch index 6ac6fc7..295cdd0 100644 --- a/ldiskfs/kernel_patches/patches/rhel6.3/export-ext4-2.6.patch +++ b/ldiskfs/kernel_patches/patches/rhel6.3/export-ext4-2.6.patch @@ -2,7 +2,7 @@ Index: linux-stage/fs/ext4/super.c =================================================================== --- linux-stage.orig/fs/ext4/super.c +++ linux-stage/fs/ext4/super.c -@@ -185,6 +185,8 @@ void ext4_journal_abort_handle(const cha +@@ -334,6 +334,8 @@ void ext4_journal_abort_handle(const cha jbd2_journal_abort_handle(handle); } @@ -11,7 +11,7 @@ Index: linux-stage/fs/ext4/super.c /* Deal with the reporting of failure conditions on a filesystem such as * inconsistencies detected or read IO failures. * -@@ -2459,6 +2461,8 @@ out_fail: +@@ -3529,6 +3531,8 @@ out_fail: return ret; } @@ -20,9 +20,9 @@ Index: linux-stage/fs/ext4/super.c /* * Setup any per-fs journal parameters now. We'll do this both on * initial mount, once the journal has been initialised but before we've -@@ -3504,6 +3508,12 @@ int ext4_map_inode_page(struct inode *in - unsigned long *blocks, int *created, int create); - EXPORT_SYMBOL(ext4_map_inode_page); +@@ -4642,6 +4646,12 @@ static void __exit exit_ext4_fs(void) + exit_ext4_system_zone(); + } +EXPORT_SYMBOL(ext4_xattr_get); +EXPORT_SYMBOL(ext4_xattr_set_handle); @@ -37,20 +37,20 @@ Index: linux-stage/fs/ext4/ext4.h =================================================================== --- linux-stage.orig/fs/ext4/ext4.h +++ linux-stage/fs/ext4/ext4.h -@@ -1024,6 +1024,8 @@ extern unsigned long ext4_count_free_ino - struct buffer_head *bh, - ext4_group_t group, - struct ext4_group_desc *desc); +@@ -1643,6 +1643,8 @@ extern unsigned ext4_init_inode_bitmap(s + struct buffer_head *bh, + ext4_group_t group, + struct ext4_group_desc *desc); +extern struct buffer_head *ext4_read_inode_bitmap(struct super_block *sb, + ext4_group_t block_group); extern void mark_bitmap_end(int start_bit, int end_bit, char *bitmap); extern int ext4_init_inode_table(struct super_block *sb, - ext4_group_t group, int barrier); + ext4_group_t group, int barrier); Index: linux-stage/fs/ext4/ialloc.c =================================================================== --- linux-stage.orig/fs/ext4/ialloc.c +++ linux-stage/fs/ext4/ialloc.c -@@ -96,7 +96,7 @@ unsigned ext4_init_inode_bitmap(struct s +@@ -97,7 +97,7 @@ unsigned ext4_init_inode_bitmap(struct s * * Return buffer_head of bitmap on success or NULL. */ @@ -59,7 +59,7 @@ Index: linux-stage/fs/ext4/ialloc.c ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) { struct ext4_group_desc *desc; -@@ -137,6 +137,7 @@ ext4_read_inode_bitmap(struct super_bloc +@@ -161,6 +161,7 @@ ext4_read_inode_bitmap(struct super_bloc } return bh; } @@ -71,7 +71,7 @@ Index: linux-stage/fs/ext4/balloc.c =================================================================== --- linux-stage.orig/fs/ext4/balloc.c +++ linux-stage/fs/ext4/balloc.c -@@ -236,6 +236,7 @@ struct ext4_group_desc * ext4_get_group_ +@@ -229,6 +229,7 @@ struct ext4_group_desc * ext4_get_group_ *bh = sbi->s_group_desc[group_desc]; return desc; } @@ -79,3 +79,15 @@ Index: linux-stage/fs/ext4/balloc.c static int ext4_valid_block_bitmap(struct super_block *sb, struct ext4_group_desc *desc, +Index: linux-stage/fs/ext4/inode.c +=================================================================== +--- linux-stage.orig/fs/ext4/inode.c ++++ linux-stage/fs/ext4/inode.c +@@ -5131,6 +5131,7 @@ out_stop: + + ext4_journal_stop(handle); + } ++EXPORT_SYMBOL(ext4_truncate); + + /* + * ext4_get_inode_loc returns with an extra refcount against the inode's diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-nlink-2.6.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-nlink-2.6.patch index 9fa6aae..dcf3f33 100644 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-nlink-2.6.patch +++ b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-nlink-2.6.patch @@ -2,9 +2,27 @@ Index: linux-stage/fs/ext4/namei.c =================================================================== --- linux-stage.orig/fs/ext4/namei.c +++ linux-stage/fs/ext4/namei.c -@@ -1709,9 +1709,8 @@ static void ext4_inc_count(handle_t *han +@@ -1609,7 +1709,7 @@ static void ext4_inc_count(handle_t *han + * DIR_NLINK feature is set if 1) nlinks > EXT4_LINK_MAX or 2) nlinks == 2, + * since this indicates that nlinks count was previously 1. */ - static void ext4_dec_count(handle_t *handle, struct inode *inode) +-static void ext4_inc_count(handle_t *handle, struct inode *inode) ++void ext4_inc_count(handle_t *handle, struct inode *inode) + { + inc_nlink(inode); + if (is_dx(inode) && inode->i_nlink > 1) { +@@ -1709,17 +1709,18 @@ static void ext4_inc_count(handle_t *han + } + } + } ++EXPORT_SYMBOL(ext4_inc_count); + + /* + * If a directory had nlink == 1, then we should let it be 1. This indicates + * directory has >EXT4_LINK_MAX subdirs. + */ +-static void ext4_dec_count(handle_t *handle, struct inode *inode) ++void ext4_dec_count(handle_t *handle, struct inode *inode) { - drop_nlink(inode); - if (S_ISDIR(inode->i_mode) && inode->i_nlink == 0) @@ -12,3 +30,7 @@ Index: linux-stage/fs/ext4/namei.c + if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 2) + drop_nlink(inode); } ++EXPORT_SYMBOL(ext4_dec_count); + + + static int ext4_add_nondir(handle_t *handle, diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/export-ext4-3.0.patch b/ldiskfs/kernel_patches/patches/sles11sp2/export-ext4-3.0.patch index 74bf0a4..e0084ff 100644 --- a/ldiskfs/kernel_patches/patches/sles11sp2/export-ext4-3.0.patch +++ b/ldiskfs/kernel_patches/patches/sles11sp2/export-ext4-3.0.patch @@ -10,18 +10,22 @@ fs/ext4/super.c | 9 +++++++++ 9 files changed, 46 insertions(+), 8 deletions(-) ---- a/fs/ext4/balloc.c -+++ b/fs/ext4/balloc.c +Index: linux-stage/fs/ext4/balloc.c +=================================================================== +--- linux-stage.orig/fs/ext4/balloc.c ++++ linux-stage/fs/ext4/balloc.c @@ -231,6 +231,7 @@ struct ext4_group_desc * ext4_get_group_ *bh = sbi->s_group_desc[group_desc]; return desc; } +EXPORT_SYMBOL(ext4_get_group_desc); - + static int ext4_valid_block_bitmap(struct super_block *sb, struct ext4_group_desc *desc, ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h +Index: linux-stage/fs/ext4/ext4.h +=================================================================== +--- linux-stage.orig/fs/ext4/ext4.h ++++ linux-stage/fs/ext4/ext4.h @@ -1783,6 +1783,8 @@ extern struct inode * ext4_orphan_get(st extern unsigned long ext4_count_free_inodes(struct super_block *); extern unsigned long ext4_count_dirs(struct super_block *); @@ -31,8 +35,10 @@ extern void ext4_mark_bitmap_end(int start_bit, int end_bit, char *bitmap); extern int ext4_init_inode_table(struct super_block *sb, ext4_group_t group, int barrier); ---- a/fs/ext4/ext4_extents.h -+++ b/fs/ext4/ext4_extents.h +Index: linux-stage/fs/ext4/ext4_extents.h +=================================================================== +--- linux-stage.orig/fs/ext4/ext4_extents.h ++++ linux-stage/fs/ext4/ext4_extents.h @@ -290,5 +290,14 @@ extern struct ext4_ext_path *ext4_ext_fi struct ext4_ext_path *); extern void ext4_ext_drop_refs(struct ext4_ext_path *); @@ -47,15 +53,17 @@ + ext4_lblk_t num, ext_prepare_callback func, + void *cbdata); #endif /* _EXT4_EXTENTS */ - ---- a/fs/ext4/ext4_jbd2.c -+++ b/fs/ext4/ext4_jbd2.c + +Index: linux-stage/fs/ext4/ext4_jbd2.c +=================================================================== +--- linux-stage.orig/fs/ext4/ext4_jbd2.c ++++ linux-stage/fs/ext4/ext4_jbd2.c @@ -19,6 +19,7 @@ int __ext4_journal_get_write_access(cons } return err; } +EXPORT_SYMBOL(__ext4_journal_get_write_access); - + /* * The ext4 forget function must perform a revoke if we are freeing data @@ -150,3 +151,4 @@ int __ext4_handle_dirty_super(const char @@ -63,9 +71,11 @@ return err; } +EXPORT_SYMBOL(__ext4_handle_dirty_metadata); ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -1236,9 +1236,9 @@ out: +Index: linux-stage/fs/ext4/extents.c +=================================================================== +--- linux-stage.orig/fs/ext4/extents.c ++++ linux-stage/fs/ext4/extents.c +@@ -1233,9 +1233,9 @@ out: * returns 0 at @phys * return value contains 0 (success) or error code */ @@ -78,7 +88,7 @@ { struct ext4_extent_idx *ix; struct ext4_extent *ex; -@@ -1301,9 +1301,9 @@ static int ext4_ext_search_left(struct i +@@ -1298,9 +1298,9 @@ static int ext4_ext_search_left(struct i * returns 0 at @phys * return value contains 0 (success) or error code */ @@ -91,17 +101,17 @@ { struct buffer_head *bh = NULL; struct ext4_extent_header *eh; -@@ -1878,7 +1878,7 @@ cleanup: +@@ -1875,7 +1875,7 @@ cleanup: return err; } - + -static int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block, +extern int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block, ext4_lblk_t num, ext_prepare_callback func, void *cbdata) { -@@ -4397,3 +4397,12 @@ int ext4_fiemap(struct inode *inode, str - +@@ -4380,3 +4380,12 @@ int ext4_fiemap(struct inode *inode, str + return error; } + @@ -113,9 +123,11 @@ +EXPORT_SYMBOL(ext4_ext_walk_space); +EXPORT_SYMBOL(ext4_ext_find_extent); +EXPORT_SYMBOL(ext4_ext_drop_refs); ---- a/fs/ext4/ialloc.c -+++ b/fs/ext4/ialloc.c -@@ -98,7 +98,7 @@ static unsigned ext4_init_inode_bitmap(s +Index: linux-stage/fs/ext4/ialloc.c +=================================================================== +--- linux-stage.orig/fs/ext4/ialloc.c ++++ linux-stage/fs/ext4/ialloc.c +@@ -99,7 +99,7 @@ static unsigned ext4_init_inode_bitmap(s * * Return buffer_head of bitmap on success or NULL. */ @@ -124,71 +136,85 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) { struct ext4_group_desc *desc; -@@ -163,6 +163,7 @@ ext4_read_inode_bitmap(struct super_bloc +@@ -164,6 +164,7 @@ ext4_read_inode_bitmap(struct super_bloc } return bh; } +EXPORT_SYMBOL(ext4_read_inode_bitmap); - + /* * NOTE! When we get the inode, we're the only people ---- a/fs/ext4/inode.c -+++ b/fs/ext4/inode.c -@@ -5096,6 +5096,7 @@ bad_inode: +Index: linux-stage/fs/ext4/inode.c +=================================================================== +--- linux-stage.orig/fs/ext4/inode.c ++++ linux-stage/fs/ext4/inode.c +@@ -4685,6 +4685,7 @@ out_stop: + ext4_journal_stop(handle); + trace_ext4_truncate_exit(inode); + } ++EXPORT_SYMBOL(ext4_truncate); + + /* + * ext4_get_inode_loc returns with an extra refcount against the inode's +@@ -5098,6 +5099,7 @@ bad_inode: iget_failed(inode); return ERR_PTR(ret); } +EXPORT_SYMBOL(ext4_iget); - + static int ext4_inode_blocks_set(handle_t *handle, struct ext4_inode *raw_inode, ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c +Index: linux-stage/fs/ext4/mballoc.c +=================================================================== +--- linux-stage.orig/fs/ext4/mballoc.c ++++ linux-stage/fs/ext4/mballoc.c @@ -3852,6 +3852,7 @@ repeat: call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); } } +EXPORT_SYMBOL(ext4_discard_preallocations); - + #ifdef CONFIG_EXT4_DEBUG static void ext4_mb_show_ac(struct ext4_allocation_context *ac) @@ -4972,3 +4973,6 @@ int ext4_trim_fs(struct super_block *sb, - + return ret; } + +EXPORT_SYMBOL(ext4_free_blocks); + ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c +Index: linux-stage/fs/ext4/super.c +=================================================================== +--- linux-stage.orig/fs/ext4/super.c ++++ linux-stage/fs/ext4/super.c @@ -194,6 +194,7 @@ __u32 ext4_itable_unused_count(struct su (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0); } +EXPORT_SYMBOL(ext4_itable_unused_count); - + void ext4_block_bitmap_set(struct super_block *sb, struct ext4_group_desc *bg, ext4_fsblk_t blk) @@ -378,6 +379,7 @@ void ext4_journal_abort_handle(const cha - + jbd2_journal_abort_handle(handle); } +EXPORT_SYMBOL(ext4_journal_abort_handle); - + static void __save_error_info(struct super_block *sb, const char *func, unsigned int line) -@@ -4272,6 +4274,7 @@ int ext4_force_commit(struct super_block - +@@ -4270,6 +4272,7 @@ int ext4_force_commit(struct super_block + return ret; } +EXPORT_SYMBOL(ext4_force_commit); - + static void ext4_write_super(struct super_block *sb) { -@@ -5208,6 +5211,12 @@ static void __exit ext4_exit_fs(void) +@@ -5198,6 +5201,12 @@ static void __exit ext4_exit_fs(void) ext4_exit_pageio(); } - + +EXPORT_SYMBOL(ext4_xattr_get); +EXPORT_SYMBOL(ext4_xattr_set_handle); +EXPORT_SYMBOL(ext4_bread); diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 620963c..1b17cb3 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -427,14 +427,26 @@ LB_LINUX_TRY_COMPILE([ #include #include ],[ - struct quotactl_ops qops = {}; - struct fs_disk_quota fdq; - qops.set_dqblk(NULL, 0, 0, &fdq); + ((struct quotactl_ops *)0)->set_dqblk(NULL, 0, 0, (struct fs_disk_quota*)0); ],[ AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1, [quotactl_ops.set_dqblk takes struct fs_disk_quota]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) + AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct kqid & fs_disk_quota]) + LB_LINUX_TRY_COMPILE([ + #include + #include + ],[ + ((struct quotactl_ops *)0)->set_dqblk((struct super_block*)0, *((struct kqid*)0), (struct fs_disk_quota*)0); + ],[ + AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1, [quotactl_ops.set_dqblk takes struct fs_disk_quota]) + AC_DEFINE(HAVE_DQUOT_KQID, 1, [quotactl_ops.set_dqblk takes struct kqid]) + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct kqid&fs_disk_quota]) + ]) ]) EXTRA_KCFLAGS="$tmp_flags" ]) @@ -716,6 +728,24 @@ AC_DEFINE(HAVE_SIMPLE_SETATTR, 1, ]) # +# truncate callback removed since 2.6.39 +# +AC_DEFUN([LC_IOP_TRUNCATE], +[AC_MSG_CHECKING([inode_operations has .truncate member function]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + ((struct inode_operations *)0)->truncate(NULL); +],[ + AC_DEFINE(HAVE_INODEOPS_TRUNCATE, 1, + [inode_operations has .truncate member function]) + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# # 2.6.39 remove unplug_fn from request_queue. # AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN], @@ -1339,6 +1369,7 @@ AC_DEFUN([LC_PROG_LINUX], # 2.6.39 LC_REQUEST_QUEUE_UNPLUG_FN LC_HAVE_FSTYPE_MOUNT + LC_IOP_TRUNCATE # 3.0 LC_DIRTY_INODE_WITH_FLAG diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c index c6ac60cb..8e7fc11 100644 --- a/lustre/osd-ldiskfs/osd_compat.c +++ b/lustre/osd-ldiskfs/osd_compat.c @@ -259,10 +259,7 @@ int osd_add_to_remote_parent(const struct lu_env *env, struct osd_device *osd, NULL); CDEBUG(D_INODE, "%s: add %s:%lu to remote parent %lu.\n", osd_name(osd), name, obj->oo_inode->i_ino, parent->d_inode->i_ino); - LASSERTF(parent->d_inode->i_nlink > 1, "%s: %lu nlink %d", - osd_name(osd), parent->d_inode->i_ino, - parent->d_inode->i_nlink); - parent->d_inode->i_nlink++; + ldiskfs_inc_count(oh->ot_handle, parent->d_inode); mark_inode_dirty(parent->d_inode); mutex_unlock(&parent->d_inode->i_mutex); RETURN(rc); @@ -296,7 +293,8 @@ int osd_delete_from_remote_parent(const struct lu_env *env, dentry = osd_child_dentry_by_inode(env, parent->d_inode, name, strlen(name)); mutex_lock(&parent->d_inode->i_mutex); - bh = osd_ldiskfs_find_entry(parent->d_inode, dentry, &de, NULL); + bh = osd_ldiskfs_find_entry(parent->d_inode, &dentry->d_name, &de, + NULL, NULL); if (bh == NULL) { mutex_unlock(&parent->d_inode->i_mutex); RETURN(-ENOENT); @@ -304,10 +302,7 @@ int osd_delete_from_remote_parent(const struct lu_env *env, CDEBUG(D_INODE, "%s: el %s:%lu to remote parent %lu.\n", osd_name(osd), name, obj->oo_inode->i_ino, parent->d_inode->i_ino); rc = ldiskfs_delete_entry(oh->ot_handle, parent->d_inode, de, bh); - LASSERTF(parent->d_inode->i_nlink > 1, "%s: %lu nlink %d", - osd_name(osd), parent->d_inode->i_ino, - parent->d_inode->i_nlink); - parent->d_inode->i_nlink--; + ldiskfs_dec_count(oh->ot_handle, parent->d_inode); mark_inode_dirty(parent->d_inode); mutex_unlock(&parent->d_inode->i_mutex); brelse(bh); @@ -339,7 +334,8 @@ int osd_lookup_in_remote_parent(struct osd_thread_info *oti, dentry = osd_child_dentry_by_inode(oti->oti_env, parent->d_inode, name, strlen(name)); mutex_lock(&parent->d_inode->i_mutex); - bh = osd_ldiskfs_find_entry(parent->d_inode, dentry, &de, NULL); + bh = osd_ldiskfs_find_entry(parent->d_inode, &dentry->d_name, &de, + NULL, NULL); if (bh == NULL) { rc = -ENOENT; } else { @@ -561,7 +557,7 @@ static int osd_obj_update_entry(struct osd_thread_info *info, ll_vfs_dq_init(parent); mutex_lock(&parent->i_mutex); - bh = osd_ldiskfs_find_entry(parent, child, &de, NULL); + bh = osd_ldiskfs_find_entry(parent, &child->d_name, &de, NULL, NULL); if (bh == NULL) GOTO(out, rc = -ENOENT); @@ -655,7 +651,7 @@ static int osd_obj_del_entry(struct osd_thread_info *info, ll_vfs_dq_init(dir); mutex_lock(&dir->i_mutex); rc = -ENOENT; - bh = osd_ldiskfs_find_entry(dir, child, &de, NULL); + bh = osd_ldiskfs_find_entry(dir, &child->d_name, &de, NULL, NULL); if (bh) { rc = ldiskfs_delete_entry(oh->ot_handle, dir, de, bh); brelse(bh); @@ -918,7 +914,7 @@ int osd_obj_map_lookup(struct osd_thread_info *info, struct osd_device *dev, dir = d_seq->d_inode; mutex_lock(&dir->i_mutex); - bh = osd_ldiskfs_find_entry(dir, child, &de, NULL); + bh = osd_ldiskfs_find_entry(dir, &child->d_name, &de, NULL, NULL); mutex_unlock(&dir->i_mutex); if (bh == NULL) @@ -1088,7 +1084,7 @@ int osd_obj_map_recover(struct osd_thread_info *info, tgt_child->d_inode = inode; /* The non-initialized src_child may be destroyed. */ - jh = ldiskfs_journal_start_sb(osd_sb(osd), + jh = osd_journal_start_sb(osd_sb(osd), LDISKFS_HT_MISC, osd_dto_credits_noquota[DTO_INDEX_DELETE] + osd_dto_credits_noquota[DTO_INDEX_INSERT] + osd_dto_credits_noquota[DTO_OBJECT_DELETE]); @@ -1100,7 +1096,7 @@ int osd_obj_map_recover(struct osd_thread_info *info, mutex_lock(&src_parent->i_mutex); mutex_lock(&dir->i_mutex); - bh = osd_ldiskfs_find_entry(dir, tgt_child, &de, NULL); + bh = osd_ldiskfs_find_entry(dir, &tgt_child->d_name, &de, NULL, NULL); if (bh != NULL) { /* XXX: If some other object occupied the same slot. And If such * inode is zero-sized and with SUID+SGID, then means it is @@ -1126,8 +1122,8 @@ int osd_obj_map_recover(struct osd_thread_info *info, /* If the src object has never been modified, then remove it. */ if (inode->i_size == 0 && inode->i_mode & S_ISUID && inode->i_mode & S_ISGID) { - bh = osd_ldiskfs_find_entry(src_parent, src_child, &de, - NULL); + bh = osd_ldiskfs_find_entry(src_parent, &src_child->d_name, + &de, NULL, NULL); if (unlikely(bh == NULL)) { mutex_unlock(&src_parent->i_mutex); ldiskfs_journal_stop(jh); @@ -1146,7 +1142,8 @@ int osd_obj_map_recover(struct osd_thread_info *info, RETURN(rc); } - bh = osd_ldiskfs_find_entry(src_parent, src_child, &de, NULL); + bh = osd_ldiskfs_find_entry(src_parent, &src_child->d_name, &de, + NULL, NULL); if (unlikely(bh == NULL)) GOTO(unlock, rc = -ENOENT); diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 6d58595..ce29c75 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -998,7 +998,7 @@ int osd_trans_start(const struct lu_env *env, struct dt_device *d, * XXX temporary stuff. Some abstraction layer should * be used. */ - jh = ldiskfs_journal_start_sb(osd_sb(dev), oh->ot_credits); + jh = osd_journal_start_sb(osd_sb(dev), LDISKFS_HT_MISC, oh->ot_credits); osd_th_started(oh); if (!IS_ERR(jh)) { oh->ot_handle = jh; @@ -2401,7 +2401,8 @@ static int osd_object_destroy(const struct lu_env *env, RETURN(-EPERM); if (S_ISDIR(inode->i_mode)) { - LASSERT(osd_inode_unlinked(inode) || inode->i_nlink == 1); + LASSERT(osd_inode_unlinked(inode) || inode->i_nlink == 1 || + inode->i_nlink == 2); /* it will check/delete the inode from remote parent, * how to optimize it? unlink performance impaction XXX */ result = osd_delete_from_remote_parent(env, osd, obj, oh); @@ -2698,20 +2699,22 @@ static int osd_declare_object_ref_add(const struct lu_env *env, static int osd_object_ref_add(const struct lu_env *env, struct dt_object *dt, struct thandle *th) { - struct osd_object *obj = osd_dt_obj(dt); - struct inode *inode = obj->oo_inode; - bool need_dirty = false; - int rc = 0; + struct osd_object *obj = osd_dt_obj(dt); + struct inode *inode = obj->oo_inode; + struct osd_thandle *oh; + int rc = 0; LINVRNT(osd_invariant(obj)); LASSERT(dt_object_exists(dt) && !dt_object_remote(dt)); LASSERT(osd_write_locked(env, obj)); LASSERT(th != NULL); + oh = container_of0(th, struct osd_thandle, ot_super); + LASSERT(oh->ot_handle != NULL); + osd_trans_exec_op(env, th, OSD_OT_REF_ADD); - /* This based on ldiskfs_inc_count(), which is not exported. - * + /* * The DIR_NLINK feature allows directories to exceed LDISKFS_LINK_MAX * (65000) subdirectories by storing "1" in i_nlink if the link count * would otherwise overflow. Directory tranversal tools understand @@ -2723,28 +2726,11 @@ static int osd_object_ref_add(const struct lu_env *env, * in case they are being linked into the PENDING directory */ spin_lock(&obj->oo_guard); - if (unlikely(!S_ISDIR(inode->i_mode) && - inode->i_nlink >= LDISKFS_LINK_MAX)) { - /* MDD should have checked this, but good to be safe */ - rc = -EMLINK; - } else if (unlikely(inode->i_nlink == 0 || - (S_ISDIR(inode->i_mode) && - inode->i_nlink >= LDISKFS_LINK_MAX))) { - /* inc_nlink from 0 may cause WARN_ON */ - set_nlink(inode, 1); - need_dirty = true; - } else if (!S_ISDIR(inode->i_mode) || - (S_ISDIR(inode->i_mode) && inode->i_nlink >= 2)) { - inc_nlink(inode); - need_dirty = true; - } /* else (S_ISDIR(inode->i_mode) && inode->i_nlink == 1) { ; } */ - + ldiskfs_inc_count(oh->ot_handle, inode); LASSERT(inode->i_nlink <= LDISKFS_LINK_MAX); spin_unlock(&obj->oo_guard); - if (need_dirty) - ll_dirty_inode(inode, I_DIRTY_DATASYNC); - + ll_dirty_inode(inode, I_DIRTY_DATASYNC); LINVRNT(osd_invariant(obj)); return rc; @@ -2777,12 +2763,16 @@ static int osd_object_ref_del(const struct lu_env *env, struct dt_object *dt, struct osd_object *obj = osd_dt_obj(dt); struct inode *inode = obj->oo_inode; struct osd_device *osd = osd_dev(dt->do_lu.lo_dev); + struct osd_thandle *oh; LINVRNT(osd_invariant(obj)); LASSERT(dt_object_exists(dt) && !dt_object_remote(dt)); LASSERT(osd_write_locked(env, obj)); LASSERT(th != NULL); + oh = container_of0(th, struct osd_thandle, ot_super); + LASSERT(oh->ot_handle != NULL); + osd_trans_exec_op(env, th, OSD_OT_REF_DEL); spin_lock(&obj->oo_guard); @@ -2798,23 +2788,11 @@ static int osd_object_ref_del(const struct lu_env *env, struct dt_object *dt, return 0; } - /* This based on ldiskfs_dec_count(), which is not exported. - * - * If a directory already has nlink == 1, then do not drop the nlink - * count to 0, even temporarily, to avoid race conditions with other - * threads not holding oo_guard seeing i_nlink == 0 in rare cases. - * - * nlink == 1 means the directory has/had > EXT4_LINK_MAX subdirs. - */ - if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 1) { - drop_nlink(inode); + ldiskfs_dec_count(oh->ot_handle, inode); + spin_unlock(&obj->oo_guard); - spin_unlock(&obj->oo_guard); - ll_dirty_inode(inode, I_DIRTY_DATASYNC); - LINVRNT(osd_invariant(obj)); - } else { - spin_unlock(&obj->oo_guard); - } + ll_dirty_inode(inode, I_DIRTY_DATASYNC); + LINVRNT(osd_invariant(obj)); return 0; } @@ -3547,7 +3525,7 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt, down_write(&obj->oo_ext_idx_sem); } - bh = ldiskfs_find_entry(dir, &dentry->d_name, &de, hlock); + bh = osd_ldiskfs_find_entry(dir, &dentry->d_name, &de, NULL, hlock); if (bh) { __u32 ino = 0; @@ -4068,7 +4046,7 @@ static int osd_ea_lookup_rec(const struct lu_env *env, struct osd_object *obj, down_read(&obj->oo_ext_idx_sem); } - bh = osd_ldiskfs_find_entry(dir, dentry, &de, hlock); + bh = osd_ldiskfs_find_entry(dir, &dentry->d_name, &de, NULL, hlock); if (bh) { struct osd_thread_info *oti = osd_oti_get(env); struct osd_inode_id *id = &oti->oti_id; @@ -5068,7 +5046,7 @@ osd_dirent_check_repair(const struct lu_env *env, struct osd_object *obj, again: if (dev->od_dirent_journal) { - jh = ldiskfs_journal_start_sb(sb, credits); + jh = osd_journal_start_sb(sb, LDISKFS_HT_MISC, credits); if (IS_ERR(jh)) { rc = PTR_ERR(jh); CERROR("%.16s: fail to start trans for dirent " @@ -5098,7 +5076,7 @@ again: } } - bh = osd_ldiskfs_find_entry(dir, dentry, &de, hlock); + bh = osd_ldiskfs_find_entry(dir, &dentry->d_name, &de, NULL, hlock); /* For dot/dotdot entry, if there is not enough space to hold the * FID-in-dirent, just keep them there. It only happens when the * device upgraded from 1.8 or restored from MDT file-level backup. diff --git a/lustre/osd-ldiskfs/osd_iam.c b/lustre/osd-ldiskfs/osd_iam.c index 203e1e7..1524e61 100644 --- a/lustre/osd-ldiskfs/osd_iam.c +++ b/lustre/osd-ldiskfs/osd_iam.c @@ -1740,7 +1740,7 @@ got: return bh; newblock: - bh = ldiskfs_append(h, inode, b, e); + bh = osd_ldiskfs_append(h, inode, b, e); return bh; fail: diff --git a/lustre/osd-ldiskfs/osd_iam.h b/lustre/osd-ldiskfs/osd_iam.h index 9c03e08..aeccdbc 100644 --- a/lustre/osd-ldiskfs/osd_iam.h +++ b/lustre/osd-ldiskfs/osd_iam.h @@ -975,8 +975,6 @@ int dx_index_is_compat(struct iam_path *path); int ldiskfs_htree_next_block(struct inode *dir, __u32 hash, struct iam_path *path, __u32 *start_hash); -struct buffer_head *ldiskfs_append(handle_t *handle, struct inode *inode, - u32 *block, int *err); int split_index_node(handle_t *handle, struct iam_path *path, struct dynlock_handle **lh); struct ldiskfs_dir_entry_2 *split_entry(struct inode *dir, diff --git a/lustre/osd-ldiskfs/osd_iam_lfix.c b/lustre/osd-ldiskfs/osd_iam_lfix.c index 7d0e93e..e36c5c8 100644 --- a/lustre/osd-ldiskfs/osd_iam_lfix.c +++ b/lustre/osd-ldiskfs/osd_iam_lfix.c @@ -856,15 +856,15 @@ int iam_lfix_create(struct inode *obj, struct super_block *sb; u32 blknr; - int result; + int result = 0; unsigned long bsize; assert_corr(obj->i_size == 0); sb = obj->i_sb; bsize = sb->s_blocksize; - root_node = ldiskfs_append(handle, obj, &blknr, &result); - leaf_node = ldiskfs_append(handle, obj, &blknr, &result); + root_node = osd_ldiskfs_append(handle, obj, &blknr, &result); + leaf_node = osd_ldiskfs_append(handle, obj, &blknr, &result); if (root_node != NULL && leaf_node != NULL) { lfix_root(root_node->b_data, bsize, keysize, ptrsize, recsize); lfix_leaf(leaf_node->b_data, bsize, keysize, ptrsize, recsize); diff --git a/lustre/osd-ldiskfs/osd_iam_lvar.c b/lustre/osd-ldiskfs/osd_iam_lvar.c index b0b8c4e..7ad8b10 100644 --- a/lustre/osd-ldiskfs/osd_iam_lvar.c +++ b/lustre/osd-ldiskfs/osd_iam_lvar.c @@ -1010,15 +1010,15 @@ int iam_lvar_create(struct inode *obj, struct super_block *sb; u32 blknr; - int result; + int result = 0; unsigned long bsize; assert_corr(obj->i_size == 0); sb = obj->i_sb; bsize = sb->s_blocksize; - root_node = ldiskfs_append(handle, obj, &blknr, &result); - leaf_node = ldiskfs_append(handle, obj, &blknr, &result); + root_node = osd_ldiskfs_append(handle, obj, &blknr, &result); + leaf_node = osd_ldiskfs_append(handle, obj, &blknr, &result); if (root_node != NULL && leaf_node != NULL) { lvar_root(root_node->b_data, bsize, keysize, ptrsize, recsize); lvar_leaf(leaf_node->b_data, bsize, keysize, ptrsize, recsize); diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index c80a916..75dfa7d 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -171,8 +171,6 @@ struct osd_mdobj_map { struct dentry *omm_remote_parent; }; -#define osd_ldiskfs_find_entry(dir, dentry, de, lock) \ - ll_ldiskfs_find_entry(dir, dentry, de, lock) #define osd_ldiskfs_add_entry(handle, child, cinode, hlock) \ ldiskfs_add_entry(handle, child, cinode, hlock) @@ -1067,5 +1065,30 @@ static inline int fid_is_internal(const struct lu_fid *fid) { return (!fid_is_namespace_visible(fid) && !fid_is_idif(fid)); } + +#ifdef JOURNAL_START_HAS_3ARGS +# define osd_journal_start_sb(sb, type, nblock) \ + ldiskfs_journal_start_sb(sb, type, nblock) +# define osd_ldiskfs_append(handle, inode, nblock, err) \ + ldiskfs_append(handle, inode, nblock) +# define osd_ldiskfs_find_entry(dir, name, de, inlined, lock) \ + ldiskfs_find_entry(dir, name, de, inlined, lock) +# define osd_journal_start(inode, type, nblocks) \ + ldiskfs_journal_start(inode, type, nblocks); +#else +# define LDISKFS_HT_MISC 0 +# define osd_journal_start_sb(sb, type, nblock) \ + ldiskfs_journal_start_sb(sb, nblock) +# define osd_ldiskfs_append(handle, inode, nblock, err) \ + ldiskfs_append(handle, inode, nblock, err) +# define osd_ldiskfs_find_entry(dir, name, de, inlined, lock) \ + ldiskfs_find_entry(dir, name, de, lock) +# define osd_journal_start(inode, type, nblocks) \ + ldiskfs_journal_start(inode, nblocks); +#endif + +void ldiskfs_inc_count(handle_t *handle, struct inode *inode); +void ldiskfs_dec_count(handle_t *handle, struct inode *inode); + #endif /* __KERNEL__ */ #endif /* _OSD_INTERNAL_H */ diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index a217bb3..4675fcc 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1211,8 +1211,19 @@ static int osd_punch(const struct lu_env *env, struct dt_object *dt, oldsize=inode->i_size; i_size_write(inode, start); truncate_pagecache(inode, oldsize, start); - if (inode->i_op->truncate) +#ifdef HAVE_INODEOPS_TRUNCATE + if (inode->i_op->truncate) { inode->i_op->truncate(inode); + } else { +#endif + if (!(inode->i_state & (I_NEW|I_FREEING))) + mutex_lock(&inode->i_mutex); + ldiskfs_truncate(inode); + if (!(inode->i_state & (I_NEW|I_FREEING))) + mutex_unlock(&inode->i_mutex); +#ifdef HAVE_INODEOPS_TRUNCATE + } +#endif /* * For a partial-page truncate, flush the page to disk immediately to diff --git a/lustre/osd-ldiskfs/osd_oi.c b/lustre/osd-ldiskfs/osd_oi.c index 2fdb3cb..ced7a16 100644 --- a/lustre/osd-ldiskfs/osd_oi.c +++ b/lustre/osd-ldiskfs/osd_oi.c @@ -117,7 +117,7 @@ static int osd_oi_index_create_one(struct osd_thread_info *info, int rc; dentry = osd_child_dentry_by_inode(env, dir, name, strlen(name)); - bh = osd_ldiskfs_find_entry(dir, dentry, &de, NULL); + bh = osd_ldiskfs_find_entry(dir, &dentry->d_name, &de, NULL, NULL); if (bh) { osd_id_gen(id, le32_to_cpu(de->inode), OSD_OII_NOGEN); brelse(bh); @@ -129,7 +129,7 @@ static int osd_oi_index_create_one(struct osd_thread_info *info, return PTR_ERR(inode); } - jh = ldiskfs_journal_start_sb(sb, 100); + jh = osd_journal_start_sb(sb, LDISKFS_HT_MISC, 100); if (IS_ERR(jh)) return PTR_ERR(jh); diff --git a/lustre/osd-ldiskfs/osd_quota.c b/lustre/osd-ldiskfs/osd_quota.c index a4fef99b..d0c0fa2 100644 --- a/lustre/osd-ldiskfs/osd_quota.c +++ b/lustre/osd-ldiskfs/osd_quota.c @@ -113,11 +113,19 @@ static int osd_acct_index_lookup(const struct lu_env *env, struct lquota_acct_rec *rec = (struct lquota_acct_rec *)dtrec; __u64 id = *((__u64 *)dtkey); int rc; +#ifdef HAVE_DQUOT_KQID + struct kqid qid; +#endif ENTRY; memset((void *)dqblk, 0, sizeof(struct obd_dqblk)); +#ifdef HAVE_DQUOT_KQID + qid = make_kqid(&init_user_ns, obj2type(dtobj), id); + rc = sb->s_qcop->get_dqblk(sb, qid, dqblk); +#else rc = sb->s_qcop->get_dqblk(sb, obj2type(dtobj), (qid_t) id, dqblk); +#endif if (rc) RETURN(rc); #ifdef HAVE_DQUOT_FS_DISK_QUOTA diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 01b9c52..24a7932 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -342,7 +342,7 @@ int osd_scrub_file_store(struct osd_scrub *scrub) dev = container_of0(scrub, struct osd_device, od_scrub); credits = osd_dto_credits_noquota[DTO_WRITE_BASE] + osd_dto_credits_noquota[DTO_WRITE_BLOCK]; - jh = ldiskfs_journal_start_sb(osd_sb(dev), credits); + jh = osd_journal_start_sb(osd_sb(dev), LDISKFS_HT_MISC, credits); if (IS_ERR(jh)) { rc = PTR_ERR(jh); CERROR("%.16s: fail to start trans for scrub store, rc = %d\n", @@ -391,7 +391,7 @@ osd_scrub_convert_ff(struct osd_thread_info *info, struct osd_device *dev, * Making the LMA to fit into the 256-byte OST inode can save time for * normal osd_check_lma() and for other OI scrub scanning in future. * So it is worth to make some slow conversion here. */ - jh = ldiskfs_journal_start_sb(osd_sb(dev), + jh = osd_journal_start_sb(osd_sb(dev), LDISKFS_HT_MISC, osd_dto_credits_noquota[DTO_XATTR_SET] * 3); if (IS_ERR(jh)) { rc = PTR_ERR(jh); -- 1.8.3.1