[CRIU] [PATCH] [RFC] locks: fix up a device returned by stat() for btrfs

Andrew Vagin avagin at parallels.com
Wed Sep 3 05:22:23 PDT 2014


On Wed, Sep 03, 2014 at 03:54:41PM +0400, Andrew Vagin wrote:
> BTRFS returns subvolume dev-id instead of superblock dev-id,
> in such case return device obtained from mountinfo (ie subvolume0).
> 
> Reported-by: Mr Jenkins
> Signed-off-by: Andrew Vagin <avagin at openvz.org>
> ---
>  file-lock.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/file-lock.c b/file-lock.c
> index b6a511f..f380010 100644
> --- a/file-lock.c
> +++ b/file-lock.c
> @@ -10,6 +10,8 @@
>  #include "fdset.h"
>  #include "files.h"
>  #include "image.h"
> +#include "mount.h"
> +#include "proc_parse.h"
>  #include "servicefd.h"
>  #include "file-lock.h"
>  #include "parasite.h"
> @@ -123,8 +125,20 @@ err:
>  
>  static inline bool lock_file_match(struct file_lock *fl, struct fd_parms *p)
>  {
> +	struct mount_info *m;
> +	dev_t dev = p->stat.st_dev;
> +
> +	/* Get the right devices for BTRFS. Look at phys_stat_resolve_dev()
> +	 * for more details.
> +	 */
> +	if (p->mnt_id != -1) {
> +		m = lookup_mnt_id(p->mnt_id);
> +		BUG_ON(m == NULL);
> +		dev = kdev_to_odev(m->s_dev);

We can meet pipes and others here:

+ setsid /mnt/btrfs/workspace/criu dump -D /mnt/btrfs/workspace/test/dump/static/pipe00/30250/1 -o dump.log -v4 -t 30250
test/zdtm.sh: line 547: 30266 Aborted                 (core dumped) setsid $CRIU_CPT $dump_cmd -D $ddump -o dump.log -v4 -t $PID $gen_args $cpt_args

> +	}
> +
>  	return fl->i_no == p->stat.st_ino &&
> -		makedev(fl->maj, fl->min) == p->stat.st_dev;
> +		makedev(fl->maj, fl->min) == dev;
>  }
>  
>  static int lock_check_fd(int lfd, struct file_lock *fl)
> -- 
> 1.9.3
> 


More information about the CRIU mailing list