[lc-checkins] CVS: linux/mm/comp_cache main.c,1.27,1.28 swapin.c,1.23,1.24 swapout.c,1.29,1.30
Status: Beta
Brought to you by:
nitin_sf
|
From: Rodrigo S. de C. <rc...@us...> - 2002-02-27 14:16:56
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv23908/mm/comp_cache
Modified Files:
main.c swapin.c swapout.c
Log Message:
- Clean pages support in compressed cache is improved even more.
- Clean and dirty pages are only removed from the compressed cache
when writeout_fragments() is called or the program exits.
- removed an obsolete code for CONFIG_COMP_SWAP
- improved writeout_fragments(), which will try to free fragments even
if we can't perform IO. In this case, we will free only clean
fragments.
Index: main.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** main.c 26 Feb 2002 20:59:01 -0000 1.27
--- main.c 27 Feb 2002 14:16:52 -0000 1.28
***************
*** 2,6 ****
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-02-26 13:37:55 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-02-26 19:44:33 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 123,127 ****
if (!dirty)
BUG();
! invalidate_comp_page(page->mapping, page->index, page);
if (PageDirty(page))
BUG();
--- 123,129 ----
if (!dirty)
BUG();
! invalidate_comp_cache(page->mapping, page->index);
! if (!PageTestandClearCompCache(page))
! BUG();
if (PageDirty(page))
BUG();
Index: swapin.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapin.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** swapin.c 26 Feb 2002 16:01:10 -0000 1.23
--- swapin.c 27 Feb 2002 14:16:52 -0000 1.24
***************
*** 2,6 ****
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-02-26 11:42:51 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-02-27 09:09:07 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 19,42 ****
void
! invalidate_comp_page(struct address_space *mapping, unsigned long offset, struct page * page) {
comp_cache_fragment_t * fragment;
int err = find_comp_page(mapping, offset, &fragment);
if (err) {
/* if the fragment has been written out, we may have
* CompCache flag, but no fragment in Comp Cache */
! if (page)
! PageClearCompCache(page);
return;
}
! if (page) {
! if (!PageTestandClearCompCache(page))
! BUG();
! if (CompFragmentDirty(fragment))
! set_page_dirty(page);
! }
!
! comp_cache_free(fragment);
}
--- 19,55 ----
void
! invalidate_comp_cache(struct address_space *mapping, unsigned long offset)
! {
comp_cache_fragment_t * fragment;
int err = find_comp_page(mapping, offset, &fragment);
+
+ if (err)
+ return;
+
+ comp_cache_free(fragment);
+ }
+ void
+ clear_comp_page(struct address_space *mapping, unsigned long offset, struct page * page)
+ {
+ comp_cache_fragment_t * fragment;
+ int err;
+
+ if (!PageCompCache(page))
+ return;
+
+ err = find_comp_page(mapping, offset, &fragment);
+
if (err) {
/* if the fragment has been written out, we may have
* CompCache flag, but no fragment in Comp Cache */
! PageClearCompCache(page);
return;
}
! if (!PageCompCache(page))
! BUG();
! if (CompFragmentTestandClearDirty(fragment))
! set_page_dirty(page);
}
***************
*** 102,105 ****
--- 115,119 ----
}
SetPageUptodate(page);
+ PageSetCompCache(page);
}
***************
*** 129,140 ****
compression_algorithms[current_algorithm].stats.pgccin++;
! /* NOTE: we have to make sure to free the fragment only when
! * the page fault has been serviced since we may shrink the
! * cache and move down the vswap entry */
! comp_cache_free_locked(fragment);
!
! PageClearCompCache(page);
! UnlockPage(page);
!
return 0;
--- 143,148 ----
compression_algorithms[current_algorithm].stats.pgccin++;
! UnlockPage(fragment->comp_page->page);
! UnlockPage(page);
return 0;
***************
*** 231,235 ****
UnlockPage(fragment->comp_page->page);
- PageSetCompCache(page);
page_cache_release(page);
UnlockPage(page);
--- 239,242 ----
Index: swapout.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** swapout.c 26 Feb 2002 16:01:10 -0000 1.29
--- swapout.c 27 Feb 2002 14:16:52 -0000 1.30
***************
*** 2,6 ****
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-02-26 12:53:44 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-02-26 19:54:15 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 151,155 ****
* we have a comp_page where we can store the new page */
static void
! writeout_fragments(void) {
int (*writepage)(struct page *);
struct list_head * fragment_lh, * next_fragment;
--- 151,155 ----
* we have a comp_page where we can store the new page */
static void
! writeout_fragments(unsigned int gfp_mask) {
int (*writepage)(struct page *);
struct list_head * fragment_lh, * next_fragment;
***************
*** 169,184 ****
page = fragment->comp_page->page;
! /* page locked? move it to the back of the list */
! if (TryLockPage(page)) {
! list_del(fragment_lh);
! list_add(fragment_lh, &lru_queue);
! maxscan++;
continue;
- }
if (!CompFragmentDirty(fragment)) {
comp_cache_free_locked(fragment);
continue;
}
swap_cache_page = 0;
--- 169,191 ----
page = fragment->comp_page->page;
! /* move it to the back of the list */
! list_del(fragment_lh);
! list_add(fragment_lh, &lru_queue);
!
! /* page locked */
! if (TryLockPage(page))
continue;
+ /* clean page, let's free it */
if (!CompFragmentDirty(fragment)) {
comp_cache_free_locked(fragment);
continue;
}
+
+ /* we can't perform IO, so we can't go on */
+ if (!(gfp_mask & __GFP_FS)) {
+ UnlockPage(page);
+ continue;
+ }
swap_cache_page = 0;
***************
*** 301,311 ****
}
! if (!(gfp_mask & __GFP_FS))
! goto failed;
!
! writeout_fragments();
}
- failed:
return NULL;
--- 308,314 ----
}
! writeout_fragments(gfp_mask);
}
return NULL;
|