Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
[SQUASHED] Revert recent fuse commits
Browse files Browse the repository at this point in the history
Revert "ANDROID: fs/fuse: Keep FUSE file times consistent with lower file"

This reverts commit a7bb2be.

Revert "UPSTREAM: fuse: fix matching of FUSE_DEV_IOC_CLONE command"

This reverts commit 1fe9a2c.

Revert "ANDROID: fuse/passthrough: API V2 with __u32 open argument"

This reverts commit 3adc642.

Revert "FROMLIST: fuse: Allocate unlikely used ioctl number for passthrough V1"

This reverts commit 4291b8c.

Revert "FROMLIST: fuse: Fix crediantials leak in passthrough read_iter"

This reverts commit 6d5c23b.

Revert "FROMLIST: fuse: Introduce passthrough for mmap"

This reverts commit b82fc98.

Revert "FROMLIST: fuse: Use daemon creds in passthrough mode"

This reverts commit fc16aae.

Revert "FROMLIST: fuse: Handle asynchronous read and write in passthrough"

This reverts commit 0e24815.

Revert "FROMLIST: fuse: Introduce synchronous read and write for passthrough"

This reverts commit 87aae7f.

Revert "FROMLIST: fuse: Passthrough initialization and release"

This reverts commit dd54ceb.

Revert "FROMLIST: fuse: Definitions and ioctl for passthrough"

This reverts commit d3283a7.

Revert "FROMLIST: fuse: 32-bit user space ioctl compat for fuse device"

This reverts commit d792b60.

Revert "FROMLIST: fs: Generic function to convert iocb to rw flags"

This reverts commit 778c932.
  • Loading branch information
mvaisakh committed May 30, 2023
1 parent 7c4afb9 commit 6fc55d2
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 410 deletions.
1 change: 0 additions & 1 deletion fs/fuse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ obj-$(CONFIG_CUSE) += cuse.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
fuse-objs += passthrough.o
virtiofs-y += virtio_fs.o
39 changes: 13 additions & 26 deletions fs/fuse/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2266,50 +2266,37 @@ static int fuse_device_clone(struct fuse_conn *fc, struct file *new)
static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
int res;
int oldfd;
struct fuse_dev *fud = NULL;

switch (cmd) {
case FUSE_DEV_IOC_CLONE:
res = -EFAULT;
if (!get_user(oldfd, (__u32 __user *)arg)) {
int err = -ENOTTY;

if (cmd == FUSE_DEV_IOC_CLONE) {
int oldfd;

err = -EFAULT;
if (!get_user(oldfd, (__u32 __user *) arg)) {
struct file *old = fget(oldfd);

res = -EINVAL;
err = -EINVAL;
if (old) {
struct fuse_dev *fud = NULL;

/*
* Check against file->f_op because CUSE
* uses the same ioctl handler.
*/
if (old->f_op == file->f_op &&
old->f_cred->user_ns ==
file->f_cred->user_ns)
old->f_cred->user_ns == file->f_cred->user_ns)
fud = fuse_get_dev(old);

if (fud) {
mutex_lock(&fuse_mutex);
res = fuse_device_clone(fud->fc, file);
err = fuse_device_clone(fud->fc, file);
mutex_unlock(&fuse_mutex);
}
fput(old);
}
}
break;
case FUSE_DEV_IOC_PASSTHROUGH_OPEN:
res = -EFAULT;
if (!get_user(oldfd, (__u32 __user *)arg)) {
res = -EINVAL;
fud = fuse_get_dev(file);
if (fud)
res = fuse_passthrough_open(fud, oldfd);
}
break;
default:
res = -ENOTTY;
break;
}
return res;
return err;
}

const struct file_operations fuse_dev_operations = {
Expand Down
1 change: 0 additions & 1 deletion fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,
ff->fh = outopen.fh;
ff->nodeid = outentry.nodeid;
ff->open_flags = outopen.open_flags;
fuse_passthrough_setup(fc, ff, &outopen);
inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation,
&outentry.attr, entry_attr_timeout(&outentry), 0);
if (!inode) {
Expand Down
15 changes: 3 additions & 12 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
if (!err) {
ff->fh = outarg.fh;
ff->open_flags = outarg.open_flags;
fuse_passthrough_setup(fc, ff, &outarg);

} else if (err != -ENOSYS) {
fuse_file_free(ff);
return err;
Expand Down Expand Up @@ -287,8 +287,6 @@ void fuse_release_common(struct file *file, bool isdir)
struct fuse_release_args *ra = ff->release_args;
int opcode = isdir ? FUSE_RELEASEDIR : FUSE_RELEASE;

fuse_passthrough_release(&ff->passthrough);

fuse_prepare_release(fi, ff, file->f_flags, opcode);

if (ff->flock) {
Expand Down Expand Up @@ -1598,9 +1596,7 @@ static ssize_t fuse_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
if (fuse_is_bad(file_inode(file)))
return -EIO;

if (ff->passthrough.filp)
return fuse_passthrough_read_iter(iocb, to);
else if (!(ff->open_flags & FOPEN_DIRECT_IO))
if (!(ff->open_flags & FOPEN_DIRECT_IO))
return fuse_cache_read_iter(iocb, to);
else
return fuse_direct_read_iter(iocb, to);
Expand All @@ -1614,9 +1610,7 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (fuse_is_bad(file_inode(file)))
return -EIO;

if (ff->passthrough.filp)
return fuse_passthrough_write_iter(iocb, from);
else if (!(ff->open_flags & FOPEN_DIRECT_IO))
if (!(ff->open_flags & FOPEN_DIRECT_IO))
return fuse_cache_write_iter(iocb, from);
else
return fuse_direct_write_iter(iocb, from);
Expand Down Expand Up @@ -2330,9 +2324,6 @@ static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)
{
struct fuse_file *ff = file->private_data;

if (ff->passthrough.filp)
return fuse_passthrough_mmap(file, vma);

if (ff->open_flags & FOPEN_DIRECT_IO) {
/* Can't provide the coherency needed for MAP_SHARED */
if (vma->vm_flags & VM_MAYSHARE)
Expand Down
32 changes: 0 additions & 32 deletions fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,6 @@ enum {
struct fuse_conn;
struct fuse_release_args;

/**
* Reference to lower filesystem file for read/write operations handled in
* passthrough mode.
* This struct also tracks the credentials to be used for handling read/write
* operations.
*/
struct fuse_passthrough {
struct file *filp;
struct cred *cred;
};

/** FUSE specific file data */
struct fuse_file {
/** Fuse connection for this file */
Expand Down Expand Up @@ -221,9 +210,6 @@ struct fuse_file {

} readdir;

/** Container for data related to the passthrough functionality */
struct fuse_passthrough passthrough;

/** RB node to be linked on fuse_conn->polled_files */
struct rb_node polled_node;

Expand Down Expand Up @@ -740,9 +726,6 @@ struct fuse_conn {
/* Do not show mount options */
unsigned int no_mount_options:1;

/** Passthrough mode for read/write IO */
unsigned int passthrough:1;

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

Expand Down Expand Up @@ -778,12 +761,6 @@ struct fuse_conn {

/** List of device instances belonging to this connection */
struct list_head devices;

/** IDR for passthrough requests */
struct idr passthrough_req;

/** Protects passthrough_req */
spinlock_t passthrough_req_lock;
};

static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
Expand Down Expand Up @@ -1134,13 +1111,4 @@ unsigned int fuse_len_args(unsigned int numargs, struct fuse_arg *args);
u64 fuse_get_unique(struct fuse_iqueue *fiq);
void fuse_free_conn(struct fuse_conn *fc);

/* passthrough.c */
int fuse_passthrough_open(struct fuse_dev *fud, u32 lower_fd);
int fuse_passthrough_setup(struct fuse_conn *fc, struct fuse_file *ff,
struct fuse_open_out *openarg);
void fuse_passthrough_release(struct fuse_passthrough *passthrough);
ssize_t fuse_passthrough_read_iter(struct kiocb *iocb, struct iov_iter *to);
ssize_t fuse_passthrough_write_iter(struct kiocb *iocb, struct iov_iter *from);
ssize_t fuse_passthrough_mmap(struct file *file, struct vm_area_struct *vma);

#endif /* _FS_FUSE_I_H */
23 changes: 1 addition & 22 deletions fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ void fuse_conn_init(struct fuse_conn *fc, struct user_namespace *user_ns,
memset(fc, 0, sizeof(*fc));
spin_lock_init(&fc->lock);
spin_lock_init(&fc->bg_lock);
spin_lock_init(&fc->passthrough_req_lock);
init_rwsem(&fc->killsb);
refcount_set(&fc->count, 1);
atomic_set(&fc->dev_count, 1);
Expand All @@ -637,7 +636,6 @@ void fuse_conn_init(struct fuse_conn *fc, struct user_namespace *user_ns,
INIT_LIST_HEAD(&fc->bg_queue);
INIT_LIST_HEAD(&fc->entry);
INIT_LIST_HEAD(&fc->devices);
idr_init(&fc->passthrough_req);
atomic_set(&fc->num_waiting, 0);
fc->max_background = FUSE_DEFAULT_MAX_BACKGROUND;
fc->congestion_threshold = FUSE_DEFAULT_CONGESTION_THRESHOLD;
Expand Down Expand Up @@ -974,12 +972,6 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_args *args,
min_t(unsigned int, FUSE_MAX_MAX_PAGES,
max_t(unsigned int, arg->max_pages, 1));
}
if (arg->flags & FUSE_PASSTHROUGH) {
fc->passthrough = 1;
/* Prevent further stacking */
fc->sb->s_stack_depth =
FILESYSTEM_MAX_STACK_DEPTH;
}
} else {
ra_pages = fc->max_read / PAGE_SIZE;
fc->no_lock = 1;
Expand Down Expand Up @@ -1017,8 +1009,7 @@ void fuse_send_init(struct fuse_conn *fc)
FUSE_WRITEBACK_CACHE | FUSE_NO_OPEN_SUPPORT |
FUSE_PARALLEL_DIROPS | FUSE_HANDLE_KILLPRIV | FUSE_POSIX_ACL |
FUSE_ABORT_ERROR | FUSE_MAX_PAGES | FUSE_CACHE_SYMLINKS |
FUSE_NO_OPENDIR_SUPPORT | FUSE_EXPLICIT_INVAL_DATA |
FUSE_PASSTHROUGH;
FUSE_NO_OPENDIR_SUPPORT | FUSE_EXPLICIT_INVAL_DATA;
ia->args.opcode = FUSE_INIT;
ia->args.in_numargs = 1;
ia->args.in_args[0].size = sizeof(ia->in);
Expand All @@ -1039,21 +1030,9 @@ void fuse_send_init(struct fuse_conn *fc)
}
EXPORT_SYMBOL_GPL(fuse_send_init);

static int free_fuse_passthrough(int id, void *p, void *data)
{
struct fuse_passthrough *passthrough = (struct fuse_passthrough *)p;

fuse_passthrough_release(passthrough);
kfree(p);

return 0;
}

void fuse_free_conn(struct fuse_conn *fc)
{
WARN_ON(!list_empty(&fc->devices));
idr_for_each(&fc->passthrough_req, free_fuse_passthrough, NULL);
idr_destroy(&fc->passthrough_req);
kfree_rcu(fc, rcu);
}
EXPORT_SYMBOL_GPL(fuse_free_conn);
Expand Down
Loading

0 comments on commit 6fc55d2

Please sign in to comment.