[Devel] [vzlin-dev] [PATCH rh7] ploop: must acquire write access on space allocation

Dmitry Monakhov dmonakhov at openvz.org
Wed Mar 16 05:22:01 PDT 2016


Maxim Patlasov <mpatlasov at virtuozzo.com> writes:

> Port Dima's patch:
>
>> ploop must obey write access convention on slow path.
>>
>> Normally no one shoult freeze private-fs bcause this may result in weird glitches.
>> But in case of vzfs-layout freezefs is possible for a small about of time.
>> https://jira.sw.ru/browse/PSBM-20150
>>
>> Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
>
Ack-by: Dmitry Monakhov <dmonakhov at openvz.org>
> Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
> ---
>  drivers/block/ploop/io_direct.c |   17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
> index d6f0f21..0c7e0c4 100644
> --- a/drivers/block/ploop/io_direct.c
> +++ b/drivers/block/ploop/io_direct.c
> @@ -384,6 +384,8 @@ cached_submit(struct ploop_io *io, iblock_t iblk, struct ploop_request * preq,
>  	end_pos = pos + clu_siz;
>  	used_pos = (io->alloc_head - 1) << (io->plo->cluster_log + 9);
>  
> +	file_start_write(io->files.file);
> +
>  #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24)
>  	if (use_prealloc && end_pos > used_pos && may_fallocate) {
>  		if (unlikely(io->prealloced_size < clu_siz)) {
> @@ -398,7 +400,7 @@ try_again:
>  					prealloc = clu_siz;
>  					goto try_again;
>  				} else {
> -					return err;
> +					goto end_write;
>  				}
>  			}
>  
> @@ -414,14 +416,17 @@ try_again:
>  		sector_t len = 1 << preq->plo->cluster_log;
>  		struct extent_map * em = extent_lookup_create(io, sec, len);
>  
> -		if (unlikely(IS_ERR(em)))
> -			return PTR_ERR(em);
> +		if (unlikely(IS_ERR(em))) {
> +			err = PTR_ERR(em);
> +			goto end_write;
> +		}
>  
>  		preq->iblock = iblk;
>  		preq->eng_io = io;
>  		set_bit(PLOOP_REQ_POST_SUBMIT, &preq->state);
>  		dio_submit_pad(io, preq, sbl, size, em);
> -		return 0;
> +		err = 0;
> +		goto end_write;
>  	}
>  
>  	bio_iter_init(&biter, sbl);
> @@ -496,6 +501,8 @@ try_again:
>  			mod_timer(&io->fsync_timer, jiffies + plo->tune.fsync_delay);
>  		spin_unlock_irq(&plo->lock);
>  	}
> +end_write:
> +	file_end_write(io->files.file);
>  	return err;
>  }
>  
> @@ -506,9 +513,11 @@ dio_post_submit(struct ploop_io *io, struct ploop_request * preq)
>  	loff_t clu_siz = 1 << (preq->plo->cluster_log + 9);
>  	int err;
>  
> +	file_start_write(io->files.file);
>  	err = io->files.file->f_op->fallocate(io->files.file,
>  					      FALLOC_FL_CONVERT_UNWRITTEN,
>  					      (loff_t)sec << 9, clu_siz);
> +	file_end_write(io->files.file);
>  	if (err) {
>  		PLOOP_REQ_SET_ERROR(preq, err);
>  		set_bit(PLOOP_S_ABORT, &preq->plo->state);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/devel/attachments/20160316/7d339ccb/attachment.sig>


More information about the Devel mailing list