DM Snapshot: move exception code to new file
Subsystems (2)
PATCH 1/1 DM Snapshot: move exception code to new file
Patch name: dm-snap-move-exception-code-to-new-file.patch
Extract exception table/cache code from dm-snap.c so that it can be used elsewhere. I've created the new files, dm-exception.[ch]. I chose against including this code in this dm-exception-store.[ch] files.
Signed-off-by Jonathan Brassow <[email protected]>
drivers/md/dm-exception-store.h +1 -63
@@ -12,26 +12,7 @@#include <linux/blkdev.h> #include <linux/device-mapper.h> - -/* -* The snapshot code deals with largish chunks of the disk at a -* time. Typically 32k - 512k. -*/ -typedef sector_t chunk_t ; - -/* -* An exception is used where an old chunk of data has been -* replaced by a new one. -* If chunk_t is 64 bits in size, the top 8 bits of new_chunk hold the number -* of chunks that follow contiguously. Remaining bits hold the number of the -* chunk within the device. -*/ -struct dm_exception { -struct list_head hash_list; - -chunk_t old_chunk; -chunk_t new_chunk; -}; +#include "dm-exception.h" /* * Abstraction to handle the meta/layout of exception stores (the
@@ -109,49 +90,6 @@ struct dm_exception_store { };/* -* Funtions to manipulate consecutive chunks -*/ -# if defined(CONFIG_LBD ) || (BITS_PER_LONG ==64 ) -# define DM_CHUNK_CONSECUTIVE_BITS 8 -# define DM_CHUNK_NUMBER_BITS 56 - -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_exception *e) -{ -return e->new_chunk >>DM_CHUNK_NUMBER_BITS ; -} - -static inline void dm_consecutive_chunk_count_inc (struct dm_exception *e) -{ - e->new_chunk += (1ULL <<DM_CHUNK_NUMBER_BITS ); - -BUG_ON (!dm_consecutive_chunk_count (e)); -} - -# else -# define DM_CHUNK_CONSECUTIVE_BITS 0 - -static inline chunk_t dm_chunk_number (chunk_t chunk) -{ -return chunk; -} - -static inline unsigned dm_consecutive_chunk_count (struct dm_exception *e) -{ -return 0 ; -} - -static inline void dm_consecutive_chunk_count_inc (struct dm_exception *e) -{ -} - -# endif - -/* * Return the number of sectors in the device. */ static inline sector_t get_dev_size (struct block_device *bdev)
drivers/md/dm-exception.c new file +163 -0
163 lines not on this page · raw message
drivers/md/dm-exception.h new file +104 -0
104 lines not on this page · raw message
drivers/md/dm-snap.c +0 -168
186 lines not on this page · raw message
drivers/md/Makefile +2 -2
@@ -5,8 +5,8 @@ dm-mod-objs := dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \ dm-ioctl.o dm-io.o dm-kcopyd.o dm-sysfs.o dm-multipath-objs := dm-path-selector.o dm-mpath.o -dm-snapshot-objs := dm-snap.o dm-exception-store.o dm-snap-transient.o \ - dm-snap-persistent.o +dm-snapshot-objs := dm-snap.o dm-exception.o dm-exception-store.o \ + dm-snap-persistent.o dm-snap-transient.o dm-mirror-objs := dm-raid1.o md-mod-objs := md.o bitmap.o raid456-objs := raid5.o raid6algos.o raid6recov.o raid6tables.o \