diff options
author | Amir Goldstein <amir73il@gmail.com> | 2024-02-01 16:38:06 +0300 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2024-02-23 19:36:32 +0300 |
commit | d2c487f150ae00e3cb9faf57aceacc584e0a130c (patch) | |
tree | ac1ca5774d3ac29b9e3af1c58d437e7c34c4b94c /fs/fuse/file.c | |
parent | 7de64d521bf92396b7da8ae0600188ea5d75a4c9 (diff) | |
download | linux-d2c487f150ae00e3cb9faf57aceacc584e0a130c.tar.xz |
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>
Diffstat (limited to 'fs/fuse/file.c')
-rw-r--r-- | fs/fuse/file.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index c7f21b439d2b..27f50b4bd7f3 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -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)) |