[lc-checkins] CVS: linux/mm/comp_cache compswap.c,NONE,1.1 proc.c,1.3,1.4 Makefile,1.2,1.3 main.c,1.
Status: Beta
Brought to you by:
nitin_sf
|
From: Rodrigo S. de C. <rc...@us...> - 2001-12-13 19:13:01
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv23494/mm/comp_cache
Modified Files:
Makefile main.c
Added Files:
compswap.c proc.c
Log Message:
First batch of changes to remove #ifdefs and make code cleaner.
It follows Documentation/SubmittingPatches document.
--- NEW FILE ---
/*
* linux/mm/comp_cache/vswap.c
*
* Time-stamp: <2001-12-13 13:29:36 rcastro>
*
* Linux Virtual Memory Compressed Cache
*
* Author: Rodrigo S. de Castro <rc...@im...>
* Licensed under the GPL - 2001
*/
#include <linux/comp_cache.h>
void
set_comp_swp_entry(swp_entry_t entry, int compressed, int algorithm)
{
struct swap_info_struct * p;
unsigned long offset, type;
if (vswap_address(entry))
BUG();
if (!entry.val)
goto bad_entry;
type = SWP_TYPE(entry);
if (type >= nr_swapfiles)
goto bad_file;
p = type + swap_info;
offset = SWP_OFFSET(entry);
if (offset >= p->max)
goto bad_offset;
if (!p->swap_map[offset])
goto bad_unused;
if (!compressed) {
ClearEntryCompressed(p, offset);
ClearEntryWKdm(p, offset);
ClearEntryWK4x4(p, offset);
return;
}
SetEntryCompressed(p, offset);
/* we cannot clear the algorithm relative to the entry until
* we swap it out again, because the swap cache page may be
* freed and thus it will be reread (and decompressed
* again). Therefore that's why we clean the flag here */
ClearEntryWKdm(p, offset);
ClearEntryWK4x4(p, offset);
switch(algorithm) {
case WKDM_IDX:
SetEntryWKdm(p, offset);
break;
case WK4X4_IDX:
SetEntryWK4x4(p, offset);
break;
default:
BUG();
}
out:
return;
bad_entry:
printk("Null entry in swap_compressed\n");
goto out;
bad_file:
printk("Bad swap file entry (scse) %08lx\n", entry.val);
goto out;
bad_offset:
printk("Bad swap offset entry %08lx\n", entry.val);
goto out;
bad_unused:
printk("Unused swap offset entry in swap_compressed %08lx\n", entry.val);
goto out;
}
unsigned short
swap_algorithm(swp_entry_t entry)
{
struct swap_info_struct * p;
unsigned long offset, type;
int retval = -1;
if (vswap_address(entry))
BUG();
if (!entry.val)
goto bad_entry;
type = SWP_TYPE(entry);
if (type >= nr_swapfiles)
goto bad_file;
p = type + swap_info;
offset = SWP_OFFSET(entry);
if (offset >= p->max)
goto bad_offset;
if (!p->swap_map[offset])
goto bad_unused;
if (!EntryCompressed(p, offset))
goto bad_compressed;
if (EntryWKdm(p, offset))
retval = WKDM_IDX;
if (EntryWK4x4(p, offset))
retval = WK4X4_IDX;
if (retval == -1)
BUG();
out:
return retval;
bad_entry:
printk("Null entry in swap_compressed\n");
goto out;
bad_file:
printk("Bad swap file entry (swap_algorithm) %08lx\n", entry.val);
goto out;
bad_offset:
printk("Bad swap offset entry %08lx\n", entry.val);
goto out;
bad_unused:
printk("Unused swap offset entry in swap_compressed %08lx\n", entry.val);
goto out;
bad_compressed:
printk("Swap offset entry not compressed %08lx\n", entry.val);
goto out;
}
int
swap_compressed(swp_entry_t entry)
{
struct swap_info_struct * p;
unsigned long offset, type;
int retval = 0;
if (vswap_address(entry))
BUG();
if (!entry.val)
goto bad_entry;
type = SWP_TYPE(entry);
if (type >= nr_swapfiles)
goto bad_file;
p = type + swap_info;
offset = SWP_OFFSET(entry);
if (offset >= p->max)
goto bad_offset;
if (!p->swap_map[offset])
goto bad_unused;
retval = EntryCompressed(p, offset);
out:
return retval;
bad_entry:
printk("Null entry in swap_compressed\n");
goto out;
bad_file:
printk("Bad swap file entry (swap_compressed) %08lx\n", entry.val);
goto out;
bad_offset:
printk("Bad swap offset entry %08lx\n", entry.val);
goto out;
bad_unused:
printk("Unused swap offset entry in swap_compressed %08lx\n", entry.val);
goto out;
}
Index: Makefile
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Makefile 2001/10/01 22:43:59 1.2
--- Makefile 2001/12/13 19:12:58 1.3
***************
*** 5,9 ****
O_TARGET := comp_cache.o
! obj-y := main.o vswap.o free.o swapout.o swapin.o avl.o aux.o WK4x4.o WKdm.o
include $(TOPDIR)/Rules.make
--- 5,13 ----
O_TARGET := comp_cache.o
! obj-y := main.o vswap.o free.o swapout.o swapin.o avl.o aux.o proc.o WK4x4.o WKdm.o
!
! ifeq ($(CONFIG_COMP_SWAP),y)
! obj-y += compswap.o
! endif
include $(TOPDIR)/Rules.make
Index: main.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** main.c 2001/12/12 20:45:46 1.7
--- main.c 2001/12/13 19:12:58 1.8
***************
*** 2,6 ****
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2001-12-10 16:59:47 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2001-12-13 10:43:48 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 42,51 ****
kmem_cache_t * fragment_cachep;
- int tmp_comp_cache_size = 20, tmp_comp_cache_size_min = 0, tmp_comp_cache_size_max = 50;
-
/* compression algorithms */
compression_algorithm_t compression_algorithms[NUM_ALGORITHMS];
int current_algorithm;
- int algorithm_min = WKDM_IDX<WK4X4_IDX?WKDM_IDX:WK4X4_IDX, algorithm_max = WKDM_IDX>WK4X4_IDX?WKDM_IDX:WK4X4_IDX;
static char buffer_compressed[MAX_COMPRESSED_SIZE];
--- 42,48 ----
|