diff for duplicates of <20121102182945.GC30100@konrad-lan.dumpdata.com> diff --git a/a/1.txt b/N1/1.txt index 681b4ca..6287a4b 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -54,3 +54,305 @@ On Wed, Oct 31, 2012 at 08:07:50AM -0700, Dan Magenheimer wrote: Those could use some #define's and bool, so please see attached patch which does this. + +>From a89c1224ec1957f1afaf4fbc1de349124bed6c67 Mon Sep 17 00:00:00 2001 +From: Dan Magenheimer <dan.magenheimer@oracle.com> +Date: Wed, 31 Oct 2012 08:07:50 -0700 +Subject: [PATCH 1/2] mm: cleancache: lazy initialization to allow tmem + backends to build/run as modules + +With the goal of allowing tmem backends (zcache, ramster, Xen tmem) to be +built/loaded as modules rather than built-in and enabled by a boot parameter, +this patch provides "lazy initialization", allowing backends to register to +cleancache even after filesystems were mounted. Calls to init_fs and +init_shared_fs are remembered as fake poolids but no real tmem_pools created. +On backend registration the fake poolids are mapped to real poolids and +respective tmem_pools. + +Signed-off-by: Stefan Hengelein <ilendir@googlemail.com> +Signed-off-by: Florian Schmaus <fschmaus@gmail.com> +Signed-off-by: Andor Daam <andor.daam@googlemail.com> +Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com> +[v1: Minor fixes: used #define for some values and bools] +Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> +--- + include/linux/cleancache.h | 1 + + mm/cleancache.c | 156 ++++++++++++++++++++++++++++++++++++++++----- + 2 files changed, 140 insertions(+), 17 deletions(-) + +diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h +index 42e55de..f7e32f0 100644 +--- a/include/linux/cleancache.h ++++ b/include/linux/cleancache.h +@@ -37,6 +37,7 @@ extern struct cleancache_ops + cleancache_register_ops(struct cleancache_ops *ops); + extern void __cleancache_init_fs(struct super_block *); + extern void __cleancache_init_shared_fs(char *, struct super_block *); ++#define CLEANCACHE_HAS_LAZY_INIT + extern int __cleancache_get_page(struct page *); + extern void __cleancache_put_page(struct page *); + extern void __cleancache_invalidate_page(struct address_space *, struct page *); +diff --git a/mm/cleancache.c b/mm/cleancache.c +index 32e6f41..318a0ad 100644 +--- a/mm/cleancache.c ++++ b/mm/cleancache.c +@@ -45,15 +45,45 @@ static u64 cleancache_puts; + static u64 cleancache_invalidates; + + /* ++ * When no backend is registered all calls to init_fs and init_shard_fs ++ * are registered and fake poolids are given to the respective ++ * super block but no tmem_pools are created. When a backend ++ * registers with cleancache the previous calls to init_fs and ++ * init_shared_fs are executed to create tmem_pools and set the ++ * respective poolids. While no backend is registered all "puts", ++ * "gets" and "flushes" are ignored or fail. ++ */ ++#define MAX_INITIALIZABLE_FS 32 ++#define FAKE_FS_POOLID_OFFSET 1000 ++#define FAKE_SHARED_FS_POOLID_OFFSET 2000 ++ ++#define FS_NO_BACKEND (-1) ++#define FS_UNKNOWN (-2) ++static int fs_poolid_map[MAX_INITIALIZABLE_FS]; ++static int shared_fs_poolid_map[MAX_INITIALIZABLE_FS]; ++ ++static char *uuids[MAX_INITIALIZABLE_FS]; ++static bool __read_mostly backend_registered; ++ ++/* + * register operations for cleancache, returning previous thus allowing + * detection of multiple backends and possible nesting + */ + struct cleancache_ops cleancache_register_ops(struct cleancache_ops *ops) + { + struct cleancache_ops old = cleancache_ops; ++ int i; + + cleancache_ops = *ops; +- cleancache_enabled = 1; ++ ++ backend_registered = true; ++ for (i = 0; i < MAX_INITIALIZABLE_FS; i++) { ++ if (fs_poolid_map[i] == FS_NO_BACKEND) ++ fs_poolid_map[i] = (*cleancache_ops.init_fs)(PAGE_SIZE); ++ if (shared_fs_poolid_map[i] == FS_NO_BACKEND) ++ shared_fs_poolid_map[i] = (*cleancache_ops.init_shared_fs) ++ (uuids[i], PAGE_SIZE); ++ } + return old; + } + EXPORT_SYMBOL(cleancache_register_ops); +@@ -61,15 +91,38 @@ EXPORT_SYMBOL(cleancache_register_ops); + /* Called by a cleancache-enabled filesystem at time of mount */ + void __cleancache_init_fs(struct super_block *sb) + { +- sb->cleancache_poolid = (*cleancache_ops.init_fs)(PAGE_SIZE); ++ int i; ++ ++ for (i = 0; i < MAX_INITIALIZABLE_FS; i++) { ++ if (fs_poolid_map[i] == FS_UNKNOWN) { ++ sb->cleancache_poolid = i + FAKE_FS_POOLID_OFFSET; ++ if (backend_registered) ++ fs_poolid_map[i] = (*cleancache_ops.init_fs)(PAGE_SIZE); ++ else ++ fs_poolid_map[i] = FS_NO_BACKEND; ++ break; ++ } ++ } + } + EXPORT_SYMBOL(__cleancache_init_fs); + + /* Called by a cleancache-enabled clustered filesystem at time of mount */ + void __cleancache_init_shared_fs(char *uuid, struct super_block *sb) + { +- sb->cleancache_poolid = +- (*cleancache_ops.init_shared_fs)(uuid, PAGE_SIZE); ++ int i; ++ ++ for (i = 0; i < MAX_INITIALIZABLE_FS; i++) { ++ if (shared_fs_poolid_map[i] == FS_UNKNOWN) { ++ sb->cleancache_poolid = i + FAKE_SHARED_FS_POOLID_OFFSET; ++ uuids[i] = uuid; ++ if (backend_registered) ++ shared_fs_poolid_map[i] = (*cleancache_ops.init_shared_fs) ++ (uuid, PAGE_SIZE); ++ else ++ shared_fs_poolid_map[i] = FS_NO_BACKEND; ++ break; ++ } ++ } + } + EXPORT_SYMBOL(__cleancache_init_shared_fs); + +@@ -99,6 +152,19 @@ static int cleancache_get_key(struct inode *inode, + } + + /* ++ * Returns a pool_id that is associated with a given fake poolid. ++ */ ++static int get_poolid_from_fake(int fake_pool_id) ++{ ++ if (fake_pool_id >= FAKE_SHARED_FS_POOLID_OFFSET) ++ return shared_fs_poolid_map[fake_pool_id - ++ FAKE_SHARED_FS_POOLID_OFFSET]; ++ else if (fake_pool_id >= FAKE_FS_POOLID_OFFSET) ++ return fs_poolid_map[fake_pool_id - FAKE_FS_POOLID_OFFSET]; ++ return FS_NO_BACKEND; ++} ++ ++/* + * "Get" data from cleancache associated with the poolid/inode/index + * that were specified when the data was put to cleanache and, if + * successful, use it to fill the specified page with data and return 0. +@@ -109,17 +175,26 @@ int __cleancache_get_page(struct page *page) + { + int ret = -1; + int pool_id; ++ int fake_pool_id; + struct cleancache_filekey key = { .u.key = { 0 } }; + ++ if (!backend_registered) { ++ cleancache_failed_gets++; ++ goto out; ++ } ++ + VM_BUG_ON(!PageLocked(page)); +- pool_id = page->mapping->host->i_sb->cleancache_poolid; +- if (pool_id < 0) ++ fake_pool_id = page->mapping->host->i_sb->cleancache_poolid; ++ if (fake_pool_id < 0) + goto out; ++ pool_id = get_poolid_from_fake(fake_pool_id); + + if (cleancache_get_key(page->mapping->host, &key) < 0) + goto out; + +- ret = (*cleancache_ops.get_page)(pool_id, key, page->index, page); ++ if (pool_id >= 0) ++ ret = (*cleancache_ops.get_page)(pool_id, ++ key, page->index, page); + if (ret == 0) + cleancache_succ_gets++; + else +@@ -138,12 +213,23 @@ EXPORT_SYMBOL(__cleancache_get_page); + void __cleancache_put_page(struct page *page) + { + int pool_id; ++ int fake_pool_id; + struct cleancache_filekey key = { .u.key = { 0 } }; + ++ if (!backend_registered) { ++ cleancache_puts++; ++ return; ++ } ++ + VM_BUG_ON(!PageLocked(page)); +- pool_id = page->mapping->host->i_sb->cleancache_poolid; ++ fake_pool_id = page->mapping->host->i_sb->cleancache_poolid; ++ if (fake_pool_id < 0) ++ return; ++ ++ pool_id = get_poolid_from_fake(fake_pool_id); ++ + if (pool_id >= 0 && +- cleancache_get_key(page->mapping->host, &key) >= 0) { ++ cleancache_get_key(page->mapping->host, &key) >= 0) { + (*cleancache_ops.put_page)(pool_id, key, page->index, page); + cleancache_puts++; + } +@@ -158,14 +244,22 @@ void __cleancache_invalidate_page(struct address_space *mapping, + struct page *page) + { + /* careful... page->mapping is NULL sometimes when this is called */ +- int pool_id = mapping->host->i_sb->cleancache_poolid; ++ int pool_id; ++ int fake_pool_id = mapping->host->i_sb->cleancache_poolid; + struct cleancache_filekey key = { .u.key = { 0 } }; + +- if (pool_id >= 0) { ++ if (!backend_registered) ++ return; ++ ++ if (fake_pool_id >= 0) { ++ pool_id = get_poolid_from_fake(fake_pool_id); ++ if (pool_id < 0) ++ return; ++ + VM_BUG_ON(!PageLocked(page)); + if (cleancache_get_key(mapping->host, &key) >= 0) { + (*cleancache_ops.invalidate_page)(pool_id, +- key, page->index); ++ key, page->index); + cleancache_invalidates++; + } + } +@@ -179,9 +273,18 @@ EXPORT_SYMBOL(__cleancache_invalidate_page); + */ + void __cleancache_invalidate_inode(struct address_space *mapping) + { +- int pool_id = mapping->host->i_sb->cleancache_poolid; ++ int pool_id; ++ int fake_pool_id = mapping->host->i_sb->cleancache_poolid; + struct cleancache_filekey key = { .u.key = { 0 } }; + ++ if (!backend_registered) ++ return; ++ ++ if (fake_pool_id < 0) ++ return; ++ ++ pool_id = get_poolid_from_fake(fake_pool_id); ++ + if (pool_id >= 0 && cleancache_get_key(mapping->host, &key) >= 0) + (*cleancache_ops.invalidate_inode)(pool_id, key); + } +@@ -194,16 +297,30 @@ EXPORT_SYMBOL(__cleancache_invalidate_inode); + */ + void __cleancache_invalidate_fs(struct super_block *sb) + { +- if (sb->cleancache_poolid >= 0) { +- int old_poolid = sb->cleancache_poolid; +- sb->cleancache_poolid = -1; +- (*cleancache_ops.invalidate_fs)(old_poolid); ++ int index; ++ int fake_pool_id = sb->cleancache_poolid; ++ int old_poolid = fake_pool_id; ++ ++ if (fake_pool_id >= FAKE_SHARED_FS_POOLID_OFFSET) { ++ index = fake_pool_id - FAKE_SHARED_FS_POOLID_OFFSET; ++ old_poolid = shared_fs_poolid_map[index]; ++ shared_fs_poolid_map[index] = FS_UNKNOWN; ++ uuids[index] = NULL; ++ } else if (fake_pool_id >= FAKE_FS_POOLID_OFFSET) { ++ index = fake_pool_id - FAKE_FS_POOLID_OFFSET; ++ old_poolid = fs_poolid_map[index]; ++ fs_poolid_map[index] = FS_UNKNOWN; + } ++ sb->cleancache_poolid = -1; ++ if (backend_registered) ++ (*cleancache_ops.invalidate_fs)(old_poolid); + } + EXPORT_SYMBOL(__cleancache_invalidate_fs); + + static int __init init_cleancache(void) + { ++ int i; ++ + #ifdef CONFIG_DEBUG_FS + struct dentry *root = debugfs_create_dir("cleancache", NULL); + if (root == NULL) +@@ -215,6 +332,11 @@ static int __init init_cleancache(void) + debugfs_create_u64("invalidates", S_IRUGO, + root, &cleancache_invalidates); + #endif ++ for (i = 0; i < MAX_INITIALIZABLE_FS; i++) { ++ fs_poolid_map[i] = FS_UNKNOWN; ++ shared_fs_poolid_map[i] = FS_UNKNOWN; ++ } ++ cleancache_enabled = 1; + return 0; + } + module_init(init_cleancache) +-- +1.7.11.7 diff --git a/a/content_digest b/N1/content_digest index 33c15c2..5e8876b 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -73,6 +73,308 @@ "> +static int backend_registered;\n" "\n" "Those could use some #define's and bool, so please see attached\n" - patch which does this. + "patch which does this.\n" + "\n" + ">From a89c1224ec1957f1afaf4fbc1de349124bed6c67 Mon Sep 17 00:00:00 2001\n" + "From: Dan Magenheimer <dan.magenheimer@oracle.com>\n" + "Date: Wed, 31 Oct 2012 08:07:50 -0700\n" + "Subject: [PATCH 1/2] mm: cleancache: lazy initialization to allow tmem\n" + " backends to build/run as modules\n" + "\n" + "With the goal of allowing tmem backends (zcache, ramster, Xen tmem) to be\n" + "built/loaded as modules rather than built-in and enabled by a boot parameter,\n" + "this patch provides \"lazy initialization\", allowing backends to register to\n" + "cleancache even after filesystems were mounted. Calls to init_fs and\n" + "init_shared_fs are remembered as fake poolids but no real tmem_pools created.\n" + "On backend registration the fake poolids are mapped to real poolids and\n" + "respective tmem_pools.\n" + "\n" + "Signed-off-by: Stefan Hengelein <ilendir@googlemail.com>\n" + "Signed-off-by: Florian Schmaus <fschmaus@gmail.com>\n" + "Signed-off-by: Andor Daam <andor.daam@googlemail.com>\n" + "Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>\n" + "[v1: Minor fixes: used #define for some values and bools]\n" + "Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>\n" + "---\n" + " include/linux/cleancache.h | 1 +\n" + " mm/cleancache.c | 156 ++++++++++++++++++++++++++++++++++++++++-----\n" + " 2 files changed, 140 insertions(+), 17 deletions(-)\n" + "\n" + "diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h\n" + "index 42e55de..f7e32f0 100644\n" + "--- a/include/linux/cleancache.h\n" + "+++ b/include/linux/cleancache.h\n" + "@@ -37,6 +37,7 @@ extern struct cleancache_ops\n" + " \tcleancache_register_ops(struct cleancache_ops *ops);\n" + " extern void __cleancache_init_fs(struct super_block *);\n" + " extern void __cleancache_init_shared_fs(char *, struct super_block *);\n" + "+#define CLEANCACHE_HAS_LAZY_INIT\n" + " extern int __cleancache_get_page(struct page *);\n" + " extern void __cleancache_put_page(struct page *);\n" + " extern void __cleancache_invalidate_page(struct address_space *, struct page *);\n" + "diff --git a/mm/cleancache.c b/mm/cleancache.c\n" + "index 32e6f41..318a0ad 100644\n" + "--- a/mm/cleancache.c\n" + "+++ b/mm/cleancache.c\n" + "@@ -45,15 +45,45 @@ static u64 cleancache_puts;\n" + " static u64 cleancache_invalidates;\n" + " \n" + " /*\n" + "+ * When no backend is registered all calls to init_fs and init_shard_fs\n" + "+ * are registered and fake poolids are given to the respective\n" + "+ * super block but no tmem_pools are created. When a backend\n" + "+ * registers with cleancache the previous calls to init_fs and\n" + "+ * init_shared_fs are executed to create tmem_pools and set the\n" + "+ * respective poolids. While no backend is registered all \"puts\",\n" + "+ * \"gets\" and \"flushes\" are ignored or fail.\n" + "+ */\n" + "+#define MAX_INITIALIZABLE_FS 32\n" + "+#define FAKE_FS_POOLID_OFFSET 1000\n" + "+#define FAKE_SHARED_FS_POOLID_OFFSET 2000\n" + "+\n" + "+#define FS_NO_BACKEND (-1)\n" + "+#define FS_UNKNOWN (-2)\n" + "+static int fs_poolid_map[MAX_INITIALIZABLE_FS];\n" + "+static int shared_fs_poolid_map[MAX_INITIALIZABLE_FS];\n" + "+\n" + "+static char *uuids[MAX_INITIALIZABLE_FS];\n" + "+static bool __read_mostly backend_registered;\n" + "+\n" + "+/*\n" + " * register operations for cleancache, returning previous thus allowing\n" + " * detection of multiple backends and possible nesting\n" + " */\n" + " struct cleancache_ops cleancache_register_ops(struct cleancache_ops *ops)\n" + " {\n" + " \tstruct cleancache_ops old = cleancache_ops;\n" + "+\tint i;\n" + " \n" + " \tcleancache_ops = *ops;\n" + "-\tcleancache_enabled = 1;\n" + "+\n" + "+\tbackend_registered = true;\n" + "+\tfor (i = 0; i < MAX_INITIALIZABLE_FS; i++) {\n" + "+\t\tif (fs_poolid_map[i] == FS_NO_BACKEND)\n" + "+\t\t\tfs_poolid_map[i] = (*cleancache_ops.init_fs)(PAGE_SIZE);\n" + "+\t\tif (shared_fs_poolid_map[i] == FS_NO_BACKEND)\n" + "+\t\t\tshared_fs_poolid_map[i] = (*cleancache_ops.init_shared_fs)\n" + "+\t\t\t\t\t(uuids[i], PAGE_SIZE);\n" + "+\t}\n" + " \treturn old;\n" + " }\n" + " EXPORT_SYMBOL(cleancache_register_ops);\n" + "@@ -61,15 +91,38 @@ EXPORT_SYMBOL(cleancache_register_ops);\n" + " /* Called by a cleancache-enabled filesystem at time of mount */\n" + " void __cleancache_init_fs(struct super_block *sb)\n" + " {\n" + "-\tsb->cleancache_poolid = (*cleancache_ops.init_fs)(PAGE_SIZE);\n" + "+\tint i;\n" + "+\n" + "+\tfor (i = 0; i < MAX_INITIALIZABLE_FS; i++) {\n" + "+\t\tif (fs_poolid_map[i] == FS_UNKNOWN) {\n" + "+\t\t\tsb->cleancache_poolid = i + FAKE_FS_POOLID_OFFSET;\n" + "+\t\t\tif (backend_registered)\n" + "+\t\t\t\tfs_poolid_map[i] = (*cleancache_ops.init_fs)(PAGE_SIZE);\n" + "+\t\t\telse\n" + "+\t\t\t\tfs_poolid_map[i] = FS_NO_BACKEND;\n" + "+\t\t\tbreak;\n" + "+\t\t}\n" + "+\t}\n" + " }\n" + " EXPORT_SYMBOL(__cleancache_init_fs);\n" + " \n" + " /* Called by a cleancache-enabled clustered filesystem at time of mount */\n" + " void __cleancache_init_shared_fs(char *uuid, struct super_block *sb)\n" + " {\n" + "-\tsb->cleancache_poolid =\n" + "-\t\t(*cleancache_ops.init_shared_fs)(uuid, PAGE_SIZE);\n" + "+\tint i;\n" + "+\n" + "+\tfor (i = 0; i < MAX_INITIALIZABLE_FS; i++) {\n" + "+\t\tif (shared_fs_poolid_map[i] == FS_UNKNOWN) {\n" + "+\t\t\tsb->cleancache_poolid = i + FAKE_SHARED_FS_POOLID_OFFSET;\n" + "+\t\t\tuuids[i] = uuid;\n" + "+\t\t\tif (backend_registered)\n" + "+\t\t\t\tshared_fs_poolid_map[i] = (*cleancache_ops.init_shared_fs)\n" + "+\t\t\t\t\t\t(uuid, PAGE_SIZE);\n" + "+\t\t\telse\n" + "+\t\t\t\tshared_fs_poolid_map[i] = FS_NO_BACKEND;\n" + "+\t\t\tbreak;\n" + "+\t\t}\n" + "+\t}\n" + " }\n" + " EXPORT_SYMBOL(__cleancache_init_shared_fs);\n" + " \n" + "@@ -99,6 +152,19 @@ static int cleancache_get_key(struct inode *inode,\n" + " }\n" + " \n" + " /*\n" + "+ * Returns a pool_id that is associated with a given fake poolid.\n" + "+ */\n" + "+static int get_poolid_from_fake(int fake_pool_id)\n" + "+{\n" + "+\tif (fake_pool_id >= FAKE_SHARED_FS_POOLID_OFFSET)\n" + "+\t\treturn shared_fs_poolid_map[fake_pool_id -\n" + "+\t\t\tFAKE_SHARED_FS_POOLID_OFFSET];\n" + "+\telse if (fake_pool_id >= FAKE_FS_POOLID_OFFSET)\n" + "+\t\treturn fs_poolid_map[fake_pool_id - FAKE_FS_POOLID_OFFSET];\n" + "+\treturn FS_NO_BACKEND;\n" + "+}\n" + "+\n" + "+/*\n" + " * \"Get\" data from cleancache associated with the poolid/inode/index\n" + " * that were specified when the data was put to cleanache and, if\n" + " * successful, use it to fill the specified page with data and return 0.\n" + "@@ -109,17 +175,26 @@ int __cleancache_get_page(struct page *page)\n" + " {\n" + " \tint ret = -1;\n" + " \tint pool_id;\n" + "+\tint fake_pool_id;\n" + " \tstruct cleancache_filekey key = { .u.key = { 0 } };\n" + " \n" + "+\tif (!backend_registered) {\n" + "+\t\tcleancache_failed_gets++;\n" + "+\t\tgoto out;\n" + "+\t}\n" + "+\n" + " \tVM_BUG_ON(!PageLocked(page));\n" + "-\tpool_id = page->mapping->host->i_sb->cleancache_poolid;\n" + "-\tif (pool_id < 0)\n" + "+\tfake_pool_id = page->mapping->host->i_sb->cleancache_poolid;\n" + "+\tif (fake_pool_id < 0)\n" + " \t\tgoto out;\n" + "+\tpool_id = get_poolid_from_fake(fake_pool_id);\n" + " \n" + " \tif (cleancache_get_key(page->mapping->host, &key) < 0)\n" + " \t\tgoto out;\n" + " \n" + "-\tret = (*cleancache_ops.get_page)(pool_id, key, page->index, page);\n" + "+\tif (pool_id >= 0)\n" + "+\t\tret = (*cleancache_ops.get_page)(pool_id,\n" + "+\t\t\t\tkey, page->index, page);\n" + " \tif (ret == 0)\n" + " \t\tcleancache_succ_gets++;\n" + " \telse\n" + "@@ -138,12 +213,23 @@ EXPORT_SYMBOL(__cleancache_get_page);\n" + " void __cleancache_put_page(struct page *page)\n" + " {\n" + " \tint pool_id;\n" + "+\tint fake_pool_id;\n" + " \tstruct cleancache_filekey key = { .u.key = { 0 } };\n" + " \n" + "+\tif (!backend_registered) {\n" + "+\t\tcleancache_puts++;\n" + "+\t\treturn;\n" + "+\t}\n" + "+\n" + " \tVM_BUG_ON(!PageLocked(page));\n" + "-\tpool_id = page->mapping->host->i_sb->cleancache_poolid;\n" + "+\tfake_pool_id = page->mapping->host->i_sb->cleancache_poolid;\n" + "+\tif (fake_pool_id < 0)\n" + "+\t\treturn;\n" + "+\n" + "+\tpool_id = get_poolid_from_fake(fake_pool_id);\n" + "+\n" + " \tif (pool_id >= 0 &&\n" + "-\t cleancache_get_key(page->mapping->host, &key) >= 0) {\n" + "+\t\tcleancache_get_key(page->mapping->host, &key) >= 0) {\n" + " \t\t(*cleancache_ops.put_page)(pool_id, key, page->index, page);\n" + " \t\tcleancache_puts++;\n" + " \t}\n" + "@@ -158,14 +244,22 @@ void __cleancache_invalidate_page(struct address_space *mapping,\n" + " \t\t\t\t\tstruct page *page)\n" + " {\n" + " \t/* careful... page->mapping is NULL sometimes when this is called */\n" + "-\tint pool_id = mapping->host->i_sb->cleancache_poolid;\n" + "+\tint pool_id;\n" + "+\tint fake_pool_id = mapping->host->i_sb->cleancache_poolid;\n" + " \tstruct cleancache_filekey key = { .u.key = { 0 } };\n" + " \n" + "-\tif (pool_id >= 0) {\n" + "+\tif (!backend_registered)\n" + "+\t\treturn;\n" + "+\n" + "+\tif (fake_pool_id >= 0) {\n" + "+\t\tpool_id = get_poolid_from_fake(fake_pool_id);\n" + "+\t\tif (pool_id < 0)\n" + "+\t\t\treturn;\n" + "+\n" + " \t\tVM_BUG_ON(!PageLocked(page));\n" + " \t\tif (cleancache_get_key(mapping->host, &key) >= 0) {\n" + " \t\t\t(*cleancache_ops.invalidate_page)(pool_id,\n" + "-\t\t\t\t\t\t\t key, page->index);\n" + "+\t\t\t\t\tkey, page->index);\n" + " \t\t\tcleancache_invalidates++;\n" + " \t\t}\n" + " \t}\n" + "@@ -179,9 +273,18 @@ EXPORT_SYMBOL(__cleancache_invalidate_page);\n" + " */\n" + " void __cleancache_invalidate_inode(struct address_space *mapping)\n" + " {\n" + "-\tint pool_id = mapping->host->i_sb->cleancache_poolid;\n" + "+\tint pool_id;\n" + "+\tint fake_pool_id = mapping->host->i_sb->cleancache_poolid;\n" + " \tstruct cleancache_filekey key = { .u.key = { 0 } };\n" + " \n" + "+\tif (!backend_registered)\n" + "+\t\treturn;\n" + "+\n" + "+\tif (fake_pool_id < 0)\n" + "+\t\treturn;\n" + "+\n" + "+\tpool_id = get_poolid_from_fake(fake_pool_id);\n" + "+\n" + " \tif (pool_id >= 0 && cleancache_get_key(mapping->host, &key) >= 0)\n" + " \t\t(*cleancache_ops.invalidate_inode)(pool_id, key);\n" + " }\n" + "@@ -194,16 +297,30 @@ EXPORT_SYMBOL(__cleancache_invalidate_inode);\n" + " */\n" + " void __cleancache_invalidate_fs(struct super_block *sb)\n" + " {\n" + "-\tif (sb->cleancache_poolid >= 0) {\n" + "-\t\tint old_poolid = sb->cleancache_poolid;\n" + "-\t\tsb->cleancache_poolid = -1;\n" + "-\t\t(*cleancache_ops.invalidate_fs)(old_poolid);\n" + "+\tint index;\n" + "+\tint fake_pool_id = sb->cleancache_poolid;\n" + "+\tint old_poolid = fake_pool_id;\n" + "+\n" + "+\tif (fake_pool_id >= FAKE_SHARED_FS_POOLID_OFFSET) {\n" + "+\t\tindex = fake_pool_id - FAKE_SHARED_FS_POOLID_OFFSET;\n" + "+\t\told_poolid = shared_fs_poolid_map[index];\n" + "+\t\tshared_fs_poolid_map[index] = FS_UNKNOWN;\n" + "+\t\tuuids[index] = NULL;\n" + "+\t} else if (fake_pool_id >= FAKE_FS_POOLID_OFFSET) {\n" + "+\t\tindex = fake_pool_id - FAKE_FS_POOLID_OFFSET;\n" + "+\t\told_poolid = fs_poolid_map[index];\n" + "+\t\tfs_poolid_map[index] = FS_UNKNOWN;\n" + " \t}\n" + "+\tsb->cleancache_poolid = -1;\n" + "+\tif (backend_registered)\n" + "+\t\t(*cleancache_ops.invalidate_fs)(old_poolid);\n" + " }\n" + " EXPORT_SYMBOL(__cleancache_invalidate_fs);\n" + " \n" + " static int __init init_cleancache(void)\n" + " {\n" + "+\tint i;\n" + "+\n" + " #ifdef CONFIG_DEBUG_FS\n" + " \tstruct dentry *root = debugfs_create_dir(\"cleancache\", NULL);\n" + " \tif (root == NULL)\n" + "@@ -215,6 +332,11 @@ static int __init init_cleancache(void)\n" + " \tdebugfs_create_u64(\"invalidates\", S_IRUGO,\n" + " \t\t\t\troot, &cleancache_invalidates);\n" + " #endif\n" + "+\tfor (i = 0; i < MAX_INITIALIZABLE_FS; i++) {\n" + "+\t\tfs_poolid_map[i] = FS_UNKNOWN;\n" + "+\t\tshared_fs_poolid_map[i] = FS_UNKNOWN;\n" + "+\t}\n" + "+\tcleancache_enabled = 1;\n" + " \treturn 0;\n" + " }\n" + " module_init(init_cleancache)\n" + "-- \n" + 1.7.11.7 -de1db8531ca06b0eea3e009fd5c9c0647a4e0bf6ec511dbb8cba23d5e1777dbc +7091bb91d3e5f9f395f79fa2003eba17f332f7a9d23d56419f654ce539274932
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.