[Devel] [PATCH RHEL7 COMMIT] ploop: must acquire write access on space allocation

Konstantin Khorenko khorenko at virtuozzo.com
Fri Mar 18 04:26:34 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.3
------>
commit bbfef101578d18739f11c24fffbb355569fe0082
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date:   Fri Mar 18 15:26:34 2016 +0400

    ploop: must acquire write access on space allocation
    
    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>
    
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
    Acked-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
 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);


More information about the Devel mailing list