Skip to content

Commit 7f94ed2

Browse files
committed
Merge branch 'sunrpc'
2 parents 149a4fd + ce27230 commit 7f94ed2

File tree

7 files changed

+136
-74
lines changed

7 files changed

+136
-74
lines changed

include/linux/sunrpc/sched.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ void rpc_wake_up_queued_task(struct rpc_wait_queue *,
230230
struct rpc_task *);
231231
void rpc_wake_up(struct rpc_wait_queue *);
232232
struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *);
233+
struct rpc_task *rpc_wake_up_first_on_wq(struct workqueue_struct *wq,
234+
struct rpc_wait_queue *,
235+
bool (*)(struct rpc_task *, void *),
236+
void *);
233237
struct rpc_task *rpc_wake_up_first(struct rpc_wait_queue *,
234238
bool (*)(struct rpc_task *, void *),
235239
void *);
@@ -247,6 +251,7 @@ void rpc_show_tasks(struct net *);
247251
int rpc_init_mempool(void);
248252
void rpc_destroy_mempool(void);
249253
extern struct workqueue_struct *rpciod_workqueue;
254+
extern struct workqueue_struct *xprtiod_workqueue;
250255
void rpc_prepare_task(struct rpc_task *task);
251256

252257
static inline int rpc_wait_for_completion_task(struct rpc_task *task)

include/linux/sunrpc/xprtsock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct sock_xprt {
8080
#define TCP_RPC_REPLY (1UL << 6)
8181

8282
#define XPRT_SOCK_CONNECTING 1U
83+
#define XPRT_SOCK_DATA_READY (2)
8384

8485
#endif /* __KERNEL__ */
8586

net/sunrpc/clnt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,7 @@ static void rpc_cb_add_xprt_release(void *calldata)
25772577
kfree(data);
25782578
}
25792579

2580-
const static struct rpc_call_ops rpc_cb_add_xprt_call_ops = {
2580+
static const struct rpc_call_ops rpc_cb_add_xprt_call_ops = {
25812581
.rpc_call_done = rpc_cb_add_xprt_done,
25822582
.rpc_release = rpc_cb_add_xprt_release,
25832583
};

net/sunrpc/sched.c

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ static struct rpc_wait_queue delay_queue;
5454
/*
5555
* rpciod-related stuff
5656
*/
57-
struct workqueue_struct *rpciod_workqueue;
57+
struct workqueue_struct *rpciod_workqueue __read_mostly;
58+
struct workqueue_struct *xprtiod_workqueue __read_mostly;
5859

5960
/*
6061
* Disable the timer for a given RPC task. Should be called with
@@ -329,7 +330,8 @@ EXPORT_SYMBOL_GPL(__rpc_wait_for_completion_task);
329330
* lockless RPC_IS_QUEUED() test) before we've had a chance to test
330331
* the RPC_TASK_RUNNING flag.
331332
*/
332-
static void rpc_make_runnable(struct rpc_task *task)
333+
static void rpc_make_runnable(struct workqueue_struct *wq,
334+
struct rpc_task *task)
333335
{
334336
bool need_wakeup = !rpc_test_and_set_running(task);
335337

@@ -338,7 +340,7 @@ static void rpc_make_runnable(struct rpc_task *task)
338340
return;
339341
if (RPC_IS_ASYNC(task)) {
340342
INIT_WORK(&task->u.tk_work, rpc_async_schedule);
341-
queue_work(rpciod_workqueue, &task->u.tk_work);
343+
queue_work(wq, &task->u.tk_work);
342344
} else
343345
wake_up_bit(&task->tk_runstate, RPC_TASK_QUEUED);
344346
}
@@ -407,13 +409,16 @@ void rpc_sleep_on_priority(struct rpc_wait_queue *q, struct rpc_task *task,
407409
EXPORT_SYMBOL_GPL(rpc_sleep_on_priority);
408410

409411
/**
410-
* __rpc_do_wake_up_task - wake up a single rpc_task
412+
* __rpc_do_wake_up_task_on_wq - wake up a single rpc_task
413+
* @wq: workqueue on which to run task
411414
* @queue: wait queue
412415
* @task: task to be woken up
413416
*
414417
* Caller must hold queue->lock, and have cleared the task queued flag.
415418
*/
416-
static void __rpc_do_wake_up_task(struct rpc_wait_queue *queue, struct rpc_task *task)
419+
static void __rpc_do_wake_up_task_on_wq(struct workqueue_struct *wq,
420+
struct rpc_wait_queue *queue,
421+
struct rpc_task *task)
417422
{
418423
dprintk("RPC: %5u __rpc_wake_up_task (now %lu)\n",
419424
task->tk_pid, jiffies);
@@ -428,23 +433,32 @@ static void __rpc_do_wake_up_task(struct rpc_wait_queue *queue, struct rpc_task
428433

429434
__rpc_remove_wait_queue(queue, task);
430435

431-
rpc_make_runnable(task);
436+
rpc_make_runnable(wq, task);
432437

433438
dprintk("RPC: __rpc_wake_up_task done\n");
434439
}
435440

436441
/*
437442
* Wake up a queued task while the queue lock is being held
438443
*/
439-
static void rpc_wake_up_task_queue_locked(struct rpc_wait_queue *queue, struct rpc_task *task)
444+
static void rpc_wake_up_task_on_wq_queue_locked(struct workqueue_struct *wq,
445+
struct rpc_wait_queue *queue, struct rpc_task *task)
440446
{
441447
if (RPC_IS_QUEUED(task)) {
442448
smp_rmb();
443449
if (task->tk_waitqueue == queue)
444-
__rpc_do_wake_up_task(queue, task);
450+
__rpc_do_wake_up_task_on_wq(wq, queue, task);
445451
}
446452
}
447453

454+
/*
455+
* Wake up a queued task while the queue lock is being held
456+
*/
457+
static void rpc_wake_up_task_queue_locked(struct rpc_wait_queue *queue, struct rpc_task *task)
458+
{
459+
rpc_wake_up_task_on_wq_queue_locked(rpciod_workqueue, queue, task);
460+
}
461+
448462
/*
449463
* Wake up a task on a specific queue
450464
*/
@@ -518,7 +532,8 @@ static struct rpc_task *__rpc_find_next_queued(struct rpc_wait_queue *queue)
518532
/*
519533
* Wake up the first task on the wait queue.
520534
*/
521-
struct rpc_task *rpc_wake_up_first(struct rpc_wait_queue *queue,
535+
struct rpc_task *rpc_wake_up_first_on_wq(struct workqueue_struct *wq,
536+
struct rpc_wait_queue *queue,
522537
bool (*func)(struct rpc_task *, void *), void *data)
523538
{
524539
struct rpc_task *task = NULL;
@@ -529,14 +544,23 @@ struct rpc_task *rpc_wake_up_first(struct rpc_wait_queue *queue,
529544
task = __rpc_find_next_queued(queue);
530545
if (task != NULL) {
531546
if (func(task, data))
532-
rpc_wake_up_task_queue_locked(queue, task);
547+
rpc_wake_up_task_on_wq_queue_locked(wq, queue, task);
533548
else
534549
task = NULL;
535550
}
536551
spin_unlock_bh(&queue->lock);
537552

538553
return task;
539554
}
555+
556+
/*
557+
* Wake up the first task on the wait queue.
558+
*/
559+
struct rpc_task *rpc_wake_up_first(struct rpc_wait_queue *queue,
560+
bool (*func)(struct rpc_task *, void *), void *data)
561+
{
562+
return rpc_wake_up_first_on_wq(rpciod_workqueue, queue, func, data);
563+
}
540564
EXPORT_SYMBOL_GPL(rpc_wake_up_first);
541565

542566
static bool rpc_wake_up_next_func(struct rpc_task *task, void *data)
@@ -814,7 +838,7 @@ void rpc_execute(struct rpc_task *task)
814838
bool is_async = RPC_IS_ASYNC(task);
815839

816840
rpc_set_active(task);
817-
rpc_make_runnable(task);
841+
rpc_make_runnable(rpciod_workqueue, task);
818842
if (!is_async)
819843
__rpc_execute(task);
820844
}
@@ -1071,10 +1095,22 @@ static int rpciod_start(void)
10711095
* Create the rpciod thread and wait for it to start.
10721096
*/
10731097
dprintk("RPC: creating workqueue rpciod\n");
1074-
/* Note: highpri because network receive is latency sensitive */
1075-
wq = alloc_workqueue("rpciod", WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
1098+
wq = alloc_workqueue("rpciod", WQ_MEM_RECLAIM, 0);
1099+
if (!wq)
1100+
goto out_failed;
10761101
rpciod_workqueue = wq;
1077-
return rpciod_workqueue != NULL;
1102+
/* Note: highpri because network receive is latency sensitive */
1103+
wq = alloc_workqueue("xprtiod", WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
1104+
if (!wq)
1105+
goto free_rpciod;
1106+
xprtiod_workqueue = wq;
1107+
return 1;
1108+
free_rpciod:
1109+
wq = rpciod_workqueue;
1110+
rpciod_workqueue = NULL;
1111+
destroy_workqueue(wq);
1112+
out_failed:
1113+
return 0;
10781114
}
10791115

10801116
static void rpciod_stop(void)
@@ -1088,6 +1124,9 @@ static void rpciod_stop(void)
10881124
wq = rpciod_workqueue;
10891125
rpciod_workqueue = NULL;
10901126
destroy_workqueue(wq);
1127+
wq = xprtiod_workqueue;
1128+
xprtiod_workqueue = NULL;
1129+
destroy_workqueue(wq);
10911130
}
10921131

10931132
void

net/sunrpc/xprt.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static void xprt_clear_locked(struct rpc_xprt *xprt)
220220
clear_bit(XPRT_LOCKED, &xprt->state);
221221
smp_mb__after_atomic();
222222
} else
223-
queue_work(rpciod_workqueue, &xprt->task_cleanup);
223+
queue_work(xprtiod_workqueue, &xprt->task_cleanup);
224224
}
225225

226226
/*
@@ -295,7 +295,8 @@ static void __xprt_lock_write_next(struct rpc_xprt *xprt)
295295
if (test_and_set_bit(XPRT_LOCKED, &xprt->state))
296296
return;
297297

298-
if (rpc_wake_up_first(&xprt->sending, __xprt_lock_write_func, xprt))
298+
if (rpc_wake_up_first_on_wq(xprtiod_workqueue, &xprt->sending,
299+
__xprt_lock_write_func, xprt))
299300
return;
300301
xprt_clear_locked(xprt);
301302
}
@@ -324,7 +325,8 @@ static void __xprt_lock_write_next_cong(struct rpc_xprt *xprt)
324325
return;
325326
if (RPCXPRT_CONGESTED(xprt))
326327
goto out_unlock;
327-
if (rpc_wake_up_first(&xprt->sending, __xprt_lock_write_cong_func, xprt))
328+
if (rpc_wake_up_first_on_wq(xprtiod_workqueue, &xprt->sending,
329+
__xprt_lock_write_cong_func, xprt))
328330
return;
329331
out_unlock:
330332
xprt_clear_locked(xprt);
@@ -645,7 +647,7 @@ void xprt_force_disconnect(struct rpc_xprt *xprt)
645647
set_bit(XPRT_CLOSE_WAIT, &xprt->state);
646648
/* Try to schedule an autoclose RPC call */
647649
if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0)
648-
queue_work(rpciod_workqueue, &xprt->task_cleanup);
650+
queue_work(xprtiod_workqueue, &xprt->task_cleanup);
649651
xprt_wake_pending_tasks(xprt, -EAGAIN);
650652
spin_unlock_bh(&xprt->transport_lock);
651653
}
@@ -672,7 +674,7 @@ void xprt_conditional_disconnect(struct rpc_xprt *xprt, unsigned int cookie)
672674
set_bit(XPRT_CLOSE_WAIT, &xprt->state);
673675
/* Try to schedule an autoclose RPC call */
674676
if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0)
675-
queue_work(rpciod_workqueue, &xprt->task_cleanup);
677+
queue_work(xprtiod_workqueue, &xprt->task_cleanup);
676678
xprt_wake_pending_tasks(xprt, -EAGAIN);
677679
out:
678680
spin_unlock_bh(&xprt->transport_lock);
@@ -689,7 +691,7 @@ xprt_init_autodisconnect(unsigned long data)
689691
if (test_and_set_bit(XPRT_LOCKED, &xprt->state))
690692
goto out_abort;
691693
spin_unlock(&xprt->transport_lock);
692-
queue_work(rpciod_workqueue, &xprt->task_cleanup);
694+
queue_work(xprtiod_workqueue, &xprt->task_cleanup);
693695
return;
694696
out_abort:
695697
spin_unlock(&xprt->transport_lock);

net/sunrpc/xprtmultipath.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,12 @@ struct rpc_xprt *xprt_iter_next_entry_multiple(struct rpc_xprt_iter *xpi,
271271
xprt_switch_find_xprt_t find_next)
272272
{
273273
struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch);
274-
struct list_head *head;
275274

276275
if (xps == NULL)
277276
return NULL;
278-
head = &xps->xps_xprt_list;
279-
if (xps->xps_nxprts < 2)
280-
return xprt_switch_find_first_entry(head);
281-
return xprt_switch_set_next_cursor(head, &xpi->xpi_cursor, find_next);
277+
return xprt_switch_set_next_cursor(&xps->xps_xprt_list,
278+
&xpi->xpi_cursor,
279+
find_next);
282280
}
283281

284282
static

0 commit comments

Comments
 (0)