summaryrefslogtreecommitdiff
path: root/kernel/power/tuxonice_bio.h
blob: 2f717f5c55c08dfe528e5b1a328ea32a648d724c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * kernel/power/tuxonice_bio.h
 *
 * Copyright (C) 2004-2015 Nigel Cunningham (nigel at nigelcunningham com au)
 *
 * Distributed under GPLv2.
 *
 * This file contains declarations for functions exported from
 * tuxonice_bio.c, which contains low level io functions.
 */

#include <linux/buffer_head.h>
#include "tuxonice_extent.h"

void toi_put_extent_chain(struct hibernate_extent_chain *chain);
int toi_add_to_extent_chain(struct hibernate_extent_chain *chain,
                unsigned long start, unsigned long end);

struct hibernate_extent_saved_state {
        int extent_num;
        struct hibernate_extent *extent_ptr;
        unsigned long offset;
};

struct toi_bdev_info {
        struct toi_bdev_info *next;
        struct hibernate_extent_chain blocks;
        struct block_device *bdev;
        struct toi_module_ops *allocator;
        int allocator_index;
        struct hibernate_extent_chain allocations;
        char name[266]; /* "swap on " or "file " + up to 256 chars */

        /* Saved in header */
        char uuid[17];
        dev_t dev_t;
        int prio;
        int bmap_shift;
        int blocks_per_page;
        unsigned long pages_used;
        struct hibernate_extent_saved_state saved_state[4];
};

struct toi_extent_iterate_state {
        struct toi_bdev_info *current_chain;
        int num_chains;
        int saved_chain_number[4];
        struct toi_bdev_info *saved_chain_ptr[4];
};

/*
 * Our exported interface so the swapwriter and filewriter don't
 * need these functions duplicated.
 */
struct toi_bio_ops {
        int (*bdev_page_io) (int rw, struct block_device *bdev, long pos,
                        struct page *page);
        int (*register_storage)(struct toi_bdev_info *new);
        void (*free_storage)(void);
};

struct toi_allocator_ops {
        unsigned long (*toi_swap_storage_available) (void);
};

extern struct toi_bio_ops toi_bio_ops;

extern char *toi_writer_buffer;
extern int toi_writer_buffer_posn;

struct toi_bio_allocator_ops {
        int (*register_storage) (void);
        unsigned long (*storage_available)(void);
        int (*allocate_storage) (struct toi_bdev_info *, unsigned long);
        int (*bmap) (struct toi_bdev_info *);
        void (*free_storage) (struct toi_bdev_info *);
        unsigned long (*free_unused_storage) (struct toi_bdev_info *, unsigned long used);
};

extern int toi_bio_register_storage(void);