mirror of
https://github.com/torvalds/linux.git
synced 2026-10-29 21:06:02 +01:00
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>
This commit is contained in:
parent
8765dcb96f
commit
a46fd918f7
|
|
@ -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 @@ static int cache_data_alloc(struct pcache_cache *cache, struct pcache_cache_key
|
|||
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. */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user