dm thin: return error from alloc_data_block if pool is not in write mode
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 5f1b11e..1988019 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -923,6 +923,9 @@
if (pool->no_free_space)
return -ENOSPC;
+ if (get_pool_mode(pool) != PM_WRITE)
+ return -EINVAL;
+
r = dm_pool_get_free_block_count(pool->pmd, &free_blocks);
if (r)
return r;