From 954e167fdb580d514747512ce2bd1c9c29a77418 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 3 Jul 2013 09:59:44 +0200 Subject: [PATCH 1/4] Add dev symlink in udev rules after cache config This could prevent mounting filesystem before the cache, especially in WB mode. The device can be used in fstab being sure that cache is ready. Signed-off-by: Laurent Barbe --- CLI/eio_cli | 1 + Documents/94-Enhanceio.template | 1 + 2 files changed, 2 insertions(+) diff --git a/CLI/eio_cli b/CLI/eio_cli index 3453b35..566ebce 100755 --- a/CLI/eio_cli +++ b/CLI/eio_cli @@ -137,6 +137,7 @@ do rm -f /dev/$$i; ln -f -s /dev/$env{disk_name} /dev/$$i; done'" TEST!="/proc/enhanceio/", RUN+="/sbin/eio_cli \ enable -d /dev/$env{disk_name} -s /dev/$env{ssd_name} -m \ -b -p -c " +, SYMLINK+="eio-" LABEL="EIO_EOF" """ diff --git a/Documents/94-Enhanceio.template b/Documents/94-Enhanceio.template index 899f9c2..14be827 100644 --- a/Documents/94-Enhanceio.template +++ b/Documents/94-Enhanceio.template @@ -29,5 +29,6 @@ LABEL="EIO_SETUP" PROGRAM="/bin/sh -c 'cat /dev/enhanceio//.disk_name'", ENV{disk_name}="%c" TEST!="/proc/enhanceio/", RUN+="/sbin/eio_cli enable -d /dev/$env{disk_name} -s /dev/$env{ssd_name} -m -b -c " + , SYMLINK+="eio-" LABEL="EIO_EOF" From 7a087a168212bd800f82293f202361124a141c54 Mon Sep 17 00:00:00 2001 From: Philipp Edelmann Date: Tue, 21 Oct 2014 22:27:01 +0200 Subject: [PATCH 2/4] do not use typedef for struct ctl_table The typedef for struct ctl_table was removed from the kernel in commit e5eea0981a3840f3f39f43d2d00461c4c24018e7. This change to eio_procfs.c works with kernel versions before and after the change. --- Driver/enhanceio/eio_procfs.c | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Driver/enhanceio/eio_procfs.c b/Driver/enhanceio/eio_procfs.c index 8306c27..a341566 100644 --- a/Driver/enhanceio/eio_procfs.c +++ b/Driver/enhanceio/eio_procfs.c @@ -52,7 +52,7 @@ static struct sysctl_table_dir *sysctl_handle_dir; * eio_zerostats_sysctl */ static int -eio_zerostats_sysctl(ctl_table *table, int write, void __user *buffer, +eio_zerostats_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { struct cache_c *dmc = (struct cache_c *)table->extra1; @@ -120,7 +120,7 @@ eio_zerostats_sysctl(ctl_table *table, int write, void __user *buffer, * - sets the eio sysctl mem_limit_pct value */ static int -eio_mem_limit_pct_sysctl(ctl_table *table, int write, void __user *buffer, +eio_mem_limit_pct_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { struct cache_c *dmc = (struct cache_c *)table->extra1; @@ -167,7 +167,7 @@ eio_mem_limit_pct_sysctl(ctl_table *table, int write, void __user *buffer, * eio_clean_sysctl */ static int -eio_clean_sysctl(ctl_table *table, int write, void __user *buffer, +eio_clean_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { struct cache_c *dmc = (struct cache_c *)table->extra1; @@ -249,7 +249,7 @@ eio_clean_sysctl(ctl_table *table, int write, void __user *buffer, * eio_dirty_high_threshold_sysctl */ static int -eio_dirty_high_threshold_sysctl(ctl_table *table, int write, +eio_dirty_high_threshold_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { @@ -331,7 +331,7 @@ eio_dirty_high_threshold_sysctl(ctl_table *table, int write, * eio_dirty_low_threshold_sysctl */ static int -eio_dirty_low_threshold_sysctl(ctl_table *table, int write, +eio_dirty_low_threshold_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { @@ -419,7 +419,7 @@ eio_dirty_low_threshold_sysctl(ctl_table *table, int write, * eio_dirty_set_high_threshold_sysctl */ static int -eio_dirty_set_high_threshold_sysctl(ctl_table *table, int write, +eio_dirty_set_high_threshold_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { @@ -505,7 +505,7 @@ eio_dirty_set_high_threshold_sysctl(ctl_table *table, int write, * eio_dirty_set_low_threshold_sysctl */ static int -eio_dirty_set_low_threshold_sysctl(ctl_table *table, int write, +eio_dirty_set_low_threshold_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { @@ -598,7 +598,7 @@ eio_dirty_set_low_threshold_sysctl(ctl_table *table, int write, * eio_autoclean_threshold_sysctl */ static int -eio_autoclean_threshold_sysctl(ctl_table *table, int write, +eio_autoclean_threshold_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { @@ -674,7 +674,7 @@ eio_autoclean_threshold_sysctl(ctl_table *table, int write, * eio_time_based_clean_interval_sysctl */ static int -eio_time_based_clean_interval_sysctl(ctl_table *table, int write, +eio_time_based_clean_interval_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { @@ -768,7 +768,7 @@ static void eio_sysctl_unregister_invalidate(struct cache_c *dmc); * eio_control_sysctl */ int -eio_control_sysctl(ctl_table *table, int write, void __user *buffer, +eio_control_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { int rv = 0; @@ -929,10 +929,10 @@ eio_control_sysctl(ctl_table *table, int write, void __user *buffer, #define PROC_IOSZ_HIST "io_hist" #define PROC_CONFIG "config" -static int eio_invalidate_sysctl(ctl_table *table, int write, +static int eio_invalidate_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos); -static void *eio_find_sysctl_data(struct cache_c *dmc, ctl_table *vars); +static void *eio_find_sysctl_data(struct cache_c *dmc, struct ctl_table *vars); static char *eio_cons_sysctl_devname(struct cache_c *dmc); static char *eio_cons_procfs_cachename(struct cache_c *dmc, char *path_component); @@ -1011,10 +1011,10 @@ static const struct file_operations eio_config_operations = { */ static struct sysctl_table_dir { struct ctl_table_header *sysctl_header; - ctl_table vars[0 + 1]; - ctl_table dev[0 + 1]; - ctl_table dir[1 + 1]; - ctl_table root[1 + 1]; + struct ctl_table vars[0 + 1]; + struct ctl_table dev[0 + 1]; + struct ctl_table dir[1 + 1]; + struct ctl_table root[1 + 1]; } sysctl_template_dir = { .vars = { }, .dev = { @@ -1039,10 +1039,10 @@ static struct sysctl_table_dir { static struct sysctl_table_common { struct ctl_table_header *sysctl_header; - ctl_table vars[NUM_COMMON_SYSCTLS + 1]; - ctl_table dev[1 + 1]; - ctl_table dir[1 + 1]; - ctl_table root[1 + 1]; + struct ctl_table vars[NUM_COMMON_SYSCTLS + 1]; + struct ctl_table dev[1 + 1]; + struct ctl_table dir[1 + 1]; + struct ctl_table root[1 + 1]; } sysctl_template_common = { .vars = { { /* 1 */ @@ -1089,10 +1089,10 @@ static struct sysctl_table_common { static struct sysctl_table_writeback { struct ctl_table_header *sysctl_header; - ctl_table vars[NUM_WRITEBACK_SYSCTLS + 1]; - ctl_table dev[1 + 1]; - ctl_table dir[1 + 1]; - ctl_table root[1 + 1]; + struct ctl_table vars[NUM_WRITEBACK_SYSCTLS + 1]; + struct ctl_table dev[1 + 1]; + struct ctl_table dir[1 + 1]; + struct ctl_table root[1 + 1]; } sysctl_template_writeback = { .vars = { { /* 1 */ @@ -1169,10 +1169,10 @@ static struct sysctl_table_writeback { #define NUM_INVALIDATE_SYSCTLS (1) static struct sysctl_table_invalidate { struct ctl_table_header *sysctl_header; - ctl_table vars[NUM_INVALIDATE_SYSCTLS + 1]; - ctl_table dev[1 + 1]; - ctl_table dir[1 + 1]; - ctl_table root[1 + 1]; + struct ctl_table vars[NUM_INVALIDATE_SYSCTLS + 1]; + struct ctl_table dev[1 + 1]; + struct ctl_table dir[1 + 1]; + struct ctl_table root[1 + 1]; } sysctl_template_invalidate = { .vars = { { /* 1 */ @@ -1317,7 +1317,7 @@ static spinlock_t invalidate_spin_lock; * eio_invalidate_sysctl */ static int -eio_invalidate_sysctl(ctl_table *table, int write, void __user *buffer, +eio_invalidate_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { static int have_sector; @@ -1389,7 +1389,7 @@ eio_invalidate_sysctl(ctl_table *table, int write, void __user *buffer, /* * eio_find_sysctl_data */ -static void *eio_find_sysctl_data(struct cache_c *dmc, ctl_table *vars) +static void *eio_find_sysctl_data(struct cache_c *dmc, struct ctl_table *vars) { if (strcmp(vars->procname, "do_clean") == 0) From 445430bf1669f3b904fc3536352a1f7ce3226acf Mon Sep 17 00:00:00 2001 From: Philipp Edelmann Date: Tue, 21 Oct 2014 22:32:18 +0200 Subject: [PATCH 3/4] fix errors due to changes in wait_on_bit_lock The old wait_on_bit_lock was replaced by wait_on_bit_lock_action. We use that on kernels >= 3.17. --- Driver/enhanceio/eio.h | 4 ++++ Driver/enhanceio/eio_conf.c | 15 ++++++++++----- Driver/enhanceio/eio_ttc.c | 7 ++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Driver/enhanceio/eio.h b/Driver/enhanceio/eio.h index 2e22057..d1bc7cd 100644 --- a/Driver/enhanceio/eio.h +++ b/Driver/enhanceio/eio.h @@ -128,7 +128,11 @@ struct eio_control_s { unsigned long synch_flags; }; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)) +int eio_wait_schedule(struct wait_bit_key *unused); +#else int eio_wait_schedule(void *unused); +#endif struct eio_event { struct task_struct *process; /* handle of the sleeping process */ diff --git a/Driver/enhanceio/eio_conf.c b/Driver/enhanceio/eio_conf.c index 6a255cf..c38486f 100644 --- a/Driver/enhanceio/eio_conf.c +++ b/Driver/enhanceio/eio_conf.c @@ -89,7 +89,12 @@ static struct notifier_block eio_ssd_rm_notifier = { .priority = 0, }; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)) +int eio_wait_schedule(struct wait_bit_key *unused) +#else +#define wait_on_bit_lock_action wait_on_bit_lock int eio_wait_schedule(void *unused) +#endif { schedule(); @@ -1842,7 +1847,7 @@ int eio_cache_create(struct cache_rec_short *cache) dmc->sysctl_active.mem_limit_pct = 75; - (void)wait_on_bit_lock((void *)&eio_control->synch_flags, + (void)wait_on_bit_lock_action((void *)&eio_control->synch_flags, EIO_UPDATE_LIST, eio_wait_schedule, TASK_UNINTERRUPTIBLE); dmc->next_cache = cache_list_head; @@ -1901,7 +1906,7 @@ int eio_cache_create(struct cache_rec_short *cache) vfree((void *)dmc->cache_sets); vfree((void *)EIO_CACHE(dmc)); - (void)wait_on_bit_lock((void *)&eio_control->synch_flags, + (void)wait_on_bit_lock_action((void *)&eio_control->synch_flags, EIO_UPDATE_LIST, eio_wait_schedule, TASK_UNINTERRUPTIBLE); nodepp = &cache_list_head; @@ -2055,7 +2060,7 @@ int eio_cache_delete(char *cache_name, int do_delete) vfree((void *)dmc->cache_sets); eio_ttc_put_device(&dmc->disk_dev); eio_put_cache_device(dmc); - (void)wait_on_bit_lock((void *)&eio_control->synch_flags, + (void)wait_on_bit_lock_action((void *)&eio_control->synch_flags, EIO_UPDATE_LIST, eio_wait_schedule, TASK_UNINTERRUPTIBLE); nodepp = &cache_list_head; @@ -2387,7 +2392,7 @@ eio_notify_reboot(struct notifier_block *this, unsigned long code, void *x) if (eio_reboot_notified == EIO_REBOOT_HANDLING_DONE) return NOTIFY_DONE; - (void)wait_on_bit_lock((void *)&eio_control->synch_flags, + (void)wait_on_bit_lock_action((void *)&eio_control->synch_flags, EIO_HANDLE_REBOOT, eio_wait_schedule, TASK_UNINTERRUPTIBLE); if (eio_reboot_notified == EIO_REBOOT_HANDLING_DONE) { @@ -2400,7 +2405,7 @@ eio_notify_reboot(struct notifier_block *this, unsigned long code, void *x) EIO_ASSERT(eio_reboot_notified == 0); eio_reboot_notified = EIO_REBOOT_HANDLING_INPROG; - (void)wait_on_bit_lock((void *)&eio_control->synch_flags, + (void)wait_on_bit_lock_action((void *)&eio_control->synch_flags, EIO_UPDATE_LIST, eio_wait_schedule, TASK_UNINTERRUPTIBLE); for (dmc = cache_list_head; dmc != NULL; dmc = dmc->next_cache) { diff --git a/Driver/enhanceio/eio_ttc.c b/Driver/enhanceio/eio_ttc.c index cab9176..c3e5f14 100644 --- a/Driver/enhanceio/eio_ttc.c +++ b/Driver/enhanceio/eio_ttc.c @@ -31,6 +31,11 @@ #include #include "eio.h" #include "eio_ttc.h" + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)) +#define wait_on_bit_lock_action wait_on_bit_lock +#endif + static struct rw_semaphore eio_ttc_lock[EIO_HASHTBL_SIZE]; static struct list_head eio_ttc_list[EIO_HASHTBL_SIZE]; @@ -1497,7 +1502,7 @@ int eio_reboot_handling(void) if (eio_reboot_notified == EIO_REBOOT_HANDLING_DONE) return 0; - (void)wait_on_bit_lock((void *)&eio_control->synch_flags, + (void)wait_on_bit_lock_action((void *)&eio_control->synch_flags, EIO_HANDLE_REBOOT, eio_wait_schedule, TASK_UNINTERRUPTIBLE); if (eio_reboot_notified == EIO_REBOOT_HANDLING_DONE) { From df6213797367d32d759447791ffe76b95d200bf3 Mon Sep 17 00:00:00 2001 From: Philipp Edelmann Date: Mon, 15 Dec 2014 12:31:07 +0100 Subject: [PATCH 4/4] fix compilation on Linux 3.18 The function smp_mb__after_clear_bit is finally gone after being deprecated for some time. It is replaced by smp_mb__after_atomic, which was available since Linux 3.15. --- Driver/enhanceio/eio_conf.c | 16 ++++++++++------ Driver/enhanceio/eio_ttc.c | 9 +++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Driver/enhanceio/eio_conf.c b/Driver/enhanceio/eio_conf.c index c38486f..cabf236 100644 --- a/Driver/enhanceio/eio_conf.c +++ b/Driver/enhanceio/eio_conf.c @@ -101,6 +101,10 @@ int eio_wait_schedule(void *unused) return 0; } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)) +#define smp_mb__after_atomic smp_mb__after_clear_bit +#endif + /* * Check if the System RAM threshold > requested memory, don't care * if threshold is set to 0. Return value is 0 for fail and 1 for success. @@ -1853,7 +1857,7 @@ int eio_cache_create(struct cache_rec_short *cache) dmc->next_cache = cache_list_head; cache_list_head = dmc; clear_bit(EIO_UPDATE_LIST, (void *)&eio_control->synch_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit((void *)&eio_control->synch_flags, EIO_UPDATE_LIST); prev_set = -1; @@ -1918,7 +1922,7 @@ int eio_cache_create(struct cache_rec_short *cache) nodepp = &((*nodepp)->next_cache); } clear_bit(EIO_UPDATE_LIST, (void *)&eio_control->synch_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit((void *)&eio_control->synch_flags, EIO_UPDATE_LIST); bad5: eio_kcached_client_destroy(dmc); @@ -2072,7 +2076,7 @@ int eio_cache_delete(char *cache_name, int do_delete) nodepp = &((*nodepp)->next_cache); } clear_bit(EIO_UPDATE_LIST, &eio_control->synch_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit((void *)&eio_control->synch_flags, EIO_UPDATE_LIST); out: @@ -2397,7 +2401,7 @@ eio_notify_reboot(struct notifier_block *this, unsigned long code, void *x) TASK_UNINTERRUPTIBLE); if (eio_reboot_notified == EIO_REBOOT_HANDLING_DONE) { clear_bit(EIO_HANDLE_REBOOT, (void *)&eio_control->synch_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit((void *)&eio_control->synch_flags, EIO_HANDLE_REBOOT); return NOTIFY_DONE; @@ -2425,12 +2429,12 @@ eio_notify_reboot(struct notifier_block *this, unsigned long code, void *x) eio_md_store(dmc); } clear_bit(EIO_UPDATE_LIST, (void *)&eio_control->synch_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit((void *)&eio_control->synch_flags, EIO_UPDATE_LIST); eio_reboot_notified = EIO_REBOOT_HANDLING_DONE; clear_bit(EIO_HANDLE_REBOOT, (void *)&eio_control->synch_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit((void *)&eio_control->synch_flags, EIO_HANDLE_REBOOT); return NOTIFY_DONE; } diff --git a/Driver/enhanceio/eio_ttc.c b/Driver/enhanceio/eio_ttc.c index c3e5f14..078bbc3 100644 --- a/Driver/enhanceio/eio_ttc.c +++ b/Driver/enhanceio/eio_ttc.c @@ -36,6 +36,11 @@ #define wait_on_bit_lock_action wait_on_bit_lock #endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)) +#define smp_mb__after_atomic smp_mb__after_clear_bit +#endif + + static struct rw_semaphore eio_ttc_lock[EIO_HASHTBL_SIZE]; static struct list_head eio_ttc_list[EIO_HASHTBL_SIZE]; @@ -1507,7 +1512,7 @@ int eio_reboot_handling(void) TASK_UNINTERRUPTIBLE); if (eio_reboot_notified == EIO_REBOOT_HANDLING_DONE) { clear_bit(EIO_HANDLE_REBOOT, (void *)&eio_control->synch_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit((void *)&eio_control->synch_flags, EIO_HANDLE_REBOOT); return 0; @@ -1609,7 +1614,7 @@ int eio_reboot_handling(void) eio_reboot_notified = EIO_REBOOT_HANDLING_DONE; clear_bit(EIO_HANDLE_REBOOT, (void *)&eio_control->synch_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit((void *)&eio_control->synch_flags, EIO_HANDLE_REBOOT); return 0; }