Re: [PATCH 02/20] block, blksnap: header file of the module interface

Christoph Hellwig
2022-07-06T13:03:58Z

On Mon, Jun 13, 2022 at 06:52:55PM +0300, Sergei Shtepa wrote:
> The header file contains a set of declarations, structures and control
> requests (ioctl) that allows to manage the module from the user space.

I think this should go into include/uapi/ if you want it in a global
place.

> +#pragma once

In the kernel we use classic #ifdef based guards.

> +#include <linux/types.h>
> +#include <linux/uuid.h>

The uuid_t type can't be used in a userspae API. Please use a raw
__u8 API and then use import_uuid.

> +#define BLK_SNAP_MODULE_NAME "blksnap"

Does this belong into a user interface?

> +#define BLK_SNAP_IMAGE_NAME "blksnap-image"
> +#define BLK_SNAP 'V'
> +
> +enum blk_snap_ioctl {
> + /*
> + * Service controls
> + */
> + blk_snap_ioctl_version,
> + /*
> + * Contols for tracking
> + */
> + blk_snap_ioctl_tracker_remove,
> + blk_snap_ioctl_tracker_collect,
> + blk_snap_ioctl_tracker_read_cbt_map,
> + blk_snap_ioctl_tracker_mark_dirty_blocks,
> + /*
> + * Snapshot contols
> + */
> + blk_snap_ioctl_snapshot_create,
> + blk_snap_ioctl_snapshot_destroy,
> + blk_snap_ioctl_snapshot_append_storage,
> + blk_snap_ioctl_snapshot_take,
> + blk_snap_ioctl_snapshot_collect,
> + blk_snap_ioctl_snapshot_collect_images,
> + blk_snap_ioctl_snapshot_wait_event,
> + blk_snap_ioctl_end,

For uapis classic #defines have the adnvantage that userspace can test
for their presence if new ones get added. Also the _end one should not
be in an UAPI header as new ones can be added at any time.