From d33235ac9a4d43474518e239d1c76fd74d5cb732 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 13 Nov 2013 12:03:34 -0500 Subject: [PATCH] LU-3974 llite: fix mkdir endless loop Running on 3.11-rc4 kernel, I got below endless loop. It turns to be that Lustre always saves the first page of a dir inode mapping at index ~0UL. And after commit 5a720394 (mm: teach truncate_inode_pages_range() to handle non page aligned ranges), truncate_inode_pages_range() _NO LONGER_ truncates the page that is sitting at index ~0UL. [16768.998006] mkdir R running task 0 2717 2716 0x00000080 [16768.998073] 000000000000000e 0000000000000000 0000000000000000 ffff88000be00460 [16768.998157] ffff88000ea65908 ffffffff810fec3e ffff88000ea65968 ffff8800229e7750 [16768.998241] ffff88000ea658b8 0000000000000000 0000000000000000 ffff88000ea65958 [16768.998326] Call Trace: [16768.998401] [] ? rcu_read_unlock+0x1c/0x2d [16768.998473] [] ? find_get_pages+0xf5/0x11b [16768.998530] [] ? pagevec_lookup+0x20/0x2a [16768.998586] [] ? truncate_inode_pages_range.part.2+0x161/0x39a [16768.998680] [] ? ll_md_blocking_ast+0x338/0x62f [lustre] [16768.998744] [] ? truncate_inode_pages_range+0x38/0x3f [16768.998805] [] ? truncate_inode_pages+0x12/0x14 [16768.998871] [] ? ll_md_blocking_ast+0x444/0x62f [lustre] [16768.998948] [] ? arch_local_irq_save+0x9/0xc [16768.999022] [] ? ldlm_cancel_callback+0x67/0x12a [ptlrpc] [16768.999100] [] ? ldlm_cli_cancel_local+0xf3/0x2bc [ptlrpc] [16768.999176] [] ? ldlm_cli_cancel_list_local+0x7e/0x1e4 [ptlrpc] [16768.999268] [] ? ldlm_cancel_resource_local+0x1aa/0x1b9 [ptlrpc] [16768.999385] [] ? mdc_resource_get_unused+0xf8/0x115 [mdc] [16768.999472] [] ? trace_hardirqs_on+0xd/0xf [16768.999533] [] ? mdc_create+0x11e/0x4db [mdc] [16768.999597] [] ? mutex_unlock+0xe/0x10 [16768.999654] [] ? lmv_create+0x355/0x3e9 [lmv] [16768.999712] [] ? final_putname+0x35/0x39 [16768.999775] [] ? ll_new_node+0x33b/0x3ff [lustre] [16768.999841] [] ? ll_mkdir+0xf2/0x127 [lustre] [16768.999897] [] ? vfs_mkdir+0x84/0xc9 [16768.999961] [] ? SyS_mkdirat+0x77/0xad [16769.000014] [] ? SyS_mkdir+0x19/0x1b [16769.000066] [] ? system_call_fastpath+0x16/0x1b Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman Signed-off-by: James Simmons Change-Id: Ib0898ce908271b155ee9ef46ea53059cb78d0c63 Reviewed-on: http://review.whamcloud.com/8237 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman --- lustre/include/lustre_lite.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lustre/include/lustre_lite.h b/lustre/include/lustre_lite.h index 4a88dd4..7729bdb 100644 --- a/lustre/include/lustre_lite.h +++ b/lustre/include/lustre_lite.h @@ -146,10 +146,14 @@ static inline void ll_dir_chain_fini(struct ll_dir_chain *chain) static inline unsigned long hash_x_index(__u64 hash, int hash64) { #ifdef __KERNEL__ - if (BITS_PER_LONG == 32 && hash64) - hash >>= 32; + if (BITS_PER_LONG == 32 && hash64) + hash >>= 32; #endif - return ~0UL - hash; + /* save hash 0 as index 0 because otherwise we'll save it at + * page index end (~0UL) and it causes truncate_inode_pages_range() + * to loop forever. + */ + return ~0UL - (hash + !hash); } /** @} lite */ -- 1.8.3.1