[Devel] [PATCH RHEL7 COMMIT] ploop: expose open_count to sysfs

Konstantin Khorenko khorenko at odin.com
Mon May 18 21:27:06 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.1
------>
commit 97ba7085978ee4245beaf43c5543cb230094189d
Author: Andrey Smetanin <asmetanin at virtuozzo.com>
Date:   Tue May 19 08:27:06 2015 +0400

    ploop: expose open_count to sysfs
    
    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 <MPatlasov at 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
 };
 



More information about the Devel mailing list