diff options
| author | Jianyun Gao <jianyungao89@gmail.com> | 2026-07-17 16:38:56 +0800 |
|---|---|---|
| committer | Mikulas Patocka <mpatocka@redhat.com> | 2026-07-20 15:44:29 +0200 |
| commit | a46fd918f7907ecdfd1b1d03210463eef80f0def (patch) | |
| tree | 725d6ce0e001457f25bd7cae1f5faf73fadbbbb5 | |
| parent | 8765dcb96f00b65de4a59b29c25fed5d8b3cedf1 (diff) | |
dm-pcache: remove unused 'allocated' variable in cache_data_alloc()
The 'allocated' variable is never non-zero when its value is consumed.
'to_alloc' was always equal to key->len, so replace them with key->len
directly.
Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
| -rw-r--r-- | drivers/md/dm-pcache/cache_req.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/md/dm-pcache/cache_req.c b/drivers/md/dm-pcache/cache_req.c index cc5747d472e9..b2cb3c7615d4 100644 --- a/drivers/md/dm-pcache/cache_req.c +++ b/drivers/md/dm-pcache/cache_req.c @@ -39,13 +39,11 @@ static int cache_data_alloc(struct pcache_cache *cache, struct pcache_cache_key struct pcache_cache_pos *head_pos; struct pcache_cache_segment *cache_seg; u32 seg_remain; - u32 allocated = 0, to_alloc; int ret = 0; preempt_disable(); data_head = get_data_head(cache); again: - to_alloc = key->len - allocated; if (!data_head->head_pos.cache_seg) { seg_remain = 0; } else { @@ -57,10 +55,9 @@ again: seg_remain = cache_seg_remain(head_pos); } - if (seg_remain > to_alloc) { + if (seg_remain > key->len) { /* If remaining space in segment is sufficient for the cache key, allocate it. */ - cache_pos_advance(head_pos, to_alloc); - allocated += to_alloc; + cache_pos_advance(head_pos, key->len); cache_seg_get(cache_seg); } else if (seg_remain) { /* If remaining space is not enough, allocate the remaining space and adjust the cache key length. */ |
