summaryrefslogtreecommitdiff
path: root/drivers/md/dm-cache-target.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2021-06-30 18:19:39 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2021-06-30 18:19:39 -0700
commit2cfa582be80081fb8db02d4d9b44bff34b82ac54 (patch)
tree2faf8db8426b389ca8c9ed76065c688431bb7eb9 /drivers/md/dm-cache-target.c
parentdbe69e43372212527abf48609aba7fc39a6daa27 (diff)
parent5c0de3d72f8c05678ed769bea24e98128f7ab570 (diff)
Merge tag 'for-5.14/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper updates from Mike Snitzer: - Various DM persistent-data library improvements and fixes that benefit both the DM thinp and cache targets. - A few small DM kcopyd efficiency improvements. - Significant zoned related block core, DM core and DM zoned target changes that culminate with adding zoned append emulation (which is required to properly fix DM crypt's zoned support). - Various DM writecache target changes that improve efficiency. Adds an optional "metadata_only" feature that only promotes bios flagged with REQ_META. But the most significant improvement is writecache's ability to pause writeback, for a confiurable time, if/when the working set is larger than the cache (and the cache is full) -- this ensures performance is no worse than the slower origin device. * tag 'for-5.14/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: (35 commits) dm writecache: make writeback pause configurable dm writecache: pause writeback if cache full and origin being written directly dm io tracker: factor out IO tracker dm btree remove: assign new_root only when removal succeeds dm zone: fix dm_revalidate_zones() memory allocation dm ps io affinity: remove redundant continue statement dm writecache: add optional "metadata_only" parameter dm writecache: add "cleaner" and "max_age" to Documentation dm writecache: write at least 4k when committing dm writecache: flush origin device when writing and cache is full dm writecache: have ssd writeback wait if the kcopyd workqueue is busy dm writecache: use list_move instead of list_del/list_add in writecache_writeback() dm writecache: commit just one block, not a full page dm writecache: remove unused gfp_t argument from wc_add_block() dm crypt: Fix zoned block device support dm: introduce zone append emulation dm: rearrange core declarations for extended use from dm-zone.c block: introduce BIO_ZONE_WRITE_LOCKED bio flag block: introduce bio zone helpers block: improve handling of all zones reset operation ...
Diffstat (limited to 'drivers/md/dm-cache-target.c')
-rw-r--r--drivers/md/dm-cache-target.c82
1 files changed, 6 insertions, 76 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 6ab01ff25747..8e4ced5a2516 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -8,6 +8,7 @@
#include "dm-bio-prison-v2.h"
#include "dm-bio-record.h"
#include "dm-cache-metadata.h"
+#include "dm-io-tracker.h"
#include <linux/dm-io.h>
#include <linux/dm-kcopyd.h>
@@ -39,77 +40,6 @@ DECLARE_DM_KCOPYD_THROTTLE_WITH_MODULE_PARM(cache_copy_throttle,
/*----------------------------------------------------------------*/
-struct io_tracker {
- spinlock_t lock;
-
- /*
- * Sectors of in-flight IO.
- */
- sector_t in_flight;
-
- /*
- * The time, in jiffies, when this device became idle (if it is
- * indeed idle).
- */
- unsigned long idle_time;
- unsigned long last_update_time;
-};
-
-static void iot_init(struct io_tracker *iot)
-{
- spin_lock_init(&iot->lock);
- iot->in_flight = 0ul;
- iot->idle_time = 0ul;
- iot->last_update_time = jiffies;
-}
-
-static bool __iot_idle_for(struct io_tracker *iot, unsigned long jifs)
-{
- if (iot->in_flight)
- return false;
-
- return time_after(jiffies, iot->idle_time + jifs);
-}
-
-static bool iot_idle_for(struct io_tracker *iot, unsigned long jifs)
-{
- bool r;
-
- spin_lock_irq(&iot->lock);
- r = __iot_idle_for(iot, jifs);
- spin_unlock_irq(&iot->lock);
-
- return r;
-}
-
-static void iot_io_begin(struct io_tracker *iot, sector_t len)
-{
- spin_lock_irq(&iot->lock);
- iot->in_flight += len;
- spin_unlock_irq(&iot->lock);
-}
-
-static void __iot_io_end(struct io_tracker *iot, sector_t len)
-{
- if (!len)
- return;
-
- iot->in_flight -= len;
- if (!iot->in_flight)
- iot->idle_time = jiffies;
-}
-
-static void iot_io_end(struct io_tracker *iot, sector_t len)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&iot->lock, flags);
- __iot_io_end(iot, len);
- spin_unlock_irqrestore(&iot->lock, flags);
-}
-
-/*----------------------------------------------------------------*/
-
/*
* Represents a chunk of future work. 'input' allows continuations to pass
* values between themselves, typically error values.
@@ -470,7 +400,7 @@ struct cache {
struct batcher committer;
struct work_struct commit_ws;
- struct io_tracker tracker;
+ struct dm_io_tracker tracker;
mempool_t migration_pool;
@@ -866,7 +796,7 @@ static void accounted_begin(struct cache *cache, struct bio *bio)
if (accountable_bio(cache, bio)) {
pb = get_per_bio_data(bio);
pb->len = bio_sectors(bio);
- iot_io_begin(&cache->tracker, pb->len);
+ dm_iot_io_begin(&cache->tracker, pb->len);
}
}
@@ -874,7 +804,7 @@ static void accounted_complete(struct cache *cache, struct bio *bio)
{
struct per_bio_data *pb = get_per_bio_data(bio);
- iot_io_end(&cache->tracker, pb->len);
+ dm_iot_io_end(&cache->tracker, pb->len);
}
static void accounted_request(struct cache *cache, struct bio *bio)
@@ -1642,7 +1572,7 @@ enum busy {
static enum busy spare_migration_bandwidth(struct cache *cache)
{
- bool idle = iot_idle_for(&cache->tracker, HZ);
+ bool idle = dm_iot_idle_for(&cache->tracker, HZ);
sector_t current_volume = (atomic_read(&cache->nr_io_migrations) + 1) *
cache->sectors_per_block;
@@ -2603,7 +2533,7 @@ static int cache_create(struct cache_args *ca, struct cache **result)
batcher_init(&cache->committer, commit_op, cache,
issue_op, cache, cache->wq);
- iot_init(&cache->tracker);
+ dm_iot_init(&cache->tracker);
init_rwsem(&cache->background_work_lock);
prevent_background_work(cache);