Skip to content

Commit

Permalink
Merge tag 'fuse-fixes-5.4-rc6' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/mszeredi/fuse

Pull fuse fixes from Miklos Szeredi:
 "Mostly virtiofs fixes, but also fixes a regression and couple of
  longstanding data/metadata writeback ordering issues"

* tag 'fuse-fixes-5.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse:
  fuse: redundant get_fuse_inode() calls in fuse_writepages_fill()
  fuse: Add changelog entries for protocols 7.1 - 7.8
  fuse: truncate pending writes on O_TRUNC
  fuse: flush dirty data/metadata before non-truncate setattr
  virtiofs: Remove set but not used variable 'fc'
  virtiofs: Retry request submission from worker context
  virtiofs: Count pending forgets as in_flight forgets
  virtiofs: Set FR_SENT flag only after request has been sent
  virtiofs: No need to check fpq->connected state
  virtiofs: Do not end request in submission context
  fuse: don't advise readdirplus for negative lookup
  fuse: don't dereference req->args on finished request
  virtio-fs: don't show mount options
  virtio-fs: Change module name to virtiofs.ko
  • Loading branch information
Linus Torvalds committed Oct 29, 2019
2 parents 8005803 + 091d1a7 commit 23fdb19
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 65 deletions.
3 changes: 2 additions & 1 deletion fs/fuse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

obj-$(CONFIG_FUSE_FS) += fuse.o
obj-$(CONFIG_CUSE) += cuse.o
obj-$(CONFIG_VIRTIO_FS) += virtio_fs.o
obj-$(CONFIG_VIRTIO_FS) += virtiofs.o

fuse-objs := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o
virtiofs-y += virtio_fs.o
4 changes: 3 additions & 1 deletion fs/fuse/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,12 @@ static void flush_bg_queue(struct fuse_conn *fc)
void fuse_request_end(struct fuse_conn *fc, struct fuse_req *req)
{
struct fuse_iqueue *fiq = &fc->iq;
bool async = req->args->end;
bool async;

if (test_and_set_bit(FR_FINISHED, &req->flags))
goto put_request;

async = req->args->end;
/*
* test_and_set_bit() implies smp_mb() between bit
* changing and below intr_entry check. Pairs with
Expand Down
16 changes: 15 additions & 1 deletion fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
else
fuse_invalidate_entry_cache(entry);

fuse_advise_use_readdirplus(dir);
if (inode)
fuse_advise_use_readdirplus(dir);
return newent;

out_iput:
Expand Down Expand Up @@ -1521,6 +1522,19 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
is_truncate = true;
}

/* Flush dirty data/metadata before non-truncate SETATTR */
if (is_wb && S_ISREG(inode->i_mode) &&
attr->ia_valid &
(ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_MTIME_SET |
ATTR_TIMES_SET)) {
err = write_inode_now(inode, true);
if (err)
return err;

fuse_set_nowrite(inode);
fuse_release_nowrite(inode);
}

if (is_truncate) {
fuse_set_nowrite(inode);
set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
Expand Down
14 changes: 8 additions & 6 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,28 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
{
struct fuse_conn *fc = get_fuse_conn(inode);
int err;
bool lock_inode = (file->f_flags & O_TRUNC) &&
bool is_wb_truncate = (file->f_flags & O_TRUNC) &&
fc->atomic_o_trunc &&
fc->writeback_cache;

err = generic_file_open(inode, file);
if (err)
return err;

if (lock_inode)
if (is_wb_truncate) {
inode_lock(inode);
fuse_set_nowrite(inode);
}

err = fuse_do_open(fc, get_node_id(inode), file, isdir);

if (!err)
fuse_finish_open(inode, file);

if (lock_inode)
if (is_wb_truncate) {
fuse_release_nowrite(inode);
inode_unlock(inode);
}

return err;
}
Expand Down Expand Up @@ -1997,7 +2001,7 @@ static int fuse_writepages_fill(struct page *page,

if (!data->ff) {
err = -EIO;
data->ff = fuse_write_file_get(fc, get_fuse_inode(inode));
data->ff = fuse_write_file_get(fc, fi);
if (!data->ff)
goto out_unlock;
}
Expand Down Expand Up @@ -2042,8 +2046,6 @@ static int fuse_writepages_fill(struct page *page,
* under writeback, so we can release the page lock.
*/
if (data->wpa == NULL) {
struct fuse_inode *fi = get_fuse_inode(inode);

err = -ENOMEM;
wpa = fuse_writepage_args_alloc();
if (!wpa) {
Expand Down
4 changes: 4 additions & 0 deletions fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ struct fuse_fs_context {
bool destroy:1;
bool no_control:1;
bool no_force_umount:1;
bool no_mount_options:1;
unsigned int max_read;
unsigned int blksize;
const char *subtype;
Expand Down Expand Up @@ -713,6 +714,9 @@ struct fuse_conn {
/** Do not allow MNT_FORCE umount */
unsigned int no_force_umount:1;

/* Do not show mount options */
unsigned int no_mount_options:1;

/** The number of requests waiting for completion */
atomic_t num_waiting;

Expand Down
4 changes: 4 additions & 0 deletions fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,9 @@ static int fuse_show_options(struct seq_file *m, struct dentry *root)
struct super_block *sb = root->d_sb;
struct fuse_conn *fc = get_fuse_conn_super(sb);

if (fc->no_mount_options)
return 0;

seq_printf(m, ",user_id=%u", from_kuid_munged(fc->user_ns, fc->user_id));
seq_printf(m, ",group_id=%u", from_kgid_munged(fc->user_ns, fc->group_id));
if (fc->default_permissions)
Expand Down Expand Up @@ -1180,6 +1183,7 @@ int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx)
fc->destroy = ctx->destroy;
fc->no_control = ctx->no_control;
fc->no_force_umount = ctx->no_force_umount;
fc->no_mount_options = ctx->no_mount_options;

err = -ENOMEM;
root = fuse_get_root_inode(sb, ctx->rootmode);
Expand Down
Loading

0 comments on commit 23fdb19

Please sign in to comment.