Re: [PATCH bpf-next 1/2] bpf: Add kfunc bpf_get_dentry_xattr() to read xattr from dentry
From: Al Viro
Date: Fri Jul 26 2024 - 01:34:47 EST
On Thu, Jul 25, 2024 at 04:47:05PM -0700, Song Liu wrote:
> +__bpf_kfunc struct dentry *bpf_file_dentry(const struct file *file)
> +{
> + /* file_dentry() does not hold reference to the dentry. We add a
> + * dget() here so that we can add KF_ACQUIRE flag to
> + * bpf_file_dentry().
> + */
> + return dget(file_dentry(file));
> +}
> +
> +__bpf_kfunc struct dentry *bpf_dget_parent(struct dentry *dentry)
> +{
> + return dget_parent(dentry);
> +}
> +
> +__bpf_kfunc void bpf_dput(struct dentry *dentry)
> +{
> + return dput(dentry);
> +}
If you keep a file reference, why bother grabbing dentry one?
If not, you have a very bad trouble if that opened file is the only
thing that keeps the filesystem busy.
It's almost certainly a wrong interface; please, explain what
exactly are you trying to do here.