Commit 1054e8f
nfsd: prevent callback tasks running concurrently
The nfsd4_callback workqueue jobs exist to queue backchannel RPCs to
rpciod. Because they run in different workqueue contexts, the rpc_task
can run concurrently with the workqueue job itself, should it become
requeued. This is problematic as there is no locking when accessing the
fields in the nfsd4_callback.
Add a new unsigned long to nfsd4_callback and declare a new
NFSD4_CALLBACK_RUNNING flag to be set in it. When attempting to run a
workqueue job, do a test_and_set_bit() on that flag first, and don't
queue the workqueue job if it returns true. Clear NFSD4_CALLBACK_RUNNING
in nfsd41_destroy_cb().
This also gives us a more reliable mechanism for handling queueing
failures in codepaths where we have to take references under spinlocks.
We can now do the test_and_set_bit on NFSD4_CALLBACK_RUNNING first, and
only take references to the objects if that returns false.
Most of the nfsd4_run_cb() callers are converted to use this new flag or
the nfsd4_try_run_cb() wrapper. The main exception is the callback
channel probe, which has its own synchronization.
Signed-off-by: Jeff Layton <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>1 parent 9254c8a commit 1054e8f
File tree
5 files changed
+26
-8
lines changed- fs/nfsd
5 files changed
+26
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1312 | 1312 | | |
1313 | 1313 | | |
1314 | 1314 | | |
| 1315 | + | |
1315 | 1316 | | |
1316 | 1317 | | |
1317 | 1318 | | |
| |||
1632 | 1633 | | |
1633 | 1634 | | |
1634 | 1635 | | |
| 1636 | + | |
1635 | 1637 | | |
1636 | 1638 | | |
1637 | 1639 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
348 | | - | |
349 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
350 | 351 | | |
351 | 352 | | |
352 | 353 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1847 | 1847 | | |
1848 | 1848 | | |
1849 | 1849 | | |
1850 | | - | |
| 1850 | + | |
1851 | 1851 | | |
1852 | 1852 | | |
1853 | 1853 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3232 | 3232 | | |
3233 | 3233 | | |
3234 | 3234 | | |
3235 | | - | |
3236 | | - | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
3237 | 3239 | | |
3238 | 3240 | | |
3239 | 3241 | | |
| |||
5422 | 5424 | | |
5423 | 5425 | | |
5424 | 5426 | | |
| 5427 | + | |
| 5428 | + | |
| 5429 | + | |
| 5430 | + | |
5425 | 5431 | | |
5426 | 5432 | | |
5427 | 5433 | | |
| |||
6910 | 6916 | | |
6911 | 6917 | | |
6912 | 6918 | | |
6913 | | - | |
| 6919 | + | |
6914 | 6920 | | |
6915 | 6921 | | |
6916 | 6922 | | |
| |||
7839 | 7845 | | |
7840 | 7846 | | |
7841 | 7847 | | |
7842 | | - | |
| 7848 | + | |
7843 | 7849 | | |
7844 | 7850 | | |
7845 | 7851 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
780 | 782 | | |
781 | 783 | | |
782 | 784 | | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
783 | 792 | | |
784 | 793 | | |
785 | 794 | | |
| |||
0 commit comments