]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/md/dm-raid1.c
[PATCH] md: fix problem with raid6 intent bitmap
[linux-2.6-omap-h63xx.git] / drivers / md / dm-raid1.c
index 8632825137538bbb050eadf6cf0c13b101cdc05d..6b0fc16709295b7732a50e0ca97b5d1d1e009662 100644 (file)
@@ -122,7 +122,7 @@ static inline sector_t region_to_sector(struct region_hash *rh, region_t region)
 /* FIXME move this */
 static void queue_bio(struct mirror_set *ms, struct bio *bio, int rw);
 
-static void *region_alloc(unsigned int __nocast gfp_mask, void *pool_data)
+static void *region_alloc(gfp_t gfp_mask, void *pool_data)
 {
        return kmalloc(sizeof(struct region), gfp_mask);
 }
@@ -376,16 +376,18 @@ static void rh_inc(struct region_hash *rh, region_t region)
        read_lock(&rh->hash_lock);
        reg = __rh_find(rh, region);
 
+       spin_lock_irq(&rh->region_lock);
        atomic_inc(&reg->pending);
 
-       spin_lock_irq(&rh->region_lock);
        if (reg->state == RH_CLEAN) {
-               rh->log->type->mark_region(rh->log, reg->key);
-
                reg->state = RH_DIRTY;
                list_del_init(&reg->list);      /* take off the clean list */
-       }
-       spin_unlock_irq(&rh->region_lock);
+               spin_unlock_irq(&rh->region_lock);
+
+               rh->log->type->mark_region(rh->log, reg->key);
+       } else
+               spin_unlock_irq(&rh->region_lock);
+
 
        read_unlock(&rh->hash_lock);
 }
@@ -408,21 +410,17 @@ static void rh_dec(struct region_hash *rh, region_t region)
        reg = __rh_lookup(rh, region);
        read_unlock(&rh->hash_lock);
 
+       spin_lock_irqsave(&rh->region_lock, flags);
        if (atomic_dec_and_test(&reg->pending)) {
-               spin_lock_irqsave(&rh->region_lock, flags);
-               if (atomic_read(&reg->pending)) { /* check race */
-                       spin_unlock_irqrestore(&rh->region_lock, flags);
-                       return;
-               }
                if (reg->state == RH_RECOVERING) {
                        list_add_tail(&reg->list, &rh->quiesced_regions);
                } else {
                        reg->state = RH_CLEAN;
                        list_add(&reg->list, &rh->clean_regions);
                }
-               spin_unlock_irqrestore(&rh->region_lock, flags);
                should_wake = 1;
        }
+       spin_unlock_irqrestore(&rh->region_lock, flags);
 
        if (should_wake)
                wake();