mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 20:54:10 +08:00
fuse: prepare for failing open response
In preparation for inode io modes, a server open response could fail due to conflicting inode io modes. Allow returning an error from fuse_finish_open() and handle the error in the callers. fuse_finish_open() is used as the callback of finish_open(), so that FMODE_OPENED will not be set if fuse_finish_open() fails. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
7de64d521b
commit
d2c487f150
@ -692,13 +692,15 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,
|
||||
d_instantiate(entry, inode);
|
||||
fuse_change_entry_timeout(entry, &outentry);
|
||||
fuse_dir_changed(dir);
|
||||
err = finish_open(file, entry, generic_file_open);
|
||||
err = generic_file_open(inode, file);
|
||||
if (!err) {
|
||||
file->private_data = ff;
|
||||
err = finish_open(file, entry, fuse_finish_open);
|
||||
}
|
||||
if (err) {
|
||||
fi = get_fuse_inode(inode);
|
||||
fuse_sync_release(fi, ff, flags);
|
||||
} else {
|
||||
file->private_data = ff;
|
||||
fuse_finish_open(inode, file);
|
||||
if (fm->fc->atomic_o_trunc && trunc)
|
||||
truncate_pagecache(inode, 0);
|
||||
else if (!(ff->open_flags & FOPEN_KEEP_CACHE))
|
||||
|
@ -200,7 +200,7 @@ static void fuse_link_write_file(struct file *file)
|
||||
spin_unlock(&fi->lock);
|
||||
}
|
||||
|
||||
void fuse_finish_open(struct inode *inode, struct file *file)
|
||||
int fuse_finish_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct fuse_file *ff = file->private_data;
|
||||
struct fuse_conn *fc = get_fuse_conn(inode);
|
||||
@ -212,6 +212,8 @@ void fuse_finish_open(struct inode *inode, struct file *file)
|
||||
|
||||
if ((file->f_mode & FMODE_WRITE) && fc->writeback_cache)
|
||||
fuse_link_write_file(file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fuse_truncate_update_attr(struct inode *inode, struct file *file)
|
||||
@ -230,7 +232,9 @@ static void fuse_truncate_update_attr(struct inode *inode, struct file *file)
|
||||
static int fuse_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct fuse_mount *fm = get_fuse_mount(inode);
|
||||
struct fuse_inode *fi = get_fuse_inode(inode);
|
||||
struct fuse_conn *fc = fm->fc;
|
||||
struct fuse_file *ff;
|
||||
int err;
|
||||
bool is_truncate = (file->f_flags & O_TRUNC) && fc->atomic_o_trunc;
|
||||
bool is_wb_truncate = is_truncate && fc->writeback_cache;
|
||||
@ -258,16 +262,17 @@ static int fuse_open(struct inode *inode, struct file *file)
|
||||
|
||||
err = fuse_do_open(fm, get_node_id(inode), file, false);
|
||||
if (!err) {
|
||||
fuse_finish_open(inode, file);
|
||||
if (is_truncate)
|
||||
ff = file->private_data;
|
||||
err = fuse_finish_open(inode, file);
|
||||
if (err)
|
||||
fuse_sync_release(fi, ff, file->f_flags);
|
||||
else if (is_truncate)
|
||||
fuse_truncate_update_attr(inode, file);
|
||||
}
|
||||
|
||||
if (is_wb_truncate || dax_truncate)
|
||||
fuse_release_nowrite(inode);
|
||||
if (!err) {
|
||||
struct fuse_file *ff = file->private_data;
|
||||
|
||||
if (is_truncate)
|
||||
truncate_pagecache(inode, 0);
|
||||
else if (!(ff->open_flags & FOPEN_KEEP_CACHE))
|
||||
|
@ -1033,7 +1033,7 @@ void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos,
|
||||
|
||||
struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release);
|
||||
void fuse_file_free(struct fuse_file *ff);
|
||||
void fuse_finish_open(struct inode *inode, struct file *file);
|
||||
int fuse_finish_open(struct inode *inode, struct file *file);
|
||||
|
||||
void fuse_sync_release(struct fuse_inode *fi, struct fuse_file *ff,
|
||||
unsigned int flags);
|
||||
|
Loading…
Reference in New Issue
Block a user