Skip to content

Commit 2b515ce

Browse files
raeburnMikulas Patocka
authored andcommitted
dm vdo vio-pool: add a pool pointer to pooled_vio
This allows us to simplify the return_vio_to_pool interface. Also, we don't need to use vdo_forget on local variables or arguments that are about to go out of scope anyway. Signed-off-by: Ken Raeburn <raeburn@redhat.com> Signed-off-by: Matthew Sakai <msakai@redhat.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
1 parent 148a9ce commit 2b515ce

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

drivers/md/dm-vdo/block-map.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ static void write_page_if_not_dirtied(struct vdo_waiter *waiter, void *context)
15441544

15451545
static void return_to_pool(struct block_map_zone *zone, struct pooled_vio *vio)
15461546
{
1547-
return_vio_to_pool(zone->vio_pool, vio);
1547+
return_vio_to_pool(vio);
15481548
check_for_drain_complete(zone);
15491549
}
15501550

@@ -1837,7 +1837,7 @@ static void finish_block_map_page_load(struct vdo_completion *completion)
18371837

18381838
if (!vdo_copy_valid_page(vio->data, nonce, pbn, page))
18391839
vdo_format_block_map_page(page, nonce, pbn, false);
1840-
return_vio_to_pool(zone->vio_pool, pooled);
1840+
return_vio_to_pool(pooled);
18411841

18421842
/* Release our claim to the load and wake any waiters */
18431843
release_page_lock(data_vio, "load");
@@ -1851,10 +1851,9 @@ static void handle_io_error(struct vdo_completion *completion)
18511851
struct vio *vio = as_vio(completion);
18521852
struct pooled_vio *pooled = container_of(vio, struct pooled_vio, vio);
18531853
struct data_vio *data_vio = completion->parent;
1854-
struct block_map_zone *zone = pooled->context;
18551854

18561855
vio_record_metadata_io_error(vio);
1857-
return_vio_to_pool(zone->vio_pool, pooled);
1856+
return_vio_to_pool(pooled);
18581857
abort_load(data_vio, result);
18591858
}
18601859

@@ -2499,7 +2498,7 @@ static void finish_cursor(struct cursor *cursor)
24992498
struct cursors *cursors = cursor->parent;
25002499
struct vdo_completion *completion = cursors->completion;
25012500

2502-
return_vio_to_pool(cursors->pool, vdo_forget(cursor->vio));
2501+
return_vio_to_pool(vdo_forget(cursor->vio));
25032502
if (--cursors->active_roots > 0)
25042503
return;
25052504

drivers/md/dm-vdo/slab-depot.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,7 @@ static void complete_reaping(struct vdo_completion *completion)
414414
{
415415
struct slab_journal *journal = completion->parent;
416416

417-
return_vio_to_pool(journal->slab->allocator->vio_pool,
418-
vio_as_pooled_vio(as_vio(vdo_forget(completion))));
417+
return_vio_to_pool(vio_as_pooled_vio(as_vio(completion)));
419418
finish_reaping(journal);
420419
reap_slab_journal(journal);
421420
}
@@ -698,7 +697,7 @@ static void complete_write(struct vdo_completion *completion)
698697
sequence_number_t committed = get_committing_sequence_number(pooled);
699698

700699
list_del_init(&pooled->list_entry);
701-
return_vio_to_pool(journal->slab->allocator->vio_pool, vdo_forget(pooled));
700+
return_vio_to_pool(pooled);
702701

703702
if (result != VDO_SUCCESS) {
704703
vio_record_metadata_io_error(as_vio(completion));
@@ -1076,7 +1075,7 @@ static void finish_reference_block_write(struct vdo_completion *completion)
10761075
/* Release the slab journal lock. */
10771076
adjust_slab_journal_block_reference(&slab->journal,
10781077
block->slab_journal_lock_to_release, -1);
1079-
return_vio_to_pool(slab->allocator->vio_pool, pooled);
1078+
return_vio_to_pool(pooled);
10801079

10811080
/*
10821081
* We can't clear the is_writing flag earlier as releasing the slab journal lock may cause
@@ -1170,7 +1169,7 @@ static void handle_io_error(struct vdo_completion *completion)
11701169
struct vdo_slab *slab = ((struct reference_block *) completion->parent)->slab;
11711170

11721171
vio_record_metadata_io_error(vio);
1173-
return_vio_to_pool(slab->allocator->vio_pool, vio_as_pooled_vio(vio));
1172+
return_vio_to_pool(vio_as_pooled_vio(vio));
11741173
slab->active_count--;
11751174
vdo_enter_read_only_mode(slab->allocator->depot->vdo, result);
11761175
check_if_slab_drained(slab);
@@ -2242,7 +2241,7 @@ static void finish_reference_block_load(struct vdo_completion *completion)
22422241
struct vdo_slab *slab = block->slab;
22432242

22442243
unpack_reference_block((struct packed_reference_block *) vio->data, block);
2245-
return_vio_to_pool(slab->allocator->vio_pool, pooled);
2244+
return_vio_to_pool(pooled);
22462245
slab->active_count--;
22472246
clear_provisional_references(block);
22482247

@@ -2429,7 +2428,7 @@ static void finish_loading_journal(struct vdo_completion *completion)
24292428
initialize_journal_state(journal);
24302429
}
24312430

2432-
return_vio_to_pool(slab->allocator->vio_pool, vio_as_pooled_vio(vio));
2431+
return_vio_to_pool(vio_as_pooled_vio(vio));
24332432
vdo_finish_loading_with_result(&slab->state, allocate_counters_if_clean(slab));
24342433
}
24352434

@@ -2449,7 +2448,7 @@ static void handle_load_error(struct vdo_completion *completion)
24492448
struct vio *vio = as_vio(completion);
24502449

24512450
vio_record_metadata_io_error(vio);
2452-
return_vio_to_pool(journal->slab->allocator->vio_pool, vio_as_pooled_vio(vio));
2451+
return_vio_to_pool(vio_as_pooled_vio(vio));
24532452
vdo_finish_loading_with_result(&journal->slab->state, result);
24542453
}
24552454

drivers/md/dm-vdo/vio.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ int make_vio_pool(struct vdo *vdo, size_t pool_size, thread_id_t thread_id,
345345
}
346346

347347
pooled->context = context;
348+
pooled->pool = pool;
348349
list_add_tail(&pooled->pool_entry, &pool->available);
349350
}
350351

@@ -419,12 +420,13 @@ void acquire_vio_from_pool(struct vio_pool *pool, struct vdo_waiter *waiter)
419420
}
420421

421422
/**
422-
* return_vio_to_pool() - Return a vio to the pool
423-
* @pool: The vio pool.
423+
* return_vio_to_pool() - Return a vio to its pool
424424
* @vio: The pooled vio to return.
425425
*/
426-
void return_vio_to_pool(struct vio_pool *pool, struct pooled_vio *vio)
426+
void return_vio_to_pool(struct pooled_vio *vio)
427427
{
428+
struct vio_pool *pool = vio->pool;
429+
428430
VDO_ASSERT_LOG_ONLY((pool->thread_id == vdo_get_callback_thread_id()),
429431
"vio pool entry returned on same thread as it was acquired");
430432

drivers/md/dm-vdo/vio.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ struct pooled_vio {
3030
void *context;
3131
/* The list entry used by the pool */
3232
struct list_head pool_entry;
33+
/* The pool this vio is allocated from */
34+
struct vio_pool *pool;
3335
};
3436

3537
/**
@@ -194,6 +196,6 @@ int __must_check make_vio_pool(struct vdo *vdo, size_t pool_size, thread_id_t th
194196
void free_vio_pool(struct vio_pool *pool);
195197
bool __must_check is_vio_pool_busy(struct vio_pool *pool);
196198
void acquire_vio_from_pool(struct vio_pool *pool, struct vdo_waiter *waiter);
197-
void return_vio_to_pool(struct vio_pool *pool, struct pooled_vio *vio);
199+
void return_vio_to_pool(struct pooled_vio *vio);
198200

199201
#endif /* VIO_H */

0 commit comments

Comments
 (0)