Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Add a flashcache release number, exported by /proc/flashcache_version…
Browse files Browse the repository at this point in the history
… (and

/proc/flashcache_wt_version).
  • Loading branch information
Mohan Srinivasan committed Aug 3, 2010
1 parent f96fb9d commit 88a2461
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
38 changes: 38 additions & 0 deletions flashcache-wt/src/flashcache_wt.c
Expand Up @@ -36,6 +36,8 @@
#include <linux/pagemap.h>
#include <linux/random.h>
#include <linux/version.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
#include "dm.h"
Expand All @@ -52,6 +54,9 @@

#include "flashcache_wt.h"

#define FLASHCACHE_WT_SW_VERSION "flashcache_wt-1.0"
char *flashcache_wt_sw_version = FLASHCACHE_WT_SW_VERSION;

static struct workqueue_struct *_kcached_wq;
static struct work_struct _kcached_work;

Expand Down Expand Up @@ -1213,6 +1218,26 @@ static struct target_type cache_target = {
.status = cache_status,
};

static int
flashcache_wt_version_show(struct seq_file *seq, void *v)
{
seq_printf(seq, "Flashcache_wt Version : %s\n", flashcache_wt_sw_version);
return 0;
}

static int
flashcache_wt_version_open(struct inode *inode, struct file *file)
{
return single_open(file, &flashcache_wt_version_show, NULL);
}

static struct file_operations flashcache_wt_version_operations = {
.open = flashcache_wt_version_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

/*
* Initiate a cache target.
*/
Expand Down Expand Up @@ -1243,6 +1268,15 @@ flashcache_wt_init(void)
if (r < 0) {
DMERR("cache: register failed %d", r);
}
#ifdef CONFIG_PROC_FS
{
struct proc_dir_entry *entry;

entry = create_proc_entry("flashcache_wt_version", 0, NULL);
if (entry)
entry->proc_fops = &flashcache_wt_version_operations;
}
#endif
return r;
}

Expand All @@ -1262,6 +1296,10 @@ flashcache_wt_exit(void)
#endif
jobs_exit();
destroy_workqueue(_kcached_wq);
#ifdef CONFIG_PROC_FS
remove_proc_entry("flashcache_wt_version", NULL);
#endif

}

module_init(flashcache_wt_init);
Expand Down
28 changes: 27 additions & 1 deletion src/flashcache_conf.c
Expand Up @@ -1927,6 +1927,28 @@ static struct file_operations flashcache_pidlists_operations = {
.release = single_release,
};

extern char *flashcache_sw_version;

static int
flashcache_version_show(struct seq_file *seq, void *v)
{
seq_printf(seq, "Flashcache Version : %s\n", flashcache_sw_version);
return 0;
}

static int
flashcache_version_open(struct inode *inode, struct file *file)
{
return single_open(file, &flashcache_version_show, NULL);
}

static struct file_operations flashcache_version_operations = {
.open = flashcache_version_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

/*
* Initiate a cache target.
*/
Expand Down Expand Up @@ -1973,7 +1995,10 @@ flashcache_init(void)
entry->proc_fops = &flashcache_iosize_hist_operations;
entry = create_proc_entry("flashcache_pidlists", 0, NULL);
if (entry)
entry->proc_fops = &flashcache_pidlists_operations;
entry->proc_fops = &flashcache_pidlists_operations;
entry = create_proc_entry("flashcache_version", 0, NULL);
if (entry)
entry->proc_fops = &flashcache_version_operations;
}
#endif
flashcache_control = (struct flashcache_control_s *)
Expand Down Expand Up @@ -2005,6 +2030,7 @@ flashcache_exit(void)
remove_proc_entry("flashcache_errors", NULL);
remove_proc_entry("flashcache_iosize_hist", NULL);
remove_proc_entry("flashcache_pidlists", NULL);
remove_proc_entry("flashcache_version", NULL);
#endif
kfree(flashcache_control);
}
Expand Down
3 changes: 3 additions & 0 deletions src/flashcache_main.c
Expand Up @@ -68,6 +68,9 @@
* cache read miss.
*/

#define FLASHCACHE_SW_VERSION "flashcache-1.0"
char *flashcache_sw_version = FLASHCACHE_SW_VERSION;

static void flashcache_read_miss(struct cache_c *dmc, struct bio* bio,
int index);
static void flashcache_write(struct cache_c *dmc, struct bio* bio);
Expand Down

0 comments on commit 88a2461

Please sign in to comment.