]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/md/dm-exception-store.h
dm snapshot: move cow ref from exception store to snap core
[net-next-2.6.git] / drivers / md / dm-exception-store.h
index 8a223a48802c0c867f79818045399937e650bf5e..bb8874653de188022a6685311dcd6fe348ffb962 100644 (file)
@@ -26,7 +26,7 @@ typedef sector_t chunk_t;
  * of chunks that follow contiguously.  Remaining bits hold the number of the
  * chunk within the device.
  */
-struct dm_snap_exception {
+struct dm_exception {
        struct list_head hash_list;
 
        chunk_t old_chunk;
@@ -64,13 +64,13 @@ struct dm_exception_store_type {
         * Find somewhere to store the next exception.
         */
        int (*prepare_exception) (struct dm_exception_store *store,
-                                 struct dm_snap_exception *e);
+                                 struct dm_exception *e);
 
        /*
         * Update the metadata with this exception.
         */
        void (*commit_exception) (struct dm_exception_store *store,
-                                 struct dm_snap_exception *e,
+                                 struct dm_exception *e,
                                  void (*callback) (void *, int success),
                                  void *callback_context);
 
@@ -86,19 +86,19 @@ struct dm_exception_store_type {
        /*
         * Return how full the snapshot is.
         */
-       void (*fraction_full) (struct dm_exception_store *store,
-                              sector_t *numerator,
-                              sector_t *denominator);
+       void (*usage) (struct dm_exception_store *store,
+                      sector_t *total_sectors, sector_t *sectors_allocated,
+                      sector_t *metadata_sectors);
 
        /* For internal device-mapper use only. */
        struct list_head list;
 };
 
+struct dm_snapshot;
+
 struct dm_exception_store {
        struct dm_exception_store_type *type;
-       struct dm_target *ti;
-
-       struct dm_dev *cow;
+       struct dm_snapshot *snap;
 
        /* Size of data blocks saved - must be a power of 2 */
        unsigned chunk_size;
@@ -108,6 +108,11 @@ struct dm_exception_store {
        void *context;
 };
 
+/*
+ * Obtain the cow device used by a given snapshot.
+ */
+struct dm_dev *dm_snap_cow(struct dm_snapshot *snap);
+
 /*
  * Funtions to manipulate consecutive chunks
  */
@@ -120,12 +125,12 @@ static inline chunk_t dm_chunk_number(chunk_t chunk)
        return chunk & (chunk_t)((1ULL << DM_CHUNK_NUMBER_BITS) - 1ULL);
 }
 
-static inline unsigned dm_consecutive_chunk_count(struct dm_snap_exception *e)
+static inline unsigned dm_consecutive_chunk_count(struct dm_exception *e)
 {
        return e->new_chunk >> DM_CHUNK_NUMBER_BITS;
 }
 
-static inline void dm_consecutive_chunk_count_inc(struct dm_snap_exception *e)
+static inline void dm_consecutive_chunk_count_inc(struct dm_exception *e)
 {
        e->new_chunk += (1ULL << DM_CHUNK_NUMBER_BITS);
 
@@ -140,12 +145,12 @@ static inline chunk_t dm_chunk_number(chunk_t chunk)
        return chunk;
 }
 
-static inline unsigned dm_consecutive_chunk_count(struct dm_snap_exception *e)
+static inline unsigned dm_consecutive_chunk_count(struct dm_exception *e)
 {
        return 0;
 }
 
-static inline void dm_consecutive_chunk_count_inc(struct dm_snap_exception *e)
+static inline void dm_consecutive_chunk_count_inc(struct dm_exception *e)
 {
 }
 
@@ -162,7 +167,7 @@ static inline sector_t get_dev_size(struct block_device *bdev)
 static inline chunk_t sector_to_chunk(struct dm_exception_store *store,
                                      sector_t sector)
 {
-       return (sector & ~store->chunk_mask) >> store->chunk_shift;
+       return sector >> store->chunk_shift;
 }
 
 int dm_exception_store_type_register(struct dm_exception_store_type *type);
@@ -173,6 +178,7 @@ int dm_exception_store_set_chunk_size(struct dm_exception_store *store,
                                      char **error);
 
 int dm_exception_store_create(struct dm_target *ti, int argc, char **argv,
+                             struct dm_snapshot *snap,
                              unsigned *args_used,
                              struct dm_exception_store **store);
 void dm_exception_store_destroy(struct dm_exception_store *store);