From 70fd4dc51f080538cfcad505c922f8539b7e3406 Mon Sep 17 00:00:00 2001 From: Leseb Date: Wed, 14 Nov 2012 00:43:48 +0100 Subject: [PATCH 1/5] Fixed the /proc path of flashcache_version It might be due to an upgrade change. The location of flashcache_version changed. --- src/ocf/flashcache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ocf/flashcache b/src/ocf/flashcache index 0edd020..a5ed8ab 100755 --- a/src/ocf/flashcache +++ b/src/ocf/flashcache @@ -92,12 +92,12 @@ flashcache_start() { exit $OCF_ERR_INSTALLED fi - if [ ! -e /proc/flashcache_version ]; then + if [ ! -e /proc/flashcache/flashcache_version ]; then ocf_log debug "Flashcache support not loaded, loading module" ocf_run modprobe -v flashcache || exit $OCF_ERR_INSTALLED fi - ocf_log debug "Flashcache module information obtained from kernel: `cat /proc/flashcache_version`" + ocf_log debug "Flashcache module information obtained from kernel: `cat /proc/flashcache/flashcache_version`" # actually start up the resource here (make sure to immediately # exit with an $OCF_ERR_ error code if anything goes seriously From f99b7c4f7c50a5449dcf760efe66cfe8382fc36b Mon Sep 17 00:00:00 2001 From: Roi Dayan Date: Tue, 22 Jan 2013 14:32:27 +0200 Subject: [PATCH 2/5] Fix flashcache_load getting cachedev from argv when using flags The cachedev parameter is in position 3 when no flags specificed. When -v is used then cachedev will be in position 4. Signed-off-by: Roi Dayan --- src/utils/flashcache_load.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/flashcache_load.c b/src/utils/flashcache_load.c index 9a149d4..cb841a9 100644 --- a/src/utils/flashcache_load.c +++ b/src/utils/flashcache_load.c @@ -114,7 +114,7 @@ main(int argc, char **argv) } } - if ((argc < 2) || (argc > 3)) { + if ((argc < 2) || (argc > 4)) { usage(pname); } @@ -143,10 +143,10 @@ main(int argc, char **argv) } // switch to new vdev name if requested by load command - if (argc == 3) { - cachedev = argv[optind]; - } else { + if (optind == argc) { cachedev = sb->cache_devname; + } else { + cachedev = argv[optind]; } disk_devname = sb->disk_devname; From f5ca34ef4c7096e7e60f499eebad1596ff2221af Mon Sep 17 00:00:00 2001 From: Shannon Jones Date: Sat, 9 Feb 2013 18:16:23 -0600 Subject: [PATCH 3/5] Fix use-after-free in flashcache_destroy The sb variable points to buf. But buf gets freed and reallocated, so the old pointer points to freed memory. The variable is then reused to invalidate the cache_sb_state, but the change never gets saved because the buf that is written to disk does not point to the same memory. --- src/utils/flashcache_destroy.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/flashcache_destroy.c b/src/utils/flashcache_destroy.c index b974401..308215e 100644 --- a/src/utils/flashcache_destroy.c +++ b/src/utils/flashcache_destroy.c @@ -51,6 +51,7 @@ usage(char *pname) } char *pname; +char *sb_buf; char *buf; main(int argc, char **argv) @@ -84,16 +85,16 @@ main(int argc, char **argv) exit(1); } lseek(cache_fd, 0, SEEK_SET); - buf = (char *)malloc(512); - if (!buf) { + sb_buf = (char *)malloc(512); + if (!sb_buf) { fprintf(stderr, "Failed to allocate sector buffer\n"); exit(1); } - if (read(cache_fd, buf, 512) < 0) { + if (read(cache_fd, sb_buf, 512) < 0) { fprintf(stderr, "Cannot read Flashcache superblock %s\n", ssd_devname); exit(1); } - sb = (struct flash_superblock *)buf; + sb = (struct flash_superblock *)sb_buf; if (!(sb->cache_sb_state == CACHE_MD_STATE_DIRTY || sb->cache_sb_state == CACHE_MD_STATE_CLEAN || sb->cache_sb_state == CACHE_MD_STATE_FASTCLEAN || @@ -113,7 +114,6 @@ main(int argc, char **argv) lseek(cache_fd, md_block_bytes, SEEK_SET); /* lseek past the superblock to first MD slot */ md_slots_per_block = (md_block_bytes / (sizeof(struct flash_cacheblock))); - free(buf); buf = (char *)malloc(md_block_bytes); if (!buf) { fprintf(stderr, "Failed to allocate sector buffer\n"); @@ -154,7 +154,7 @@ main(int argc, char **argv) pname, ssd_devname); sb->cache_sb_state = 0; lseek(cache_fd, 0, SEEK_SET); - if (write(cache_fd, buf, 512) < 0) { + if (write(cache_fd, sb_buf, 512) < 0) { fprintf(stderr, "Cannot write Flashcache superblock %s\n", ssd_devname); exit(1); } From dfd810ac6685af42925ec9d51df3ba4b3c91aae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Pitucha?= Date: Sat, 23 Feb 2013 11:38:25 +0000 Subject: [PATCH 4/5] Run depmod on the right kernel --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 6480664..9276430 100644 --- a/src/Makefile +++ b/src/Makefile @@ -42,7 +42,7 @@ utils: modules_install: modules install -o root -g root -m 0755 -d $(DESTDIR)/lib/modules/$(KERNEL_SOURCE_VERSION)/extra/flashcache/ install -o root -g root -m 0755 flashcache.ko $(DESTDIR)/lib/modules/$(KERNEL_SOURCE_VERSION)/extra/flashcache/ - depmod -a + depmod -a $(KERNEL_SOURCE_VERSION) .PHONY: utils_install utils_install: utils From 0740c594355b45c67b48bb396e94bacbd480c980 Mon Sep 17 00:00:00 2001 From: slavik Date: Fri, 19 Apr 2013 20:53:21 +0600 Subject: [PATCH 5/5] added 3.9.0 support --- src/flashcache_conf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/flashcache_conf.c b/src/flashcache_conf.c index f72200e..eb47d64 100644 --- a/src/flashcache_conf.c +++ b/src/flashcache_conf.c @@ -1671,11 +1671,16 @@ flashcache_init(void) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) r = kcopyd_client_create(FLASHCACHE_COPY_PAGES, &flashcache_kcp_client); -#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)) || (defined(RHEL_RELEASE_CODE) && (RHEL_RELEASE_CODE >= 1538)) +elif ((LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0))&&(LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))) || (defined(RHEL_RELEASE_CODE) && (RHEL_RELEASE_CODE >= 1538)) flashcache_kcp_client = dm_kcopyd_client_create(); if ((r = IS_ERR(flashcache_kcp_client))) { r = PTR_ERR(flashcache_kcp_client); } +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) + flashcache_kcp_client = dm_kcopyd_client_create(NULL); + if ((r = IS_ERR(flashcache_kcp_client))) { + r = PTR_ERR(flashcache_kcp_client); + } #else /* .26 <= VERSION < 3.0.0 */ r = dm_kcopyd_client_create(FLASHCACHE_COPY_PAGES, &flashcache_kcp_client); #endif /* .26 <= VERSION < 3.0.0 */