Whamcloud - gitweb
LU-6075 osd: race for check/chance od_dirent_journal 11/13311/4
authorFan Yong <fan.yong@intel.com>
Wed, 22 Oct 2014 17:34:26 +0000 (01:34 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 19 Jan 2015 23:47:01 +0000 (23:47 +0000)
Originally, the osd_device::od_dirent_journal was a bit variable,
changing such variable can happen when other is changing other bit
that is in the same integer in parallel. Because there is no lock
protection when change the bits, one thread changing may overwrite
others. So split the osd_device::od_dirent_journal as independent
variable.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I859932290ebf3b94be4f588f8e3e9635fe204d49
Reviewed-on: http://review.whamcloud.com/13311
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Liang Zhen <liang.zhen@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h

index db71792..2f93f70 100644 (file)
@@ -5379,7 +5379,7 @@ osd_dirent_check_repair(const struct lu_env *env, struct osd_object *obj,
                  osd_dto_credits_noquota[DTO_INDEX_INSERT] + 1 + 1 + 2;
 
 again:
                  osd_dto_credits_noquota[DTO_INDEX_INSERT] + 1 + 1 + 2;
 
 again:
-       if (dev->od_dirent_journal) {
+       if (dev->od_dirent_journal != 0) {
                jh = osd_journal_start_sb(sb, LDISKFS_HT_MISC, credits);
                if (IS_ERR(jh)) {
                        rc = PTR_ERR(jh);
                jh = osd_journal_start_sb(sb, LDISKFS_HT_MISC, credits);
                if (IS_ERR(jh)) {
                        rc = PTR_ERR(jh);
@@ -5455,7 +5455,7 @@ again:
                                GOTO(out_inode, rc = 0);
                        }
 
                                GOTO(out_inode, rc = 0);
                        }
 
-                       if (!dev->od_dirent_journal) {
+                       if (dev->od_dirent_journal == 0) {
                                iput(inode);
                                brelse(bh);
                                if (hlock != NULL)
                                iput(inode);
                                brelse(bh);
                                if (hlock != NULL)
@@ -5487,7 +5487,7 @@ again:
                                GOTO(out_inode, rc = 0);
                        }
 
                                GOTO(out_inode, rc = 0);
                        }
 
-                       if (!dev->od_dirent_journal) {
+                       if (dev->od_dirent_journal == 0) {
                                iput(inode);
                                brelse(bh);
                                if (hlock != NULL)
                                iput(inode);
                                brelse(bh);
                                if (hlock != NULL)
@@ -5526,7 +5526,7 @@ again:
                        GOTO(out_inode, rc = 0);
                }
 
                        GOTO(out_inode, rc = 0);
                }
 
-               if (!dev->od_dirent_journal) {
+               if (dev->od_dirent_journal == 0) {
                        iput(inode);
                        brelse(bh);
                        if (hlock != NULL)
                        iput(inode);
                        brelse(bh);
                        if (hlock != NULL)
@@ -5579,7 +5579,7 @@ out_journal:
        if (hlock != NULL) {
                ldiskfs_htree_unlock(hlock);
        } else {
        if (hlock != NULL) {
                ldiskfs_htree_unlock(hlock);
        } else {
-               if (dev->od_dirent_journal)
+               if (dev->od_dirent_journal != 0)
                        up_write(&obj->oo_ext_idx_sem);
                else
                        up_read(&obj->oo_ext_idx_sem);
                        up_write(&obj->oo_ext_idx_sem);
                else
                        up_read(&obj->oo_ext_idx_sem);
index f4b03f8..f6a04a3 100644 (file)
@@ -234,19 +234,19 @@ struct osd_device {
        unsigned int              od_fl_capa:1,
                                  od_maybe_new:1,
                                  od_noscrub:1,
        unsigned int              od_fl_capa:1,
                                  od_maybe_new:1,
                                  od_noscrub:1,
-                                 od_dirent_journal:1,
                                  od_igif_inoi:1,
                                  od_check_ff:1,
                                  od_is_ost:1,
                                  od_lma_self_repair:1;
 
                                  od_igif_inoi:1,
                                  od_check_ff:1,
                                  od_is_ost:1,
                                  od_lma_self_repair:1;
 
-        unsigned long             od_capa_timeout;
-        __u32                     od_capa_alg;
-        struct lustre_capa_key   *od_capa_keys;
+       unsigned long             od_capa_timeout;
+       __u32                     od_capa_alg;
+       __u32                     od_dirent_journal;
+       struct lustre_capa_key   *od_capa_keys;
        struct hlist_head        *od_capa_hash;
 
        struct proc_dir_entry    *od_proc_entry;
        struct hlist_head        *od_capa_hash;
 
        struct proc_dir_entry    *od_proc_entry;
-        struct lprocfs_stats     *od_stats;
+       struct lprocfs_stats     *od_stats;
 
        spinlock_t                od_osfs_lock;
 
 
        spinlock_t                od_osfs_lock;