dm snapshot: report merge failure in status
[safe/jmp/linux-2.6] / drivers / md / dm-exception-store.h
index 9274969..e8dfa06 100644 (file)
@@ -75,6 +75,23 @@ struct dm_exception_store_type {
                                  void *callback_context);
 
        /*
+        * Returns 0 if the exception store is empty.
+        *
+        * If there are exceptions still to be merged, sets
+        * *last_old_chunk and *last_new_chunk to the most recent
+        * still-to-be-merged chunk and returns the number of
+        * consecutive previous ones.
+        */
+       int (*prepare_merge) (struct dm_exception_store *store,
+                             chunk_t *last_old_chunk, chunk_t *last_new_chunk);
+
+       /*
+        * Clear the last n exceptions.
+        * nr_merged must be <= the value returned by prepare_merge.
+        */
+       int (*commit_merge) (struct dm_exception_store *store, int nr_merged);
+
+       /*
         * The snapshot is invalid, note this in the metadata.
         */
        void (*drop_snapshot) (struct dm_exception_store *store);
@@ -86,19 +103,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;
@@ -109,6 +126,11 @@ struct dm_exception_store {
 };
 
 /*
+ * Obtain the cow device used by a given snapshot.
+ */
+struct dm_dev *dm_snap_cow(struct dm_snapshot *snap);
+
+/*
  * Funtions to manipulate consecutive chunks
  */
 #  if defined(CONFIG_LBDAF) || (BITS_PER_LONG == 64)
@@ -132,6 +154,13 @@ static inline void dm_consecutive_chunk_count_inc(struct dm_exception *e)
        BUG_ON(!dm_consecutive_chunk_count(e));
 }
 
+static inline void dm_consecutive_chunk_count_dec(struct dm_exception *e)
+{
+       BUG_ON(!dm_consecutive_chunk_count(e));
+
+       e->new_chunk -= (1ULL << DM_CHUNK_NUMBER_BITS);
+}
+
 #  else
 #    define DM_CHUNK_CONSECUTIVE_BITS 0
 
@@ -149,6 +178,10 @@ static inline void dm_consecutive_chunk_count_inc(struct dm_exception *e)
 {
 }
 
+static inline void dm_consecutive_chunk_count_dec(struct dm_exception *e)
+{
+}
+
 #  endif
 
 /*
@@ -173,6 +206,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);