Re: [PATCH v5 19/31] qcow2: Add subcluster support to calculate_l2_meta()

2020-05-07 Thread Alberto Garcia
On Thu 07 May 2020 05:34:18 PM CEST, Alberto Garcia wrote: > On Wed 06 May 2020 07:39:48 PM CEST, Eric Blake wrote: >> In fact, if we rely on 20/31 checking for invalid subclusters when >> computing nb_clusters, we could probably assert that the start and end >> cluster in this function are not

Re: [PATCH v5 19/31] qcow2: Add subcluster support to calculate_l2_meta()

2020-05-07 Thread Alberto Garcia
On Wed 06 May 2020 07:39:48 PM CEST, Eric Blake wrote: > In fact, if we rely on 20/31 checking for invalid subclusters when > computing nb_clusters, we could probably assert that the start and end > cluster in this function are not invalid, instead of adding the fail: > label. I think you're

Re: [PATCH v5 19/31] qcow2: Add subcluster support to calculate_l2_meta()

2020-05-06 Thread Eric Blake
On 5/6/20 12:14 PM, Alberto Garcia wrote: Note that you are only skipping until the first normal subcluster, even if other zero/unallocated clusters occur between the first normal cluster and the start of the action. That's correct. Or visually, suppose we have:

Re: [PATCH v5 19/31] qcow2: Add subcluster support to calculate_l2_meta()

2020-05-06 Thread Alberto Garcia
On Tue 05 May 2020 11:59:18 PM CEST, Eric Blake wrote: >> +for (i = first_sc; i <= last_sc; i++) { >> +unsigned c = i / s->subclusters_per_cluster; >> +unsigned sc = i % s->subclusters_per_cluster; >> +l2_entry = get_l2_entry(s, l2_slice, l2_index + c);

Re: [PATCH v5 19/31] qcow2: Add subcluster support to calculate_l2_meta()

2020-05-05 Thread Eric Blake
On 5/5/20 12:38 PM, Alberto Garcia wrote: If an image has subclusters then there are more copy-on-write scenarios that we need to consider. Let's say we have a write request from the middle of subcluster #3 until the end of the cluster: 1) If we are writing to a newly allocated cluster then we

[PATCH v5 19/31] qcow2: Add subcluster support to calculate_l2_meta()

2020-05-05 Thread Alberto Garcia
If an image has subclusters then there are more copy-on-write scenarios that we need to consider. Let's say we have a write request from the middle of subcluster #3 until the end of the cluster: 1) If we are writing to a newly allocated cluster then we need copy-on-write. The previous contents