{
/* Make sure stores before this are seen on another CPU */
smp_wmb();
- fc->initialized = 1;
+ fc->chan->initialized = 1;
}
static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background)
{
- return !fc->initialized || (for_background && fc->blocked) ||
- (fc->io_uring && fc->connected && !fuse_uring_ready(fc));
+ return !fc->chan->initialized || (for_background && fc->chan->blocked) ||
+ (fc->io_uring && fc->chan->connected && !fuse_uring_ready(fc));
}
static void fuse_drop_waiting(struct fuse_conn *fc)
{
/*
- * lockess check of fc->connected is okay, because atomic_dec_and_test()
+ * lockess check of fc->chan->connected is okay, because atomic_dec_and_test()
* provides a memory barrier matched with the one in fuse_wait_aborted()
* to ensure no wake-up is missed.
*/
- if (atomic_dec_and_test(&fc->num_waiting) &&
- !READ_ONCE(fc->connected)) {
+ if (atomic_dec_and_test(&fc->chan->num_waiting) &&
+ !READ_ONCE(fc->chan->connected)) {
/* wake up aborters */
- wake_up_all(&fc->blocked_waitq);
+ wake_up_all(&fc->chan->blocked_waitq);
}
}
kgid_t fsgid;
int err;
- atomic_inc(&fc->num_waiting);
+ atomic_inc(&fc->chan->num_waiting);
if (fuse_block_alloc(fc, for_background)) {
err = -EINTR;
- if (wait_event_state_exclusive(fc->blocked_waitq,
+ if (wait_event_state_exclusive(fc->chan->blocked_waitq,
!fuse_block_alloc(fc, for_background),
(TASK_KILLABLE | TASK_FREEZABLE)))
goto out;
smp_rmb();
err = -ENOTCONN;
- if (!fc->connected)
+ if (!fc->chan->connected)
goto out;
err = -ECONNREFUSED;
err = -ENOMEM;
if (!req) {
if (for_background)
- wake_up(&fc->blocked_waitq);
+ wake_up(&fc->chan->blocked_waitq);
goto out;
}
* request was allocated but not sent
*/
spin_lock(&fc->chan->bg_lock);
- if (!fc->blocked)
- wake_up(&fc->blocked_waitq);
+ if (!fc->chan->blocked)
+ wake_up(&fc->chan->blocked_waitq);
spin_unlock(&fc->chan->bg_lock);
}
INIT_LIST_HEAD(&fch->devices);
spin_lock_init(&fch->bg_lock);
INIT_LIST_HEAD(&fch->bg_queue);
+ init_waitqueue_head(&fch->blocked_waitq);
+ atomic_set(&fch->num_waiting, 0);
fch->max_background = FUSE_DEFAULT_MAX_BACKGROUND;
+ fch->initialized = 0;
+ fch->blocked = 0;
+ fch->connected = 1;
return fch;
}
* - it was already set to a different fc
* - it was set to disconneted
*/
- fc->connected = 0;
+ fc->chan->connected = 0;
} else {
list_add_tail(&fud->entry, &fc->chan->devices);
fuse_conn_get(fc);
}
}
-void fuse_request_bg_finish(struct fuse_conn *fc, struct fuse_req *req)
+void fuse_request_bg_finish(struct fuse_chan *fch, struct fuse_req *req)
{
- lockdep_assert_held(&fc->chan->bg_lock);
+ lockdep_assert_held(&fch->bg_lock);
clear_bit(FR_BACKGROUND, &req->flags);
- if (fc->chan->num_background == fc->chan->max_background) {
- fc->blocked = 0;
- wake_up(&fc->blocked_waitq);
- } else if (!fc->blocked) {
+ if (fch->num_background == fch->max_background) {
+ fch->blocked = 0;
+ wake_up(&fch->blocked_waitq);
+ } else if (!fch->blocked) {
/*
* Wake up next waiter, if any. It's okay to use
* waitqueue_active(), as we've already synced up
- * fc->blocked with waiters with the wake_up() call
+ * fch->blocked with waiters with the wake_up() call
* above.
*/
- if (waitqueue_active(&fc->blocked_waitq))
- wake_up(&fc->blocked_waitq);
+ if (waitqueue_active(&fch->blocked_waitq))
+ wake_up(&fch->blocked_waitq);
}
- fc->chan->num_background--;
- fc->chan->active_background--;
+ fch->num_background--;
+ fch->active_background--;
}
/*
WARN_ON(test_bit(FR_SENT, &req->flags));
if (test_bit(FR_BACKGROUND, &req->flags)) {
spin_lock(&fc->chan->bg_lock);
- fuse_request_bg_finish(fc, req);
+ fuse_request_bg_finish(fc->chan, req);
flush_bg_queue(fc);
spin_unlock(&fc->chan->bg_lock);
} else {
ssize_t ret;
if (args->force) {
- atomic_inc(&fc->num_waiting);
+ atomic_inc(&fc->chan->num_waiting);
req = fuse_request_alloc(fm, GFP_KERNEL | __GFP_NOFAIL);
if (!args->nocreds)
WARN_ON(!test_bit(FR_BACKGROUND, &req->flags));
if (!test_bit(FR_WAITING, &req->flags)) {
__set_bit(FR_WAITING, &req->flags);
- atomic_inc(&fc->num_waiting);
+ atomic_inc(&fc->chan->num_waiting);
}
__set_bit(FR_ISREPLY, &req->flags);
#endif
spin_lock(&fc->chan->bg_lock);
- if (likely(fc->connected)) {
+ if (likely(fc->chan->connected)) {
fc->chan->num_background++;
if (fc->chan->num_background == fc->chan->max_background)
- fc->blocked = 1;
+ fc->chan->blocked = 1;
list_add_tail(&req->list, &fc->chan->bg_queue);
flush_bg_queue(fc);
queued = true;
unsigned int i;
spin_lock(&fc->lock);
- if (!fc->connected) {
+ if (!fc->chan->connected) {
spin_unlock(&fc->lock);
return;
}
* Only allow notifications during while the connection is in an
* initialized and connected state
*/
- if (!fc->initialized || !fc->connected)
+ if (!fc->chan->initialized || !fc->chan->connected)
return -EINVAL;
/* Don't try to move folios (yet) */
struct fuse_iqueue *fiq = &fc->chan->iq;
spin_lock(&fc->lock);
- if (fc->connected) {
+ if (fc->chan->connected) {
struct fuse_dev *fud;
struct fuse_req *req, *next;
LIST_HEAD(to_end);
if (fc->timeout.req_timeout)
cancel_delayed_work(&fc->timeout.work);
- /* Background queuing checks fc->connected under bg_lock */
+ /* Background queuing checks fc->chan->connected under bg_lock */
spin_lock(&fc->chan->bg_lock);
- fc->connected = 0;
+ fc->chan->connected = 0;
spin_unlock(&fc->chan->bg_lock);
fuse_set_initialized(fc);
spin_unlock(&fpq->lock);
}
spin_lock(&fc->chan->bg_lock);
- fc->blocked = 0;
+ fc->chan->blocked = 0;
fc->chan->max_background = UINT_MAX;
flush_bg_queue(fc);
spin_unlock(&fc->chan->bg_lock);
spin_unlock(&fiq->lock);
kill_fasync(&fiq->fasync, SIGIO, POLL_IN);
end_polls(fc);
- wake_up_all(&fc->blocked_waitq);
+ wake_up_all(&fc->chan->blocked_waitq);
spin_unlock(&fc->lock);
fuse_dev_end_requests(&to_end);
{
/* matches implicit memory barrier in fuse_drop_waiting() */
smp_mb();
- wait_event(fc->blocked_waitq, atomic_read(&fc->num_waiting) == 0);
+ wait_event(fc->chan->blocked_waitq, atomic_read(&fc->chan->num_waiting) == 0);
fuse_uring_wait_stopped_queues(fc);
}
if (test_bit(FR_BACKGROUND, &req->flags)) {
queue->active_background--;
spin_lock(&fc->chan->bg_lock);
- fuse_request_bg_finish(fc, req);
+ fuse_request_bg_finish(fc->chan, req);
fuse_uring_flush_bg(queue);
spin_unlock(&fc->chan->bg_lock);
}
max_payload_size = max(max_payload_size, fc->max_pages * PAGE_SIZE);
spin_lock(&fc->lock);
- if (!fc->connected) {
+ if (!fc->chan->connected) {
spin_unlock(&fc->lock);
goto out_err;
}
return err;
fpq = &queue->fpq;
- if (!READ_ONCE(fc->connected))
+ if (!READ_ONCE(fc->chan->connected))
return err;
spin_lock(&queue->lock);
spin_lock(&fc->lock);
/* abort teardown path is running or has run */
- if (!fc->connected) {
+ if (!fc->chan->connected) {
spin_unlock(&fc->lock);
if (atomic_dec_and_test(&ring->queue_refs))
wake_up_all(&ring->stop_waitq);
if (ready) {
WRITE_ONCE(fiq->ops, &fuse_io_uring_ops);
smp_store_release(&ring->ready, true);
- wake_up_all(&fc->blocked_waitq);
+ wake_up_all(&fc->chan->blocked_waitq);
}
}
return 0;
if (fc->aborted)
return -ECONNABORTED;
- if (!fc->connected)
+ if (!fc->chan->connected)
return -ENOTCONN;
/*
* fuse_uring_register() needs the ring to be initialized,
* we need to know the max payload size
*/
- if (!fc->initialized)
+ if (!fc->chan->initialized)
return -EAGAIN;
switch (cmd_op) {
pr_info_once("FUSE_IO_URING_CMD_REGISTER failed err=%d\n",
err);
fc->io_uring = 0;
- wake_up_all(&fc->blocked_waitq);
+ wake_up_all(&fc->chan->blocked_waitq);
return err;
}
break;
spin_lock(&fc->chan->bg_lock);
fc->chan->num_background++;
if (fc->chan->num_background == fc->chan->max_background)
- fc->blocked = 1;
+ fc->chan->blocked = 1;
fuse_uring_flush_bg(queue);
spin_unlock(&fc->chan->bg_lock);