The patch shows number of opened instances of ploop-device (plo->open_count)
in /sys/block/ploopN/pstate/open_count. This will allow userspace to decide
whether a ploop-device is used by someone (e.g. backup) by scanning the
open_count for all ploop-devices.

https://jira.sw.ru/browse/PSBM-24754

Signed-off-by: Maxim Patlasov <mpatla...@parallels.com>
---
 drivers/block/ploop/sysfs.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/block/ploop/sysfs.c b/drivers/block/ploop/sysfs.c
index 5c31826..3ef53ac 100644
--- a/drivers/block/ploop/sysfs.c
+++ b/drivers/block/ploop/sysfs.c
@@ -383,6 +383,11 @@ static u32 show_event(struct ploop_device * plo)
        return ret;
 }
 
+static u32 show_open_count(struct ploop_device * plo)
+{
+       return atomic_read(&plo->open_count);
+}
+
 static ssize_t print_cookie(struct ploop_device * plo, char * page)
 {
        return sprintf(page, "%s\n", plo->cookie);
@@ -466,6 +471,7 @@ static struct attribute *state_attributes[] = {
        _A(top),
        _A(event),
        _A3(cookie),
+       _A(open_count),
        NULL
 };
 
-- 
1.9.3

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to