Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
mtdswap.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/blktrans.h>
#include <linux/rbtree.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/genhd.h>
#include <linux/swap.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/device.h>
#include <linux/math64.h>

Go to the source code of this file.

Data Structures

struct  swap_eb
 
struct  mtdswap_tree
 
struct  mtdswap_dev
 
struct  mtdswap_oobdata
 

Macros

#define MTDSWAP_PREFIX   "mtdswap"
 
#define CLEAN_BLOCK_THRESHOLD   20
 
#define LOW_FRAG_GC_TRESHOLD   5
 
#define MAX_ERASE_DIFF   4000
 
#define COLLECT_NONDIRTY_BASE   MAX_ERASE_DIFF
 
#define COLLECT_NONDIRTY_FREQ1   6
 
#define COLLECT_NONDIRTY_FREQ2   4
 
#define PAGE_UNDEF   UINT_MAX
 
#define BLOCK_UNDEF   UINT_MAX
 
#define BLOCK_ERROR   (UINT_MAX - 1)
 
#define BLOCK_MAX   (UINT_MAX - 2)
 
#define EBLOCK_BAD   (1 << 0)
 
#define EBLOCK_NOMAGIC   (1 << 1)
 
#define EBLOCK_BITFLIP   (1 << 2)
 
#define EBLOCK_FAILED   (1 << 3)
 
#define EBLOCK_READERR   (1 << 4)
 
#define EBLOCK_IDX_SHIFT   5
 
#define MTDSWAP_ECNT_MIN(rbroot)
 
#define MTDSWAP_ECNT_MAX(rbroot)
 
#define MTDSWAP_MAGIC_CLEAN   0x2095
 
#define MTDSWAP_MAGIC_DIRTY   (MTDSWAP_MAGIC_CLEAN + 1)
 
#define MTDSWAP_TYPE_CLEAN   0
 
#define MTDSWAP_TYPE_DIRTY   1
 
#define MTDSWAP_OOBSIZE   sizeof(struct mtdswap_oobdata)
 
#define MTDSWAP_ERASE_RETRIES   3 /* Before marking erase block bad */
 
#define MTDSWAP_IO_RETRIES   3
 
#define MIN_SPARE_EBLOCKS   2
 
#define MIN_ERASE_BLOCKS   (MIN_SPARE_EBLOCKS + 1)
 
#define TREE_ROOT(d, name)   (&d->trees[MTDSWAP_ ## name].root)
 
#define TREE_EMPTY(d, name)   (TREE_ROOT(d, name)->rb_node == NULL)
 
#define TREE_NONEMPTY(d, name)   (!TREE_EMPTY(d, name))
 
#define TREE_COUNT(d, name)   (d->trees[MTDSWAP_ ## name].count)
 
#define MTDSWAP_MBD_TO_MTDSWAP(dev)   ((struct mtdswap_dev *)dev->priv)
 

Enumerations

enum  {
  MTDSWAP_CLEAN, MTDSWAP_USED, MTDSWAP_LOWFRAG, MTDSWAP_HIFRAG,
  MTDSWAP_DIRTY, MTDSWAP_BITFLIP, MTDSWAP_FAILING, MTDSWAP_TREE_CNT
}
 
enum  { MTDSWAP_SCANNED_CLEAN, MTDSWAP_SCANNED_DIRTY, MTDSWAP_SCANNED_BITFLIP, MTDSWAP_SCANNED_BAD }
 

Functions

struct mtdswap_oobdata __attribute__ ((packed))
 
 module_param_string (partitions, partitions, sizeof(partitions), 0444)
 
 MODULE_PARM_DESC (partitions,"MTD partition numbers to use as swap ""partitions=\"1,3,5\"")
 
 module_param (spare_eblocks, uint, 0444)
 
 MODULE_PARM_DESC (spare_eblocks,"Percentage of spare erase blocks for ""garbage collection (default 10%)")
 
 module_param (header, bool, 0444)
 
 MODULE_PARM_DESC (header,"Include builtin swap header (default 0, without header)")
 
 module_init (mtdswap_modinit)
 
 module_exit (mtdswap_modexit)
 
 MODULE_LICENSE ("GPL")
 
 MODULE_AUTHOR ("Jarkko Lavinen <[email protected]>")
 
 MODULE_DESCRIPTION ("Block device access to an MTD suitable for using as ""swap space")
 

Variables

__le16 magic
 
__le32 count
 
enum { ... }  __attribute__
 

Macro Definition Documentation

#define BLOCK_ERROR   (UINT_MAX - 1)

Definition at line 72 of file mtdswap.c.

#define BLOCK_MAX   (UINT_MAX - 2)

Definition at line 73 of file mtdswap.c.

#define BLOCK_UNDEF   UINT_MAX

Definition at line 71 of file mtdswap.c.

#define CLEAN_BLOCK_THRESHOLD   20

Definition at line 47 of file mtdswap.c.

#define COLLECT_NONDIRTY_BASE   MAX_ERASE_DIFF

Definition at line 66 of file mtdswap.c.

#define COLLECT_NONDIRTY_FREQ1   6

Definition at line 67 of file mtdswap.c.

#define COLLECT_NONDIRTY_FREQ2   4

Definition at line 68 of file mtdswap.c.

#define EBLOCK_BAD   (1 << 0)

Definition at line 75 of file mtdswap.c.

#define EBLOCK_BITFLIP   (1 << 2)

Definition at line 77 of file mtdswap.c.

#define EBLOCK_FAILED   (1 << 3)

Definition at line 78 of file mtdswap.c.

#define EBLOCK_IDX_SHIFT   5

Definition at line 80 of file mtdswap.c.

#define EBLOCK_NOMAGIC   (1 << 1)

Definition at line 76 of file mtdswap.c.

#define EBLOCK_READERR   (1 << 4)

Definition at line 79 of file mtdswap.c.

#define LOW_FRAG_GC_TRESHOLD   5

Definition at line 53 of file mtdswap.c.

#define MAX_ERASE_DIFF   4000

Definition at line 65 of file mtdswap.c.

#define MIN_ERASE_BLOCKS   (MIN_SPARE_EBLOCKS + 1)

Definition at line 173 of file mtdswap.c.

#define MIN_SPARE_EBLOCKS   2

Definition at line 172 of file mtdswap.c.

#define MTDSWAP_ECNT_MAX (   rbroot)
Value:
(rb_entry(rb_last(rbroot), struct swap_eb, \
rb)->erase_count)

Definition at line 94 of file mtdswap.c.

#define MTDSWAP_ECNT_MIN (   rbroot)
Value:
(rb_entry(rb_first(rbroot), struct swap_eb, \
rb)->erase_count)

Definition at line 92 of file mtdswap.c.

#define MTDSWAP_ERASE_RETRIES   3 /* Before marking erase block bad */

Definition at line 156 of file mtdswap.c.

#define MTDSWAP_IO_RETRIES   3

Definition at line 157 of file mtdswap.c.

#define MTDSWAP_MAGIC_CLEAN   0x2095

Definition at line 150 of file mtdswap.c.

#define MTDSWAP_MAGIC_DIRTY   (MTDSWAP_MAGIC_CLEAN + 1)

Definition at line 151 of file mtdswap.c.

#define MTDSWAP_MBD_TO_MTDSWAP (   dev)    ((struct mtdswap_dev *)dev->priv)

Definition at line 180 of file mtdswap.c.

#define MTDSWAP_OOBSIZE   sizeof(struct mtdswap_oobdata)

Definition at line 154 of file mtdswap.c.

#define MTDSWAP_PREFIX   "mtdswap"

Definition at line 42 of file mtdswap.c.

#define MTDSWAP_TYPE_CLEAN   0

Definition at line 152 of file mtdswap.c.

#define MTDSWAP_TYPE_DIRTY   1

Definition at line 153 of file mtdswap.c.

#define PAGE_UNDEF   UINT_MAX

Definition at line 70 of file mtdswap.c.

#define TREE_COUNT (   d,
  name 
)    (d->trees[MTDSWAP_ ## name].count)

Definition at line 178 of file mtdswap.c.

#define TREE_EMPTY (   d,
  name 
)    (TREE_ROOT(d, name)->rb_node == NULL)

Definition at line 176 of file mtdswap.c.

#define TREE_NONEMPTY (   d,
  name 
)    (!TREE_EMPTY(d, name))

Definition at line 177 of file mtdswap.c.

#define TREE_ROOT (   d,
  name 
)    (&d->trees[MTDSWAP_ ## name].root)

Definition at line 175 of file mtdswap.c.

Enumeration Type Documentation

anonymous enum
Enumerator:
MTDSWAP_CLEAN 
MTDSWAP_USED 
MTDSWAP_LOWFRAG 
MTDSWAP_HIFRAG 
MTDSWAP_DIRTY 
MTDSWAP_BITFLIP 
MTDSWAP_FAILING 
MTDSWAP_TREE_CNT 

Definition at line 102 of file mtdswap.c.

anonymous enum
Enumerator:
MTDSWAP_SCANNED_CLEAN 
MTDSWAP_SCANNED_DIRTY 
MTDSWAP_SCANNED_BITFLIP 
MTDSWAP_SCANNED_BAD 

Definition at line 159 of file mtdswap.c.

Function Documentation

struct mtdswap_oobdata __attribute__ ( (packed)  )
read

Definition at line 171 of file esd_usb2.c.

MODULE_AUTHOR ( "Jarkko Lavinen <[email protected]>"  )
MODULE_DESCRIPTION ( "Block device access to an MTD suitable for using as ""swap space"  )
module_exit ( mtdswap_modexit  )
module_init ( mtdswap_modinit  )
MODULE_LICENSE ( "GPL"  )
module_param ( spare_eblocks  ,
uint  ,
0444   
)
module_param ( header  ,
bool  ,
0444   
)
module_param_string ( partitions  ,
partitions  ,
sizeof(partitions)  ,
0444   
)
MODULE_PARM_DESC ( partitions  ,
"MTD partition numbers to use as swap ""  partitions = \"1,3,5\"" 
)
MODULE_PARM_DESC ( spare_eblocks  ,
"Percentage of spare erase blocks for ""garbage collection (default 10%)"   
)
MODULE_PARM_DESC ( header  ,
"Include builtin swap header (default 0, without header)"   
)

Variable Documentation

enum { ... } __attribute__
__le32 count

Definition at line 150 of file mtdswap.c.

__le16 magic

Definition at line 149 of file mtdswap.c.