mm/fs: add hooks to support cleancache
Subsystems (5)
PATCH v8 4/8 mm/fs: add hooks to support cleancache
[PATCH V8 4/8] mm/fs: add hooks to support cleancache
This fourth patch of eight in this cleancache series provides the core hooks in VFS for: initializing cleancache per filesystem; capturing clean pages reclaimed by page cache; attempting to get pages from cleancache before filesystem read; and ensuring coherency between pagecache, disk, and cleancache. Note that the placement of these hooks was stable from 2.6.18 to 2.6.38; a minor semantic change was required due to a patchset in 2.6.39.
All hooks become no-ops if CONFIG_CLEANCACHE is unset, or become a check of a boolean global if CONFIG_CLEANCACHE is set but no cleancache "backend" has claimed cleancache_ops.
Details and a FAQ can be found in Documentation/vm/cleancache.txt
---
Diffstat:
fs/buffer.c | 5 +++++ fs/mpage.c | 7 +++++++ fs/super.c | 3 +++ mm/filemap.c | 11 +++++++++++ mm/truncate.c | 6 ++++++ 5 files changed, 32 insertions(+)
fs/super.c +3 -0
@@ -31,6 +31,7 @@#include <linux/mutex.h> #include <linux/backing-dev.h> #include <linux/rculist_bl.h> +#include <linux/cleancache.h> #include "internal.h"
@@ -112,6 +113,7 @@ static struct super_block *alloc_super(s s->s_maxbytes =MAX_NON_LFS ; s->s_op = &default_op; s->s_time_gran =1000000000 ; + s->cleancache_poolid =-1 ; } out:return s;
@@ -177,6 +179,7 @@ void deactivate_locked_super(struct supe {struct file_system_type *fs = s->s_type;if (atomic_dec_and_test (&s->s_active)) { +cleancache_flush_fs (s); fs->kill_sb (s);/* * We need to call rcu_barrier so all the delayed rcu free
fs/buffer.c +5 -0
@@ -41,6 +41,7 @@#include <linux/bitops.h> #include <linux/mpage.h> #include <linux/bit_spinlock.h> +#include <linux/cleancache.h> static int fsync_buffers_list (spinlock_t *lock,struct list_head *list);
@@ -269,6 +270,10 @@ void invalidate_bdev(struct block_deviceinvalidate_bh_lrus ();lru_add_drain_all ();/* make sure all lru add caches are flushed */ invalidate_mapping_pages (mapping,0 ,-1 ); +/* 99% of the time, we don't need to flush the cleancache on the bdev. +* But, for the strange corners, lets be cautious +*/ +cleancache_flush_inode (mapping); }EXPORT_SYMBOL (invalidate_bdev);
fs/mpage.c +7 -0
@@ -27,6 +27,7 @@#include <linux/writeback.h> #include <linux/backing-dev.h> #include <linux/pagevec.h> +#include <linux/cleancache.h> /* * I/O completion handler for multipage BIOs.
@@ -271,6 +272,12 @@ do_mpage_readpage(struct bio *bio, strucSetPageMappedToDisk (page); } +if (fully_mapped && blocks_per_page ==1 && !PageUptodate (page) && +cleancache_get_page (page) ==0 ) { +SetPageUptodate (page); + goto confused; + } +/* * This page will go to BIO. Do we need to send this BIO off first? */
mm/filemap.c +11 -0
@@ -34,6 +34,7 @@#include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */ #include <linux/memcontrol.h> #include <linux/mm_inline.h> /* for page_is_file_cache() */ +#include <linux/cleancache.h> #include "internal.h" /*
@@ -118,6 +119,16 @@ void __delete_from_page_cache(struct pag {struct address_space *mapping = page->mapping; +/* +* if we're uptodate, flush out into the cleancache, otherwise +* invalidate any existing cleancache entries. We can't leave +* stale data around in the cleancache once our page is gone +*/ +if (PageUptodate (page) &&PageMappedToDisk (page)) +cleancache_put_page (page); +else +cleancache_flush_page (mapping, page); +radix_tree_delete (&mapping->page_tree, page->index); page->mapping =NULL ; mapping->nrpages--;
mm/truncate.c +6 -0
@@ -19,6 +19,7 @@#include <linux/task_io_accounting_ops.h> #include <linux/buffer_head.h> /* grr. try_to_release_page, do_invalidatepage */ +#include <linux/cleancache.h> #include "internal.h"
@@ -51,6 +52,7 @@ void do_invalidatepage(struct page *pagestatic inline void truncate_partial_page (struct page *page,unsigned partial) {zero_user_segment (page, partial,PAGE_CACHE_SIZE ); +cleancache_flush_page (page->mapping, page);if (page_has_private (page))do_invalidatepage (page, partial); }
@@ -214,6 +216,7 @@ void truncate_inode_pages_range(struct apgoff_t next;int i; +cleancache_flush_inode (mapping);if (mapping->nrpages ==0 )return ;
@@ -291,6 +294,7 @@ void truncate_inode_pages_range(struct apagevec_release (&pvec);mem_cgroup_uncharge_end (); } +cleancache_flush_inode (mapping); }EXPORT_SYMBOL (truncate_inode_pages_range);
@@ -440,6 +444,7 @@ int invalidate_inode_pages2_range(structint did_range_unmap =0 ;int wrapped =0 ; +cleancache_flush_inode (mapping);pagevec_init (&pvec,0 ); next = start; while (next <= end && !wrapped &&
@@ -498,6 +503,7 @@ int invalidate_inode_pages2_range(structmem_cgroup_uncharge_end ();cond_resched (); } +cleancache_flush_inode (mapping);return ret; }EXPORT_SYMBOL_GPL (invalidate_inode_pages2_range);
Hi Dan,
Quoted 34 lines · Dan Magenheimer
[PATCH V8 4/8] mm/fs: add hooks to support cleancache
This fourth patch of eight in this cleancache series provides the core hooks in VFS for: initializing cleancache per filesystem; capturing clean pages reclaimed by page cache; attempting to get pages from cleancache before filesystem read; and ensuring coherency between pagecache, disk, and cleancache. =C2=A0Note that the placement of these hooks was stable from 2.6.18 to 2.6.38; a minor semantic change was required due to a patchset in 2.6.39.
All hooks become no-ops if
CONFIG_CLEANCACHEis unset, or become a check of a boolean global ifCONFIG_CLEANCACHEis set but no cleancache "backend" has claimedcleancache_ops.Details and a FAQ can be found in
Documentation/vm/cleancache.txt[v8: [email protected]: adapt to new remove_from_page_cache function]Signed-off-by Chris Mason <[email protected]>Signed-off-by Dan Magenheimer <[email protected]>Reviewed-by Jeremy Fitzhardinge <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>Cc Andrew Morton <[email protected]>Cc Al Viro <[email protected]>Cc Matthew Wilcox <[email protected]>Cc Nick Piggin <[email protected]>Cc Mel Gorman <[email protected]>Cc Rik Van Riel <[email protected]>Cc Jan Beulich <[email protected]>Cc Andreas Dilger <[email protected]>Cc Ted Ts'o <[email protected]>Cc Mark Fasheh <[email protected]>Cc Joel Becker <[email protected]>Cc Nitin Gupta <[email protected]>
Quoted 4 lines
---
Diffstat:
=C2=A0fs/buffer.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A05 +++++
Quoted 1 line
=C2=A0fs/mpage.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A07 +++++++
Quoted 1 line
=C2=A0fs/super.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A03 +++
Quoted 1 line
=C2=A0mm/filemap.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 11 +++++++++++
Quoted 1 line
=C2=A0mm/truncate.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A06 ++++++
fs/super.c =C2=A0 =C2=A0 =C2=A02011-04-13=
Quoted 4 lines
=C2=A05 files changed, 32 insertions(+)
fs/super.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/super.c 2011-04-11 18:21:51.000000000 -0600 +0
-0
17:08:09.175853426 -0600
Quoted 10 lines
fs/super.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/super.c 2011-04-11 18:21:51.000000000 -0600 +0
-0@@ -31,6 +31,7 @@=C2=A0#include <
linux/mutex.h>
=C2=A0#include <linux/backing-dev.h>
=C2=A0#include <linux/rculist_bl.h>
+#include <linux/cleancache.h>
=C2=A0#include "internal.h"fs/super.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/super.c 2011-04-11 18:21:51.000000000 -0600 +0
-0@@ -112,6 +113,7 @@ static struct super_block *alloc_super(s=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s->s_maxbytes =3D =
MAX_NON_LFS;
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s->s_op =3D &defau=
lt_op;
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s->s_time_gran =3D=
1000000000;
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
s->cleancache_poolid=
=3D -1;
fs/super.c =C2=A0 =C2=A0 =C2=A02011-04-13= void deactivate_locked_super(struct supe · line 182
Quoted 8 lines
=C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0out:
=C2=A0 =C2=A0 =C2=A0 =C2=A0return s;fs/super.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/super.c 2011-04-11 18:21:51.000000000 -0600 +1
-0@@ -177,6 +179,7 @@ void deactivate_locked_super(struct supe =C2=A0{ =C2=A0 =C2=A0 =C2=A0 =C2=A0struct file_system_type *fs =3D s->s_type; =C2=A0 =C2=A0 =C2=A0 =C2=A0if (atomic_dec_and_test(&s->s_active)) { + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cleancache_flush_fs(s)=
;
Quoted 3 lines
fs/super.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/super.c 2011-04-11 18:21:51.000000000 -0600 +0
-0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fs->kill_sb(s);=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * We need to call=
rcu_barrier so all the delayed rcu free
Quoted 1 line
---
linux-2.6.39-rc3/fs/buffer.c=C2=A0 =C2=A0 =C2=A0 =C2=A02011-04-11 18=
:21:51.000000000 -0600
Quoted 1 line
+++
linux-2.6.39-rc3-cleancache/fs/buffer.c=C2=A0 =C2=A0 2011-04-13 17:0=
7:24.700917174 -0600
Quoted 7 lines
fs/super.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/super.c 2011-04-11 18:21:51.000000000 -0600 +0
-0@@ -41,6 +41,7 @@=C2=A0#include <
linux/bitops.h>
=C2=A0#include <linux/mpage.h>
=C2=A0#include <linux/bit_spinlock.h>
+#include <linux/cleancache.h>=C2=A0static int fsync_buffers_list(spinlock_t *lock, struct
list_head*l=
ist);
Quoted 4 lines
fs/super.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/super.c 2011-04-11 18:21:51.000000000 -0600 +0
-0@@ -269,6 +270,10 @@ void invalidate_bdev(struct block_device =C2=A0 =C2=A0 =C2=A0 =C2=A0invalidate_bh_lrus();=C2=A0 =C2=A0 =C2=A0 =C2=A0lru_add_drain_all(); =C2=A0 =C2=A0/* make sure=
all lru add caches are flushed */
Quoted 2 lines
=C2=A0 =C2=A0 =C2=A0 =C2=A0invalidate_mapping_pages(mapping, 0, -1);
+ =C2=A0 =C2=A0 =C2=A0 /* 99% of the time, we don't need to flush the cle=
ancache on the bdev.
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0* But, for the strange corners, lets be caut=
ious
fs/mpage.c =C2=A0 =C2=A0 =C2=A02011-04-13=
Quoted 7 lines
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
+ =C2=A0 =C2=A0 =C2=A0cleancache_flush_inode(mapping); =C2=A0}
=C2=A0EXPORT_SYMBOL(invalidate_bdev);fs/mpage.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/mpage.c 2011-04-11 18:21:51.000000000 -0600 +0
-0
17:07:24.706913410 -0600
Quoted 10 lines
fs/mpage.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/mpage.c 2011-04-11 18:21:51.000000000 -0600 +0
-0@@ -27,6 +27,7 @@=C2=A0#include <
linux/writeback.h>
=C2=A0#include <linux/backing-dev.h>
=C2=A0#include <linux/pagevec.h>
+#include <linux/cleancache.h>=C2=A0/*
=C2=A0* I/O completion handler for multipage BIOs.fs/mpage.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/mpage.c 2011-04-11 18:21:51.000000000 -0600 +0
-0@@ -271,6 +272,12 @@ do_mpage_readpage(struct bio *bio, struc=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0SetPageMappedToDis=
k(page);
Quoted 3 lines
=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0 =C2=A0 if (
fully_mapped&&blocks_per_page=3D=3D 1 && !P=
ageUptodate(page) &&
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
cleancache_get_page(page)=3D=3D 0) =
{
Quoted 6 lines
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SetPageUptodate(page);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto confused;
+ =C2=A0 =C2=A0 =C2=A0 }
+
=C2=A0 =C2=A0 =C2=A0 =C2=A0/*
=C2=A0 =C2=A0 =C2=A0 =C2=A0 * This page will go to BIO. =C2=A0Do we need =
to send this BIO off first?
Quoted 2 lines
=C2=A0 =C2=A0 =C2=A0 =C2=A0 */
---linux-2.6.39-rc3/mm/filemap.c=C2=A0 =C2=A0 =C2=A0 2011-04-11 18:21:5=
1.000000000 -0600
Quoted 1 line
+++
linux-2.6.39-rc3-cleancache/mm/filemap.c=C2=A0 =C2=A02011-04-13 17:0=
9:46.367852002 -0600
Quoted 11 lines
fs/mpage.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/mpage.c 2011-04-11 18:21:51.000000000 -0600 +0
-0@@ -34,6 +34,7 @@=C2=A0#include <
linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */ =C2=A0#include <linux/memcontrol.h>
=C2=A0#include <linux/mm_inline.h> /* forpage_is_file_cache()*/ +#include <linux/cleancache.h>
=C2=A0#include "internal.h"=C2=A0/*
fs/mpage.c =C2=A0 =C2=A0 =C2=A02011-04-13= renamed from fs/mpage.c 2011-04-11 18:21:51.000000000 -0600 +0
-0@@ -118,6 +119,16 @@ void __delete_from_page_cache(struct pag =C2=A0{=C2=A0 =C2=A0 =C2=A0 =C2=A0struct
address_space*mapping =3D page->mappin=
g;
Quoted 3 lines
+ =C2=A0 =C2=A0 =C2=A0 /*
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0* if we're uptodate, flush out into the clea=
ncache, otherwise
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0* invalidate any existing cleancache entries=
. =C2=A0We can't leave
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0* stale data around in the cleancache once o=
ur page is gone
Quoted 3 lines
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
+ =C2=A0 =C2=A0 =C2=A0 if (PageUptodate(page) && PageMappedToDisk(page))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cleancache_put_page(pa=
ge);
Quoted 2 lines
+ =C2=A0 =C2=A0 =C2=A0 else
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cleancache_flush_page(=
mapping, page);
Quoted 1 line
+
First of all, thanks for resolving conflict with my patch.
Before I suggested a thing about cleancache_flush_page, cleancache_flush_in= ode.
what's the meaning of flush's semantic?
I thought it means invalidation.
AFAIC, how about change flush with invalidate?
--=20
Kind regards,
Minchan Kim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi Minchan --
Quoted 1 line
First of all, thanks for resolving conflict with my patch.
You're welcome! As I pointed out offlist, yours was the first change in MM that caused any semantic changes to the cleancache core hooks patch since before 2.6.18.
=20
Quoted 6 lines
Before I suggested a thing about
cleancache_flush_page,cleancache_flush_inode.
=20
what's the meaning of flush's semantic?
I thought it means invalidation.
AFAIC, how about change flush with invalidate?
I'm not sure the words "flush" and "invalidate" are defined precisely or used consistently everywhere in computer science, but I think that "invalidate" is to destroy a "pointer" to some data, but not necessarily destroy the
data itself. And "flush" means to actually remove
the data. So one would "invalidate a mapping" but one would "flush a cache".
Since cleancache_flush_page and cleancache_flush_inode semantically remove data from cleancache, I think flush is a better name than invalidate.
Does that make sense?
Thanks,
Dan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 23 lines · On Fri, 15 Apr 2011 07:47:57 -0700 (PDT) Dan Magenheimer…
Hi Minchan --
Quoted 1 line
First of all, thanks for resolving conflict with my patch.
You're welcome! As I pointed out offlist, yours was the first change in MM that caused any semantic changes to the cleancache core hooks patch since before 2.6.18.
Quoted 6 lines
Before I suggested a thing about
cleancache_flush_page,cleancache_flush_inode.what's the meaning of flush's semantic?
I thought it means invalidation.
AFAIC, how about change flush with invalidate?I'm not sure the words "flush" and "invalidate" are defined precisely or used consistently everywhere in computer science, but I think that "invalidate" is to destroy a "pointer" to some data, but not necessarily destroy the
data itself. And "flush" means to actually remove
the data. So one would "invalidate a mapping" but one would "flush a cache".
Quoted 6 lines
Since
cleancache_flush_pageandcleancache_flush_inodesemantically remove data from cleancache, I think flush is a better name than invalidate.Does that make sense?
nope ;)
Kernel code freely uses "flush" to refer to both invalidation and to writeback, sometimes in confusing ways. In this case, cleancache_flush_inode and cleancache_flush_page rather sound like they might write those things to backing store.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 25 lines
From: Andrew Morton [mailto:[email protected]] On Fri, 15 Apr 2011 07:47:57 -0700 (PDT) Dan Magenheimer <[email protected]> wrote:
=20Quoted 21 lines
Hi Minchan --
Quoted 6 lines
Before I suggested a thing about
cleancache_flush_page,cleancache_flush_inode.what's the meaning of flush's semantic?
I thought it means invalidation.
AFAIC, how about change flush with invalidate?I'm not sure the words "flush" and "invalidate" are defined precisely or used consistently everywhere in computer science, but I think that "invalidate" is to destroy a "pointer" to some data, but not necessarily destroy the
data itself. And "flush" means to actually remove
the data. So one would "invalidate a mapping" but one would "flush a cache".Since
cleancache_flush_pageandcleancache_flush_inodesemantically remove data from cleancache, I think flush is a better name than invalidate.
Quoted 8 lines
Quoted 1 line
Does that make sense?
=20
nope ;)
=20
Kernel code freely uses "flush" to refer to both invalidation and to writeback, sometimes in confusing ways. In this case,cleancache_flush_inodeandcleancache_flush_pagerather sound like they might write those things to backing store.
OK, I guess I am displaying my kernel-newbie-ness... though, in this case, writeback of a cleancache page to backing store doesn't make much sense either (since cleancache pages are by definition "clean").
I'm happy to rename the hooks, though will probably not repost a V9 unless/until more substantive changes collect... unless someone considers this an unmergeable offense.
Thanks for the feedback, Minchan and Andrew!
Dan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 22 lines · Andrew Morton
Quoted 15 lines
Quoted 6 lines
Before I suggested a thing about
cleancache_flush_page,cleancache_flush_inode.what's the meaning of flush's semantic?
I thought it means invalidation.
AFAIC, how about change flush with invalidate?I'm not sure the words "flush" and "invalidate" are defined precisely or used consistently everywhere in computer science, but I think that "invalidate" is to destroy a "pointer" to some data, but not necessarily destroy the
data itself. And "flush" means to actually remove
the data. So one would "invalidate a mapping" but one would "flush a cache".Quoted 6 lines
Since
cleancache_flush_pageandcleancache_flush_inodesemantically remove data from cleancache, I think flush is a better name than invalidate.Does that make sense?
Quoted 6 lines
nope ;)
Kernel code freely uses "flush" to refer to both invalidation and to writeback, sometimes in confusing ways. In this case,
cleancache_flush_inodeandcleancache_flush_pagerather sound like they might write those things to backing store.
I'd like to mention about *_{get,put}_page too. In linux get/put is not meaning read/write. There is {get,put}_page those are refcount stuff (Yeah, and I felt those methods does refcount by quick read. But it seems to be false. There is no xen codes, so I don't know actually though.).
And I agree, I also think the needing thing is consistency on the linux codes (term).
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Quoted 32 lines
From: OGAWA Hirofumi [mailto:[email protected]] =20
Andrew Morton <[email protected]> writes:
=20Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Before I suggested a thing about
cleancache_flush_page,cleancache_flush_inode.what's the meaning of flush's semantic?
I thought it means invalidation.
AFAIC, how about change flush with invalidate?I'm not sure the words "flush" and "invalidate" are defined precisely or used consistently everywhere in computer science, but I think that "invalidate" is to destroy a "pointer" to some data, but not necessarily destroy the
data itself. And "flush" means to actually remove
the data. So one would "invalidate a mapping" but one would "flush a cache".Since
cleancache_flush_pageandcleancache_flush_inodesemantically remove data from cleancache, I think flush is a better name than invalidate.Quoted 7 lines
Quoted 1 line
Does that make sense?
nope ;)
Kernel code freely uses "flush" to refer to both invalidation and to writeback, sometimes in confusing ways. In this case,
cleancache_flush_inodeandcleancache_flush_pagerather sound likethey
Quoted 1 line
might write those things to backing store.
Quoted 13 lines
=20
I'd like to mention about *_{get,put}_page too. In linux get/put is not meaning read/write. There is {get,put}_page those are refcount stuff (Yeah, and I felt those methods does refcount by quick read. But it seems to be false. There is no xen codes, so I don't know actually though.).
=20
And I agree, I also think the needing thing is consistency on the linux codes (term).
=20
Thanks.
--
OGAWA Hirofumi <[email protected]>
Hmmm, yes, that's a point of confusion also. No, cleancache put/get do not have any relationship with reference counting.
Andrew, I wonder if you would be so kind as to read the following and make a "ruling". If you determine a preferable set of names, I will abide by your decision and repost (if necessary).
The problem is this: The English language has a limited number of words that can be used to represent data motion and mapping and most/all of them are already used in the kernel, often, to quote Andrew, "in confusing ways." Complicating this, I think the semantics of the cleancache operations are different from the semantics of any other kernel operation... intentionally so, because the value of cleancache is a direct result of those differing semantics. And the cleancache semantics
are fairly complex (again intentionally) so a single function name can't possibly describe the semantics.
The cleancache operations are:
- put (page)
- get (page)
- flush page
- flush inode
- init fs
- flush fs
I think these names are reasonable representations of the semantics of the operations performed... but I'm not a kernel expert so there is certainly room for disagreement. Though I absolutely recognize the importance of a "name", I am primarily interested in merging the semantics of the operations and would happily accept any name that kernel developers could agree on. However, I fear that there will be NO name that will satisfy all, so would prefer to keep the existing names. If some renaming is eventually agreed upon, this could be done post-merge.
Here's a brief description of the semantics:
The cleancache operation currently known as "put" has the following semantics: If *possible*, please take the data contained in the pageframe referred to by this struct page into cleancache and associate it with the filesystem-determined "handle" derived from the struct page.
The cleancache operation currently known as "get" has the following semantics: Derive the filesystem-determined handle from this struct page. If cleancache contains a page matching that handle, recreate the page of data from cleancache and place the results in the pageframe referred to by the struct page. Then delete in cleancache any record of the handle and any data associated with it, so that a subsequent "get" will no longer find a match for the handle; any space used for the data can also be freed.
(Note that "take the data" and "recreate the page of data" are similar in semantics to "copy to" and "copy from", but since the cleancache operation may perform an "inflight" transformation on the data, and "copy" usually means a byte-for-byte replication, the word "copy" is also misleading.)
The cleancache operation currently known as "flush" has the following semantics: Derive the filesystem-determined handle from this struct page and struct mapping. If cleancache contains a page matching that handle, delete in cleancache any record of the handle and any data associated with it, so that a subsequent "get" will no longer find a match for the handle; any space used for the data can also be freed
The cleancache operation currently known as "flush inode" has the following semantics: Derive the filesystem-determined filekey from this struct mapping. If cleancache contains ANY handles matching that filekey, delete in cleancache any record of any matching handle and any data associated with those handles; any space used for the data can also be freed.
The cleancache operation currently known as "init fs" has the following semantics: Create a unique poolid to refer to this filesystem and save it in the superblock's cleancache_poolid field.
The cleancache operation currently known as "flush fs" has the following semantics: Get the cleancache_poolid field from this superblock. If cleancache contains ANY handles associated with that poolid, delete in cleancache any record of any matching handles and any data associated with those handles; any space used for the data can also be freed. Also, set the superblock's cleancache_poolid to be invalid and, in cleancache, recycle the poolid so a subsequent init_fs operation can reuse it.
That's all!
Thanks,
Dan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 137 lines · Dan Magenheimer
Quoted 39 lines
From: OGAWA Hirofumi [mailto:[email protected]]
Quoted 19 lines · Andrew Morton
Quoted 19 lines
Quoted 6 lines
Before I suggested a thing about
cleancache_flush_page,cleancache_flush_inode.what's the meaning of flush's semantic?
I thought it means invalidation.
AFAIC, how about change flush with invalidate?I'm not sure the words "flush" and "invalidate" are defined precisely or used consistently everywhere in computer science, but I think that "invalidate" is to destroy a "pointer" to some data, but not necessarily destroy the data itself. =C2=A0 And "flush" means to actually remove the data. =C2=A0So one would "invalidate a mapping" but one would "flush a cache".
Since
cleancache_flush_pageandcleancache_flush_inodesemantically remove data from cleancache, I think flush is a better name than invalidate.Quoted 7 lines
Quoted 1 line
Does that make sense?
nope ;)
Kernel code freely uses "flush" to refer to both invalidation and to writeback, sometimes in confusing ways. =C2=A0In this case,
cleancache_flush_inodeandcleancache_flush_pagerather sound likethey
Quoted 1 line
might write those things to backing store.
I'd like to mention about *_{get,put}_page too. In linux get/put is not meaning read/write. There is {get,put}_page those are refcount stuff (Yeah, and I felt those methods does refcount by quick read. But it seems to be false. There is no xen codes, so I don't know actually though.).
Quoted 6 lines
And I agree, I also think the needing thing is consistency on the linux codes (term).
Thanks.
--
OGAWA Hirofumi <[email protected]>Hmmm, yes, that's a point of confusion also. =C2=A0No, cleancache put/get do not have any relationship with reference counting.
Andrew, I wonder if you would be so kind as to read the following and make a "ruling". =C2=A0If you determine a preferable set of names, I will abide by your decision and repost (if necessary).
The problem is this: The English language has a limited number of words that can be used to represent data motion and mapping and most/all of them are already used in the kernel, often, to quote Andrew, "in confusing ways." =C2=A0Complicating this, I think the semantics of the cleancache operations are different from the semantics of any other kernel operation... intentionally so, because the value of cleancache is a direct result of those differing semantics. =C2=A0And the cleancache semantics are fairly complex (again intentionally) so a single function name can't possibly describe the semantics.
The cleancache operations are:
- put (page)
- get (page)
- flush page
- flush inode
- init fs
- flush fsI think these names are reasonable representations of the semantics of the operations performed... but I'm not a kernel expert so there is certainly room for disagreement. =C2=A0Though I absolutely recognize the importance of a "name", I am primarily interested in merging the semantics of the operations and would happily accept any name that kernel developers could agree on. =C2=A0However, I fear that there will be NO name that will satisfy all, so would prefer to keep the existing names. If some renaming is eventually agreed upon, this could be done post-merge.
Here's a brief description of the semantics:
The cleancache operation currently known as "put" has the following semantics: =C2=A0If *possible*, please take the data contained in the pageframe referred to by this struct page into cleancache and associate it with the filesystem-determined "handle" derived from the struct page.
The cleancache operation currently known as "get" has the following semantics: =C2=A0Derive the filesystem-determined handle from this struct page. =C2=A0If cleancache contains a page matching that handle, recreate the page of data from cleancache and place the results in the pageframe referred to by the struct page. =C2=A0Then delete in cleancache any record of the handle and any data associated with it, so that a subsequent "get" will no longer find a match for the handle; any space used for the data can also be freed.
(Note that "take the data" and "recreate the page of data" are similar in semantics to "copy to" and "copy from", but since the cleancache operation may perform an "inflight" transformation on the data, and "copy" usually means a byte-for-byte replication, the word "copy" is also misleading.)
The cleancache operation currently known as "flush" has the following semantics: =C2=A0Derive the filesystem-determined handle from this struct page and struct mapping. =C2=A0If cleancache contains a page matching that handle, delete in cleancache any record of the handle and any data associated with it, so that a subsequent "get" will no longer find a match for the handle; any space used for the data can also be freed
The cleancache operation currently known as "flush inode" has the following semantics: Derive the filesystem-determined filekey from this struct mapping. =C2=A0If cleancache contains ANY handles matching that filekey, delete in cleancache any record of any matching handle and any data associated with those handles; any space used for the data can also be freed.
The cleancache operation currently known as "init fs" has the following semantics: Create a unique poolid to refer to this filesystem and save it in the superblock's
cleancache_poolidfield.The cleancache operation currently known as "flush fs" has the following semantics: Get the
cleancache_poolidfield from this superblock. =C2=A0If cleancache contains ANY handles associated with that poolid, delete in cleancache any record of any matching handles and any data associated with those handles; any space used for the data can also be freed. Also, set the superblock'scleancache_poolidto be invalid and, in cleancache, recycle the poolid so a subsequentinit_fsoperation can reuse it.
Quoted 5 lines
That's all!
Thanks,
Dan
At least, I didn't confused your semantics except just flush. That's why I suggested only flush but after seeing your explaining, there is another thing I want to change. The get/put is common semantic of reference counting in kernel but in POV your semantics, it makes sense to me but get has a exclusive semantic so I want to represent it with API name. Maybe cleancache_get_page_exclusive.
The summary is that I don't want to change all API name. Just two thing. (I am not sure you and others agree on me. It's just suggestion).
1. cleancache_flush_page -> cleancache_[invalidate|remove]_page
2. cleancache_get_page -> cleancache_get_page_exclusive
BTW, Nice description.
Please include it in documentation if we can't reach the conclusion. It will help others to understand semantic of cleancache.
Thanks, Dan.
--=20
Kind regards,
Minchan Kim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 57 lines
From: Minchan Kim [mailto:[email protected]]
Quoted 51 lines · Dan Magenheimer
Quoted 4 lines
From: OGAWA Hirofumi [mailto:[email protected]]
Andrew Morton <[email protected]> writes:
Andrew, I wonder if you would be so kind as to read the following and make a "ruling". =C2=A0If you determine a preferable set of names, I will abide by your decision and repost (if necessary).
The problem is this: The English language has a limited number of words that can be used to represent data motion and mapping and most/all of them are already used in the kernel, often, to quote Andrew, "in confusing ways." =C2=A0Complicating this, I think the semantics of the cleancache operations are different from the semantics of any other kernel operation... intentionally so, because the value of cleancache is a direct result of those differing semantics. =C2=A0And the cleancache semantics are fairly complex (again intentionally) so a single function name can't possibly describe the semantics.
The cleancache operations are:
- put (page)
- get (page)
- flush page
- flush inode
- init fs
- flush fsI think these names are reasonable representations of the semantics of the operations performed... but I'm not a kernel expert so there is certainly room for disagreement. =C2=A0Though I absolutely recognize the importance of a "name", I am primarily interested in merging the semantics of the operations and would happily accept any name that kernel developers could agree on. =C2=A0However, I fear that there will be NO name that will satisfy all, so would prefer to keep the existing names. If some renaming is eventually agreed upon, this could be done post-merge.
Here's a brief description of the semantics:
: <semantics for other operations elided> :The cleancache operation currently known as "get" has the following semantics: =C2=A0Derive the filesystem-determined handle from this struct page. =C2=A0If cleancache contains a page matching that handle, recreate the page of data from cleancache and place the results in the pageframe referred to by the struct page. =C2=A0Then delete in cleancache any record of the handle and any data associated with it, so that a subsequent "get" will no longer find a match for the handle; any space used for the data can also be freed.
Quoted 3 lines
: <semantics for other operations elided> :
Quoted 15 lines
=20
At least, I didn't confused your semantics except just flush. That's why I suggested only flush but after seeing your explaining, there is another thing I want to change. The get/put is common semantic of reference counting in kernel but in POV your semantics, it makes sense to me but get has a exclusive semantic so I want to represent it with API name. Maybecleancache_get_page_exclusive.
=20
The summary is that I don't want to change all API name. Just two thing.
(I am not sure you and others agree on me. It's just suggestion). =20
1.cleancache_flush_page-> cleancache_[invalidate|remove]_page
2.cleancache_get_page->cleancache_get_page_exclusive
=20
Hi Minchan --
Thanks for continuing to be interested in this and sorry for my delayed response.
Actually, your comment about "get_page_exclusive" points out an incompleteness in my description of the semantics for cleancache_get_page.
First, I forgot to list cleancache_init_shared_fs, which is the equivalent of cleancache_init_fs but used for clustered filesystems. (Support is included in the patch for ocfs2 but I haven't played with it in quite some time and my focus has been on the other filesystems, so it slipped my mind :-}
The cleancache_get_page operation has a slightly different semantics depending on which of the init_fs calls was used. However, the location of the cleancache_get_page hook is the same regardless of the fs, so the name of the operation must represent both semantics. In the case of init_fs (non-shared), the behavior of cleancache_get_page is that the get is "destructive"; the page is removed from cleancache on a successful get. In the case of a init_shared_fs, however, the get is "non-destructive"; the page is NOT removed from cleancache. When cleancache contains pages from multiple kernels (e.g. Xen guests or different machines in a RAMster cluster), this semantic difference can make a big performance difference for a clustered filesystem. Since zcache only contains pages for a single kernel, the difference is moot.
Because of this, I am hesitant to add "exclusive" to the end of the name of the operation.
Quoted 3 lines
BTW, Nice description.
Please include it in documentation if we can't reach the conclusion. It will help others to understand semantic of cleancache.
Thanks! Nearly all of the description already exists in various places in the patch but I agree that it would be good if I add a new section to the Documentation file with the exact semantics.
Dan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>