Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fs/fuse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ obj-$(CONFIG_FUSE_FS) += fuse.o
obj-$(CONFIG_CUSE) += cuse.o
obj-$(CONFIG_VIRTIO_FS) += virtiofs.o

fuse-y := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o ioctl.o
fuse-y := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o ioctl.o fuse_dlm_cache.o
fuse-y += iomode.o
fuse-$(CONFIG_FUSE_DAX) += dax.o
fuse-$(CONFIG_FUSE_IO_URING) += dev_uring.o
Expand Down
40 changes: 40 additions & 0 deletions fs/fuse/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/swap.h>
#include <linux/splice.h>
#include <linux/sched.h>
#include <linux/nmi.h>

#define CREATE_TRACE_POINTS
#include "fuse_trace.h"
Expand Down Expand Up @@ -2147,6 +2148,45 @@ static void end_polls(struct fuse_conn *fc)
}
}

/*
* Flush all pending requests and wait for them. Only call this function when
* it is no longer possible for other threads to add requests.
*/
void fuse_flush_requests(struct fuse_conn *fc, unsigned long timeout)
{
unsigned long deadline;

spin_lock(&fc->lock);
if (!fc->connected) {
spin_unlock(&fc->lock);
return;
}

/* Push all the background requests to the queue. */
spin_lock(&fc->bg_lock);
fc->blocked = 0;
fc->max_background = UINT_MAX;
flush_bg_queue(fc);
spin_unlock(&fc->bg_lock);
spin_unlock(&fc->lock);

fuse_uring_flush_bg(fc);

/*
* Wait 30s for all the events to complete or abort. Touch the
* watchdog once per second so that we don't trip the hangcheck timer
* while waiting for the fuse server.
*/
deadline = jiffies + timeout;
smp_mb();
while (fc->connected &&
(!timeout || time_before(jiffies, deadline)) &&
wait_event_timeout(fc->blocked_waitq,
!fc->connected || atomic_read(&fc->num_waiting) == 0,
HZ) == 0)
touch_softlockup_watchdog();
}

/*
* Abort all requests.
*
Expand Down
17 changes: 10 additions & 7 deletions fs/fuse/dev_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static struct fuse_ring_ent *uring_cmd_to_ring_ent(struct io_uring_cmd *cmd)
return pdu->ent;
}

static void fuse_uring_flush_bg(struct fuse_ring_queue *queue)
static void fuse_uring_flush_queue_bg(struct fuse_ring_queue *queue)
{
struct fuse_ring *ring = queue->ring;
struct fuse_conn *fc = ring->fc;
Expand Down Expand Up @@ -106,7 +106,7 @@ static void fuse_uring_req_end(struct fuse_ring_ent *ent, struct fuse_req *req,
if (test_bit(FR_BACKGROUND, &req->flags)) {
queue->active_background--;
spin_lock(&fc->bg_lock);
fuse_uring_flush_bg(queue);
fuse_uring_flush_queue_bg(queue);
spin_unlock(&fc->bg_lock);
}

Expand Down Expand Up @@ -135,11 +135,14 @@ static void fuse_uring_abort_end_queue_requests(struct fuse_ring_queue *queue)
fuse_dev_end_requests(&req_list);
}

void fuse_uring_abort_end_requests(struct fuse_ring *ring)
void fuse_uring_flush_bg(struct fuse_conn *fc)
{
int qid;
struct fuse_ring_queue *queue;
struct fuse_conn *fc = ring->fc;
struct fuse_ring *ring = fc->ring;

if (!ring)
return;

for (qid = 0; qid < ring->nr_queues; qid++) {
queue = READ_ONCE(ring->queues[qid]);
Expand All @@ -151,10 +154,9 @@ void fuse_uring_abort_end_requests(struct fuse_ring *ring)
WARN_ON_ONCE(ring->fc->max_background != UINT_MAX);
spin_lock(&queue->lock);
spin_lock(&fc->bg_lock);
fuse_uring_flush_bg(queue);
fuse_uring_flush_queue_bg(queue);
spin_unlock(&fc->bg_lock);
spin_unlock(&queue->lock);
fuse_uring_abort_end_queue_requests(queue);
}
}

Expand Down Expand Up @@ -472,6 +474,7 @@ void fuse_uring_stop_queues(struct fuse_ring *ring)
if (!queue)
continue;

fuse_uring_abort_end_queue_requests(queue);
fuse_uring_teardown_entries(queue);
}

Expand Down Expand Up @@ -1493,7 +1496,7 @@ bool fuse_uring_queue_bq_req(struct fuse_req *req)
fc->num_background++;
if (fc->num_background == fc->max_background)
fc->blocked = 1;
fuse_uring_flush_bg(queue);
fuse_uring_flush_queue_bg(queue);
spin_unlock(&fc->bg_lock);

/*
Expand Down
12 changes: 10 additions & 2 deletions fs/fuse/dev_uring_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct fuse_ring {
bool fuse_uring_enabled(void);
void fuse_uring_destruct(struct fuse_conn *fc);
void fuse_uring_stop_queues(struct fuse_ring *ring);
void fuse_uring_abort_end_requests(struct fuse_ring *ring);
void fuse_uring_flush_bg(struct fuse_conn *fc);
int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags);
void fuse_uring_queue_fuse_req(struct fuse_iqueue *fiq, struct fuse_req *req);
bool fuse_uring_queue_bq_req(struct fuse_req *req);
Expand All @@ -156,7 +156,7 @@ static inline void fuse_uring_abort(struct fuse_conn *fc)
return;

if (atomic_read(&ring->queue_refs) > 0) {
fuse_uring_abort_end_requests(ring);
fuse_uring_flush_bg(fc);
fuse_uring_stop_queues(ring);
}
}
Expand Down Expand Up @@ -204,6 +204,14 @@ static inline bool fuse_uring_remove_pending_req(struct fuse_req *req)
return false;
}

static inline bool fuse_uring_request_expired(struct fuse_conn *fc)
{
}

static inline void fuse_uring_flush_bg(struct fuse_conn *fc)
{
}

#endif /* CONFIG_FUSE_IO_URING */

#endif /* _FS_FUSE_DEV_URING_I_H */
6 changes: 6 additions & 0 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
See the file COPYING.
*/

#include "fuse_dlm_cache.h"
#include "fuse_i.h"

#include <linux/pagemap.h>
Expand Down Expand Up @@ -1923,6 +1924,8 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
* truncation has already been done by OPEN. But still
* need to truncate page cache.
*/
if (fc->dlm && fc->writeback_cache)
fuse_dlm_cache_release_locks(fi);
i_size_write(inode, 0);
truncate_pagecache(inode, 0);
goto out;
Expand Down Expand Up @@ -2028,6 +2031,9 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
*/
if ((is_truncate || !is_wb) &&
S_ISREG(inode->i_mode) && oldsize != outarg.attr.size) {
if (fc->dlm && fc->writeback_cache)
fuse_dlm_unlock_range(fi, outarg.attr.size & PAGE_MASK, -1);

truncate_pagecache(inode, outarg.attr.size);
invalidate_inode_pages2(mapping);
}
Expand Down
Loading