[Devel] [PATCH rh7] ploop: push_backup: fix ploop_push_backup_io_read()

Konstantin Khorenko khorenko at virtuozzo.com
Thu May 12 07:05:21 PDT 2016


On 05/12/2016 04:26 AM, Maxim Patlasov wrote:
> ploop_push_backup_io_read() services ioctl(PLOOP_IOC_PUSH_BACKUP_IO)
> for direction = PLOOP_READ.
>
> If at least one extent is successfully filled, the -ENOENT error from
> ploop_pb_get_pending() must be interpreted as "OK, no more data present".
>
> https://jira.sw.ru/browse/PSBM-45000
>
> Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
> ---
>   drivers/block/ploop/dev.c |    4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
> index 1e511d7..c103b79 100644
> --- a/drivers/block/ploop/dev.c
> +++ b/drivers/block/ploop/dev.c
> @@ -4585,7 +4585,9 @@ static int ploop_push_backup_io_read(struct ploop_device *plo, unsigned long arg
>   	while (n_extents < ctl->n_extents) {
>   		cluster_t clu, len;
>   		rc = ploop_pb_get_pending(plo->pbd, &clu, &len, n_extents);
> -		if (rc)
> +		if (rc == -ENOENT && n_extents)
> +			break;
> +		else if (rc)
>   			goto io_read_done;
>
>   		e[n_extents].clu = clu;
>

Is userspace forced to provide an empty buffer which is going to be filled by ioctl(PLOOP_IOC_PUSH_BACKUP_IO)?

If no and n_extents == 0 and ploop_pb_get_pending() returned -ENOENT due to some reason,
userspace might read garbage from n_extents (which is probably left from previous iteration)
and don't detect a failure.

May be to fill struct ploop_push_backup_io_ctl in userspace data on errors as well?


More information about the Devel mailing list