[Devel] [PATCH v2 1/4] fs/fuse kio_pcs: move pcs_ireq_queue_fail()

Pavel Butsykin pbutsykin at virtuozzo.com
Sat Jun 9 16:07:22 MSK 2018


The pcs internal request queue may be waiting not only for mapping ioctl's,
but also for FUSE_SETATTR ioctl within fuse_size_grow_work(). Thus,
pcs_ireq_queue_fail() looks like a common interface to complete with an error
all pending ireq's.

This patch moves pcs_ireq_queue_fail() from pcs_map.c to pcs_req.c and make it
exported.

Signed-off-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_map.c | 34 ----------------------------------
 fs/fuse/kio/pcs/pcs_req.c | 31 +++++++++++++++++++++++++++++++
 fs/fuse/kio/pcs/pcs_req.h |  2 ++
 3 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index 9a05e247fe47..f20db1d5b3f9 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -36,8 +36,6 @@ static struct pcs_cs_list *cs_link_to_cs_list(struct pcs_cs_link *csl)
 	return cs_list;
 }
 
-static void pcs_ireq_queue_fail(struct list_head *queue, int error);
-
 abs_time_t get_real_time_ms(void)
 {
 	struct timespec tv = current_kernel_time();
@@ -151,7 +149,6 @@ static void pcs_map_reset(struct pcs_map_entry * m)
 {
 	m->state &= ~(PCS_MAP_READABLE|PCS_MAP_WRITEABLE);
 }
-static void pcs_ireq_queue_fail(struct list_head *queue, int error);
 static void map_sync_work_add(struct pcs_map_entry *m, unsigned long timeout);
 static void map_sync_work_del(struct pcs_map_entry *m);
 
@@ -758,37 +755,6 @@ unlock:
 	BUG_ON(cs->is_dead);
 }
 
-noinline static void pcs_ireq_queue_fail(struct list_head *queue, int error)
-{
-	while (!list_empty(queue)) {
-		struct pcs_int_request *ireq = list_first_entry(queue, struct pcs_int_request, list);
-
-		list_del_init(&ireq->list);
-
-		pcs_set_local_error(&ireq->error, error);
-
-		if (ireq->type == PCS_IREQ_TRUNCATE) {
-			ireq_on_error(ireq);
-
-			if (!(ireq->flags & IREQ_F_FATAL)) {
-				if (ireq_is_timed_out(ireq)) {
-					pcs_log(LOG_ERR, "timeout while truncate(%d) request on \"" DENTRY_FMT "\" last err=%u",
-						ireq->type, DENTRY_ARGS(ireq->dentry), ireq->error.value);
-					BUG();
-				}
-				pcs_clear_error(&ireq->error);
-
-				TRACE("requeue truncate(%d) %llu@" DENTRY_FMT "\n", ireq->type,
-				      (unsigned long long)ireq->truncreq.offset, DENTRY_ARGS(ireq->dentry));
-
-				ireq_delay(ireq);
-				continue;
-			}
-		}
-		ireq_complete(ireq);
-	}
-}
-
 void transfer_sync_data(struct pcs_cs_list * new_cs_list, struct pcs_cs_list * old_cs_list)
 {
 	int i, k;
diff --git a/fs/fuse/kio/pcs/pcs_req.c b/fs/fuse/kio/pcs/pcs_req.c
index a05f1e43c94c..9516768c47d4 100644
--- a/fs/fuse/kio/pcs/pcs_req.c
+++ b/fs/fuse/kio/pcs/pcs_req.c
@@ -121,3 +121,34 @@ void ireq_handle_hole(struct pcs_int_request *ireq)
 
 	ireq_complete(ireq);
 }
+
+noinline void pcs_ireq_queue_fail(struct list_head *queue, int error)
+{
+	while (!list_empty(queue)) {
+		struct pcs_int_request *ireq = list_first_entry(queue, struct pcs_int_request, list);
+
+		list_del_init(&ireq->list);
+
+		pcs_set_local_error(&ireq->error, error);
+
+		if (ireq->type == PCS_IREQ_TRUNCATE) {
+			ireq_on_error(ireq);
+
+			if (!(ireq->flags & IREQ_F_FATAL)) {
+				if (ireq_is_timed_out(ireq)) {
+					pcs_log(LOG_ERR, "timeout while truncate(%d) request on \"" DENTRY_FMT "\" last err=%u",
+						ireq->type, DENTRY_ARGS(ireq->dentry), ireq->error.value);
+					BUG();
+				}
+				pcs_clear_error(&ireq->error);
+
+				TRACE("requeue truncate(%d) %llu@" DENTRY_FMT "\n", ireq->type,
+				      (unsigned long long)ireq->truncreq.offset, DENTRY_ARGS(ireq->dentry));
+
+				ireq_delay(ireq);
+				continue;
+			}
+		}
+		ireq_complete(ireq);
+	}
+}
diff --git a/fs/fuse/kio/pcs/pcs_req.h b/fs/fuse/kio/pcs/pcs_req.h
index 6f49018e3988..557e8e476856 100644
--- a/fs/fuse/kio/pcs/pcs_req.h
+++ b/fs/fuse/kio/pcs/pcs_req.h
@@ -332,4 +332,6 @@ void ireq_handle_hole(struct pcs_int_request *ireq);
 
 void pcs_process_ireq(struct pcs_int_request *ireq);
 
+void pcs_ireq_queue_fail(struct list_head *queue, int error);
+
 #endif /* _PCS_REQ_H_ */
-- 
2.15.1



More information about the Devel mailing list