mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
ANDROID: fuse-bpf: Adjust backing handle funcs
Cleaned up some args, and adjusted so we can choose to not update the actual values for the next patch. Test: fuse_test Bug: 219958836 Change-Id: I025b7026357b119e2cd588f25f0976f5d4b68090 Signed-off-by: Daniel Rosenberg <drosen@google.com>
This commit is contained in:
@@ -1172,23 +1172,17 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int handle_inode_backing_fd(struct inode *inode, struct dentry *entry,
|
int fuse_handle_backing(struct fuse_entry_bpf *feb, struct inode **backing_inode,
|
||||||
struct fuse_entry_bpf_out *febo,
|
struct path *backing_path) {
|
||||||
struct fuse_entry_bpf *feb)
|
switch (feb->out.backing_action) {
|
||||||
{
|
|
||||||
struct fuse_inode *fi = get_fuse_inode(inode);
|
|
||||||
struct fuse_dentry *fd = get_fuse_dentry(entry);
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
switch (febo->backing_action) {
|
|
||||||
case FUSE_ACTION_KEEP:
|
case FUSE_ACTION_KEEP:
|
||||||
/* backing inode/path are added in fuse_lookup_backing */
|
/* backing inode/path are added in fuse_lookup_backing */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FUSE_ACTION_REMOVE:
|
case FUSE_ACTION_REMOVE:
|
||||||
iput(fi->backing_inode);
|
iput(*backing_inode);
|
||||||
fi->backing_inode = NULL;
|
*backing_inode = NULL;
|
||||||
path_put_init(&fd->backing_path);
|
path_put_init(backing_path);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FUSE_ACTION_REPLACE: {
|
case FUSE_ACTION_REPLACE: {
|
||||||
@@ -1199,14 +1193,14 @@ int handle_inode_backing_fd(struct inode *inode, struct dentry *entry,
|
|||||||
if (IS_ERR(backing_file))
|
if (IS_ERR(backing_file))
|
||||||
return PTR_ERR(backing_file);
|
return PTR_ERR(backing_file);
|
||||||
|
|
||||||
if (fi->backing_inode)
|
if (backing_inode)
|
||||||
iput(fi->backing_inode);
|
iput(*backing_inode);
|
||||||
fi->backing_inode = backing_file->f_inode;
|
*backing_inode = backing_file->f_inode;
|
||||||
ihold(fi->backing_inode);
|
ihold(*backing_inode);
|
||||||
|
|
||||||
path_put(&fd->backing_path);
|
path_put(backing_path);
|
||||||
fd->backing_path = backing_file->f_path;
|
*backing_path = backing_file->f_path;
|
||||||
path_get(&fd->backing_path);
|
path_get(backing_path);
|
||||||
|
|
||||||
fput(backing_file);
|
fput(backing_file);
|
||||||
break;
|
break;
|
||||||
@@ -1216,34 +1210,31 @@ int handle_inode_backing_fd(struct inode *inode, struct dentry *entry,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int handle_inode_bpf(struct inode *inode, struct inode *parent,
|
int fuse_handle_bpf_prog(struct fuse_entry_bpf *feb, struct inode *parent,
|
||||||
struct fuse_entry_bpf_out *febo,
|
struct bpf_prog **bpf)
|
||||||
struct fuse_entry_bpf *feb)
|
|
||||||
{
|
{
|
||||||
struct fuse_inode *fi = get_fuse_inode(inode);
|
|
||||||
struct fuse_inode *pi;
|
struct fuse_inode *pi;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
// Parent isn't presented, but we want to keep
|
// Parent isn't presented, but we want to keep
|
||||||
// Don't touch bpf program at all in this case
|
// Don't touch bpf program at all in this case
|
||||||
if (febo->bpf_action == FUSE_ACTION_KEEP && !parent) {
|
if (feb->out.bpf_action == FUSE_ACTION_KEEP && !parent) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fi->bpf) {
|
if (*bpf) {
|
||||||
bpf_prog_put(fi->bpf);
|
bpf_prog_put(*bpf);
|
||||||
fi->bpf = NULL;
|
*bpf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (febo->bpf_action) {
|
switch (feb->out.bpf_action) {
|
||||||
case FUSE_ACTION_KEEP:
|
case FUSE_ACTION_KEEP:
|
||||||
pi = get_fuse_inode(parent);
|
pi = get_fuse_inode(parent);
|
||||||
fi->bpf = pi->bpf;
|
*bpf = pi->bpf;
|
||||||
if (fi->bpf)
|
if (*bpf)
|
||||||
bpf_prog_inc(fi->bpf);
|
bpf_prog_inc(*bpf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FUSE_ACTION_REMOVE:
|
case FUSE_ACTION_REMOVE:
|
||||||
@@ -1259,7 +1250,7 @@ int handle_inode_bpf(struct inode *inode, struct inode *parent,
|
|||||||
if (IS_ERR(bpf_prog))
|
if (IS_ERR(bpf_prog))
|
||||||
return PTR_ERR(bpf_prog);
|
return PTR_ERR(bpf_prog);
|
||||||
|
|
||||||
fi->bpf = bpf_prog;
|
*bpf = bpf_prog;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1268,7 +1259,7 @@ int handle_inode_bpf(struct inode *inode, struct inode *parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir,
|
struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir,
|
||||||
@@ -1302,11 +1293,11 @@ struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir,
|
|||||||
if (IS_ERR(inode))
|
if (IS_ERR(inode))
|
||||||
return ERR_PTR(PTR_ERR(inode));
|
return ERR_PTR(PTR_ERR(inode));
|
||||||
|
|
||||||
error = handle_inode_bpf(inode, dir, febo, feb);
|
error = fuse_handle_bpf_prog(feb, dir, &get_fuse_inode(inode)->bpf);
|
||||||
if (error)
|
if (error)
|
||||||
return ERR_PTR(error);
|
return ERR_PTR(error);
|
||||||
|
|
||||||
error = handle_inode_backing_fd(inode, entry, febo, feb);
|
error = fuse_handle_backing(feb, &get_fuse_inode(inode)->backing_inode, &fd->backing_path);
|
||||||
if (error)
|
if (error)
|
||||||
return ERR_PTR(error);
|
return ERR_PTR(error);
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,6 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
|
|||||||
fuse_lookup_init(fm->fc, &args, get_node_id(d_inode(parent)),
|
fuse_lookup_init(fm->fc, &args, get_node_id(d_inode(parent)),
|
||||||
&entry->d_name, &outarg, &bpf_arg.out);
|
&entry->d_name, &outarg, &bpf_arg.out);
|
||||||
ret = fuse_simple_request(fm, &args);
|
ret = fuse_simple_request(fm, &args);
|
||||||
dput(parent);
|
|
||||||
|
|
||||||
#ifdef CONFIG_FUSE_BPF
|
#ifdef CONFIG_FUSE_BPF
|
||||||
if (ret == sizeof(bpf_arg.out)) {
|
if (ret == sizeof(bpf_arg.out)) {
|
||||||
@@ -244,17 +243,18 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
|
|||||||
if (!entry)
|
if (!entry)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = handle_inode_backing_fd(inode, entry,
|
ret = fuse_handle_backing(&bpf_arg, &get_fuse_inode(inode)->backing_inode,
|
||||||
&bpf_arg.out, &bpf_arg);
|
&get_fuse_dentry(entry)->backing_path);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = handle_inode_bpf(inode, entry->d_parent->d_inode,
|
ret = fuse_handle_bpf_prog(&bpf_arg, parent->d_inode,
|
||||||
&bpf_arg.out, &bpf_arg);
|
&get_fuse_inode(inode)->bpf);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
dput(parent);
|
||||||
/* Zero nodeid is same as -ENOENT */
|
/* Zero nodeid is same as -ENOENT */
|
||||||
if (!ret && !outarg.nodeid)
|
if (!ret && !outarg.nodeid)
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
@@ -548,13 +548,13 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name
|
|||||||
if (!*inode)
|
if (!*inode)
|
||||||
goto bpf_arg_out;
|
goto bpf_arg_out;
|
||||||
|
|
||||||
err = handle_inode_backing_fd(*inode, entry,
|
err = fuse_handle_backing(&bpf_arg,
|
||||||
&bpf_arg.out, &bpf_arg);
|
&get_fuse_inode(*inode)->backing_inode,
|
||||||
|
&get_fuse_dentry(entry)->backing_path);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = handle_inode_bpf(*inode, NULL,
|
err = fuse_handle_bpf_prog(&bpf_arg, NULL, &get_fuse_inode(*inode)->bpf);
|
||||||
&bpf_arg.out, &bpf_arg);
|
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
bpf_arg_out:
|
bpf_arg_out:
|
||||||
|
|||||||
@@ -1597,12 +1597,10 @@ struct fuse_lookup_io {
|
|||||||
struct fuse_entry_bpf feb;
|
struct fuse_entry_bpf feb;
|
||||||
};
|
};
|
||||||
|
|
||||||
int handle_inode_backing_fd(struct inode *inode, struct dentry *entry,
|
int fuse_handle_backing(struct fuse_entry_bpf *feb, struct inode **backing_inode,
|
||||||
struct fuse_entry_bpf_out *febo,
|
struct path *backing_path);
|
||||||
struct fuse_entry_bpf *feb);
|
int fuse_handle_bpf_prog(struct fuse_entry_bpf *feb, struct inode *parent,
|
||||||
int handle_inode_bpf(struct inode *inode, struct inode *parent,
|
struct bpf_prog **bpf);
|
||||||
struct fuse_entry_bpf_out *febo,
|
|
||||||
struct fuse_entry_bpf *feb);
|
|
||||||
|
|
||||||
int fuse_lookup_initialize(struct fuse_bpf_args *fa, struct fuse_lookup_io *feo,
|
int fuse_lookup_initialize(struct fuse_bpf_args *fa, struct fuse_lookup_io *feo,
|
||||||
struct inode *dir, struct dentry *entry, unsigned int flags);
|
struct inode *dir, struct dentry *entry, unsigned int flags);
|
||||||
|
|||||||
Reference in New Issue
Block a user