Commit 68319837 authored by Amir Goldstein's avatar Amir Goldstein Committed by Wen Zhiwei
Browse files

ovl: pass realinode to ovl_encode_real_fh() instead of realdentry

stable inclusion
from stable-v6.6.74
commit 955a355e179f0d9694eea797ce9171e23589882b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBSPQB

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=955a355e179f0d9694eea797ce9171e23589882b



--------------------------------

commit 07aeefae7ff44d80524375253980b1bdee2396b0 upstream.

We want to be able to encode an fid from an inode with no alias.

Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Link: https://lore.kernel.org/r/20250105162404.357058-2-amir73il@gmail.com


Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
Stable-dep-of: c45beebfde34 ("ovl: support encoding fid from inode with no alias")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
[re-applied over v6.6.71 with conflict resolved]
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent bbe7abe8
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -371,13 +371,13 @@ int ovl_set_attr(struct ovl_fs *ofs, struct dentry *upperdentry,
	return err;
}

struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode,
				  bool is_upper)
{
	struct ovl_fh *fh;
	int fh_type, dwords;
	int buflen = MAX_HANDLE_SZ;
	uuid_t *uuid = &real->d_sb->s_uuid;
	uuid_t *uuid = &realinode->i_sb->s_uuid;
	int err;

	/* Make sure the real fid stays 32bit aligned */
@@ -394,7 +394,8 @@ struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
	 * the price or reconnecting the dentry.
	 */
	dwords = buflen >> 2;
	fh_type = exportfs_encode_fh(real, (void *)fh->fb.fid, &dwords, 0);
	fh_type = exportfs_encode_inode_fh(realinode, (void *)fh->fb.fid,
					   &dwords, NULL, 0);
	buflen = (dwords << 2);

	err = -EIO;
@@ -438,7 +439,7 @@ int ovl_set_origin(struct ovl_fs *ofs, struct dentry *lower,
	 * up and a pure upper inode.
	 */
	if (ovl_can_decode_fh(lower->d_sb)) {
		fh = ovl_encode_real_fh(ofs, lower, false);
		fh = ovl_encode_real_fh(ofs, d_inode(lower), false);
		if (IS_ERR(fh))
			return PTR_ERR(fh);
	}
@@ -461,7 +462,7 @@ static int ovl_set_upper_fh(struct ovl_fs *ofs, struct dentry *upper,
	const struct ovl_fh *fh;
	int err;

	fh = ovl_encode_real_fh(ofs, upper, true);
	fh = ovl_encode_real_fh(ofs, d_inode(upper), true);
	if (IS_ERR(fh))
		return PTR_ERR(fh);

+3 −2
Original line number Diff line number Diff line
@@ -228,6 +228,7 @@ static int ovl_check_encode_origin(struct dentry *dentry)
static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry,
			     u32 *fid, int buflen)
{
	struct inode *inode = d_inode(dentry);
	struct ovl_fh *fh = NULL;
	int err, enc_lower;
	int len;
@@ -241,8 +242,8 @@ static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry,
		goto fail;

	/* Encode an upper or lower file handle */
	fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_dentry_lower(dentry) :
				ovl_dentry_upper(dentry), !enc_lower);
	fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_inode_lower(inode) :
				ovl_inode_upper(inode), !enc_lower);
	if (IS_ERR(fh))
		return PTR_ERR(fh);

+2 −2
Original line number Diff line number Diff line
@@ -523,7 +523,7 @@ int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry,
	struct ovl_fh *fh;
	int err;

	fh = ovl_encode_real_fh(ofs, real, is_upper);
	fh = ovl_encode_real_fh(ofs, d_inode(real), is_upper);
	err = PTR_ERR(fh);
	if (IS_ERR(fh)) {
		fh = NULL;
@@ -720,7 +720,7 @@ int ovl_get_index_name(struct ovl_fs *ofs, struct dentry *origin,
	struct ovl_fh *fh;
	int err;

	fh = ovl_encode_real_fh(ofs, origin, false);
	fh = ovl_encode_real_fh(ofs, d_inode(origin), false);
	if (IS_ERR(fh))
		return PTR_ERR(fh);

+1 −1
Original line number Diff line number Diff line
@@ -821,7 +821,7 @@ int ovl_copy_up_with_data(struct dentry *dentry);
int ovl_maybe_copy_up(struct dentry *dentry, int flags);
int ovl_copy_xattr(struct super_block *sb, const struct path *path, struct dentry *new);
int ovl_set_attr(struct ovl_fs *ofs, struct dentry *upper, struct kstat *stat);
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode,
				  bool is_upper);
int ovl_set_origin(struct ovl_fs *ofs, struct dentry *lower,
		   struct dentry *upper);