Commit 99bc9f2
NFS: add barriers when testing for NFS_FSDATA_BLOCKED
dentry->d_fsdata is set to NFS_FSDATA_BLOCKED while unlinking or
renaming-over a file to ensure that no open succeeds while the NFS
operation progressed on the server.
Setting dentry->d_fsdata to NFS_FSDATA_BLOCKED is done under ->d_lock
after checking the refcount is not elevated. Any attempt to open the
file (through that name) will go through lookp_open() which will take
->d_lock while incrementing the refcount, we can be sure that once the
new value is set, __nfs_lookup_revalidate() *will* see the new value and
will block.
We don't have any locking guarantee that when we set ->d_fsdata to NULL,
the wait_var_event() in __nfs_lookup_revalidate() will notice.
wait/wake primitives do NOT provide barriers to guarantee order. We
must use smp_load_acquire() in wait_var_event() to ensure we look at an
up-to-date value, and must use smp_store_release() before wake_up_var().
This patch adds those barrier functions and factors out
block_revalidate() and unblock_revalidate() far clarity.
There is also a hypothetical bug in that if memory allocation fails
(which never happens in practice) we might leave ->d_fsdata locked.
This patch adds the missing call to unblock_revalidate().
Reported-and-tested-by: Richard Kojedzinszky <richard+debian+bugreport@kojedz.in>
Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1071501
Fixes: 3c59366 ("NFS: don't unhash dentry during unlink/rename")
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>1 parent 33c94d7 commit 99bc9f2
1 file changed
+32
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1803 | 1803 | | |
1804 | 1804 | | |
1805 | 1805 | | |
1806 | | - | |
| 1806 | + | |
1807 | 1807 | | |
1808 | | - | |
| 1808 | + | |
| 1809 | + | |
1809 | 1810 | | |
1810 | 1811 | | |
1811 | 1812 | | |
| |||
1818 | 1819 | | |
1819 | 1820 | | |
1820 | 1821 | | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
1821 | 1845 | | |
1822 | 1846 | | |
1823 | 1847 | | |
| |||
2551 | 2575 | | |
2552 | 2576 | | |
2553 | 2577 | | |
2554 | | - | |
2555 | | - | |
2556 | | - | |
| 2578 | + | |
2557 | 2579 | | |
2558 | 2580 | | |
2559 | 2581 | | |
2560 | 2582 | | |
2561 | | - | |
2562 | | - | |
| 2583 | + | |
2563 | 2584 | | |
2564 | 2585 | | |
2565 | 2586 | | |
| |||
2666 | 2687 | | |
2667 | 2688 | | |
2668 | 2689 | | |
2669 | | - | |
2670 | | - | |
| 2690 | + | |
2671 | 2691 | | |
2672 | 2692 | | |
2673 | 2693 | | |
| |||
2729 | 2749 | | |
2730 | 2750 | | |
2731 | 2751 | | |
2732 | | - | |
2733 | | - | |
2734 | | - | |
2735 | | - | |
2736 | | - | |
2737 | 2752 | | |
2738 | 2753 | | |
2739 | 2754 | | |
| |||
2755 | 2770 | | |
2756 | 2771 | | |
2757 | 2772 | | |
2758 | | - | |
| 2773 | + | |
2759 | 2774 | | |
2760 | 2775 | | |
2761 | 2776 | | |
| |||
2767 | 2782 | | |
2768 | 2783 | | |
2769 | 2784 | | |
| 2785 | + | |
| 2786 | + | |
2770 | 2787 | | |
2771 | 2788 | | |
2772 | 2789 | | |
| |||
0 commit comments