Skip to content

Commit 66214ed

Browse files
author
Mike Snitzer
committed
dm vdo funnel-queue: change from uds_ to vdo_ namespace
Also return VDO_SUCCESS from vdo_make_funnel_queue. Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Chung Chung <[email protected]> Signed-off-by: Matthew Sakai <[email protected]>
1 parent 41c58a3 commit 66214ed

File tree

6 files changed

+49
-49
lines changed

6 files changed

+49
-49
lines changed

drivers/md/dm-vdo/data-vio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ static void process_release_callback(struct vdo_completion *completion)
718718

719719
for (processed = 0; processed < DATA_VIO_RELEASE_BATCH_SIZE; processed++) {
720720
struct data_vio *data_vio;
721-
struct funnel_queue_entry *entry = uds_funnel_queue_poll(pool->queue);
721+
struct funnel_queue_entry *entry = vdo_funnel_queue_poll(pool->queue);
722722

723723
if (entry == NULL)
724724
break;
@@ -748,7 +748,7 @@ static void process_release_callback(struct vdo_completion *completion)
748748
/* Pairs with the barrier in schedule_releases(). */
749749
smp_mb();
750750

751-
reschedule = !uds_is_funnel_queue_empty(pool->queue);
751+
reschedule = !vdo_is_funnel_queue_empty(pool->queue);
752752
drained = (!reschedule &&
753753
vdo_is_state_draining(&pool->state) &&
754754
check_for_drain_complete_locked(pool));
@@ -865,8 +865,8 @@ int make_data_vio_pool(struct vdo *vdo, data_vio_count_t pool_size,
865865
process_release_callback, vdo->thread_config.cpu_thread,
866866
NULL);
867867

868-
result = uds_make_funnel_queue(&pool->queue);
869-
if (result != UDS_SUCCESS) {
868+
result = vdo_make_funnel_queue(&pool->queue);
869+
if (result != VDO_SUCCESS) {
870870
free_data_vio_pool(vdo_forget(pool));
871871
return result;
872872
}
@@ -924,7 +924,7 @@ void free_data_vio_pool(struct data_vio_pool *pool)
924924
destroy_data_vio(data_vio);
925925
}
926926

927-
uds_free_funnel_queue(vdo_forget(pool->queue));
927+
vdo_free_funnel_queue(vdo_forget(pool->queue));
928928
vdo_free(pool);
929929
}
930930

@@ -1283,7 +1283,7 @@ static void finish_cleanup(struct data_vio *data_vio)
12831283
(completion->result != VDO_SUCCESS)) {
12841284
struct data_vio_pool *pool = completion->vdo->data_vio_pool;
12851285

1286-
uds_funnel_queue_put(pool->queue, &completion->work_queue_entry_link);
1286+
vdo_funnel_queue_put(pool->queue, &completion->work_queue_entry_link);
12871287
schedule_releases(pool);
12881288
return;
12891289
}

drivers/md/dm-vdo/dedupe.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,7 @@ static void finish_index_operation(struct uds_request *request)
22462246
atomic_read(&context->state));
22472247
}
22482248

2249-
uds_funnel_queue_put(context->zone->timed_out_complete, &context->queue_entry);
2249+
vdo_funnel_queue_put(context->zone->timed_out_complete, &context->queue_entry);
22502250
}
22512251

22522252
/**
@@ -2275,7 +2275,7 @@ static void check_for_drain_complete(struct hash_zone *zone)
22752275
struct dedupe_context *context;
22762276
struct funnel_queue_entry *entry;
22772277

2278-
entry = uds_funnel_queue_poll(zone->timed_out_complete);
2278+
entry = vdo_funnel_queue_poll(zone->timed_out_complete);
22792279
if (entry == NULL)
22802280
break;
22812281

@@ -2373,7 +2373,7 @@ static int __must_check initialize_zone(struct vdo *vdo, struct hash_zones *zone
23732373

23742374
INIT_LIST_HEAD(&zone->available);
23752375
INIT_LIST_HEAD(&zone->pending);
2376-
result = uds_make_funnel_queue(&zone->timed_out_complete);
2376+
result = vdo_make_funnel_queue(&zone->timed_out_complete);
23772377
if (result != VDO_SUCCESS)
23782378
return result;
23792379

@@ -2475,7 +2475,7 @@ void vdo_free_hash_zones(struct hash_zones *zones)
24752475
for (i = 0; i < zones->zone_count; i++) {
24762476
struct hash_zone *zone = &zones->zones[i];
24772477

2478-
uds_free_funnel_queue(vdo_forget(zone->timed_out_complete));
2478+
vdo_free_funnel_queue(vdo_forget(zone->timed_out_complete));
24792479
vdo_int_map_free(vdo_forget(zone->hash_lock_map));
24802480
vdo_free(vdo_forget(zone->lock_array));
24812481
}
@@ -2875,7 +2875,7 @@ static struct dedupe_context * __must_check acquire_context(struct hash_zone *zo
28752875
return context;
28762876
}
28772877

2878-
entry = uds_funnel_queue_poll(zone->timed_out_complete);
2878+
entry = vdo_funnel_queue_poll(zone->timed_out_complete);
28792879
return ((entry == NULL) ?
28802880
NULL : container_of(entry, struct dedupe_context, queue_entry));
28812881
}

drivers/md/dm-vdo/funnel-queue.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "memory-alloc.h"
1010
#include "permassert.h"
1111

12-
int uds_make_funnel_queue(struct funnel_queue **queue_ptr)
12+
int vdo_make_funnel_queue(struct funnel_queue **queue_ptr)
1313
{
1414
int result;
1515
struct funnel_queue *queue;
@@ -27,10 +27,10 @@ int uds_make_funnel_queue(struct funnel_queue **queue_ptr)
2727
queue->oldest = &queue->stub;
2828

2929
*queue_ptr = queue;
30-
return UDS_SUCCESS;
30+
return VDO_SUCCESS;
3131
}
3232

33-
void uds_free_funnel_queue(struct funnel_queue *queue)
33+
void vdo_free_funnel_queue(struct funnel_queue *queue)
3434
{
3535
vdo_free(queue);
3636
}
@@ -40,7 +40,7 @@ static struct funnel_queue_entry *get_oldest(struct funnel_queue *queue)
4040
/*
4141
* Barrier requirements: We need a read barrier between reading a "next" field pointer
4242
* value and reading anything it points to. There's an accompanying barrier in
43-
* uds_funnel_queue_put() between its caller setting up the entry and making it visible.
43+
* vdo_funnel_queue_put() between its caller setting up the entry and making it visible.
4444
*/
4545
struct funnel_queue_entry *oldest = queue->oldest;
4646
struct funnel_queue_entry *next = READ_ONCE(oldest->next);
@@ -80,7 +80,7 @@ static struct funnel_queue_entry *get_oldest(struct funnel_queue *queue)
8080
* Put the stub entry back on the queue, ensuring a successor will eventually be
8181
* seen.
8282
*/
83-
uds_funnel_queue_put(queue, &queue->stub);
83+
vdo_funnel_queue_put(queue, &queue->stub);
8484

8585
/* Check again for a successor. */
8686
next = READ_ONCE(oldest->next);
@@ -100,7 +100,7 @@ static struct funnel_queue_entry *get_oldest(struct funnel_queue *queue)
100100
* Poll a queue, removing the oldest entry if the queue is not empty. This function must only be
101101
* called from a single consumer thread.
102102
*/
103-
struct funnel_queue_entry *uds_funnel_queue_poll(struct funnel_queue *queue)
103+
struct funnel_queue_entry *vdo_funnel_queue_poll(struct funnel_queue *queue)
104104
{
105105
struct funnel_queue_entry *oldest = get_oldest(queue);
106106

@@ -134,7 +134,7 @@ struct funnel_queue_entry *uds_funnel_queue_poll(struct funnel_queue *queue)
134134
* or more entries being added such that the list view is incomplete, this function will report the
135135
* queue as empty.
136136
*/
137-
bool uds_is_funnel_queue_empty(struct funnel_queue *queue)
137+
bool vdo_is_funnel_queue_empty(struct funnel_queue *queue)
138138
{
139139
return get_oldest(queue) == NULL;
140140
}
@@ -143,9 +143,9 @@ bool uds_is_funnel_queue_empty(struct funnel_queue *queue)
143143
* Check whether the funnel queue is idle or not. If the queue has entries available to be
144144
* retrieved, it is not idle. If the queue is in a transition state with one or more entries being
145145
* added such that the list view is incomplete, it may not be possible to retrieve an entry with
146-
* the uds_funnel_queue_poll() function, but the queue will not be considered idle.
146+
* the vdo_funnel_queue_poll() function, but the queue will not be considered idle.
147147
*/
148-
bool uds_is_funnel_queue_idle(struct funnel_queue *queue)
148+
bool vdo_is_funnel_queue_idle(struct funnel_queue *queue)
149149
{
150150
/*
151151
* Oldest is not the stub, so there's another entry, though if next is NULL we can't

drivers/md/dm-vdo/funnel-queue.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Copyright 2023 Red Hat
44
*/
55

6-
#ifndef UDS_FUNNEL_QUEUE_H
7-
#define UDS_FUNNEL_QUEUE_H
6+
#ifndef VDO_FUNNEL_QUEUE_H
7+
#define VDO_FUNNEL_QUEUE_H
88

99
#include <linux/atomic.h>
1010
#include <linux/cache.h>
@@ -25,19 +25,19 @@
2525
* the queue entries, and pointers to those structures are used exclusively by the queue. No macros
2626
* are defined to template the queue, so the offset of the funnel_queue_entry in the records placed
2727
* in the queue must all be the same so the client can derive their structure pointer from the
28-
* entry pointer returned by uds_funnel_queue_poll().
28+
* entry pointer returned by vdo_funnel_queue_poll().
2929
*
3030
* Callers are wholly responsible for allocating and freeing the entries. Entries may be freed as
3131
* soon as they are returned since this queue is not susceptible to the "ABA problem" present in
3232
* many lock-free data structures. The queue is dynamically allocated to ensure cache-line
3333
* alignment, but no other dynamic allocation is used.
3434
*
35-
* The algorithm is not actually 100% lock-free. There is a single point in uds_funnel_queue_put()
35+
* The algorithm is not actually 100% lock-free. There is a single point in vdo_funnel_queue_put()
3636
* at which a preempted producer will prevent the consumers from seeing items added to the queue by
3737
* later producers, and only if the queue is short enough or the consumer fast enough for it to
3838
* reach what was the end of the queue at the time of the preemption.
3939
*
40-
* The consumer function, uds_funnel_queue_poll(), will return NULL when the queue is empty. To
40+
* The consumer function, vdo_funnel_queue_poll(), will return NULL when the queue is empty. To
4141
* wait for data to consume, spin (if safe) or combine the queue with a struct event_count to
4242
* signal the presence of new entries.
4343
*/
@@ -51,7 +51,7 @@ struct funnel_queue_entry {
5151
/*
5252
* The dynamically allocated queue structure, which is allocated on a cache line boundary so the
5353
* producer and consumer fields in the structure will land on separate cache lines. This should be
54-
* consider opaque but it is exposed here so uds_funnel_queue_put() can be inlined.
54+
* consider opaque but it is exposed here so vdo_funnel_queue_put() can be inlined.
5555
*/
5656
struct __aligned(L1_CACHE_BYTES) funnel_queue {
5757
/*
@@ -67,9 +67,9 @@ struct __aligned(L1_CACHE_BYTES) funnel_queue {
6767
struct funnel_queue_entry stub;
6868
};
6969

70-
int __must_check uds_make_funnel_queue(struct funnel_queue **queue_ptr);
70+
int __must_check vdo_make_funnel_queue(struct funnel_queue **queue_ptr);
7171

72-
void uds_free_funnel_queue(struct funnel_queue *queue);
72+
void vdo_free_funnel_queue(struct funnel_queue *queue);
7373

7474
/*
7575
* Put an entry on the end of the queue.
@@ -79,7 +79,7 @@ void uds_free_funnel_queue(struct funnel_queue *queue);
7979
* from the pointer that passed in here, so every entry in the queue must have the struct
8080
* funnel_queue_entry at the same offset within the client's structure.
8181
*/
82-
static inline void uds_funnel_queue_put(struct funnel_queue *queue,
82+
static inline void vdo_funnel_queue_put(struct funnel_queue *queue,
8383
struct funnel_queue_entry *entry)
8484
{
8585
struct funnel_queue_entry *previous;
@@ -101,10 +101,10 @@ static inline void uds_funnel_queue_put(struct funnel_queue *queue,
101101
WRITE_ONCE(previous->next, entry);
102102
}
103103

104-
struct funnel_queue_entry *__must_check uds_funnel_queue_poll(struct funnel_queue *queue);
104+
struct funnel_queue_entry *__must_check vdo_funnel_queue_poll(struct funnel_queue *queue);
105105

106-
bool __must_check uds_is_funnel_queue_empty(struct funnel_queue *queue);
106+
bool __must_check vdo_is_funnel_queue_empty(struct funnel_queue *queue);
107107

108-
bool __must_check uds_is_funnel_queue_idle(struct funnel_queue *queue);
108+
bool __must_check vdo_is_funnel_queue_idle(struct funnel_queue *queue);
109109

110-
#endif /* UDS_FUNNEL_QUEUE_H */
110+
#endif /* VDO_FUNNEL_QUEUE_H */

drivers/md/dm-vdo/funnel-workqueue.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static struct vdo_completion *poll_for_completion(struct simple_work_queue *queu
9898
int i;
9999

100100
for (i = queue->common.type->max_priority; i >= 0; i--) {
101-
struct funnel_queue_entry *link = uds_funnel_queue_poll(queue->priority_lists[i]);
101+
struct funnel_queue_entry *link = vdo_funnel_queue_poll(queue->priority_lists[i]);
102102

103103
if (link != NULL)
104104
return container_of(link, struct vdo_completion, work_queue_entry_link);
@@ -123,7 +123,7 @@ static void enqueue_work_queue_completion(struct simple_work_queue *queue,
123123
completion->my_queue = &queue->common;
124124

125125
/* Funnel queue handles the synchronization for the put. */
126-
uds_funnel_queue_put(queue->priority_lists[completion->priority],
126+
vdo_funnel_queue_put(queue->priority_lists[completion->priority],
127127
&completion->work_queue_entry_link);
128128

129129
/*
@@ -275,7 +275,7 @@ static void free_simple_work_queue(struct simple_work_queue *queue)
275275
unsigned int i;
276276

277277
for (i = 0; i <= VDO_WORK_Q_MAX_PRIORITY; i++)
278-
uds_free_funnel_queue(queue->priority_lists[i]);
278+
vdo_free_funnel_queue(queue->priority_lists[i]);
279279
vdo_free(queue->common.name);
280280
vdo_free(queue);
281281
}
@@ -340,8 +340,8 @@ static int make_simple_work_queue(const char *thread_name_prefix, const char *na
340340
}
341341

342342
for (i = 0; i <= type->max_priority; i++) {
343-
result = uds_make_funnel_queue(&queue->priority_lists[i]);
344-
if (result != UDS_SUCCESS) {
343+
result = vdo_make_funnel_queue(&queue->priority_lists[i]);
344+
if (result != VDO_SUCCESS) {
345345
free_simple_work_queue(queue);
346346
return result;
347347
}

drivers/md/dm-vdo/indexer/funnel-requestqueue.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ static inline struct uds_request *poll_queues(struct uds_request_queue *queue)
6969
{
7070
struct funnel_queue_entry *entry;
7171

72-
entry = uds_funnel_queue_poll(queue->retry_queue);
72+
entry = vdo_funnel_queue_poll(queue->retry_queue);
7373
if (entry != NULL)
7474
return container_of(entry, struct uds_request, queue_link);
7575

76-
entry = uds_funnel_queue_poll(queue->main_queue);
76+
entry = vdo_funnel_queue_poll(queue->main_queue);
7777
if (entry != NULL)
7878
return container_of(entry, struct uds_request, queue_link);
7979

@@ -82,8 +82,8 @@ static inline struct uds_request *poll_queues(struct uds_request_queue *queue)
8282

8383
static inline bool are_queues_idle(struct uds_request_queue *queue)
8484
{
85-
return uds_is_funnel_queue_idle(queue->retry_queue) &&
86-
uds_is_funnel_queue_idle(queue->main_queue);
85+
return vdo_is_funnel_queue_idle(queue->retry_queue) &&
86+
vdo_is_funnel_queue_idle(queue->main_queue);
8787
}
8888

8989
/*
@@ -207,14 +207,14 @@ int uds_make_request_queue(const char *queue_name,
207207
atomic_set(&queue->dormant, false);
208208
init_waitqueue_head(&queue->wait_head);
209209

210-
result = uds_make_funnel_queue(&queue->main_queue);
211-
if (result != UDS_SUCCESS) {
210+
result = vdo_make_funnel_queue(&queue->main_queue);
211+
if (result != VDO_SUCCESS) {
212212
uds_request_queue_finish(queue);
213213
return result;
214214
}
215215

216-
result = uds_make_funnel_queue(&queue->retry_queue);
217-
if (result != UDS_SUCCESS) {
216+
result = vdo_make_funnel_queue(&queue->retry_queue);
217+
if (result != VDO_SUCCESS) {
218218
uds_request_queue_finish(queue);
219219
return result;
220220
}
@@ -244,7 +244,7 @@ void uds_request_queue_enqueue(struct uds_request_queue *queue,
244244
bool unbatched = request->unbatched;
245245

246246
sub_queue = request->requeued ? queue->retry_queue : queue->main_queue;
247-
uds_funnel_queue_put(sub_queue, &request->queue_link);
247+
vdo_funnel_queue_put(sub_queue, &request->queue_link);
248248

249249
/*
250250
* We must wake the worker thread when it is dormant. A read fence isn't needed here since
@@ -273,7 +273,7 @@ void uds_request_queue_finish(struct uds_request_queue *queue)
273273
vdo_join_threads(queue->thread);
274274
}
275275

276-
uds_free_funnel_queue(queue->main_queue);
277-
uds_free_funnel_queue(queue->retry_queue);
276+
vdo_free_funnel_queue(queue->main_queue);
277+
vdo_free_funnel_queue(queue->retry_queue);
278278
vdo_free(queue);
279279
}

0 commit comments

Comments
 (0)