Whamcloud - gitweb
LU-7315 osd-ldiskfs: handle pdo lock properly 24/16924/6
authorFan Yong <fan.yong@intel.com>
Sat, 3 Oct 2015 01:45:32 +0000 (09:45 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 4 Dec 2015 17:58:03 +0000 (17:58 +0000)
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 <fan.yong@intel.com>
Change-Id: I9db9dc758a2976849c299f76e06723e796da235d
Reviewed-on: http://review.whamcloud.com/16924
Tested-by: Jenkins
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Liang Zhen <liang.zhen@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Yang Sheng <yang.sheng@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdirop.patch
ldiskfs/kernel_patches/patches/rhel7/ext4-pdirop.patch
ldiskfs/kernel_patches/patches/sles12/ext4-pdirop.patch
lustre/osd-ldiskfs/osd_handler.c

index 32adfc1..0bbed17 100644 (file)
@@ -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) {
index a59671a..31bb3e3 100644 (file)
@@ -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) {
index 2ff2e23..6ae7e71 100644 (file)
@@ -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) {
index facf412..bc04181 100644 (file)
@@ -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;
                }