[CRIU] [PATCH 5/5] sk-unix: Don't fail if socket path lays on btrfs volume
Pavel Emelyanov
xemul at parallels.com
Fri Nov 29 03:26:13 PST 2013
On 11/29/2013 03:15 PM, Cyrill Gorcunov wrote:
> On Fri, Nov 29, 2013 at 02:49:11PM +0400, Pavel Emelyanov wrote:
>>
>>> if ((st.st_ino != uv->udiag_vfs_ino) ||
>>> - (st.st_dev != kdev_to_odev(uv->udiag_vfs_dev))) {
>>> + ((st.st_dev != kdev_to_odev(uv->udiag_vfs_dev) &&
>>> + !btrfs_dev_match(name, st.st_dev)))) {
>>
>> Why do we do name matching? Let's imagine we have a btrfs on disk with 2 subvols
>> and have a unix socket on either of them.
>>
>> Let the disk's device be D, subvol 1 id be V1, subvol 2 id be V2.
>> In this if (), let the st.st_ino is S and uv->udiag_vfs_dev is U.
>>
>> If the socket is on the btrfs disk, then we'll have S != U, U == D and
>> (S == V1 || S == V2), right? In order to fix the devices comparison we need
>> a btrfs_vol_to_dev() function that will convert V1 -> D, V2 -> D and any other
>> number to 0. This is valid, since D, V1 and V2 cannot match any other dev_t
>> in the system.
>>
>> Thus the proper if should look like this
>>
>> if (S != U) {
>> int btrfs_dev;
>>
>> /* S == V1 || S == V2 */
>> btrfs_dev = btrfs_vol_to_dev(S);
>> /* now btrfs_dev is D for btrfs and 0 otherwise */
>> if (btrfs_dev != U)
>> goto mismatch;
>> }
>
> Actually no, inode returned by diag module should match the one
> obtained from stat call, since it's not mangled by btrfs if only
> I'm not missing something obvious.
In the code above I only talk about devices. Inodes matching is
required as well, of course.
> So the only thing which may differ is a device number itself.
> Gimme somethime, I've had a scenario in my head to claim why
> longest path matching is needed but can't recall now...
OK
More information about the CRIU
mailing list