[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 02:49:11 PST 2013
On 11/29/2013 01:34 PM, Cyrill Gorcunov wrote:
>
> Because socket migh lay on btrfs volume (thus the device
> number reported by diag module won't be the same as obtained
> from stat(2)) we need to do an additional test and try
> to resolve device number with help of btrfs engine.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> sk-unix.c | 23 ++++++++++++++++-------
> 1 file changed, 16 insertions(+), 7 deletions(-)
>
> 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;
}
/* full match code here */
Thanks,
Pavel
More information about the CRIU
mailing list