]> 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:20:35 +0000 (14:20 +0200)
commit4f133fc9141abce906aae9615fe3e10c358701f2
tree4b0d01842bfd060adb9e0ba647c3a9dbbfc602ae
parentd465fedc9a9e97d6a17d82deb1c1abf1f0cd1339
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