Skip to content

Commit e16714d

Browse files
author
Miklos Szeredi
committed
fuse: duplicate ->connected in iqueue
This will allow checking ->connected just with the input queue lock. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Reviewed-by: Ashish Samant <ashish.samant@oracle.com>
1 parent f88996a commit e16714d

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎fs/fuse/cuse.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,6 @@ static int cuse_channel_open(struct inode *inode, struct file *file)
502502
INIT_LIST_HEAD(&cc->list);
503503
cc->fc.release = cuse_fc_release;
504504

505-
cc->fc.connected = 1;
506505
cc->fc.initialized = 1;
507506
rc = cuse_send_init(cc);
508507
if (rc) {

‎fs/fuse/dev.c‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
341341
forget->forget_one.nlookup = nlookup;
342342

343343
spin_lock(&fc->lock);
344-
if (fc->connected) {
344+
if (fiq->connected) {
345345
fiq->forget_list_tail->next = forget;
346346
fiq->forget_list_tail = forget;
347347
wake_up(&fiq->waitq);
@@ -471,14 +471,14 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
471471

472472
static void __fuse_request_send(struct fuse_conn *fc, struct fuse_req *req)
473473
{
474+
struct fuse_iqueue *fiq = &fc->iq;
475+
474476
BUG_ON(test_bit(FR_BACKGROUND, &req->flags));
475477
spin_lock(&fc->lock);
476-
if (!fc->connected) {
478+
if (!fiq->connected) {
477479
spin_unlock(&fc->lock);
478480
req->out.h.error = -ENOTCONN;
479481
} else {
480-
struct fuse_iqueue *fiq = &fc->iq;
481-
482482
req->in.h.unique = fuse_get_unique(fiq);
483483
queue_request(fiq, req);
484484
/* acquire extra reference, since request is still needed
@@ -619,7 +619,7 @@ static int fuse_request_send_notify_reply(struct fuse_conn *fc,
619619
__clear_bit(FR_ISREPLY, &req->flags);
620620
req->in.h.unique = unique;
621621
spin_lock(&fc->lock);
622-
if (fc->connected) {
622+
if (fiq->connected) {
623623
queue_request(fiq, req);
624624
err = 0;
625625
}
@@ -1071,7 +1071,7 @@ __acquires(fc->lock)
10711071
DECLARE_WAITQUEUE(wait, current);
10721072

10731073
add_wait_queue_exclusive(&fiq->waitq, &wait);
1074-
while (fc->connected && !request_pending(fiq)) {
1074+
while (fiq->connected && !request_pending(fiq)) {
10751075
set_current_state(TASK_INTERRUPTIBLE);
10761076
if (signal_pending(current))
10771077
break;
@@ -1261,13 +1261,13 @@ static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
12611261
restart:
12621262
spin_lock(&fc->lock);
12631263
err = -EAGAIN;
1264-
if ((file->f_flags & O_NONBLOCK) && fc->connected &&
1264+
if ((file->f_flags & O_NONBLOCK) && fiq->connected &&
12651265
!request_pending(fiq))
12661266
goto err_unlock;
12671267

12681268
request_wait(fc);
12691269
err = -ENODEV;
1270-
if (!fc->connected)
1270+
if (!fiq->connected)
12711271
goto err_unlock;
12721272
err = -ERESTARTSYS;
12731273
if (!request_pending(fiq))
@@ -2054,7 +2054,7 @@ static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
20542054
poll_wait(file, &fiq->waitq, wait);
20552055

20562056
spin_lock(&fc->lock);
2057-
if (!fc->connected)
2057+
if (!fiq->connected)
20582058
mask = POLLERR;
20592059
else if (request_pending(fiq))
20602060
mask |= POLLIN | POLLRDNORM;
@@ -2127,6 +2127,7 @@ void fuse_abort_conn(struct fuse_conn *fc)
21272127
LIST_HEAD(to_end2);
21282128

21292129
fc->connected = 0;
2130+
fiq->connected = 0;
21302131
fc->blocked = 0;
21312132
fuse_set_initialized(fc);
21322133
list_for_each_entry_safe(req, next, &fc->io, list) {

‎fs/fuse/fuse_i.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ struct fuse_req {
375375
};
376376

377377
struct fuse_iqueue {
378+
/** Connection established */
379+
unsigned connected;
380+
378381
/** Readers of the connection are waiting on this */
379382
wait_queue_head_t waitq;
380383

‎fs/fuse/inode.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ static void fuse_iqueue_init(struct fuse_iqueue *fiq)
574574
INIT_LIST_HEAD(&fiq->pending);
575575
INIT_LIST_HEAD(&fiq->interrupts);
576576
fiq->forget_list_tail = &fiq->forget_list_head;
577+
fiq->connected = 1;
577578
}
578579

579580
void fuse_conn_init(struct fuse_conn *fc)
@@ -596,6 +597,7 @@ void fuse_conn_init(struct fuse_conn *fc)
596597
fc->polled_files = RB_ROOT;
597598
fc->blocked = 0;
598599
fc->initialized = 0;
600+
fc->connected = 1;
599601
fc->attr_version = 1;
600602
get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key));
601603
}
@@ -1084,7 +1086,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
10841086

10851087
list_add_tail(&fc->entry, &fuse_conn_list);
10861088
sb->s_root = root_dentry;
1087-
fc->connected = 1;
10881089
file->private_data = fuse_conn_get(fc);
10891090
mutex_unlock(&fuse_mutex);
10901091
/*

0 commit comments

Comments
 (0)