~wb-munzinger/+junk/sanlock

« back to all changes in this revision

Viewing changes to sanlock.h

  • Committer: David Weber
  • Date: 2012-01-18 13:00:36 UTC
  • Revision ID: wb@munzinger.de-20120118130036-9a7wvhhmfuip7zx5
Tags: upstream-1.9
Import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010-2011 Red Hat, Inc.
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 */
 
9
 
 
10
#ifndef __SANLOCK_H__
 
11
#define __SANLOCK_H__
 
12
 
 
13
/* pid can own this many resources at once */
 
14
 
 
15
#define SANLK_MAX_RESOURCES     8
 
16
 
 
17
/* max resource name length */
 
18
 
 
19
#define SANLK_NAME_LEN          48   
 
20
 
 
21
/* max disk path length, includes terminating \0 byte */
 
22
 
 
23
#define SANLK_PATH_LEN          1024
 
24
 
 
25
/* max disks in a single lease */
 
26
 
 
27
#define SANLK_MAX_DISKS 4
 
28
 
 
29
/*
 
30
 * max length of a sanlk_resource in string format
 
31
 * <lockspace_name>:<resource_name>:<path>:<offset>[:<path>:<offset>...]:<lver>
 
32
 *     48 SANLK_NAME_LEN
 
33
 * +    1 colon
 
34
 * +   48 SANLK_NAME_LEN
 
35
 * +    1 colon
 
36
 * + 4184 (4 MAX_DISKS * (1024 SANLK_PATH_LEN + 1 colon + 20 offset + 1 colon))
 
37
 * +   20 lver
 
38
 * ------
 
39
 *   4302
 
40
 */
 
41
 
 
42
#define SANLK_MAX_RES_STR       4400
 
43
 
 
44
/* TODO: add more padding to sanlk_disk so we can extend sync_disk
 
45
   later without changing abi */
 
46
 
 
47
struct sanlk_disk {
 
48
        char path[SANLK_PATH_LEN]; /* must include terminating \0 */
 
49
        uint64_t offset;
 
50
        uint32_t pad1;
 
51
        uint32_t pad2;
 
52
};
 
53
 
 
54
#define SANLK_RES_LVER          0x1     /* lver field is set */
 
55
#define SANLK_RES_NUM_HOSTS     0x2     /* data32 field is new num_hosts */
 
56
 
 
57
struct sanlk_resource {
 
58
        char lockspace_name[SANLK_NAME_LEN]; /* terminating \0 not required */
 
59
        char name[SANLK_NAME_LEN]; /* terminating \0 not required */
 
60
        uint64_t lver;     /* use with SANLK_RES_LVER */
 
61
        uint64_t data64;   /* per-resource command-specific data */
 
62
        uint32_t data32;   /* per-resource command-specific data */
 
63
        uint32_t unused;
 
64
        uint32_t flags;
 
65
        uint32_t num_disks;
 
66
        /* followed by num_disks sanlk_disk structs */
 
67
        struct sanlk_disk disks[0];
 
68
};
 
69
 
 
70
/* command-specific command options (can include per resource data, but
 
71
   that requires the extra work of segmenting it by resource name) */
 
72
 
 
73
struct sanlk_options {
 
74
        char owner_name[SANLK_NAME_LEN]; /* optional user friendly name */
 
75
        uint32_t flags;
 
76
        uint32_t len;
 
77
        /* followed by len bytes (migration input will use this) */
 
78
        char str[0];
 
79
};
 
80
 
 
81
struct sanlk_lockspace {
 
82
        char name[SANLK_NAME_LEN];
 
83
        uint64_t host_id;
 
84
        uint32_t flags;
 
85
        struct sanlk_disk host_id_disk;
 
86
};
 
87
 
 
88
#endif
 
89