diff options
| author | Miklos Szeredi <mszeredi@redhat.com> | 2026-03-17 14:34:20 +0100 |
|---|---|---|
| committer | Miklos Szeredi <mszeredi@redhat.com> | 2026-06-15 14:06:15 +0200 |
| commit | 2b07cbc4e4865c246b5ba096def7fb9725d8cc1d (patch) | |
| tree | 74d94c07ad40e7451892824b3855aba0c74ce37e /fs/fuse/dev.c | |
| parent | 4e0de84063159aa1804120c6c5493bd05be35adf (diff) | |
| download | linux-2b07cbc4e4865c246b5ba096def7fb9725d8cc1d.tar.gz linux-2b07cbc4e4865c246b5ba096def7fb9725d8cc1d.zip | |
fuse: move background queuing related members to fuse_chan
Move:
- max_background
- num_background
- active_background
- bg_queue
- bg_lock
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse/dev.c')
| -rw-r--r-- | fs/fuse/dev.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 41834108bcc1..1a22d9004c85 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -181,10 +181,10 @@ static void fuse_put_request(struct fuse_req *req) * We get here in the unlikely case that a background * request was allocated but not sent */ - spin_lock(&fc->bg_lock); + spin_lock(&fc->chan->bg_lock); if (!fc->blocked) wake_up(&fc->blocked_waitq); - spin_unlock(&fc->bg_lock); + spin_unlock(&fc->chan->bg_lock); } if (test_bit(FR_WAITING, &req->flags)) { @@ -355,6 +355,9 @@ struct fuse_chan *fuse_chan_new(void) return NULL; INIT_LIST_HEAD(&fch->devices); + spin_lock_init(&fch->bg_lock); + INIT_LIST_HEAD(&fch->bg_queue); + fch->max_background = FUSE_DEFAULT_MAX_BACKGROUND; return fch; } @@ -489,23 +492,23 @@ static void flush_bg_queue(struct fuse_conn *fc) { struct fuse_iqueue *fiq = &fc->chan->iq; - while (fc->active_background < fc->max_background && - !list_empty(&fc->bg_queue)) { + while (fc->chan->active_background < fc->chan->max_background && + !list_empty(&fc->chan->bg_queue)) { struct fuse_req *req; - req = list_first_entry(&fc->bg_queue, struct fuse_req, list); + req = list_first_entry(&fc->chan->bg_queue, struct fuse_req, list); list_del(&req->list); - fc->active_background++; + fc->chan->active_background++; fuse_send_one(fiq, req); } } void fuse_request_bg_finish(struct fuse_conn *fc, struct fuse_req *req) { - lockdep_assert_held(&fc->bg_lock); + lockdep_assert_held(&fc->chan->bg_lock); clear_bit(FR_BACKGROUND, &req->flags); - if (fc->num_background == fc->max_background) { + if (fc->chan->num_background == fc->chan->max_background) { fc->blocked = 0; wake_up(&fc->blocked_waitq); } else if (!fc->blocked) { @@ -519,8 +522,8 @@ void fuse_request_bg_finish(struct fuse_conn *fc, struct fuse_req *req) wake_up(&fc->blocked_waitq); } - fc->num_background--; - fc->active_background--; + fc->chan->num_background--; + fc->chan->active_background--; } /* @@ -554,10 +557,10 @@ void fuse_request_end(struct fuse_req *req) WARN_ON(test_bit(FR_PENDING, &req->flags)); WARN_ON(test_bit(FR_SENT, &req->flags)); if (test_bit(FR_BACKGROUND, &req->flags)) { - spin_lock(&fc->bg_lock); + spin_lock(&fc->chan->bg_lock); fuse_request_bg_finish(fc, req); flush_bg_queue(fc); - spin_unlock(&fc->bg_lock); + spin_unlock(&fc->chan->bg_lock); } else { /* Wake up waiter sleeping in request_wait_answer() */ wake_up(&req->waitq); @@ -803,16 +806,16 @@ static int fuse_request_queue_background(struct fuse_req *req) return fuse_request_queue_background_uring(fc, req); #endif - spin_lock(&fc->bg_lock); + spin_lock(&fc->chan->bg_lock); if (likely(fc->connected)) { - fc->num_background++; - if (fc->num_background == fc->max_background) + fc->chan->num_background++; + if (fc->chan->num_background == fc->chan->max_background) fc->blocked = 1; - list_add_tail(&req->list, &fc->bg_queue); + list_add_tail(&req->list, &fc->chan->bg_queue); flush_bg_queue(fc); queued = true; } - spin_unlock(&fc->bg_lock); + spin_unlock(&fc->chan->bg_lock); return queued; } @@ -2534,9 +2537,9 @@ void fuse_abort_conn(struct fuse_conn *fc) cancel_delayed_work(&fc->timeout.work); /* Background queuing checks fc->connected under bg_lock */ - spin_lock(&fc->bg_lock); + spin_lock(&fc->chan->bg_lock); fc->connected = 0; - spin_unlock(&fc->bg_lock); + spin_unlock(&fc->chan->bg_lock); fuse_set_initialized(fc); list_for_each_entry(fud, &fc->chan->devices, entry) { @@ -2560,11 +2563,11 @@ void fuse_abort_conn(struct fuse_conn *fc) &to_end); spin_unlock(&fpq->lock); } - spin_lock(&fc->bg_lock); + spin_lock(&fc->chan->bg_lock); fc->blocked = 0; - fc->max_background = UINT_MAX; + fc->chan->max_background = UINT_MAX; flush_bg_queue(fc); - spin_unlock(&fc->bg_lock); + spin_unlock(&fc->chan->bg_lock); spin_lock(&fiq->lock); fiq->connected = 0; |
