[Devel] [PATCH RHEL7 COMMIT] fs/fuse kio_pcs: protect valid_for_truncate() by m->lock's
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Oct 31 16:02:51 MSK 2018
The commit is pushed to "branch-rh7-3.10.0-862.14.4.vz7.72.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.14.4.vz7.72.15
------>
commit f528febb7ad631868854baf2e1dc5211baef0ecc
Author: Pavel Butsykin <pbutsykin at virtuozzo.com>
Date: Wed Oct 31 16:02:49 2018 +0300
fs/fuse kio_pcs: protect valid_for_truncate() by m->lock's
Access to m->state can be carried out only under m->lock.
This patch protects valid_for_truncate() by m->lock's and thereby fixes
unlocked access to m->state in process_ireq_truncate().
Signed-off-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
=====================
Patchset description:
FUSE KIO: Mapping truncate fixes
https://jira.sw.ru/browse/PSBM-89539
---
fs/fuse/kio/pcs/pcs_map.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index 73808dffb8df..81a1a2a62ca4 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -2354,12 +2354,16 @@ void map_submit(struct pcs_map_entry * m, struct pcs_int_request *ireq)
static int valid_for_truncate(struct pcs_map_entry * m, struct pcs_int_request *ireq)
{
+ spin_lock(&m->lock);
+
/* This weird test means that map is valid, but points to a hole. In this case
* truncate is noop.
*/
if ((m->state & (PCS_MAP_ERROR|PCS_MAP_RESOLVING|PCS_MAP_NEW|PCS_MAP_READABLE)) ==
- (PCS_MAP_NEW|PCS_MAP_READABLE))
+ (PCS_MAP_NEW|PCS_MAP_READABLE)) {
+ spin_unlock(&m->lock);
return 1;
+ }
/* If we already have valid map, remember its version
* and switch to the next phase: invalidation and requesting
@@ -2371,6 +2375,8 @@ static int valid_for_truncate(struct pcs_map_entry * m, struct pcs_int_request *
ireq->truncreq.version = m->version;
}
/* Otherwise lookup valid map first. */
+ spin_unlock(&m->lock);
+
return 0;
}
@@ -2495,10 +2501,8 @@ noinline void pcs_mapping_truncate(struct pcs_int_request *ireq, u64 old_size)
if (m == NULL)
queue = 1;
else {
- spin_lock(&m->lock);
if (!valid_for_truncate(m, ireq))
queue = 1;
- spin_unlock(&m->lock);
}
if (queue) {
More information about the Devel
mailing list