[CRIU] [PATCH 1/2] mount: fill fstypes for btrfs mounts on restore

Andrew Vagin avagin at parallels.com
Fri Apr 18 00:16:26 PDT 2014


On Thu, Apr 17, 2014 at 05:34:43PM +0400, Pavel Emelyanov wrote:
> On 04/17/2014 03:04 PM, Andrew Vagin wrote:
> > BTRFS returns subvolume dev-id instead of superblock dev-id,
> > so we need to know which mounts are btrfs.
> > 
> > Signed-off-by: Andrew Vagin <avagin at openvz.org>
> > ---
> >  include/fs-magic.h |  4 ++++
> >  mount.c            | 13 +++++++++++++
> >  2 files changed, 17 insertions(+)
> > 
> > diff --git a/include/fs-magic.h b/include/fs-magic.h
> > index 9db3ee9..12bb982 100644
> > --- a/include/fs-magic.h
> > +++ b/include/fs-magic.h
> > @@ -33,4 +33,8 @@
> >  #define DEVPTS_SUPER_MAGIC	0x1cd1
> >  #endif
> >  
> > +#ifndef BTRFS_SUPER_MAGIC
> > +#define BTRFS_SUPER_MAGIC	0x9123683E
> > +#endif
> > +
> >  #endif /* __CR_FS_MAGIC_H__ */
> > diff --git a/mount.c b/mount.c
> > index 043b2c3..cddaf7f 100644
> > --- a/mount.c
> > +++ b/mount.c
> > @@ -25,6 +25,8 @@
> >  #include "namespaces.h"
> >  #include "protobuf.h"
> >  #include "kerndat.h"
> > +#include "fs-magic.h"
> > +
> >  #include "protobuf/mnt.pb-c.h"
> >  
> >  /*
> > @@ -1230,6 +1232,17 @@ static int do_mount_one(struct mount_info *mi)
> >  	if (ret == 0 && propagate_mount(mi))
> >  		return -1;
> >  
> > +	if (mi->fstype->code == FSTYPE__UNSUPPORTED) {
> > +		struct statfs st;
> > +
> > +		if (statfs(mi->mountpoint, &st)) {
> > +			pr_perror("Unable to statfs %s", mi->mountpoint);
> > +			return -1;
> > +		}
> > +		if (st.f_type == BTRFS_SUPER_MAGIC)
> > +			mi->fstype = find_fstype_by_name("btrfs");
> 
> mi->fstype = find_fstype_by_name(mi->fstype->name)?

mi->fstype->name is "unsuppoerted" here, because fstype->code is saved in an image
{
.name = "unsupported",
.code = FSTYPE__UNSUPPORTED,
}, 
{
.name = "btrfs",
.code = FSTYPE__UNSUPPORTED,
}

An a second reason is that pocesses can be migrated from smth to btrfs.

> 
> > +	}
> > +
> >  	return ret;
> >  }
> >  
> > 
> 
> 


More information about the CRIU mailing list