]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
db379f9b1e83a8dd5038d8b4efaa9e291457f37b
[thirdparty/kernel/stable-queue.git] /
1 From 2c43fd26e46734430122b8d2ad3024bb532df3ef Mon Sep 17 00:00:00 2001
2 From: Joe Thornber <ejt@redhat.com>
3 Date: Thu, 11 Dec 2014 11:12:19 +0000
4 Subject: dm thin: fix missing out-of-data-space to write mode transition if blocks are released
5
6 From: Joe Thornber <ejt@redhat.com>
7
8 commit 2c43fd26e46734430122b8d2ad3024bb532df3ef upstream.
9
10 Discard bios and thin device deletion have the potential to release data
11 blocks. If the thin-pool is in out-of-data-space mode, and blocks were
12 released, transition the thin-pool back to full write mode.
13
14 The correct time to do this is just after the thin-pool metadata commit.
15 It cannot be done before the commit because the space maps will not
16 allow immediate reuse of the data blocks in case there's a rollback
17 following power failure.
18
19 Signed-off-by: Joe Thornber <ejt@redhat.com>
20 Signed-off-by: Mike Snitzer <snitzer@redhat.com>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
24 drivers/md/dm-thin.c | 22 ++++++++++++++++++++--
25 1 file changed, 20 insertions(+), 2 deletions(-)
26
27 --- a/drivers/md/dm-thin.c
28 +++ b/drivers/md/dm-thin.c
29 @@ -990,6 +990,24 @@ static void schedule_external_copy(struc
30 schedule_zero(tc, virt_block, data_dest, cell, bio);
31 }
32
33 +static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
34 +
35 +static void check_for_space(struct pool *pool)
36 +{
37 + int r;
38 + dm_block_t nr_free;
39 +
40 + if (get_pool_mode(pool) != PM_OUT_OF_DATA_SPACE)
41 + return;
42 +
43 + r = dm_pool_get_free_block_count(pool->pmd, &nr_free);
44 + if (r)
45 + return;
46 +
47 + if (nr_free)
48 + set_pool_mode(pool, PM_WRITE);
49 +}
50 +
51 /*
52 * A non-zero return indicates read_only or fail_io mode.
53 * Many callers don't care about the return value.
54 @@ -1004,6 +1022,8 @@ static int commit(struct pool *pool)
55 r = dm_pool_commit_metadata(pool->pmd);
56 if (r)
57 metadata_operation_failed(pool, "dm_pool_commit_metadata", r);
58 + else
59 + check_for_space(pool);
60
61 return r;
62 }
63 @@ -1022,8 +1042,6 @@ static void check_low_water_mark(struct
64 }
65 }
66
67 -static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
68 -
69 static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
70 {
71 int r;