]> sourceware.org Git - lvm2.git/blame - lib/label/label.h
metadata: use lv_hash in segment-specific metadata parsing
[lvm2.git] / lib / label / label.h
CommitLineData
3dd5cbe5 1/*
6606c3ae 2 * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
be684599 3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
3dd5cbe5 4 *
6606c3ae
AK
5 * This file is part of LVM2.
6 *
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
be684599 9 * of the GNU Lesser General Public License v.2.1.
6606c3ae 10 *
be684599 11 * You should have received a copy of the GNU Lesser General Public License
6606c3ae 12 * along with this program; if not, write to the Free Software Foundation,
fcbef05a 13 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3dd5cbe5
PC
14 */
15
fc63d04f
JT
16#ifndef _LVM_LABEL_H
17#define _LVM_LABEL_H
3dd5cbe5 18
7f97c7ea
JT
19#include "lib/uuid/uuid.h"
20#include "lib/device/device.h"
21#include "lib/device/bcache.h"
f4a7ce7c 22
5a52dca9
AK
23#define LABEL_ID "LABELONE"
24#define LABEL_SIZE SECTOR_SIZE /* Think very carefully before changing this */
25#define LABEL_SCAN_SECTORS 4L
26#define LABEL_SCAN_SIZE (LABEL_SCAN_SECTORS << SECTOR_SHIFT)
27
4922197a 28struct labeller;
06a4a356
ZK
29struct dev_filter;
30struct cmd_context;
31struct logical_volume;
4922197a 32
5a52dca9
AK
33/* On disk - 32 bytes */
34struct label_header {
72b2cb61 35 int8_t id[8]; /* LABELONE */
5a52dca9
AK
36 uint64_t sector_xl; /* Sector number of this label */
37 uint32_t crc_xl; /* From next field to end of sector */
38 uint32_t offset_xl; /* Offset from start of struct to contents */
72b2cb61 39 int8_t type[8]; /* LVM2 001 */
5a52dca9
AK
40} __attribute__ ((packed));
41
42/* In core */
fc63d04f 43struct label {
5a52dca9
AK
44 char type[8];
45 uint64_t sector;
6036e5e0 46 struct labeller *labeller;
cc633c84 47 struct device *dev;
5a52dca9 48 void *info;
fc63d04f
JT
49};
50
51struct labeller;
52
53struct label_ops {
54 /*
55 * Is the device labelled with this format ?
56 */
4dc0ec22 57 int (*can_handle) (struct labeller * l, void *buf, uint64_t sector);
fc63d04f
JT
58
59 /*
60 * Write a label to a volume.
61 */
4dc0ec22 62 int (*write) (struct label * label, void *buf);
fc63d04f
JT
63
64 /*
5a52dca9 65 * Read a label from a volume.
fc63d04f 66 */
cc4051ee 67 int (*read) (struct cmd_context *cmd, struct labeller * l, struct device * dev,
86d831b9 68 void *label_buf, uint64_t label_sector, int *is_duplicate);
fc63d04f 69
fc63d04f 70 /*
5a52dca9 71 * Populate label_type etc.
fc63d04f 72 */
5a52dca9 73 int (*initialise_label) (struct labeller * l, struct label * label);
fc63d04f 74
6036e5e0
JT
75 /*
76 * Destroy a previously read label.
77 */
5a52dca9 78 void (*destroy_label) (struct labeller * l, struct label * label);
6036e5e0 79
fc63d04f
JT
80 /*
81 * Destructor.
82 */
5a52dca9 83 void (*destroy) (struct labeller * l);
fc63d04f
JT
84};
85
86struct labeller {
41ffa8c7 87 const struct label_ops *ops;
b8f72c0f 88 const struct format_type *fmt;
f4a7ce7c 89};
3dd5cbe5 90
fc63d04f
JT
91int label_init(void);
92void label_exit(void);
93
9b91977f 94int label_register_handler(struct labeller *handler);
fc63d04f
JT
95
96struct labeller *label_get_handler(const char *name);
97
493656dd 98int label_remove(struct device *dev);
5a52dca9 99int label_write(struct device *dev, struct label *label);
5a52dca9
AK
100struct label *label_create(struct labeller *labeller);
101void label_destroy(struct label *label);
3dd5cbe5 102
a7cb76ae 103int label_scan(struct cmd_context *cmd);
57bb46c5 104int label_scan_devs(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
a7f195b7 105int label_scan_devs_cached(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
d16142f9 106int label_scan_devs_rw(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
2c319398 107int label_scan_devs_excl(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
c3847354 108int label_scan_dev(struct cmd_context *cmd, struct device *dev);
a7cb76ae 109void label_scan_invalidate(struct device *dev);
0da29600 110void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv);
04fbffb1 111void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs);
217f3f87 112void label_scan_drop(struct cmd_context *cmd);
a7cb76ae 113void label_scan_destroy(struct cmd_context *cmd);
39e65c8f 114int label_scan_setup_bcache(void);
80654920 115int label_scan_open(struct device *dev);
28d35e5c 116int label_scan_open_excl(struct device *dev);
ccd13860 117int label_scan_open_rw(struct device *dev);
1404e5ee 118int label_scan_reopen_rw(struct device *dev);
4dc5d4ac 119int label_read_pvid(struct device *dev, int *has_pvid);
024ce50f
DT
120int label_scan_vg_online(struct cmd_context *cmd, const char *vgname,
121 int *found_none, int *found_all, int *found_incomplete);
122
a7cb76ae 123
94076245
DT
124int label_scan_for_pvid(struct cmd_context *cmd, char *pvid, struct device **dev_out);
125
e49b114f
DT
126/*
127 * Wrappers around bcache equivalents.
128 * (these make it easier to disable bcache and revert to direct rw if needed)
129 */
9a5bd01b
DT
130bool dev_read_bytes(struct device *dev, uint64_t start, size_t len, void *data);
131bool dev_write_bytes(struct device *dev, uint64_t start, size_t len, void *data);
132bool dev_write_zeros(struct device *dev, uint64_t start, size_t len);
133bool dev_set_bytes(struct device *dev, uint64_t start, size_t len, uint8_t val);
56a295f7 134bool dev_invalidate_bytes(struct device *dev, uint64_t start, size_t len);
e035e323 135void dev_invalidate(struct device *dev);
aecf5421
DT
136void dev_set_last_byte(struct device *dev, uint64_t offset);
137void dev_unset_last_byte(struct device *dev);
e49b114f 138
6ea8d975
DT
139void prepare_open_file_limit(struct cmd_context *cmd, unsigned int num_devs);
140
fc63d04f 141#endif
This page took 0.270097 seconds and 6 git commands to generate.