• Oleg Nesterov's avatar
    make resolve_source() more friendly to FSTYPE__AUTO mounts · 323726b7
    Oleg Nesterov authored
    resolve_source() insists on kdev_major() == 0, and this makes sense.
    However, at least FSTYPE__AUTO can try to use mi->source as a block
    device and pray it will work.
    
    [ Also bout this change from Oleg:
    
    Let me send another (last) functional change before the promised
    cleanups we discussed.
    
    To remind, without this patch I still can't dump/restore /home and
    /boot on my testing machine. --enable-fs xfs "works" in a sense that
    "dump" succeeds. But "restore" fails.
    
    However. Lets forget this for the moment. To me resolve_source() looks
    just wrong. Sure, I agree, it is not safe to blindly use mi->source if
    kdev_major() != 0. But this means that we should not have dumped this
    mountpoint, simply because we can't restore it.
    
    Yes, currently this works because fstypes[] contains only the diskless
    filesystems, but still.
    
    So this probably needs more cleanups too, and this patch doesn't make
    this logic look better.
    
    To me, we should do something like
    
    	static char *resolve_source(struct mount_info *mi)
    	{
    		if (kdev_major(mi->s_dev) == 0)
    			/*
    			 * Anonymous block device. Kernel creates them for
    			 * diskless mounts.
    			 */
    			return mi->source;
    
    		if (mi->fstype->code != FSTYPE__AUTO) {
    			pr_err("OOPS! something is wrong!!!\n");
    			return NULL;
    		}
    
    		// OK, this is FSTYPE__AUTO, it should "just work"
    		// by definition. Or the user should blame himself.
    
    		struct stat st;
    
    		if (stat(mi->source, &st) || !S_ISBLK(st.st_mode) ||
    		    major(st.st_rdev) != kdev_major(mi->s_dev) ||
    		    minor(st.st_rdev) != kdev_minor(mi->s_dev))
    			pr_warn("Hmm, can't verify blkdev. Lets see if mount will work...\n");
    
    		return mi->source;
    	}
    
    But this patch only does a minimal change to make FSTYPE__AUTO work
    with blkdev.
    
    ]
    Signed-off-by: 's avatarOleg Nesterov <oleg@redhat.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    323726b7
Name
Last commit
Last update
Documentation Loading commit data...
arch Loading commit data...
contrib Loading commit data...
include Loading commit data...
lib Loading commit data...
pie Loading commit data...
protobuf Loading commit data...
pycriu Loading commit data...
scripts Loading commit data...
test Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Dockerfile Loading commit data...
Makefile Loading commit data...
Makefile.config Loading commit data...
Makefile.crtools Loading commit data...
Makefile.inc Loading commit data...
README Loading commit data...
action-scripts.c Loading commit data...
aio.c Loading commit data...
bfd.c Loading commit data...
cgroup.c Loading commit data...
cr-check.c Loading commit data...
cr-dedup.c Loading commit data...
cr-dump.c Loading commit data...
cr-errno.c Loading commit data...
cr-exec.c Loading commit data...
cr-restore.c Loading commit data...
cr-service.c Loading commit data...
cr-show.c Loading commit data...
crit Loading commit data...
crtools Loading commit data...
crtools.c Loading commit data...
eventfd.c Loading commit data...
eventpoll.c Loading commit data...
fifo.c Loading commit data...
file-ids.c Loading commit data...
file-lock.c Loading commit data...
files-ext.c Loading commit data...
files-reg.c Loading commit data...
files.c Loading commit data...
fsnotify.c Loading commit data...
image-desc.c Loading commit data...
image.c Loading commit data...
ipc_ns.c Loading commit data...
irmap.c Loading commit data...
kcmp-ids.c Loading commit data...
kerndat.c Loading commit data...
libnetlink.c Loading commit data...
log.c Loading commit data...
mem.c Loading commit data...
mount.c Loading commit data...
namespaces.c Loading commit data...
net.c Loading commit data...
netfilter.c Loading commit data...
page-pipe.c Loading commit data...
page-read.c Loading commit data...
page-xfer.c Loading commit data...
pagemap-cache.c Loading commit data...
parasite-syscall.c Loading commit data...
pipes.c Loading commit data...
plugin.c Loading commit data...
proc_parse.c Loading commit data...
protobuf-desc.c Loading commit data...
protobuf.c Loading commit data...
pstree.c Loading commit data...
ptrace.c Loading commit data...
rbtree.c Loading commit data...
rst-malloc.c Loading commit data...
sd-daemon.c Loading commit data...
sd-daemon.h Loading commit data...
security.c Loading commit data...
shmem.c Loading commit data...
sigframe.c Loading commit data...
signalfd.c Loading commit data...
sk-inet.c Loading commit data...
sk-netlink.c Loading commit data...
sk-packet.c Loading commit data...
sk-queue.c Loading commit data...
sk-tcp.c Loading commit data...
sk-unix.c Loading commit data...
sockets.c Loading commit data...
stats.c Loading commit data...
string.c Loading commit data...
sysctl.c Loading commit data...
sysfs_parse.c Loading commit data...
timerfd.c Loading commit data...
tty.c Loading commit data...
tun.c Loading commit data...
util.c Loading commit data...
uts_ns.c Loading commit data...