nfsd: take file and mnt write in nfs4_upgrade_open
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / raid_class.h
CommitLineData
61a7afa2 1/*
b1081ea6
JB
2 * raid_class.h - a generic raid visualisation class
3 *
4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
5 *
6 * This file is licensed under GPLv2
61a7afa2
JB
7 */
8#include <linux/transport_class.h>
9
10struct raid_template {
11 struct transport_container raid_attrs;
12};
13
14struct raid_function_template {
15 void *cookie;
16 int (*is_raid)(struct device *);
17 void (*get_resync)(struct device *);
18 void (*get_state)(struct device *);
19};
20
21enum raid_state {
b1081ea6
JB
22 RAID_STATE_UNKNOWN = 0,
23 RAID_STATE_ACTIVE,
24 RAID_STATE_DEGRADED,
25 RAID_STATE_RESYNCING,
26 RAID_STATE_OFFLINE,
27};
28
29enum raid_level {
30 RAID_LEVEL_UNKNOWN = 0,
31 RAID_LEVEL_LINEAR,
32 RAID_LEVEL_0,
33 RAID_LEVEL_1,
8e32ca49 34 RAID_LEVEL_10,
b1081ea6
JB
35 RAID_LEVEL_3,
36 RAID_LEVEL_4,
37 RAID_LEVEL_5,
8e32ca49 38 RAID_LEVEL_50,
b1081ea6 39 RAID_LEVEL_6,
61a7afa2
JB
40};
41
42struct raid_data {
43 struct list_head component_list;
44 int component_count;
b1081ea6 45 enum raid_level level;
61a7afa2
JB
46 enum raid_state state;
47 int resync;
48};
49
b1081ea6
JB
50/* resync complete goes from 0 to this */
51#define RAID_MAX_RESYNC (10000)
52
61a7afa2
JB
53#define DEFINE_RAID_ATTRIBUTE(type, attr) \
54static inline void \
55raid_set_##attr(struct raid_template *r, struct device *dev, type value) { \
ee959b00 56 struct device *device = \
61a7afa2
JB
57 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\
58 struct raid_data *rd; \
ee959b00
TJ
59 BUG_ON(!device); \
60 rd = dev_get_drvdata(device); \
61a7afa2
JB
61 rd->attr = value; \
62} \
63static inline type \
64raid_get_##attr(struct raid_template *r, struct device *dev) { \
ee959b00 65 struct device *device = \
61a7afa2
JB
66 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\
67 struct raid_data *rd; \
ee959b00
TJ
68 BUG_ON(!device); \
69 rd = dev_get_drvdata(device); \
61a7afa2
JB
70 return rd->attr; \
71}
72
b1081ea6 73DEFINE_RAID_ATTRIBUTE(enum raid_level, level)
61a7afa2
JB
74DEFINE_RAID_ATTRIBUTE(int, resync)
75DEFINE_RAID_ATTRIBUTE(enum raid_state, state)
76
77struct raid_template *raid_class_attach(struct raid_function_template *);
78void raid_class_release(struct raid_template *);
79
ed542bed
JG
80int __must_check raid_component_add(struct raid_template *, struct device *,
81 struct device *);
82