fuse: clean up aborted

The only caller that needs fc->aborted set is fuse_conn_abort_write().
Setting fc->aborted is now racy (fuse_abort_conn() may already be in
progress or finished) but there's no reason to care.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Miklos Szeredi 2019-01-24 10:40:16 +01:00
parent 6b675738ce
commit eb98e3bdf3
5 changed files with 12 additions and 11 deletions

View File

@ -35,7 +35,9 @@ static ssize_t fuse_conn_abort_write(struct file *file, const char __user *buf,
{ {
struct fuse_conn *fc = fuse_ctl_file_conn_get(file); struct fuse_conn *fc = fuse_ctl_file_conn_get(file);
if (fc) { if (fc) {
fuse_abort_conn(fc, true); if (fc->abort_err)
fc->aborted = true;
fuse_abort_conn(fc);
fuse_conn_put(fc); fuse_conn_put(fc);
} }
return count; return count;

View File

@ -408,7 +408,7 @@ static void cuse_process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
err_region: err_region:
unregister_chrdev_region(devt, 1); unregister_chrdev_region(devt, 1);
err: err:
fuse_abort_conn(fc, false); fuse_abort_conn(fc);
goto out; goto out;
} }
@ -587,7 +587,7 @@ static ssize_t cuse_class_abort_store(struct device *dev,
{ {
struct cuse_conn *cc = dev_get_drvdata(dev); struct cuse_conn *cc = dev_get_drvdata(dev);
fuse_abort_conn(&cc->fc, false); fuse_abort_conn(&cc->fc);
return count; return count;
} }
static DEVICE_ATTR(abort, 0200, NULL, cuse_class_abort_store); static DEVICE_ATTR(abort, 0200, NULL, cuse_class_abort_store);

View File

@ -1330,7 +1330,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
goto err_unlock; goto err_unlock;
if (!fiq->connected) { if (!fiq->connected) {
err = (fc->aborted && fc->abort_err) ? -ECONNABORTED : -ENODEV; err = fc->aborted ? -ECONNABORTED : -ENODEV;
goto err_unlock; goto err_unlock;
} }
@ -1377,7 +1377,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
spin_lock(&fpq->lock); spin_lock(&fpq->lock);
clear_bit(FR_LOCKED, &req->flags); clear_bit(FR_LOCKED, &req->flags);
if (!fpq->connected) { if (!fpq->connected) {
err = (fc->aborted && fc->abort_err) ? -ECONNABORTED : -ENODEV; err = fc->aborted ? -ECONNABORTED : -ENODEV;
goto out_end; goto out_end;
} }
if (err) { if (err) {
@ -2177,7 +2177,7 @@ static void end_polls(struct fuse_conn *fc)
* is OK, the request will in that case be removed from the list before we touch * is OK, the request will in that case be removed from the list before we touch
* it. * it.
*/ */
void fuse_abort_conn(struct fuse_conn *fc, bool is_abort) void fuse_abort_conn(struct fuse_conn *fc)
{ {
struct fuse_iqueue *fiq = &fc->iq; struct fuse_iqueue *fiq = &fc->iq;
@ -2193,7 +2193,6 @@ void fuse_abort_conn(struct fuse_conn *fc, bool is_abort)
fc->connected = 0; fc->connected = 0;
spin_unlock(&fc->bg_lock); spin_unlock(&fc->bg_lock);
fc->aborted = is_abort;
fuse_set_initialized(fc); fuse_set_initialized(fc);
list_for_each_entry(fud, &fc->devices, entry) { list_for_each_entry(fud, &fc->devices, entry) {
struct fuse_pqueue *fpq = &fud->pq; struct fuse_pqueue *fpq = &fud->pq;
@ -2271,7 +2270,7 @@ int fuse_dev_release(struct inode *inode, struct file *file)
/* Are we the last open device? */ /* Are we the last open device? */
if (atomic_dec_and_test(&fc->dev_count)) { if (atomic_dec_and_test(&fc->dev_count)) {
WARN_ON(fc->iq.fasync != NULL); WARN_ON(fc->iq.fasync != NULL);
fuse_abort_conn(fc, false); fuse_abort_conn(fc);
} }
fuse_dev_free(fud); fuse_dev_free(fud);
} }

View File

@ -947,7 +947,7 @@ void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req);
bool fuse_request_queue_background(struct fuse_conn *fc, struct fuse_req *req); bool fuse_request_queue_background(struct fuse_conn *fc, struct fuse_req *req);
/* Abort all requests */ /* Abort all requests */
void fuse_abort_conn(struct fuse_conn *fc, bool is_abort); void fuse_abort_conn(struct fuse_conn *fc);
void fuse_wait_aborted(struct fuse_conn *fc); void fuse_wait_aborted(struct fuse_conn *fc);
/** /**

View File

@ -379,7 +379,7 @@ void fuse_unlock_inode(struct inode *inode, bool locked)
static void fuse_umount_begin(struct super_block *sb) static void fuse_umount_begin(struct super_block *sb)
{ {
fuse_abort_conn(get_fuse_conn_super(sb), false); fuse_abort_conn(get_fuse_conn_super(sb));
} }
static void fuse_send_destroy(struct fuse_conn *fc) static void fuse_send_destroy(struct fuse_conn *fc)
@ -1245,7 +1245,7 @@ static void fuse_sb_destroy(struct super_block *sb)
if (fc) { if (fc) {
fuse_send_destroy(fc); fuse_send_destroy(fc);
fuse_abort_conn(fc, false); fuse_abort_conn(fc);
fuse_wait_aborted(fc); fuse_wait_aborted(fc);
down_write(&fc->killsb); down_write(&fc->killsb);