Skip to content

Commit 698ab77

Browse files
rhvgoyaldjbw
authored andcommitted
dax: Add an enum for specifying dax wakup mode
Dan mentioned that he is not very fond of passing around a boolean true/false to specify if only next waiter should be woken up or all waiters should be woken up. He instead prefers that we introduce an enum and make it very explicity at the callsite itself. Easier to read code. This patch should not introduce any change of behavior. Reviewed-by: Greg Kurz <[email protected]> Reviewed-by: Jan Kara <[email protected]> Suggested-by: Dan Williams <[email protected]> Signed-off-by: Vivek Goyal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 9f4ad9e commit 698ab77

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

fs/dax.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ struct wait_exceptional_entry_queue {
144144
struct exceptional_entry_key key;
145145
};
146146

147+
/**
148+
* enum dax_wake_mode: waitqueue wakeup behaviour
149+
* @WAKE_ALL: wake all waiters in the waitqueue
150+
* @WAKE_NEXT: wake only the first waiter in the waitqueue
151+
*/
152+
enum dax_wake_mode {
153+
WAKE_ALL,
154+
WAKE_NEXT,
155+
};
156+
147157
static wait_queue_head_t *dax_entry_waitqueue(struct xa_state *xas,
148158
void *entry, struct exceptional_entry_key *key)
149159
{
@@ -182,7 +192,8 @@ static int wake_exceptional_entry_func(wait_queue_entry_t *wait,
182192
* The important information it's conveying is whether the entry at
183193
* this index used to be a PMD entry.
184194
*/
185-
static void dax_wake_entry(struct xa_state *xas, void *entry, bool wake_all)
195+
static void dax_wake_entry(struct xa_state *xas, void *entry,
196+
enum dax_wake_mode mode)
186197
{
187198
struct exceptional_entry_key key;
188199
wait_queue_head_t *wq;
@@ -196,7 +207,7 @@ static void dax_wake_entry(struct xa_state *xas, void *entry, bool wake_all)
196207
* must be in the waitqueue and the following check will see them.
197208
*/
198209
if (waitqueue_active(wq))
199-
__wake_up(wq, TASK_NORMAL, wake_all ? 0 : 1, &key);
210+
__wake_up(wq, TASK_NORMAL, mode == WAKE_ALL ? 0 : 1, &key);
200211
}
201212

202213
/*
@@ -268,7 +279,7 @@ static void put_unlocked_entry(struct xa_state *xas, void *entry)
268279
{
269280
/* If we were the only waiter woken, wake the next one */
270281
if (entry && !dax_is_conflict(entry))
271-
dax_wake_entry(xas, entry, false);
282+
dax_wake_entry(xas, entry, WAKE_NEXT);
272283
}
273284

274285
/*
@@ -286,7 +297,7 @@ static void dax_unlock_entry(struct xa_state *xas, void *entry)
286297
old = xas_store(xas, entry);
287298
xas_unlock_irq(xas);
288299
BUG_ON(!dax_is_locked(old));
289-
dax_wake_entry(xas, entry, false);
300+
dax_wake_entry(xas, entry, WAKE_NEXT);
290301
}
291302

292303
/*
@@ -524,7 +535,7 @@ static void *grab_mapping_entry(struct xa_state *xas,
524535

525536
dax_disassociate_entry(entry, mapping, false);
526537
xas_store(xas, NULL); /* undo the PMD join */
527-
dax_wake_entry(xas, entry, true);
538+
dax_wake_entry(xas, entry, WAKE_ALL);
528539
mapping->nrexceptional--;
529540
entry = NULL;
530541
xas_set(xas, index);
@@ -937,7 +948,7 @@ static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev,
937948
xas_lock_irq(xas);
938949
xas_store(xas, entry);
939950
xas_clear_mark(xas, PAGECACHE_TAG_DIRTY);
940-
dax_wake_entry(xas, entry, false);
951+
dax_wake_entry(xas, entry, WAKE_NEXT);
941952

942953
trace_dax_writeback_one(mapping->host, index, count);
943954
return ret;

0 commit comments

Comments
 (0)