[Devel] [PATCH v5 vz9 6/7] dm-ploop: make preallocations absolute instead of relative in ploop_req_prealloc()

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Jul 8 05:58:42 MSK 2025



On 7/8/25 03:48, Konstantin Khorenko wrote:
> From: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

This commit message comment looks missing:

- Preallocation in ploop_allocate_cluster() should not depend on (pos <
prealloc_start), so always try to preallocate.

> 
> https://virtuozzo.atlassian.net/browse/VSTOR-108868
> Co-developed-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
> Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
> 
> Feature: dm-ploop: ploop target driver
> ---
...

> @@ -1280,16 +1283,11 @@ static int ploop_allocate_cluster(struct ploop *ploop, u32 *dst_clu, struct file
>   	pos = CLU_TO_POS(ploop, *dst_clu);
>   	end = pos + clu_size;
>   	off = min_t(loff_t, top->file_size, end);
> +	ploop_req_prealloc(ploop, end);
> +
>   	spin_unlock_irqrestore(&ploop->bat_lock, flags);
>   
>   	if (pos < prealloc_start) {
> -		if (end + clu_size >
> -		    top->file_preallocated_area_start - (PREALLOC_SIZE/2)) {
> -			spin_lock_irqsave(&ploop->bat_lock, flags);
> -			ploop_req_prealloc(ploop, PREALLOC_SIZE);
> -			spin_unlock_irqrestore(&ploop->bat_lock, flags);
> -		}
> -
>   		/* Clu at @pos may contain dirty data */
>   		if (!ploop->falloc_new_clu)
>   			ret = ploop_punch_hole(file, pos, off - pos);
> @@ -1314,7 +1312,11 @@ static int ploop_allocate_cluster(struct ploop *ploop, u32 *dst_clu, struct file
>   	spin_lock_irqsave(&ploop->bat_lock, flags);
>   	/* size can change from parallel alloc */
>   	if (end > top->file_size) {
> -		ploop_req_prealloc(ploop, PREALLOC_SIZE);
> +		/*
> +		 * Reset preallocation, in case ploop_preallocate_cluster

s/Reset/Retry/

or

s/Reset/Re-apply/

My original "Reset" wording sounds confusing when I re-read it.

> +		 * dropped it on error path.
> +		 */
> +		ploop_req_prealloc(ploop, end);
>   		spin_unlock_irqrestore(&ploop->bat_lock, flags);
>   
>   		wait_event_interruptible(ploop->dispatcher_wq_prealloc,

-- 
Best regards, Pavel Tikhomirov
Senior Software Developer, Virtuozzo.



More information about the Devel mailing list