[lc-checkins] CVS: linux/mm/comp_cache main.c,1.28,1.29 swapin.c,1.24,1.25 swapout.c,1.30,1.31
Status: Beta
Brought to you by:
nitin_sf
|
From: Rodrigo S. de C. <rc...@us...> - 2002-02-28 00:49:02
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv26862/mm/comp_cache
Modified Files:
main.c swapin.c swapout.c
Log Message:
- Cleanups in comp_cache/main.c
- Fix to make filemap_fdatawait() to wait for compressed pages being written
out.
Index: main.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** main.c 27 Feb 2002 14:16:52 -0000 1.28
--- main.c 27 Feb 2002 19:58:51 -0000 1.29
***************
*** 2,6 ****
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-02-26 19:44:33 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-02-27 13:52:02 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 51,57 ****
int current_algorithm;
- static char buffer_compressed[MAX_COMPRESSED_SIZE];
- struct page * buffer_decompressed;
-
extern unsigned long num_physpages;
--- 51,54 ----
***************
*** 112,117 ****
comp_cache_t * comp_page;
comp_cache_fragment_t * fragment;
! unsigned short aux_comp_size, algorithm;
! static unsigned long current_compressed_page = 0;
if (!page)
--- 109,119 ----
comp_cache_t * comp_page;
comp_cache_fragment_t * fragment;
! unsigned short comp_size, algorithm;
!
! static struct page * current_compressed_page;
! static char buffer_compressed1[MAX_COMPRESSED_SIZE];
! static char buffer_compressed2[MAX_COMPRESSED_SIZE];
! unsigned long * buffer_compressed;
!
if (!page)
***************
*** 130,137 ****
}
! /* compress to a buffer */
! current_compressed_page = (unsigned long) page;
! aux_comp_size = compress(page_address(page), (unsigned long *) &buffer_compressed, &algorithm);
! comp_page = get_comp_cache_page(page, aux_comp_size, &fragment, dirty, gfp_mask);
/* if comp_page == NULL, get_comp_cache_page() gave up
--- 132,137 ----
}
! comp_size = compress(page_address(current_compressed_page = page), buffer_compressed = (unsigned long *) &buffer_compressed1, &algorithm);
! comp_page = get_comp_cache_page(page, comp_size, &fragment, dirty, gfp_mask);
/* if comp_page == NULL, get_comp_cache_page() gave up
***************
*** 149,181 ****
}
! /* TODO: add more buffers for compression. Only one may cause
! * many page to be compressed twice */
!
! if (not_compressed(fragment)) {
! memcpy(page_address(comp_page->page), page_address(page), PAGE_SIZE);
! goto out;
! }
!
! /* someone used the buffer while we slept to get a comp cache
! * entry. Let's compress it again and get a new comp_cache
! * entry, since swap cache page contents might have been
! * messed up and we can't check if that actually happened. */
! if (current_compressed_page != (unsigned long) page) {
! current_compressed_page = (unsigned long) page;
! compress(page_address(page), (unsigned long *) &buffer_compressed, &algorithm);
! }
set_fragment_algorithm(fragment, algorithm);
! if (fragment->offset + fragment->compressed_size > PAGE_SIZE)
! BUG();
!
! memcpy(page_address(comp_page->page) + fragment->offset, (unsigned long *) &buffer_compressed, fragment->compressed_size);
- out:
if (PageTestandSetCompCache(page))
BUG();
UnlockPage(comp_page->page);
-
out_failed:
UnlockPage(page);
--- 149,168 ----
}
! if (fragment->offset + fragment->compressed_size > PAGE_SIZE)
! BUG();
set_fragment_algorithm(fragment, algorithm);
! if (compressed(fragment)) {
! if (current_compressed_page != page)
! compress(page_address(page), buffer_compressed = (unsigned long *) &buffer_compressed2, &algorithm);
! memcpy(page_address(comp_page->page) + fragment->offset, buffer_compressed , fragment->compressed_size);
! } else
! memcpy(page_address(comp_page->page), page_address(page), PAGE_SIZE);
!
if (PageTestandSetCompCache(page))
BUG();
UnlockPage(comp_page->page);
out_failed:
UnlockPage(page);
***************
*** 275,283 ****
current_algorithm = WKDM_IDX;
-
- buffer_decompressed = alloc_page(GFP_KERNEL);
-
- if (!buffer_decompressed)
- panic("comp_cache_init(): cannot allocate page");
}
--- 262,265 ----
Index: swapin.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapin.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** swapin.c 27 Feb 2002 14:16:52 -0000 1.24
--- swapin.c 27 Feb 2002 19:58:51 -0000 1.25
***************
*** 2,6 ****
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-02-27 09:09:07 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-02-27 16:33:10 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 109,113 ****
/* we want to set dirty only actually mapped pages,
* not temporary swap buffers, for example */
! if (!list_empty(&page->list))
set_page_dirty(page);
list_del(&fragment->mapping_list);
--- 109,113 ----
/* we want to set dirty only actually mapped pages,
* not temporary swap buffers, for example */
! if (!CompFragmentIO(fragment))
set_page_dirty(page);
list_del(&fragment->mapping_list);
***************
*** 191,194 ****
--- 191,209 ----
{
truncate_list_comp_pages(&mapping->clean_comp_pages, 0, 0);
+ }
+
+ void
+ wait_all_comp_pages(struct address_space * mapping)
+ {
+ struct page **hash;
+ struct page * page;
+
+ while (!list_empty(&mapping->locked_comp_pages)) {
+ page = list_entry(mapping->locked_comp_pages.next, struct page, list);
+
+ list_del_init(&page->list);
+
+ wait_on_page(page);
+ }
}
Index: swapout.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** swapout.c 27 Feb 2002 14:16:52 -0000 1.30
--- swapout.c 27 Feb 2002 19:58:51 -0000 1.31
***************
*** 2,6 ****
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-02-26 19:54:15 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-02-27 16:27:01 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 24,31 ****
/**
! * - find_free_swp_buffer - gets a swap buffer page. If there's a
! * free buffer page, it will lock the page and return. Otherwise we
! * may sleep to get the lock.
! * - return value: pointer to the page which will be returned locked */
static struct swp_buffer *
find_free_swp_buffer(comp_cache_fragment_t * fragment)
--- 24,35 ----
/**
! * find_free_swp_buffer - gets a swap buffer page
! * @fragment: the fragment which will be decompressed to this buffer
! * page.
! *
! * If there's a free buffer page, it will lock the page and
! * return. Otherwise we may sleep to get the lock.
! *
! */
static struct swp_buffer *
find_free_swp_buffer(comp_cache_fragment_t * fragment)
***************
*** 36,39 ****
--- 40,46 ----
int wait;
+ if (!fragment)
+ BUG();
+
CompFragmentSetIO(fragment);
***************
*** 53,56 ****
--- 60,65 ----
}
+ list_del(&swp_buffer->page->list);
+
if (swp_buffer->page->buffers && !try_to_free_buffers(swp_buffer->page, GFP_KERNEL))
BUG();
***************
*** 111,115 ****
buffer_page->index = fragment->index;
! buffer_page->mapping = fragment->mapping;
return (swp_buffer);
--- 120,126 ----
buffer_page->index = fragment->index;
! buffer_page->mapping = fragment->mapping;
!
! list_add(&buffer_page->list, &fragment->mapping->locked_comp_pages);
return (swp_buffer);
|