Statistics
| Branch: | Revision:

root / drivers / tapdisk-image.h @ abdb293f

History | View | Annotate | Download (3.4 kB)

1
/* 
2
 * Copyright (c) 2008, XenSource Inc.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *     * Redistributions of source code must retain the above copyright
8
 *       notice, this list of conditions and the following disclaimer.
9
 *     * Redistributions in binary form must reproduce the above copyright
10
 *       notice, this list of conditions and the following disclaimer in the
11
 *       documentation and/or other materials provided with the distribution.
12
 *     * Neither the name of XenSource Inc. nor the names of its contributors
13
 *       may be used to endorse or promote products derived from this software
14
 *       without specific prior written permission.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
20
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
#ifndef _TAPDISK_IMAGE_H_
29
#define _TAPDISK_IMAGE_H_
30

    
31
#include "tapdisk.h"
32

    
33
struct td_image_handle {
34
        int                          type;
35
        char                        *name;
36

    
37
        td_flag_t                    flags;
38

    
39
        td_driver_t                 *driver;
40
        td_disk_info_t               info;
41

    
42
        struct list_head             next;
43

    
44
        /*
45
         * Basic datapath statistics, in sectors read/written.
46
         *
47
         * hits:  requests completed by this image.
48
         * fail:  requests completed with failure by this image.
49
         *
50
         * Not that we do not count e.g.
51
         * miss:  requests forwarded.
52
         * total: requests processed by this image.
53
         *
54
         * This is because we'd have to compensate for restarts due to
55
         * -EBUSY conditions. Those can be extrapolated by following
56
         * the chain instead: sum(image[i].hits, i=0..) == vbd.secs;
57
         */
58
        struct {
59
                td_sector_count_t    hits;
60
                td_sector_count_t    fail;
61
        } stats;
62
};
63

    
64
#define tapdisk_for_each_image(_image, _head)                        \
65
        list_for_each_entry(_image, _head, next)
66

    
67
#define tapdisk_for_each_image_safe(_image, _next, _head)        \
68
        list_for_each_entry_safe(_image, _next, _head, next)
69

    
70
#define tapdisk_for_each_image_reverse(_image, _head)                \
71
        list_for_each_entry_reverse(_image, _head, next)
72

    
73
#define tapdisk_image_entry(_head)                \
74
        list_entry(_head, td_image_t, next)
75

    
76
int tapdisk_image_open(int, const char *, int, td_image_t **);
77
void tapdisk_image_close(td_image_t *);
78

    
79
int tapdisk_image_open_chain(const char *, int, int, struct list_head *);
80
void tapdisk_image_close_chain(struct list_head *);
81
int tapdisk_image_validate_chain(struct list_head *);
82

    
83
td_image_t *tapdisk_image_allocate(const char *, int, td_flag_t);
84
void tapdisk_image_free(td_image_t *);
85

    
86
int tapdisk_image_check_td_request(td_image_t *, td_request_t);
87
int tapdisk_image_check_request(td_image_t *, struct td_vbd_request *);
88
void tapdisk_image_stats(td_image_t *, td_stats_t *);
89

    
90
#endif