swapfile: swap allocation use discard
[pandora-kernel.git] / include / linux / swap.h
index c3ecd47..fe79f44 100644 (file)
@@ -120,7 +120,8 @@ struct swap_extent {
 enum {
        SWP_USED        = (1 << 0),     /* is slot in swap_info[] used? */
        SWP_WRITEOK     = (1 << 1),     /* ok to write to this swap?    */
-       SWP_ACTIVE      = (SWP_USED | SWP_WRITEOK),
+       SWP_DISCARDABLE = (1 << 2),     /* blkdev supports discard */
+       SWP_DISCARDING  = (1 << 3),     /* now discarding a free cluster */
                                        /* add others here before... */
        SWP_SCANNING    = (1 << 8),     /* refcount in scan_swap_map */
 };
@@ -134,22 +135,24 @@ enum {
  * The in-memory structure used to track swap areas.
  */
 struct swap_info_struct {
-       unsigned int flags;
+       unsigned long flags;
        int prio;                       /* swap priority */
+       int next;                       /* next entry on swap list */
        struct file *swap_file;
        struct block_device *bdev;
        struct list_head extent_list;
        struct swap_extent *curr_swap_extent;
-       unsigned old_block_size;
-       unsigned short * swap_map;
+       unsigned short *swap_map;
        unsigned int lowest_bit;
        unsigned int highest_bit;
+       unsigned int lowest_alloc;      /* while preparing discard cluster */
+       unsigned int highest_alloc;     /* while preparing discard cluster */
        unsigned int cluster_next;
        unsigned int cluster_nr;
        unsigned int pages;
        unsigned int max;
        unsigned int inuse_pages;
-       int next;                       /* next entry on swap list */
+       unsigned int old_block_size;
 };
 
 struct swap_list_t {
@@ -163,7 +166,6 @@ struct swap_list_t {
 /* linux/mm/page_alloc.c */
 extern unsigned long totalram_pages;
 extern unsigned long totalreserve_pages;
-extern long nr_swap_pages;
 extern unsigned int nr_free_buffer_pages(void);
 extern unsigned int nr_free_pagecache_pages(void);
 
@@ -278,7 +280,7 @@ extern void end_swap_bio_read(struct bio *bio, int err);
 extern struct address_space swapper_space;
 #define total_swapcache_pages  swapper_space.nrpages
 extern void show_swap_cache_info(void);
-extern int add_to_swap(struct page *, gfp_t);
+extern int add_to_swap(struct page *);
 extern int add_to_swap_cache(struct page *, swp_entry_t, gfp_t);
 extern void __delete_from_swap_cache(struct page *);
 extern void delete_from_swap_cache(struct page *);
@@ -291,6 +293,7 @@ extern struct page *swapin_readahead(swp_entry_t, gfp_t,
                        struct vm_area_struct *vma, unsigned long addr);
 
 /* linux/mm/swapfile.c */
+extern long nr_swap_pages;
 extern long total_swap_pages;
 extern void si_swapinfo(struct sysinfo *);
 extern swp_entry_t get_swap_page(void);
@@ -331,7 +334,8 @@ static inline void disable_swap_token(void)
 
 #else /* CONFIG_SWAP */
 
-#define total_swap_pages                       0
+#define nr_swap_pages                          0L
+#define total_swap_pages                       0L
 #define total_swapcache_pages                  0UL
 
 #define si_swapinfo(val) \
@@ -371,6 +375,11 @@ static inline struct page *lookup_swap_cache(swp_entry_t swp)
        return NULL;
 }
 
+static inline int add_to_swap(struct page *page)
+{
+       return 0;
+}
+
 static inline int add_to_swap_cache(struct page *page, swp_entry_t entry,
                                                        gfp_t gfp_mask)
 {