};
static int write_metadata(struct snapshot_c *lc);
-
+static int write_header(struct snapshot_c *lc);
/*
* Size of the hash table for origin volumes. If we make this
* the size of the minors list then it should be nearly perfect
*/
static struct list_head *snapshot_origins = NULL;
static struct rw_semaphore origin_hash_lock;
-
+static kmem_cache_t *exception_cachep;
+static kmem_cache_t *inflight_cachep;
/*
* Hash functions
*/
struct list_head *l = &sc->hash_table[exception_hash(org, sc)];
struct exception *new_ex;
- new_ex = kmalloc(sizeof(struct exception), GFP_KERNEL);
+ new_ex = kmem_cache_alloc(exception_cachep, GFP_NOIO);
if (!new_ex) return NULL;
new_ex->rsector_org = org;
bh = iex->bh;
iex->bh = NULL;
up_write(&iex->snap->origin->lock);
- kfree(iex);
+ kmem_cache_free(inflight_cachep, iex);
while (bh) {
struct buffer_head *nextbh = bh->b_reqnext;
if (iex->snap->persistent)
write_header(iex->snap);
list_del(&iex->list);
- kfree(iex);
+ kmem_cache_free(inflight_cachep, iex);
}
}
struct list_head *l = &sc->inflight_hash_table[inflight_exception_hash(org, sc)];
struct inflight_exception *new_ex;
- new_ex = kmalloc(sizeof(struct inflight_exception), GFP_KERNEL);
+ new_ex = kmem_cache_alloc(inflight_cachep, GFP_NOIO);
if (!new_ex) return NULL;
new_ex->rsector_org = org;
struct exception *ex;
ex = list_entry(entry, struct exception, list);
list_del(&ex->list);
- kfree(ex);
+ kmem_cache_free(exception_cachep, ex);
}
}
}
DMERR("Error writing COW block");
return -1;
}
-
return 0;
}
init_rwsem(&origin_hash_lock);
}
}
+ exception_cachep = kmem_cache_create("dm-snapshot-ex",
+ sizeof(struct exception),
+ __alignof__(struct exception),
+ 0, NULL, NULL);
+ if (!exception_cachep) {
+ kfree(snapshot_origins);
+ return -1;
+ }
+
+
+ inflight_cachep = kmem_cache_create("dm-snapshot-in",
+ sizeof(struct inflight_exception),
+ __alignof__(struct inflight_exception),
+ 0, NULL, NULL);
+ if (!inflight_cachep) {
+ kfree(snapshot_origins);
+ kmem_cache_destroy(exception_cachep);
+ return -1;
+ }
+
return r;
}
if (snapshot_origins)
kfree(snapshot_origins);
+
+ kmem_cache_destroy(inflight_cachep);
+ kmem_cache_destroy(exception_cachep);
}
/*