Skip to content

Commit 9587fde

Browse files
Yuto OhnukiMiklos Szeredi
authored andcommitted
fuse: refactor duplicate queue teardown operation
Extract common queue iteration and teardown logic into fuse_uring_teardown_all_queues() helper function to eliminate code duplication between fuse_uring_async_stop_queues() and fuse_uring_stop_queues(). This is a pure refactoring with no functional changes, intended to improve maintainability. Signed-off-by: Yuto Ohnuki <ytohnuki@amazon.com> Reviewed-by: Bernd Schubert <bernd@bsbernd.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 68b69fa commit 9587fde

1 file changed

Lines changed: 16 additions & 20 deletions

File tree

fs/fuse/dev_uring.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,20 @@ static void fuse_uring_teardown_entries(struct fuse_ring_queue *queue)
397397
FRRS_AVAILABLE);
398398
}
399399

400+
static void fuse_uring_teardown_all_queues(struct fuse_ring *ring)
401+
{
402+
int qid;
403+
404+
for (qid = 0; qid < ring->nr_queues; qid++) {
405+
struct fuse_ring_queue *queue = READ_ONCE(ring->queues[qid]);
406+
407+
if (!queue)
408+
continue;
409+
410+
fuse_uring_teardown_entries(queue);
411+
}
412+
}
413+
400414
/*
401415
* Log state debug info
402416
*/
@@ -431,19 +445,10 @@ static void fuse_uring_log_ent_state(struct fuse_ring *ring)
431445

432446
static void fuse_uring_async_stop_queues(struct work_struct *work)
433447
{
434-
int qid;
435448
struct fuse_ring *ring =
436449
container_of(work, struct fuse_ring, async_teardown_work.work);
437450

438-
/* XXX code dup */
439-
for (qid = 0; qid < ring->nr_queues; qid++) {
440-
struct fuse_ring_queue *queue = READ_ONCE(ring->queues[qid]);
441-
442-
if (!queue)
443-
continue;
444-
445-
fuse_uring_teardown_entries(queue);
446-
}
451+
fuse_uring_teardown_all_queues(ring);
447452

448453
/*
449454
* Some ring entries might be in the middle of IO operations,
@@ -469,16 +474,7 @@ static void fuse_uring_async_stop_queues(struct work_struct *work)
469474
*/
470475
void fuse_uring_stop_queues(struct fuse_ring *ring)
471476
{
472-
int qid;
473-
474-
for (qid = 0; qid < ring->nr_queues; qid++) {
475-
struct fuse_ring_queue *queue = READ_ONCE(ring->queues[qid]);
476-
477-
if (!queue)
478-
continue;
479-
480-
fuse_uring_teardown_entries(queue);
481-
}
477+
fuse_uring_teardown_all_queues(ring);
482478

483479
if (atomic_read(&ring->queue_refs) > 0) {
484480
ring->teardown_time = jiffies;

0 commit comments

Comments
 (0)