drbd: debugfs: add per device data_gen_id
authorLars Ellenberg <lars.ellenberg@linbit.com>
Wed, 14 May 2014 18:33:05 +0000 (20:33 +0200)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 10 Jul 2014 16:35:21 +0000 (18:35 +0200)
The data generation identifiers used to be exposed via sysfs
at /sys/block/drbdX/drbd/meta_data/data_gen_id (out-of-tree),
for advanced policy scripting.
Bring that information over to debugfs.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_debugfs.c

index db70d6caf2205e07974c01550150ffeeb9d5149e..5c20b18540b866efb929074f7a94a039c72b09ea 100644 (file)
@@ -760,6 +760,25 @@ static int device_oldest_requests_show(struct seq_file *m, void *ignored)
        return 0;
 }
 
+static int device_data_gen_id_show(struct seq_file *m, void *ignored)
+{
+       struct drbd_device *device = m->private;
+       struct drbd_md *md;
+       enum drbd_uuid_index idx;
+
+       if (!get_ldev_if_state(device, D_FAILED))
+               return -ENODEV;
+
+       md = &device->ldev->md;
+       spin_lock_irq(&md->uuid_lock);
+       for (idx = UI_CURRENT; idx <= UI_HISTORY_END; idx++) {
+               seq_printf(m, "0x%016llX\n", md->uuid[idx]);
+       }
+       spin_unlock_irq(&md->uuid_lock);
+       put_ldev(device);
+       return 0;
+}
+
 #define drbd_debugfs_device_attr(name)                                         \
 static int device_ ## name ## _open(struct inode *inode, struct file *file)    \
 {                                                                              \
@@ -784,6 +803,7 @@ static const struct file_operations device_ ## name ## _fops = {            \
 drbd_debugfs_device_attr(oldest_requests)
 drbd_debugfs_device_attr(act_log_extents)
 drbd_debugfs_device_attr(resync_extents)
+drbd_debugfs_device_attr(data_gen_id)
 
 void drbd_debugfs_device_add(struct drbd_device *device)
 {
@@ -826,6 +846,8 @@ void drbd_debugfs_device_add(struct drbd_device *device)
        DCF(oldest_requests);
        DCF(act_log_extents);
        DCF(resync_extents);
+       DCF(data_gen_id);
+#undef DCF
        return;
 
 fail:
This page took 0.025346 seconds and 5 git commands to generate.