linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / md / dm-raid1.c
index 2cab46e..0242cc3 100644 (file)
@@ -152,6 +152,16 @@ 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(gfp_t gfp_mask, void *pool_data)
+{
+       return kmalloc(sizeof(struct region), gfp_mask);
+}
+
+static void region_free(void *element, void *pool_data)
+{
+       kfree(element);
+}
+
 #define MIN_REGIONS 64
 #define MAX_RECOVERY 1
 static int rh_init(struct region_hash *rh, struct mirror_set *ms,
@@ -193,8 +203,8 @@ static int rh_init(struct region_hash *rh, struct mirror_set *ms,
        INIT_LIST_HEAD(&rh->quiesced_regions);
        INIT_LIST_HEAD(&rh->recovered_regions);
 
-       rh->region_pool = mempool_create_kmalloc_pool(MIN_REGIONS,
-                                                     sizeof(struct region));
+       rh->region_pool = mempool_create(MIN_REGIONS, region_alloc,
+                                        region_free, NULL);
        if (!rh->region_pool) {
                vfree(rh->buckets);
                rh->buckets = NULL;
@@ -434,21 +444,9 @@ static void rh_dec(struct region_hash *rh, region_t region)
 
        spin_lock_irqsave(&rh->region_lock, flags);
        if (atomic_dec_and_test(&reg->pending)) {
-               /*
-                * There is no pending I/O for this region.
-                * We can move the region to corresponding list for next action.
-                * At this point, the region is not yet connected to any list.
-                *
-                * If the state is RH_NOSYNC, the region should be kept off
-                * from clean list.
-                * The hash entry for RH_NOSYNC will remain in memory
-                * until the region is recovered or the map is reloaded.
-                */
-
-               /* do nothing for RH_NOSYNC */
                if (reg->state == RH_RECOVERING) {
                        list_add_tail(&reg->list, &rh->quiesced_regions);
-               } else if (reg->state == RH_DIRTY) {
+               } else {
                        reg->state = RH_CLEAN;
                        list_add(&reg->list, &rh->clean_regions);
                }
@@ -937,9 +935,9 @@ static inline int _check_region_size(struct dm_target *ti, uint32_t size)
 static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
                      unsigned int mirror, char **argv)
 {
-       unsigned long long offset;
+       sector_t offset;
 
-       if (sscanf(argv[1], "%llu", &offset) != 1) {
+       if (sscanf(argv[1], SECTOR_FORMAT, &offset) != 1) {
                ti->error = "dm-mirror: Invalid offset";
                return -EINVAL;
        }
@@ -1206,17 +1204,16 @@ static int mirror_status(struct dm_target *ti, status_type_t type,
                for (m = 0; m < ms->nr_mirrors; m++)
                        DMEMIT("%s ", ms->mirror[m].dev->name);
 
-               DMEMIT("%llu/%llu",
-                       (unsigned long long)ms->rh.log->type->
-                               get_sync_count(ms->rh.log),
-                       (unsigned long long)ms->nr_regions);
+               DMEMIT(SECTOR_FORMAT "/" SECTOR_FORMAT,
+                      ms->rh.log->type->get_sync_count(ms->rh.log),
+                      ms->nr_regions);
                break;
 
        case STATUSTYPE_TABLE:
                DMEMIT("%d ", ms->nr_mirrors);
                for (m = 0; m < ms->nr_mirrors; m++)
-                       DMEMIT("%s %llu ", ms->mirror[m].dev->name,
-                               (unsigned long long)ms->mirror[m].offset);
+                       DMEMIT("%s " SECTOR_FORMAT " ",
+                              ms->mirror[m].dev->name, ms->mirror[m].offset);
        }
 
        return 0;