• Miklos Szeredi's avatar
    ovl: share inode for hard link · 51f7e52d
    Miklos Szeredi authored
    Inode attributes are copied up to overlay inode (uid, gid, mode, atime,
    mtime, ctime) so generic code using these fields works correcty.  If a hard
    link is created in overlayfs separate inodes are allocated for each link.
    If chmod/chown/etc. is performed on one of the links then the inode
    belonging to the other ones won't be updated.
    
    This patch attempts to fix this by sharing inodes for hard links.
    
    Use inode hash (with real inode pointer as a key) to make sure overlay
    inodes are shared for hard links on upper.  Hard links on lower are still
    split (which is not user observable until the copy-up happens, see
    Documentation/filesystems/overlayfs.txt under "Non-standard behavior").
    
    The inode is only inserted in the hash if it is non-directoy and upper.
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
    51f7e52d
dir.c 21.4 KB