]> git.proxmox.com Git - pve-cluster.git/commit
cfs-func-plug: use RW lock for safe cached data access
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 21 Sep 2017 12:08:00 +0000 (14:08 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 21 Sep 2017 12:27:58 +0000 (14:27 +0200)
commit77b98e816f938a35820c34e14db57ff48a4740ae
tree30ef8dd2dc56ffee5d77b6029adfb03d7230e5c9
parent31e10190497d3da8542f2838caad27d40c59b9b7
cfs-func-plug: use RW lock for safe cached data access

fuse may spawn multiple threads if there are concurrent accesses.

Our virtual files, e.g. ".members", ".rrd", are registered over our
"func" cfs plug which is a bit special.

For each unique virtual file there exists a single cfs_plug_func_t
instance, shared between all threads.
As we directly operated unlocked on members of this structure
parallel accesses raced between each other.
This could result in quite visible problems like a crash after a
double free (Bug 1504) or in less noticeable effects where one thread
may read from an inconsistent, or already freed memory region.

Add a Reader/Writer lock to efficiently address this problem.
Other plugs implement more functions and use a mutex to ensure
consistency and thus do not have this problem.

Fixes: #1504
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/src/cfs-plug-func.c
data/src/cfs-plug.h