rbd: restore zeroing past the overlap when reading from parent
diff mbox series

Message ID 20190827185705.19016-1-idryomov@gmail.com
State New
Headers show
Series
  • rbd: restore zeroing past the overlap when reading from parent
Related show

Commit Message

Ilya Dryomov Aug. 27, 2019, 6:57 p.m. UTC
The parent image is read only up to the overlap point, the rest of
the buffer should be zeroed.  This snuck in because as it turns out
the overlap test case has not been triggering this code path for
a while now.

Fixes: a9b67e69949d ("rbd: replace obj_req->tried_parent with obj_req->read_state")
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 drivers/block/rbd.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Jason Dillaman Aug. 27, 2019, 7:33 p.m. UTC | #1
On Tue, Aug 27, 2019 at 2:54 PM Ilya Dryomov <idryomov@gmail.com> wrote:
>
> The parent image is read only up to the overlap point, the rest of
> the buffer should be zeroed.  This snuck in because as it turns out
> the overlap test case has not been triggering this code path for
> a while now.
>
> Fixes: a9b67e69949d ("rbd: replace obj_req->tried_parent with obj_req->read_state")
> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
> ---
>  drivers/block/rbd.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 58d9f17363d7..13f42f5b06cc 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -3038,6 +3038,17 @@ static bool rbd_obj_advance_read(struct rbd_obj_request *obj_req, int *result)
>                 }
>                 return true;
>         case RBD_OBJ_READ_PARENT:
> +               /*
> +                * The parent image is read only up to the overlap -- zero-fill
> +                * from the overlap to the end of the request.
> +                */
> +               if (!*result) {
> +                       u32 obj_overlap = rbd_obj_img_extents_bytes(obj_req);
> +
> +                       if (obj_overlap < obj_req->ex.oe_len)
> +                               rbd_obj_zero_range(obj_req, obj_overlap,
> +                                           obj_req->ex.oe_len - obj_overlap);
> +               }
>                 return true;
>         default:
>                 BUG();
> --
> 2.19.2
>

Reviewed-by: Jason Dillaman <dillaman@redhat.com>


--
Jason

Patch
diff mbox series

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 58d9f17363d7..13f42f5b06cc 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3038,6 +3038,17 @@  static bool rbd_obj_advance_read(struct rbd_obj_request *obj_req, int *result)
 		}
 		return true;
 	case RBD_OBJ_READ_PARENT:
+		/*
+		 * The parent image is read only up to the overlap -- zero-fill
+		 * from the overlap to the end of the request.
+		 */
+		if (!*result) {
+			u32 obj_overlap = rbd_obj_img_extents_bytes(obj_req);
+
+			if (obj_overlap < obj_req->ex.oe_len)
+				rbd_obj_zero_range(obj_req, obj_overlap,
+					    obj_req->ex.oe_len - obj_overlap);
+		}
 		return true;
 	default:
 		BUG();