summaryrefslogtreecommitdiff
path: root/daemons/lvmlockd/lvmlockd-client.h
blob: 7010078a2c8f37d61641a16cbc713581c65ab7e3 (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
/*
 * Copyright (C) 2014 Red Hat, Inc.
 *
 * This file is part of LVM2.
 *
 * This copyrighted material is made available to anyone wishing to use,
 * modify, copy, or redistribute it subject to the terms and conditions
 * of the GNU Lesser General Public License v.2.1.
 */

#ifndef _LVM_LVMLOCKD_CLIENT_H
#define _LVM_LVMLOCKD_CLIENT_H

#include "daemon-client.h"

#define LVMLOCKD_SOCKET DEFAULT_RUN_DIR "/lvmlockd.socket"

/* Wrappers to open/close connection */

static inline daemon_handle lvmlockd_open(const char *socket)
{
	daemon_info lvmlockd_info = {
		.path = "lvmlockd",
		.socket = socket ?: LVMLOCKD_SOCKET,
		.protocol = "lvmlockd",
		.protocol_version = 1,
		.autostart = 0
	};

	return daemon_open(lvmlockd_info);
}

static inline void lvmlockd_close(daemon_handle h)
{
	return daemon_close(h);
}

/*
 * Errors returned as the lvmlockd result value.
 */
#define ENOLS     210 /* lockspace not found */
#define ELOCALVG  211 /* vg is local */
#define EOTHERVG  212 /* vg sysid specifies other host */
#define ESTARTING 213 /* lockspace is starting */

/*
 * Also see lvmlockd-sanlock GL_LOCK_BEGIN, VG_LOCK_BEGIN, LV_LOCK_BEGIN.
 * gl lock at sanlock lease area 65
 * vg lock at sanlock lease area 66
 * lv locks begin at sanlock lease area 67
 *
 * LV_LOCK_BEGIN + MAX_LVS_IN_VG = sanlock lease areas required
 * with 512 byte sectors, each lease area is 1MB
 * with 4k byte sectors, each lease area is 8MB (use this for sizing)
 *
 * 66+190 = 256 sanlock lease areas,
 * so we need 256 * 8MB = 2GB lock lv size to hold 190 lv leases.
 */
#define LVMLOCKD_SANLOCK_MAX_LVS_IN_VG 190
#define LVMLOCKD_SANLOCK_LV_SIZE       2147483648 /* 2GB */

#endif