Patch "dm cache: fix race when issuing a POLICY_REPLACE operation" has been added to the 4.1-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
dm cache: fix race when issuing a POLICY_REPLACE operation
to the 4.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
dm-cache-fix-race-when-issuing-a-policy_replace-operation.patch
and it can be found in the queue-4.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
fb4100ae7f312c3d614b37621c2b17b3b7cf65f8Mon Sep 17 00:00:00 2001
From: Joe Thornber <[email protected]>
Date: Wed, 20 May 2015 10:30:32 +0100
Subject: dm cache: fix race when issuing a POLICY_REPLACE operation
From: Joe Thornber <[email protected]>
commit fb4100ae7f312c3d614b37621c2b17b3b7cf65f8 upstream.
There is a race between a policy deciding to replace a cache entry, the core target writing back any dirty data from this block, and other IO threads doing IO to the same block.
This sort of problem is avoided most of the time by the core target grabbing a bio prison cell before making the request to the policy. But for a demotion the core target doesn't know which block will be demoted, so can't do this in advance.
Fix this demotion race by introducing a callback to the policy interface that allows the policy to grab the cell on behalf of the core target.
--- drivers/md/dm-cache-policy-cleaner.c | 3 + drivers/md/dm-cache-policy-internal.h | 5 +- drivers/md/dm-cache-policy-mq.c | 41 ++++++++++++++++-------- drivers/md/dm-cache-policy.h | 15 ++++++++ drivers/md/dm-cache-target.c | 58 ++++++++++++++++++++++------------ 5 files changed, 85 insertions(+), 37 deletions(-)
drivers/md/dm-cache-policy-cleaner.c +2 -1
@@ -171,7 +171,8 @@ static void remove_cache_hash_entry(stru/* Public interface (see dm-cache-policy.h */ static int wb_map (struct dm_cache_policy *pe,dm_oblock_t oblock,bool can_block,bool can_migrate,bool discarded_oblock, -struct bio *bio,struct policy_result *result) +struct bio *bio,struct policy_locker *locker, +struct policy_result *result) {struct policy *p =to_policy (pe);struct wb_cache_entry *e;
drivers/md/dm-cache-policy-internal.h +3 -2
@@ -16,9 +16,10 @@*/ static inline int policy_map (struct dm_cache_policy *p,dm_oblock_t oblock,bool can_block,bool can_migrate,bool discarded_oblock, -struct bio *bio,struct policy_result *result) +struct bio *bio,struct policy_locker *locker, +struct policy_result *result) { -return p->map (p, oblock, can_block, can_migrate, discarded_oblock, bio, result); +return p->map (p, oblock, can_block, can_migrate, discarded_oblock, bio, locker, result); }static inline int policy_lookup (struct dm_cache_policy *p,dm_oblock_t oblock,dm_cblock_t *cblock)
drivers/md/dm-cache-policy-mq.c +28 -13
130 lines not on this page · raw message
drivers/md/dm-cache-policy.h +14 -1
@@ -70,6 +70,18 @@ enum policy_operation { };/* +* When issuing a POLICY_REPLACE the policy needs to make a callback to +* lock the block being demoted. This doesn't need to occur during a +* writeback operation since the block remains in the cache. +*/ +struct policy_locker ; +typedef int (*policy_lock_fn )(struct policy_locker *l,dm_oblock_t oblock); + +struct policy_locker { +policy_lock_fn fn; +}; + +/* * This is the instruction passed back to the core target. */ struct policy_result {
@@ -122,7 +134,8 @@ struct dm_cache_policy {*/ int (*map)(struct dm_cache_policy *p,dm_oblock_t oblock,bool can_block,bool can_migrate,bool discarded_oblock, -struct bio *bio,struct policy_result *result); +struct bio *bio,struct policy_locker *locker, +struct policy_result *result);/* * Sometimes we want to see if a block is in the cache, without
drivers/md/dm-cache-target.c +38 -20
102 lines not on this page · raw message
Patches currently in stable-queue which might be from [email protected] are
queue-4.1/dm-btree-remove-fix-bug-in-redistribute3.patch queue-4.1/dm-btree-silence-lockdep-lock-inversion-in-dm_btree_del.patch queue-4.1/dm-cache-fix-race-when-issuing-a-policy_replace-operation.patch queue-4.1/dm-thin-allocate-the-cell_sort_array-dynamically.patch queue-4.1/dm-space-map-metadata-fix-occasional-leak-of-a-metadata-block-on-resize.patch