Commit 2a7eaea02b99b6e267b1e89c79acc6e9a51cee3b

Authored by Joe Thornber
Committed by Mike Snitzer
1 parent 766a78882d

dm thin: don't allow messages to be sent to a pool target in READ_ONLY or FAIL mode

You can't modify the metadata in these modes.  It's better to fail these
messages immediately than let the block-manager deny write locks on
metadata blocks.  Otherwise these failed metadata changes will trigger
'needs_check' to get set in the metadata superblock -- requiring repair
using the thin_check utility.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org

Showing 1 changed file with 6 additions and 0 deletions Side-by-side Diff

drivers/md/dm-thin.c
... ... @@ -3385,6 +3385,12 @@
3385 3385 struct pool_c *pt = ti->private;
3386 3386 struct pool *pool = pt->pool;
3387 3387  
  3388 + if (get_pool_mode(pool) >= PM_READ_ONLY) {
  3389 + DMERR("%s: unable to service pool target messages in READ_ONLY or FAIL mode",
  3390 + dm_device_name(pool->pool_md));
  3391 + return -EINVAL;
  3392 + }
  3393 +
3388 3394 if (!strcasecmp(argv[0], "create_thin"))
3389 3395 r = process_create_thin_mesg(argc, argv, pool);
3390 3396