[Devel] [PATCH RHEL10 COMMIT] fs/fuse kio: remove unused PCS_IREQ_TRUNCATE handling

Konstantin Khorenko khorenko at virtuozzo.com
Mon Nov 10 23:18:06 MSK 2025


The commit is pushed to "branch-rh10-6.12.0-55.13.1.2.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-55.13.1.2.16.vz10
------>
commit 99a6925892d58b5f9e0e0dd0089ba4952b7892b1
Author: Liu Kui <kui.liu at virtuozzo.com>
Date:   Thu Nov 6 10:14:21 2025 +0800

    fs/fuse kio: remove unused PCS_IREQ_TRUNCATE handling
    
    The PCS_IREQ_TRUNCATE request type is not used in the kio module,
    remove the associated dead code.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-116825
    
    Signed-off-by: Liu Kui <kui.liu at virtuozzo.com>
    
    Feature: vStorage
---
 fs/fuse/kio/pcs/pcs_cluster.c |   3 --
 fs/fuse/kio/pcs/pcs_map.c     | 100 ------------------------------------------
 fs/fuse/kio/pcs/pcs_map.h     |   1 -
 fs/fuse/kio/pcs/pcs_req.c     |  14 ------
 4 files changed, 118 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_cluster.c b/fs/fuse/kio/pcs/pcs_cluster.c
index 37bc30fcaa0d0..bd35b34c8f459 100644
--- a/fs/fuse/kio/pcs/pcs_cluster.c
+++ b/fs/fuse/kio/pcs/pcs_cluster.c
@@ -489,9 +489,6 @@ static void ireq_process_(struct pcs_int_request *ireq)
 	case PCS_IREQ_FLUSH:
 		process_flush_req(ireq);
 		break;
-	case PCS_IREQ_TRUNCATE:
-		process_ireq_truncate(ireq);
-		break;
 	case PCS_IREQ_CUSTOM:
 		ireq->custom.action(ireq);
 		break;
diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index 45feb4beb081c..44e463a61c3f2 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -2538,106 +2538,6 @@ void map_submit(struct pcs_map_entry * m, struct pcs_int_request *ireq)
 	} while (!done);
 }
 
-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)) {
-		spin_unlock(&m->lock);
-		return 1;
-	}
-
-	/* If we already have valid map, remember its version
-	 * and switch to the next phase: invalidation and requesting
-	 * new map.
-	 */
-	if (!(m->state & (PCS_MAP_ERROR|PCS_MAP_RESOLVING|PCS_MAP_NEW))) {
-		map_remote_error_nolock(m, PCS_ERR_CSD_STALE_MAP, m->cs_list ? m->cs_list->cs[0].info.id.val : 0);
-		ireq->truncreq.phase = 1;
-		ireq->truncreq.version = m->version;
-	}
-	/* Otherwise lookup valid map first. */
-	spin_unlock(&m->lock);
-
-	return 0;
-}
-
-
-//// TODO: truncate should probably synhroniously truncate local mapping.
-void process_ireq_truncate(struct pcs_int_request *ireq)
-{
-	struct pcs_dentry_info *di = ireq->dentry;
-	struct pcs_map_entry * m;
-	u64 end;
-
-	/* Special case: full truncate */
-	if (ireq->truncreq.offset == 0) {
-		map_truncate_tail(&di->mapping, 0);
-		ireq_complete(ireq);
-		return;
-	}
-
-	m = pcs_find_get_map(di, ireq->truncreq.offset - 1);
-
-	FUSE_KTRACE(ireq->cc->fc, "process TRUNCATE %llu@" DENTRY_FMT " %x",
-	      (unsigned long long)ireq->truncreq.offset, DENTRY_ARGS(di), m ? m->state : -1);
-
-	if (m == NULL) {
-		map_queue_on_limit(ireq);
-		return;
-	}
-	end = map_chunk_end(m);
-	if (end <= ireq->truncreq.offset)
-		goto truncate_tail;
-
-	if (ireq->truncreq.phase == 0) {
-		if (valid_for_truncate(m, ireq))
-			goto truncate_tail;
-	} else {
-		/* We already had some valid map. Must get new one. */
-		spin_lock(&m->lock);
-		if ((m->state & (PCS_MAP_ERROR|PCS_MAP_RESOLVING|PCS_MAP_NEW|PCS_MAP_READABLE)) ==
-		    (PCS_MAP_NEW|PCS_MAP_READABLE)) {
-
-			spin_unlock(&m->lock);
-			FUSE_KLOG(cc_from_maps(m->maps)->fc, LOG_INFO, "map " MAP_FMT " unexpectedly converted to hole", MAP_ARGS(m));
-			goto truncate_tail;
-		}
-
-		if (m->state & PCS_MAP_RESOLVING) {
-			list_add_tail(&ireq->list, &m->queue);
-			spin_unlock(&m->lock);
-			pcs_map_put(m);
-			return;
-		}
-
-		if (!(m->state & (PCS_MAP_ERROR|PCS_MAP_NEW))) {
-			if (map_version_compare(&m->version, &ireq->truncreq.version) > 0) {
-				spin_unlock(&m->lock);
-				goto truncate_tail;
-			}
-
-			FUSE_KTRACE(ireq->cc->fc, "map " MAP_FMT " is not updated yet", MAP_ARGS(m));
-			map_remote_error_nolock(m, PCS_ERR_CSD_STALE_MAP, m->cs_list ? m->cs_list->cs[0].info.id.val : 0);
-
-		}
-		spin_unlock(&m->lock);
-	}
-	pcs_map_queue_resolve(m, ireq, 1);
-	pcs_map_put(m);
-	return;
-
-truncate_tail:
-       map_truncate_tail(&di->mapping, end);
-       ireq_complete(ireq);
-       pcs_map_put(m);
-       return;
-}
-
 /*
  * Taking into account that user-client does proper map invalidation at resize,
  * we don't need to completely copy the functionality of pcs_mapping_truncate().
diff --git a/fs/fuse/kio/pcs/pcs_map.h b/fs/fuse/kio/pcs/pcs_map.h
index b96b8cbf83b72..56feeac497f33 100644
--- a/fs/fuse/kio/pcs/pcs_map.h
+++ b/fs/fuse/kio/pcs/pcs_map.h
@@ -199,7 +199,6 @@ void pcs_mapping_open(struct pcs_mapping * mapping);
 void pcs_mapping_invalidate(struct pcs_mapping * mapping);
 void pcs_mapping_deinit(struct pcs_mapping * mapping);
 void pcs_mapping_truncate(struct pcs_dentry_info *di, u64 new_size);
-void process_ireq_truncate(struct pcs_int_request *ireq);
 
 struct pcs_map_entry * pcs_find_get_map(struct pcs_dentry_info * de, u64 chunk);
 void map_submit(struct pcs_map_entry * m, struct pcs_int_request *ireq);
diff --git a/fs/fuse/kio/pcs/pcs_req.c b/fs/fuse/kio/pcs/pcs_req.c
index 66b535dd7d0be..67b2daf509d2c 100644
--- a/fs/fuse/kio/pcs/pcs_req.c
+++ b/fs/fuse/kio/pcs/pcs_req.c
@@ -134,20 +134,6 @@ noinline void pcs_ireq_queue_fail(struct list_head *queue, int error)
 
 		pcs_set_local_error(&ireq->error, error);
 
-		if (ireq->type == PCS_IREQ_TRUNCATE) {
-			ireq_on_error(ireq);
-
-			if (!(ireq->flags & IREQ_F_FATAL)) {
-				ireq_retry_inc(ireq);
-				pcs_clear_error(&ireq->error);
-
-				FUSE_KTRACE(ireq->cc->fc, "requeue truncate(%d) %llu@" DENTRY_FMT, ireq->type,
-				      (unsigned long long)ireq->truncreq.offset, DENTRY_ARGS(ireq->dentry));
-
-				ireq_delay(ireq);
-				continue;
-			}
-		}
 		ireq_complete(ireq);
 	}
 }


More information about the Devel mailing list