From 343364d0f06c34f403eb009de498455b5ebe14be Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Sat, 3 Oct 2015 09:45:32 +0800 Subject: [PATCH] LU-7315 osd-ldiskfs: handle pdo lock properly Inside the osd_dirent_check_repair(), if the logic comes to "goto again", it only unlock the "hlock" but without seting the variable @hlock as NULL. Althouth it will not cause any logic failure, it may make the readers to be confused. This patch will set "hlock = NULL;" explicitly to avoid trouble. On the other hand, inside ldiskfs, the pdo lock users need to check whether the lock handler is NULL or not properly. Signed-off-by: Fan Yong Change-Id: I9db9dc758a2976849c299f76e06723e796da235d Reviewed-on: http://review.whamcloud.com/16924 Tested-by: Jenkins Reviewed-by: Dmitry Eremin Tested-by: Maloo Reviewed-by: Liang Zhen Reviewed-by: Alex Zhuravlev Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- .../patches/rhel6.3/ext4-pdirop.patch | 2 +- .../kernel_patches/patches/rhel7/ext4-pdirop.patch | 2 +- .../patches/sles12/ext4-pdirop.patch | 2 +- lustre/osd-ldiskfs/osd_handler.c | 24 ++++++++++++++-------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdirop.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdirop.patch index 32adfc1..0bbed17 100644 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdirop.patch +++ b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdirop.patch @@ -1400,7 +1400,7 @@ Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/namei.c + struct dx_entry *entries, + struct dx_entry *at, u32 hash) +{ -+ if (!(ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_EXACT)) { ++ if (!(lck && ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_EXACT)) { + return DX_HASH_COL_IGNORE; /* don't care about collision */ + + } else if (at == entries + dx_get_count(entries) - 1) { diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-pdirop.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-pdirop.patch index a59671a..31bb3e3 100644 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-pdirop.patch +++ b/ldiskfs/kernel_patches/patches/rhel7/ext4-pdirop.patch @@ -1490,7 +1490,7 @@ Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c + struct dx_entry *entries, + struct dx_entry *at, u32 hash) +{ -+ if (!(ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_EXACT)) { ++ if (!(lck && ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_EXACT)) { + return DX_HASH_COL_IGNORE; /* don't care about collision */ + + } else if (at == entries + dx_get_count(entries) - 1) { diff --git a/ldiskfs/kernel_patches/patches/sles12/ext4-pdirop.patch b/ldiskfs/kernel_patches/patches/sles12/ext4-pdirop.patch index 2ff2e23..6ae7e71 100644 --- a/ldiskfs/kernel_patches/patches/sles12/ext4-pdirop.patch +++ b/ldiskfs/kernel_patches/patches/sles12/ext4-pdirop.patch @@ -1490,7 +1490,7 @@ Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c + struct dx_entry *entries, + struct dx_entry *at, u32 hash) +{ -+ if (!(ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_EXACT)) { ++ if (!(lck && ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_EXACT)) { + return DX_HASH_COL_IGNORE; /* don't care about collision */ + + } else if (at == entries + dx_get_count(entries) - 1) { diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index facf412..bc04181 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -5445,11 +5445,13 @@ again: if (jh == NULL) { brelse(bh); - if (hlock != NULL) + dev->od_dirent_journal = 1; + if (hlock != NULL) { ldiskfs_htree_unlock(hlock); - else + hlock = NULL; + } else { up_read(&obj->oo_ext_idx_sem); - dev->od_dirent_journal = 1; + } goto again; } @@ -5479,11 +5481,13 @@ again: if (jh == NULL) { brelse(bh); - if (hlock != NULL) + dev->od_dirent_journal = 1; + if (hlock != NULL) { ldiskfs_htree_unlock(hlock); - else + hlock = NULL; + } else { up_read(&obj->oo_ext_idx_sem); - dev->od_dirent_journal = 1; + } goto again; } @@ -5519,11 +5523,13 @@ again: if (jh == NULL) { brelse(bh); - if (hlock != NULL) + dev->od_dirent_journal = 1; + if (hlock != NULL) { ldiskfs_htree_unlock(hlock); - else + hlock = NULL; + } else { up_read(&obj->oo_ext_idx_sem); - dev->od_dirent_journal = 1; + } goto again; } -- 1.8.3.1