From 41ef9e4b10853c985b17e2ca5a0c430b11b40d60 Mon Sep 17 00:00:00 2001 From: Yang Sheng Date: Mon, 29 Sep 2014 06:14:44 +0800 Subject: [PATCH] LU-5584 llite: ensure all data flush out when umount Write out all extents when clear inode. Otherwise we may lose data while umount. Change-Id: I199217c96a7ba49c2f3577a65750e7956a9af63a Signed-off-by: Yang Sheng Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/12103 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- lustre/include/linux/lustre_compat25.h | 10 +++++++++- lustre/llite/llite_lib.c | 21 ++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index e2e46f9..ed26bb6 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -368,7 +368,15 @@ static inline int radix_tree_exceptional_entry(void *arg) #endif #ifndef HAVE_TRUNCATE_INODE_PAGES_FINAL -# define truncate_inode_pages_final(map) truncate_inode_pages(map, 0) +static inline void truncate_inode_pages_final(struct address_space *map) +{ + truncate_inode_pages(map, 0); + /* Workaround for LU-118 */ + if (map->nrpages) { + spin_lock_irq(&map->tree_lock); + spin_unlock_irq(&map->tree_lock); + } /* Workaround end */ +} #endif #ifndef SIZE_MAX diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 3d1c9a3..dc62d60 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2163,24 +2163,15 @@ void ll_delete_inode(struct inode *inode) ENTRY; if (S_ISREG(inode->i_mode) && lli->lli_clob != NULL) - /* discard all dirty pages before truncating them, required by - * osc_extent implementation at LU-1030. */ - cl_sync_file_range(inode, 0, OBD_OBJECT_EOF, - CL_FSYNC_DISCARD, 1); + /* It is last chance to write out dirty pages, + * otherwise we may lose data while umount */ + cl_sync_file_range(inode, 0, OBD_OBJECT_EOF, CL_FSYNC_LOCAL, 1); truncate_inode_pages_final(&inode->i_data); - /* Workaround for LU-118 */ - if (inode->i_data.nrpages) { - spin_lock_irq(&inode->i_data.tree_lock); - spin_unlock_irq(&inode->i_data.tree_lock); - LASSERTF(inode->i_data.nrpages == 0, - "inode="DFID"(%p) nrpages=%lu, see " - "https://jira.hpdd.intel.com/browse/LU-118\n", - PFID(ll_inode2fid(inode)), inode, - inode->i_data.nrpages); - } - /* Workaround end */ + LASSERTF(inode->i_data.nrpages == 0, "inode="DFID"(%p) nrpages=%lu, " + "see https://jira.hpdd.intel.com/browse/LU-118\n", + PFID(ll_inode2fid(inode)), inode, inode->i_data.nrpages); #ifdef HAVE_SBOPS_EVICT_INODE ll_clear_inode(inode); -- 1.8.3.1