Skip to content

Commit 8dcafbe

Browse files
amir73ilbsbernd
authored andcommitted
fuse: break up fuse_open_common()
fuse_open_common() has a lot of code relevant only for regular files and O_TRUNC in particular. Copy the little bit of remaining code into fuse_dir_open() and stop using this common helper for directory open. Also split out fuse_dir_finish_open() from fuse_finish_open() before we add inode io modes to fuse_finish_open(). Suggested-by: Miklos Szeredi <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]> (cherry picked from commit 7de64d5)
1 parent cbabbdd commit 8dcafbe

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

fs/fuse/dir.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,30 @@ static const char *fuse_get_link(struct dentry *dentry, struct inode *inode,
16411641

16421642
static int fuse_dir_open(struct inode *inode, struct file *file)
16431643
{
1644-
return fuse_open_common(inode, file, true);
1644+
struct fuse_mount *fm = get_fuse_mount(inode);
1645+
int err;
1646+
1647+
if (fuse_is_bad(inode))
1648+
return -EIO;
1649+
1650+
err = generic_file_open(inode, file);
1651+
if (err)
1652+
return err;
1653+
1654+
err = fuse_do_open(fm, get_node_id(inode), file, true);
1655+
if (!err) {
1656+
struct fuse_file *ff = file->private_data;
1657+
1658+
/*
1659+
* Keep handling FOPEN_STREAM and FOPEN_NONSEEKABLE for
1660+
* directories for backward compatibility, though it's unlikely
1661+
* to be useful.
1662+
*/
1663+
if (ff->open_flags & (FOPEN_STREAM | FOPEN_NONSEEKABLE))
1664+
nonseekable_open(inode, file);
1665+
}
1666+
1667+
return err;
16451668
}
16461669

16471670
static int fuse_dir_release(struct inode *inode, struct file *file)

fs/fuse/file.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static void fuse_truncate_update_attr(struct inode *inode, struct file *file)
227227
fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE);
228228
}
229229

230-
int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
230+
static int fuse_open(struct inode *inode, struct file *file)
231231
{
232232
struct fuse_mount *fm = get_fuse_mount(inode);
233233
struct fuse_conn *fc = fm->fc;
@@ -256,7 +256,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
256256
if (is_wb_truncate || dax_truncate)
257257
fuse_set_nowrite(inode);
258258

259-
err = fuse_do_open(fm, get_node_id(inode), file, isdir);
259+
err = fuse_do_open(fm, get_node_id(inode), file, false);
260260
if (!err) {
261261
fuse_finish_open(inode, file);
262262
if (is_truncate)
@@ -354,11 +354,6 @@ void fuse_release_common(struct file *file, bool isdir)
354354
(fl_owner_t) file, isdir);
355355
}
356356

357-
static int fuse_open(struct inode *inode, struct file *file)
358-
{
359-
return fuse_open_common(inode, file, false);
360-
}
361-
362357
static int fuse_release(struct inode *inode, struct file *file)
363358
{
364359
struct fuse_conn *fc = get_fuse_conn(inode);

fs/fuse/fuse_i.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,11 +1081,6 @@ void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos,
10811081
size_t count, int opcode);
10821082

10831083

1084-
/**
1085-
* Send OPEN or OPENDIR request
1086-
*/
1087-
int fuse_open_common(struct inode *inode, struct file *file, bool isdir);
1088-
10891084
struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release);
10901085
void fuse_file_free(struct fuse_file *ff);
10911086
void fuse_finish_open(struct inode *inode, struct file *file);

0 commit comments

Comments
 (0)