summaryrefslogtreecommitdiffstats
path: root/xlators/storage/bd_map/src/bd_map.h
blob: fa10e97a94714667806ee49f244914860c3029cb (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
81
82
/*
  BD translator - Exports Block devices on server side as regular
  files to client

  Copyright IBM, Corp. 2012

  This file is part of GlusterFS.

  Author:
  M. Mohan Kumar <mohan@in.ibm.com>

  This file is licensed to you under your choice of the GNU Lesser
  General Public License, version 3 or any later version (LGPLv3 or
  later), or the GNU General Public License, version 2 (GPLv2), in all
  cases as published by the Free Software Foundation.
*/

#ifndef _BD_MAP_H
#define _BD_MAP_H

#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
#endif

#include "xlator.h"
#include "mem-types.h"

#define BD_XLATOR "block device mapper xlator"

#define BACKEND_VG "vg"

/* lvm2-2.02.79 added this in lvm2app.h, but it is available for linking in
 * older versions already */
#if NEED_LVM_LV_FROM_NAME_DECL
lv_t lvm_lv_from_name(vg_t vg, const char *name);
#endif

enum gf_bd_mem_types_ {
        gf_bd_fd = gf_common_mt_end + 1,
        gf_bd_private,
        gf_bd_entry,
        gf_bd_attr,
        gf_bd_mt_end
};

/*
 * Each BD/LV is represented by this data structure
 * Usually root entry will have only children and there is no sibling for that
 * All other entries may have children and/or sibling entries
 * If an entry is a Volume Group it will have child (. & .. and Logical
 * Volumes) and also other Volume groups will be a sibling for this
 */
typedef struct bd_entry {
        struct list_head child; /* List to child */
        struct list_head sibling; /* List of siblings */
        struct bd_entry  *parent;/* Parent of this node */
        struct bd_entry  *link; /* Link to actual entry, if its . or .. */
        char             name[NAME_MAX];
        struct iatt      *attr;
        int              refcnt;
        uint64_t         size;
        pthread_rwlock_t lock;
} bd_entry_t;

/**
 * bd_fd - internal structure common to file and directory fd's
 */
typedef struct bd_fd {
        bd_entry_t      *entry;
        bd_entry_t      *p_entry; /* Parent entry */
        int             fd;
        int32_t         flag;
} bd_fd_t;

typedef struct bd_priv {
        lvm_t             handle;
        pthread_rwlock_t  lock;
        char              *vg;
} bd_priv_t;

#endif