blob: 94f367db27b0b816e9585da18f0063a1523b23ca [file] [log] [blame]
Yehuda Sadeh602adf42010-08-12 16:11:25 -07001/*
2 * Ceph - scalable distributed file system
3 *
4 * Copyright (C) 2004-2010 Sage Weil <sage@newdream.net>
5 *
6 * This is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software
9 * Foundation. See file COPYING.
10 *
11 */
12
13#ifndef CEPH_RBD_TYPES_H
14#define CEPH_RBD_TYPES_H
15
16#include <linux/types.h>
17
Alex Elder3bb59ad2012-07-10 20:30:10 -050018/* For format version 2, rbd image 'foo' consists of objects
19 * rbd_id.foo - id of image
20 * rbd_header.<id> - image metadata
21 * rbd_data.<id>.0000000000000000
22 * rbd_data.<id>.0000000000000001
23 * ... - data
24 * Clients do not access header data directly in rbd format 2.
25 */
26
27#define RBD_HEADER_PREFIX "rbd_header."
28#define RBD_DATA_PREFIX "rbd_data."
29#define RBD_ID_PREFIX "rbd_id."
30
Ilya Dryomoved95b212016-08-12 16:40:02 +020031#define RBD_LOCK_NAME "rbd_lock"
32#define RBD_LOCK_TAG "internal"
33#define RBD_LOCK_COOKIE_PREFIX "auto"
34
35enum rbd_notify_op {
36 RBD_NOTIFY_OP_ACQUIRED_LOCK = 0,
37 RBD_NOTIFY_OP_RELEASED_LOCK = 1,
38 RBD_NOTIFY_OP_REQUEST_LOCK = 2,
39 RBD_NOTIFY_OP_HEADER_UPDATE = 3,
40};
41
Yehuda Sadeh602adf42010-08-12 16:11:25 -070042/*
Alex Elder3bb59ad2012-07-10 20:30:10 -050043 * For format version 1, rbd image 'foo' consists of objects
44 * foo.rbd - image metadata
45 * rb.<idhi>.<idlo>.00000000
46 * rb.<idhi>.<idlo>.00000001
47 * ... - data
48 * There is no notion of a persistent image id in rbd format 1.
Yehuda Sadeh602adf42010-08-12 16:11:25 -070049 */
50
51#define RBD_SUFFIX ".rbd"
Alex Elder3bb59ad2012-07-10 20:30:10 -050052
Yehuda Sadeh602adf42010-08-12 16:11:25 -070053#define RBD_DIRECTORY "rbd_directory"
54#define RBD_INFO "rbd_info"
55
56#define RBD_DEFAULT_OBJ_ORDER 22 /* 4MB */
57#define RBD_MIN_OBJ_ORDER 16
58#define RBD_MAX_OBJ_ORDER 30
59
Yehuda Sadeh602adf42010-08-12 16:11:25 -070060#define RBD_COMP_NONE 0
61#define RBD_CRYPT_NONE 0
62
63#define RBD_HEADER_TEXT "<<< Rados Block Device Image >>>\n"
64#define RBD_HEADER_SIGNATURE "RBD"
65#define RBD_HEADER_VERSION "001.005"
66
Yehuda Sadeh602adf42010-08-12 16:11:25 -070067struct rbd_image_snap_ondisk {
68 __le64 id;
69 __le64 image_size;
70} __attribute__((packed));
71
72struct rbd_image_header_ondisk {
73 char text[40];
Alex Elder843a0d02012-08-31 17:29:51 -050074 char object_prefix[24];
Yehuda Sadeh602adf42010-08-12 16:11:25 -070075 char signature[4];
76 char version[8];
77 struct {
78 __u8 order;
79 __u8 crypt_type;
80 __u8 comp_type;
81 __u8 unused;
82 } __attribute__((packed)) options;
83 __le64 image_size;
84 __le64 snap_seq;
85 __le32 snap_count;
86 __le32 reserved;
87 __le64 snap_names_len;
88 struct rbd_image_snap_ondisk snaps[0];
89} __attribute__((packed));
90
91
92#endif