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>

authored by Amir Goldstein and committed by Christian Brauner 07aeefae 03f275ad

Changed files
+12 -10
fs
+6 -5
fs/overlayfs/copy_up.c
··· 415 415 return err; 416 416 } 417 417 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, 419 419 bool is_upper) 420 420 { 421 421 struct ovl_fh *fh; 422 422 int fh_type, dwords; 423 423 int buflen = MAX_HANDLE_SZ; 424 - uuid_t *uuid = &real->d_sb->s_uuid; 424 + uuid_t *uuid = &realinode->i_sb->s_uuid; 425 425 int err; 426 426 427 427 /* Make sure the real fid stays 32bit aligned */ ··· 438 438 * the price or reconnecting the dentry. 439 439 */ 440 440 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); 442 443 buflen = (dwords << 2); 443 444 444 445 err = -EIO; ··· 480 479 if (!ovl_can_decode_fh(origin->d_sb)) 481 480 return NULL; 482 481 483 - return ovl_encode_real_fh(ofs, origin, false); 482 + return ovl_encode_real_fh(ofs, d_inode(origin), false); 484 483 } 485 484 486 485 int ovl_set_origin_fh(struct ovl_fs *ofs, const struct ovl_fh *fh, ··· 505 504 const struct ovl_fh *fh; 506 505 int err; 507 506 508 - fh = ovl_encode_real_fh(ofs, upper, true); 507 + fh = ovl_encode_real_fh(ofs, d_inode(upper), true); 509 508 if (IS_ERR(fh)) 510 509 return PTR_ERR(fh); 511 510
+3 -2
fs/overlayfs/export.c
··· 223 223 static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry, 224 224 u32 *fid, int buflen) 225 225 { 226 + struct inode *inode = d_inode(dentry); 226 227 struct ovl_fh *fh = NULL; 227 228 int err, enc_lower; 228 229 int len; ··· 237 236 goto fail; 238 237 239 238 /* Encode an upper or lower file handle */ 240 - fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_dentry_lower(dentry) : 241 - ovl_dentry_upper(dentry), !enc_lower); 239 + fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_inode_lower(inode) : 240 + ovl_inode_upper(inode), !enc_lower); 242 241 if (IS_ERR(fh)) 243 242 return PTR_ERR(fh); 244 243
+2 -2
fs/overlayfs/namei.c
··· 542 542 struct ovl_fh *fh; 543 543 int err; 544 544 545 - fh = ovl_encode_real_fh(ofs, real, is_upper); 545 + fh = ovl_encode_real_fh(ofs, d_inode(real), is_upper); 546 546 err = PTR_ERR(fh); 547 547 if (IS_ERR(fh)) { 548 548 fh = NULL; ··· 738 738 struct ovl_fh *fh; 739 739 int err; 740 740 741 - fh = ovl_encode_real_fh(ofs, origin, false); 741 + fh = ovl_encode_real_fh(ofs, d_inode(origin), false); 742 742 if (IS_ERR(fh)) 743 743 return PTR_ERR(fh); 744 744
+1 -1
fs/overlayfs/overlayfs.h
··· 865 865 int ovl_maybe_copy_up(struct dentry *dentry, int flags); 866 866 int ovl_copy_xattr(struct super_block *sb, const struct path *path, struct dentry *new); 867 867 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, 869 869 bool is_upper); 870 870 struct ovl_fh *ovl_get_origin_fh(struct ovl_fs *ofs, struct dentry *origin); 871 871 int ovl_set_origin_fh(struct ovl_fs *ofs, const struct ovl_fh *fh,