Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv4225/mm/comp_cache
Modified Files:
swapout.c
Log Message:
- find_free_swp_buffer() cleanups
- Fix a bug that could corrupt the fragment->mapping->locked_pages list. The
swap buffer page is removed from the list, but if it happens that its buffer
can't be freed, it's not added back (and will certainly be removed again).
Index: swapout.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -r1.43 -r1.44
*** swapout.c 21 May 2002 18:49:06 -0000 1.43
--- swapout.c 21 May 2002 20:33:25 -0000 1.44
***************
*** 2,6 ****
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-05-21 11:23:59 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-05-21 16:52:13 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 38,41 ****
--- 38,42 ----
struct list_head * swp_buffer_lh, * tmp_lh;
struct swp_buffer * swp_buffer;
+ comp_cache_fragment_t * old_fragment;
int wait;
***************
*** 52,61 ****
list_for_each_safe(swp_buffer_lh, tmp_lh, &swp_used_buffer_head) {
swp_buffer = list_entry(swp_buffer_lh, struct swp_buffer, list);
! if (TryLockPage(swp_buffer->page)) {
if (!wait)
continue;
list_del_init(swp_buffer_lh);
! lock_page(swp_buffer->page);
}
--- 53,64 ----
list_for_each_safe(swp_buffer_lh, tmp_lh, &swp_used_buffer_head) {
swp_buffer = list_entry(swp_buffer_lh, struct swp_buffer, list);
+ buffer_page = swp_buffer->page;
+ old_fragment = swp_buffer->fragment;
! if (TryLockPage(buffer_page)) {
if (!wait)
continue;
list_del_init(swp_buffer_lh);
! lock_page(buffer_page);
}
***************
*** 63,69 ****
* right before being returned to the caller, so let's
* remove it now from any mapping->*_pages list */
! list_del(&swp_buffer->page->list);
! if (swp_buffer->page->buffers) {
unsigned int gfp_mask_buffer = gfp_mask;
--- 66,72 ----
* right before being returned to the caller, so let's
* remove it now from any mapping->*_pages list */
! list_del(&buffer_page->list);
! if (buffer_page->buffers) {
unsigned int gfp_mask_buffer = gfp_mask;
***************
*** 76,82 ****
gfp_mask_buffer &= ~__GFP_IO;
list_del_init(swp_buffer_lh);
! if (!try_to_free_buffers(swp_buffer->page, gfp_mask_buffer)) {
list_add_tail(swp_buffer_lh, &swp_used_buffer_head);
! UnlockPage(swp_buffer->page);
continue;
}
--- 79,87 ----
gfp_mask_buffer &= ~__GFP_IO;
list_del_init(swp_buffer_lh);
! if (!try_to_free_buffers(buffer_page, gfp_mask_buffer)) {
list_add_tail(swp_buffer_lh, &swp_used_buffer_head);
!
! list_add(&buffer_page->list, &old_fragment->mapping->locked_comp_pages);
! UnlockPage(buffer_page);
continue;
}
***************
*** 85,90 ****
/* has the fragment we are swapping out been swapped
* in? so let's free only the fragment struct */
! if (!CompFragmentIO(swp_buffer->fragment)) {
! kmem_cache_free(fragment_cachep, (swp_buffer->fragment));
goto out;
}
--- 90,95 ----
/* has the fragment we are swapping out been swapped
* in? so let's free only the fragment struct */
! if (!CompFragmentIO(old_fragment)) {
! kmem_cache_free(fragment_cachep, (old_fragment));
goto out;
}
***************
*** 92,103 ****
/* in the case it is waiting for merge in
* comp_cache_free(), we can't free it */
! if (!swp_buffer->fragment->mapping) {
! CompFragmentClearIO(swp_buffer->fragment);
goto out;
}
/* it's not swapped out, so let' free it */
! CompFragmentClearIO(swp_buffer->fragment);
! comp_cache_free(swp_buffer->fragment);
out:
--- 97,108 ----
/* in the case it is waiting for merge in
* comp_cache_free(), we can't free it */
! if (!old_fragment->mapping) {
! CompFragmentClearIO(old_fragment);
goto out;
}
/* it's not swapped out, so let' free it */
! CompFragmentClearIO(old_fragment);
! comp_cache_free(old_fragment);
out:
***************
*** 111,119 ****
if (!CompFragmentIO(fragment) || CompFragmentFreed(fragment)) {
CompFragmentClearIO(fragment);
! UnlockPage(swp_buffer->page);
return NULL;
}
! UnlockPage(swp_buffer->page);
if (wait)
--- 116,124 ----
if (!CompFragmentIO(fragment) || CompFragmentFreed(fragment)) {
CompFragmentClearIO(fragment);
! UnlockPage(buffer_page);
return NULL;
}
! UnlockPage(buffer_page);
if (wait)
|