[CRIU] [PATCH] btrfs: Don't fail if we meet non-subvolume mountpoint

Pavel Emelyanov xemul at parallels.com
Thu Dec 5 03:25:04 PST 2013


On 12/05/2013 03:19 PM, Cyrill Gorcunov wrote:
> On Thu, Dec 05, 2013 at 03:10:01PM +0400, Pavel Emelyanov wrote:
>>>  
>>> -	if (stat(m->mountpoint, &st)) {
>>> -		pr_perror("Can't get stat on %s", m->mountpoint);
>>> +	if (st.st_ino != BTRFS_FIRST_FREE_OBJECTID)
>>> +		return ERR_PTR(-ENOENT);
>>> +
>>> +	fd = open(m->mountpoint, O_RDONLY);
>>> +	if (fd < 0) {
>>> +		pr_perror("Can't open %s", m->mountpoint);
>>
>> Don't do start + open. Do open + fstat.
> 
> How it's different? If we hit non BTRFS_FIRST_FREE_OBJECTID we exit earlier.

It's less patching and a bit liter execution (fstat doesn't go through
path resolution).

>>>  
>>>  int btrfs_parse_mountinfo(struct mount_info *m)
>>>  {
>>> -	return btrfs_parse_volume(m) ? 0 : -1;
>>> +	struct btrfs_subvol_root *r;
>>> +
>>> +	r = btrfs_parse_volume(m);
>>> +	if (IS_ERR(r)) {
>>> +		if (PTR_ERR(r) == -ENOENT)
>>> +			return 0;
>>> +		return -1;
>>> +	}
>>> +	return r ? 0 : -1;
>>
>> This looks tricky. Why not make btrfs_parse_volume() return int and
>> decide when to report error and when not itself?
>>
> 
> I think I'll need to use this btrfs_subvol_root returned pointer for
> lazy scheme (the patch in current stat become smaller in size, that's
> the only idea I carried for now).

OK, then brush this up a little to have less than 3 if-s.


More information about the CRIU mailing list