dm thin: ensure user takes action to validate data and metadata consistency
authorMike Snitzer <snitzer@redhat.com>
Fri, 14 Feb 2014 16:58:41 +0000 (11:58 -0500)
committerMike Snitzer <snitzer@redhat.com>
Wed, 5 Mar 2014 20:25:35 +0000 (15:25 -0500)
commit07f2b6e0382ec4c59887d5954683f1a0b265574e
tree4863593c0fb83c54cb2865f4f0f6a44969aa28a6
parentcdc2b4158405f1975f9d5205096f08430eda1c0e
dm thin: ensure user takes action to validate data and metadata consistency

If a thin metadata operation fails the current transaction will abort,
whereby causing potential for IO layers up the stack (e.g. filesystems)
to have data loss.  As such, set THIN_METADATA_NEEDS_CHECK_FLAG in the
thin metadata's superblock which:
1) requires the user verify the thin metadata is consistent (e.g. use
   thin_check, etc)
2) suggests the user verify the thin data is consistent (e.g. use fsck)

The only way to clear the superblock's THIN_METADATA_NEEDS_CHECK_FLAG is
to run thin_repair.

On metadata operation failure: abort current metadata transaction, set
pool in read-only mode, and now set the needs_check flag.

As part of this change, constraints are introduced or relaxed:
* don't allow a pool to transition to write mode if needs_check is set
* don't allow data or metadata space to be resized if needs_check is set
* if a thin pool's metadata space is exhausted: the kernel will now
  force the user to take the pool offline for repair before the kernel
  will allow the metadata space to be extended.

Also, update Documentation to include information about when the thin
provisioning target commits metadata, how it handles metadata failures
and running out of space.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Joe Thornber <ejt@redhat.com>
Documentation/device-mapper/cache.txt
Documentation/device-mapper/thin-provisioning.txt
drivers/md/dm-thin-metadata.c
drivers/md/dm-thin-metadata.h
drivers/md/dm-thin.c