dm bufio: use list_move

Use list_move() instead of list_del() + list_add().

spatch with a semantic match was used to find this.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
dm persistent data: convert to use le32_add_cpu

Convert cpu_to_le32(le32_to_cpu(E1) + E2) to use le32_add_cpu().

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
dm thin: support discard with non power of two block size

Support discards when the pool's block size is not a power of 2.
The block layer assumes discard_granularity is a power of 2 (in
blkdev_issue_discard), so we set this to the largest power of 2 that is
a divides into the number of sectors in each block, but never less than
DATA_DEV_BLOCK_SIZE_MIN_SECTORS.

This patch eliminates the "Discard support must be disabled when the
block size is not a power of 2" constraint that was imposed in commit
55f2b8b ("dm thin: support for non power of 2 pool blocksize").  That
commit was incomplete: using a block size that is not a power of 2
shouldn't mean disabling discard support on the device completely.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
dm bio prison: sync with what agk is sending for v3.7

Changes introduced by these commits:

Author: Mike Snitzer <snitzer@redhat.com>
Date:   Fri Oct 12 14:27:37 2012 -0400

    dm thin: prepare to separate bio_prison code

    The bio prison code will be useful for a new DM targets.

    Prepare to move this code into a separate module, adding a dm prefix
    to structures and functions that will be exported.

    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    Signed-off-by: Joe Thornber <ejt@redhat.com>
    Signed-off-by: Alasdair G Kergon <agk@redhat.com>

Author: Mike Snitzer <snitzer@redhat.com>
Date:   Fri Oct 12 14:27:37 2012 -0400

    dm thin: move bio_prison code to separate module

    The bio prison code will be useful to other future DM targets so
    move it to a separate module.

    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    Signed-off-by: Joe Thornber <ejt@redhat.com>
    Signed-off-by: Alasdair G Kergon <agk@redhat.com>
dm block manager: reinstate context for which block failed a validator check

this was eliminated when the block manager was converted to use dm-bufio
-- but it shouldn't have been.
dm cache: rename cache_c structure to cache

Also rename 'c' variables to 'cache'.

Paves way for 2 classes of cache objects should we want to go that route
in the future (cache and cache_c, ala pool and pool_c).  Even after such
a split the bulk of the code will be dealing with 'struct cache', so
that is the reason for the pre-emptive switch to 'struct cache' and
s/c/cache/.
dm cache: eliminate offset_mask from cache structure
dm cache: set discard_zeroes_data_unsupported
dm cache: support blocksize that is not a power of 2

(IIUC the cache policies do not assume cache_size is a power of 2)
dm cache: split cache_ctr into 3 pieces

1: cache_ctr get references on specified devices and sets target
   parameters
2: cache_create takes care of creating the cache metadata, workqueue,
   and all other infrastructure
3: create_cache_policy creates the cache policy

Motivation is to allow for each piece to be extended in a seamless
manner as we look to add more capabilities to dm-cache in the future.

No functional change.
dm cache: eliminate duplicate code with process_deferred_flush_bios
dm cache metadata: add dm_cache_metadata_{read,write}_policy_name
dm cache: small error code return fix for cache_ctr
dm cache: warn if metadata device is larger than 16GB

Until the limitation is removed we should warn the user that anything
over 16GB will go unused.
dm cache: remove BLOCK_SIZE_MIN

forgot to remove it when DATA_DEV_BLOCK_SIZE_MIN_SECTORS was introduced