• Cyrill Gorcunov's avatar
    files: Use sys_kcmp to find file descriptor duplicates v4 · 2acc741a
    Cyrill Gorcunov authored
    We switch generic-object-id concept with sys_kcmp approach,
    which implies changes of image format a bit (and since it's
    early time for project overall, we're allowed to).
    
    In short -- previously every file descriptor had an ID
    generated by a kernel and exported via procfs. If the
    appropriate file descriptors were the same objects in
    kernel memory -- the IDs did match up to bit. It allows
    us to figure out which files were actually the identical
    ones and should be restored in a special way.
    
    Once sys_kcmp system call was merged into the kernel,
    we've got a new opprotunity -- to use this syscall instead.
    The syscall basically compares kernel objects and returns
    ordered results suitable for objects sorting in a userspace.
    
    For us it means -- we treat every file descriptor as a combination
    of 'genid' and 'subid'. While 'genid' serves for fast comparison
    between fds, the 'subid' is kind of a second key, which guarantees
    uniqueness of genid+subid tuple over all file descritors found
    in a process (or group of processes).
    
    To be able to find and dump file descriptors in a single pass we
    collect every fd into a global rbtree, where (!) each node might
    become a root for a subtree as well.
    
    The main tree carries only non-equal genid. If we find genid which
    is already in tree, we need to make sure that it's either indeed
    a duplicate or not. For this we use sys_kcmp syscall and if we
    find that file descriptors are different -- we simply put new
    fd into a subtree.
    Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
    Acked-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    2acc741a
Name
Last commit
Last update
Documentation Loading commit data...
include Loading commit data...
test Loading commit data...
tools Loading commit data...
.gitignore Loading commit data...
COPYING Loading commit data...
Makefile Loading commit data...
Makefile.inc Loading commit data...
README Loading commit data...
cr-dump.c Loading commit data...
cr-restore.c Loading commit data...
cr-show.c Loading commit data...
crtools.c Loading commit data...
file-ids.c Loading commit data...
files.c Loading commit data...
gen-offsets.sh Loading commit data...
ipc_ns.c Loading commit data...
libnetlink.c Loading commit data...
log.c Loading commit data...
namespaces.c Loading commit data...
parasite-syscall.c Loading commit data...
parasite.c Loading commit data...
parasite.lds.S Loading commit data...
proc_parse.c Loading commit data...
ptrace.c Loading commit data...
rbtree.c Loading commit data...
restorer-log.c Loading commit data...
restorer.c Loading commit data...
restorer.lds.S Loading commit data...
sockets.c Loading commit data...
sysctl.c Loading commit data...
util-net.c Loading commit data...
util.c Loading commit data...
uts_ns.c Loading commit data...