[Devel] [PATCH RHEL7 COMMIT] ploop: increase logging on errors when opening new deltas

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jun 30 20:56:48 MSK 2023


The commit is pushed to "branch-rh7-3.10.0-1160.90.1.vz7.200.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.90.1.vz7.200.2
------>
commit 121d3eb4d17c4e055877fe8a06edc2cae725b333
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date:   Thu Jun 8 19:16:43 2023 +0300

    ploop: increase logging on errors when opening new deltas
    
    Ocassionally we got EBUSY but it is a bit over used,
    so it is not clear what it means.
    
    Add more logging to catch the source of the error.
    
    https://jira.vzint.dev/browse/PSBM-146836
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
    Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 drivers/block/ploop/dev.c         |  9 ++++++++-
 drivers/block/ploop/fmt_ploop1.c  |  4 +++-
 drivers/block/ploop/io_kaio.c     | 13 ++++++++++---
 drivers/block/ploop/io_kaio_map.c |  7 +++++--
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 6eb22168b5fe..75e427927713 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -3572,8 +3572,11 @@ static int ploop_replace_delta(struct ploop_device * plo, unsigned long arg)
 			   sizeof(struct ploop_ctl_chunk)))
 		return -EFAULT;
 
-	if (plo->maintenance_type != PLOOP_MNTN_OFF)
+	if (plo->maintenance_type != PLOOP_MNTN_OFF) {
+		if (printk_ratelimit())
+			PL_WARN(plo, "Attempt to replace while in maintenance mode\n");
 		return -EBUSY;
+	}
 
 	old_delta = find_delta(plo, ctl.pctl_level);
 	if (old_delta == NULL)
@@ -3586,6 +3589,10 @@ static int ploop_replace_delta(struct ploop_device * plo, unsigned long arg)
 	if (IS_ERR(delta))
 		return PTR_ERR(delta);
 
+	WARN_ONCE(delta->ops != old_delta->ops,
+		  "New delta uses different io %p vs %p\n",
+		  delta->ops, old_delta->ops);
+
 	err = delta->ops->compose(delta, 1, &chunk);
 	if (err)
 		goto out_destroy;
diff --git a/drivers/block/ploop/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index e59a9eb50ac2..a0369db35c83 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -314,8 +314,10 @@ ploop1_open(struct ploop_delta * delta)
 	if (!(delta->flags & PLOOP_FMT_RDONLY)) {
 		pvd_header_set_disk_in_use(vh);
 		err = delta->io.ops->sync_write(&delta->io, ph->dyn_page, 4096, 0, 0);
-		if (err)
+		if (err) {
+			PL_ERR(delta->plo, "failed to update in use err=%d\n", err);
 			goto out_err;
+		}
 	}
 
 	delta->io.alloc_head = ph->alloc_head;
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 35c0fad43baf..098f6c7b5f2d 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -966,17 +966,23 @@ static int kaio_open(struct ploop_io * io)
 	io->files.bdev = io->files.inode->i_sb->s_bdev;
 
 	err = io->ops->sync(io);
-	if (err)
+	if (err) {
+		PL_WARN(delta->plo, "open failed to sync err=%d\n", err);
 		return err;
+	}
 
 	mutex_lock(&io->files.inode->i_mutex);
 	err = kaio_invalidate_cache(io);
-	if (!err)
+	if (err)
+		PL_WARN(delta->plo, "invaldiate_cache failed err=%d\n", err);
+	else
 		err = ploop_kaio_open(file, delta->flags & PLOOP_FMT_RDONLY);
 	mutex_unlock(&io->files.inode->i_mutex);
 
-	if (err)
+	if (err) {
+		PL_WARN(delta->plo, "open failed err=%d\n", err);
 		return err;
+	}
 
 	io->files.em_tree = &dummy_em_tree;
 
@@ -988,6 +994,7 @@ static int kaio_open(struct ploop_io * io)
 			err = PTR_ERR(io->fsync_thread);
 			io->fsync_thread = NULL;
 			ploop_kaio_close(io->files.mapping, 0);
+			PL_WARN(delta->plo, "fsync thread start failed=%d\n", err);
 			return err;
 		}
 
diff --git a/drivers/block/ploop/io_kaio_map.c b/drivers/block/ploop/io_kaio_map.c
index d4ff39d95e74..59e35c562ef9 100644
--- a/drivers/block/ploop/io_kaio_map.c
+++ b/drivers/block/ploop/io_kaio_map.c
@@ -35,10 +35,13 @@ int ploop_kaio_open(struct file * file, int rdonly)
 				else
 					m->readers++;
 			} else {
-				if (m->readers)
+				if (m->readers) {
+					pr_warn("File is already active:%d\n",
+						m->readers);
 					err = -EBUSY;
-				else
+				} else {
 					m->readers = -1;
+				}
 			}
 			goto kaio_open_done;
 		}


More information about the Devel mailing list