Skip to content

Commit 07aeefa

Browse files
amir73ilbrauner
authored andcommitted
ovl: pass realinode to ovl_encode_real_fh() instead of realdentry
We want to be able to encode an fid from an inode with no alias. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://lore.kernel.org/r/20250105162404.357058-2-amir73il@gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 03f275a commit 07aeefa

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

fs/overlayfs/copy_up.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,13 @@ int ovl_set_attr(struct ovl_fs *ofs, struct dentry *upperdentry,
415415
return err;
416416
}
417417

418-
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
418+
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode,
419419
bool is_upper)
420420
{
421421
struct ovl_fh *fh;
422422
int fh_type, dwords;
423423
int buflen = MAX_HANDLE_SZ;
424-
uuid_t *uuid = &real->d_sb->s_uuid;
424+
uuid_t *uuid = &realinode->i_sb->s_uuid;
425425
int err;
426426

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

444445
err = -EIO;
@@ -479,7 +480,7 @@ struct ovl_fh *ovl_get_origin_fh(struct ovl_fs *ofs, struct dentry *origin)
479480
if (!ovl_can_decode_fh(origin->d_sb))
480481
return NULL;
481482

482-
return ovl_encode_real_fh(ofs, origin, false);
483+
return ovl_encode_real_fh(ofs, d_inode(origin), false);
483484
}
484485

485486
int ovl_set_origin_fh(struct ovl_fs *ofs, const struct ovl_fh *fh,
@@ -504,7 +505,7 @@ static int ovl_set_upper_fh(struct ovl_fs *ofs, struct dentry *upper,
504505
const struct ovl_fh *fh;
505506
int err;
506507

507-
fh = ovl_encode_real_fh(ofs, upper, true);
508+
fh = ovl_encode_real_fh(ofs, d_inode(upper), true);
508509
if (IS_ERR(fh))
509510
return PTR_ERR(fh);
510511

fs/overlayfs/export.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ static int ovl_check_encode_origin(struct dentry *dentry)
223223
static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry,
224224
u32 *fid, int buflen)
225225
{
226+
struct inode *inode = d_inode(dentry);
226227
struct ovl_fh *fh = NULL;
227228
int err, enc_lower;
228229
int len;
@@ -236,8 +237,8 @@ static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry,
236237
goto fail;
237238

238239
/* Encode an upper or lower file handle */
239-
fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_dentry_lower(dentry) :
240-
ovl_dentry_upper(dentry), !enc_lower);
240+
fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_inode_lower(inode) :
241+
ovl_inode_upper(inode), !enc_lower);
241242
if (IS_ERR(fh))
242243
return PTR_ERR(fh);
243244

fs/overlayfs/namei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ int ovl_verify_origin_xattr(struct ovl_fs *ofs, struct dentry *dentry,
542542
struct ovl_fh *fh;
543543
int err;
544544

545-
fh = ovl_encode_real_fh(ofs, real, is_upper);
545+
fh = ovl_encode_real_fh(ofs, d_inode(real), is_upper);
546546
err = PTR_ERR(fh);
547547
if (IS_ERR(fh)) {
548548
fh = NULL;
@@ -738,7 +738,7 @@ int ovl_get_index_name(struct ovl_fs *ofs, struct dentry *origin,
738738
struct ovl_fh *fh;
739739
int err;
740740

741-
fh = ovl_encode_real_fh(ofs, origin, false);
741+
fh = ovl_encode_real_fh(ofs, d_inode(origin), false);
742742
if (IS_ERR(fh))
743743
return PTR_ERR(fh);
744744

fs/overlayfs/overlayfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ int ovl_copy_up_with_data(struct dentry *dentry);
865865
int ovl_maybe_copy_up(struct dentry *dentry, int flags);
866866
int ovl_copy_xattr(struct super_block *sb, const struct path *path, struct dentry *new);
867867
int ovl_set_attr(struct ovl_fs *ofs, struct dentry *upper, struct kstat *stat);
868-
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
868+
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode,
869869
bool is_upper);
870870
struct ovl_fh *ovl_get_origin_fh(struct ovl_fs *ofs, struct dentry *origin);
871871
int ovl_set_origin_fh(struct ovl_fs *ofs, const struct ovl_fh *fh,

0 commit comments

Comments
 (0)