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

Commit

Permalink
fix compilation on kernel 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor committed Jul 6, 2013
1 parent 91b7a08 commit 36548a0
Showing 1 changed file with 79 additions and 28 deletions.
107 changes: 79 additions & 28 deletions src/flashcache_procfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,12 @@ flashcache_stats_show(struct seq_file *seq, void *v)
static int
flashcache_stats_open(struct inode *inode, struct file *file)
{
return single_open(file, &flashcache_stats_show, PDE(inode)->data);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
return single_open(file, &flashcache_stats_show, PDE(inode)->data);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
return single_open(file, &flashcache_stats_show, PDE_DATA(inode));
#endif
}

static struct file_operations flashcache_stats_operations = {
Expand Down Expand Up @@ -849,7 +854,12 @@ flashcache_errors_show(struct seq_file *seq, void *v)
static int
flashcache_errors_open(struct inode *inode, struct file *file)
{
return single_open(file, &flashcache_errors_show, PDE(inode)->data);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
return single_open(file, &flashcache_errors_show, PDE(inode)->data);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
return single_open(file, &flashcache_errors_show, PDE_DATA(inode));
#endif
}

static struct file_operations flashcache_errors_operations = {
Expand All @@ -874,7 +884,12 @@ flashcache_iosize_hist_show(struct seq_file *seq, void *v)
static int
flashcache_iosize_hist_open(struct inode *inode, struct file *file)
{
return single_open(file, &flashcache_iosize_hist_show, PDE(inode)->data);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
return single_open(file, &flashcache_iosize_hist_show, PDE(inode)->data);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
return single_open(file, &flashcache_iosize_hist_show, PDE_DATA(inode));
#endif
}

static struct file_operations flashcache_iosize_hist_operations = {
Expand Down Expand Up @@ -913,7 +928,12 @@ flashcache_pidlists_show(struct seq_file *seq, void *v)
static int
flashcache_pidlists_open(struct inode *inode, struct file *file)
{
return single_open(file, &flashcache_pidlists_show, PDE(inode)->data);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
return single_open(file, &flashcache_pidlists_show, PDE(inode)->data);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
return single_open(file, &flashcache_pidlists_show, PDE_DATA(inode));
#endif
}

static struct file_operations flashcache_pidlists_operations = {
Expand All @@ -938,7 +958,12 @@ flashcache_version_show(struct seq_file *seq, void *v)
static int
flashcache_version_open(struct inode *inode, struct file *file)
{
return single_open(file, &flashcache_version_show, PDE(inode)->data);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
return single_open(file, &flashcache_version_show, PDE(inode)->data);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
return single_open(file, &flashcache_version_show, PDE_DATA(inode));
#endif
}

static struct file_operations flashcache_version_operations = {
Expand All @@ -955,9 +980,15 @@ flashcache_module_procfs_init(void)
struct proc_dir_entry *entry;

if (proc_mkdir("flashcache", NULL)) {
entry = create_proc_entry("flashcache/flashcache_version", 0, NULL);
if (entry)
entry->proc_fops = &flashcache_version_operations;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
entry = create_proc_entry("flashcache/flashcache_version", 0, NULL);
if (entry)
entry->proc_fops = &flashcache_version_operations;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
entry = proc_create("flashcache/flashcache_version", 0, NULL, &flashcache_version_operations);
#endif

}
#endif /* CONFIG_PROC_FS */
}
Expand Down Expand Up @@ -1029,35 +1060,55 @@ flashcache_ctr_procfs(struct cache_c *dmc)
return;

s = flashcache_cons_procfs_cachename(dmc, "flashcache_stats");
entry = create_proc_entry(s, 0, NULL);
if (entry) {
entry->proc_fops = &flashcache_stats_operations;
entry->data = dmc;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
entry = create_proc_entry(s, 0, NULL);
if (entry) {
entry->proc_fops = &flashcache_stats_operations;
entry->data = dmc;
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
entry = proc_create_data(s, 0, NULL, &flashcache_stats_operations, dmc);
#endif
kfree(s);

s = flashcache_cons_procfs_cachename(dmc, "flashcache_errors");
entry = create_proc_entry(s, 0, NULL);
if (entry) {
entry->proc_fops = &flashcache_errors_operations;
entry->data = dmc;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
entry = create_proc_entry(s, 0, NULL);
if (entry) {
entry->proc_fops = &flashcache_errors_operations;
entry->data = dmc;
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
entry = proc_create_data(s, 0, NULL, &flashcache_errors_operations, dmc);
#endif
kfree(s);

s = flashcache_cons_procfs_cachename(dmc, "flashcache_iosize_hist");
entry = create_proc_entry(s, 0, NULL);
if (entry) {
entry->proc_fops = &flashcache_iosize_hist_operations;
entry->data = dmc;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
entry = create_proc_entry(s, 0, NULL);
if (entry) {
entry->proc_fops = &flashcache_iosize_hist_operations;
entry->data = dmc;
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
entry = proc_create_data(s, 0, NULL, &flashcache_iosize_hist_operations, dmc);
#endif
kfree(s);

s = flashcache_cons_procfs_cachename(dmc, "flashcache_pidlists");
entry = create_proc_entry(s, 0, NULL);
if (entry) {
entry->proc_fops = &flashcache_pidlists_operations;
entry->data = dmc;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
entry = create_proc_entry(s, 0, NULL);
if (entry) {
entry->proc_fops = &flashcache_pidlists_operations;
entry->data = dmc;
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
entry = proc_create_data(s, 0, NULL, &flashcache_pidlists_operations, dmc);
#endif
kfree(s);

if (dmc->cache_mode == FLASHCACHE_WRITE_BACK)
Expand Down

0 comments on commit 36548a0

Please sign in to comment.