diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 16:39:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 16:39:11 -0500 |
commit | 9228ff90387e276ad67b10c0eb525c9d6a57d5e9 (patch) | |
tree | e7c87b68daba7cf7ca4c342c6b52165bd78fbe16 /include | |
parent | 9360b53661a2c7754517b2925580055bacc8ec38 (diff) | |
parent | d2ec180c23a5a1bfe34d8638b0342a47c00cf70f (diff) |
Merge branch 'for-3.8/drivers' of git://git.kernel.dk/linux-block
Pull block driver update from Jens Axboe:
"Now that the core bits are in, here are the driver bits for 3.8. The
branch contains:
- A huge pile of drbd bits that were dumped from the 3.7 merge
window. Following that, it was both made perfectly clear that
there is going to be no more over-the-wall pulls and how the
situation on individual pulls can be improved.
- A few cleanups from Akinobu Mita for drbd and cciss.
- Queue improvement for loop from Lukas. This grew into adding a
generic interface for waiting/checking an even with a specific
lock, allowing this to be pulled out of md and now loop and drbd is
also using it.
- A few fixes for xen back/front block driver from Roger Pau Monne.
- Partition improvements from Stephen Warren, allowing partiion UUID
to be used as an identifier."
* 'for-3.8/drivers' of git://git.kernel.dk/linux-block: (609 commits)
drbd: update Kconfig to match current dependencies
drbd: Fix drbdsetup wait-connect, wait-sync etc... commands
drbd: close race between drbd_set_role and drbd_connect
drbd: respect no-md-barriers setting also when changed online via disk-options
drbd: Remove obsolete check
drbd: fixup after wait_even_lock_irq() addition to generic code
loop: Limit the number of requests in the bio list
wait: add wait_event_lock_irq() interface
xen-blkfront: free allocated page
xen-blkback: move free persistent grants code
block: partition: msdos: provide UUIDs for partitions
init: reduce PARTUUID min length to 1 from 36
block: store partition_meta_info.uuid as a string
cciss: use check_signature()
cciss: cleanup bitops usage
drbd: use copy_highpage
drbd: if the replication link breaks during handshake, keep retrying
drbd: check return of kmalloc in receive_uuids
drbd: Broadcast sync progress no more often than once per second
drbd: don't try to clear bits once the disk has failed
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/drbd.h | 81 | ||||
-rw-r--r-- | include/linux/drbd_genl.h | 378 | ||||
-rw-r--r-- | include/linux/drbd_genl_api.h | 55 | ||||
-rw-r--r-- | include/linux/drbd_limits.h | 90 | ||||
-rw-r--r-- | include/linux/drbd_nl.h | 163 | ||||
-rw-r--r-- | include/linux/drbd_tag_magic.h | 84 | ||||
-rw-r--r-- | include/linux/genhd.h | 8 | ||||
-rw-r--r-- | include/linux/genl_magic_func.h | 422 | ||||
-rw-r--r-- | include/linux/genl_magic_struct.h | 277 | ||||
-rw-r--r-- | include/linux/idr.h | 11 | ||||
-rw-r--r-- | include/linux/loop.h | 3 | ||||
-rw-r--r-- | include/linux/lru_cache.h | 67 | ||||
-rw-r--r-- | include/linux/wait.h | 164 |
13 files changed, 1473 insertions, 330 deletions
diff --git a/include/linux/drbd.h b/include/linux/drbd.h index 47e3d4850584..0c5a18ec322c 100644 --- a/include/linux/drbd.h +++ b/include/linux/drbd.h | |||
@@ -51,12 +51,11 @@ | |||
51 | 51 | ||
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | |||
55 | extern const char *drbd_buildtag(void); | 54 | extern const char *drbd_buildtag(void); |
56 | #define REL_VERSION "8.3.13" | 55 | #define REL_VERSION "8.4.2" |
57 | #define API_VERSION 88 | 56 | #define API_VERSION 1 |
58 | #define PRO_VERSION_MIN 86 | 57 | #define PRO_VERSION_MIN 86 |
59 | #define PRO_VERSION_MAX 96 | 58 | #define PRO_VERSION_MAX 101 |
60 | 59 | ||
61 | 60 | ||
62 | enum drbd_io_error_p { | 61 | enum drbd_io_error_p { |
@@ -66,7 +65,8 @@ enum drbd_io_error_p { | |||
66 | }; | 65 | }; |
67 | 66 | ||
68 | enum drbd_fencing_p { | 67 | enum drbd_fencing_p { |
69 | FP_DONT_CARE, | 68 | FP_NOT_AVAIL = -1, /* Not a policy */ |
69 | FP_DONT_CARE = 0, | ||
70 | FP_RESOURCE, | 70 | FP_RESOURCE, |
71 | FP_STONITH | 71 | FP_STONITH |
72 | }; | 72 | }; |
@@ -102,6 +102,20 @@ enum drbd_on_congestion { | |||
102 | OC_DISCONNECT, | 102 | OC_DISCONNECT, |
103 | }; | 103 | }; |
104 | 104 | ||
105 | enum drbd_read_balancing { | ||
106 | RB_PREFER_LOCAL, | ||
107 | RB_PREFER_REMOTE, | ||
108 | RB_ROUND_ROBIN, | ||
109 | RB_LEAST_PENDING, | ||
110 | RB_CONGESTED_REMOTE, | ||
111 | RB_32K_STRIPING, | ||
112 | RB_64K_STRIPING, | ||
113 | RB_128K_STRIPING, | ||
114 | RB_256K_STRIPING, | ||
115 | RB_512K_STRIPING, | ||
116 | RB_1M_STRIPING, | ||
117 | }; | ||
118 | |||
105 | /* KEEP the order, do not delete or insert. Only append. */ | 119 | /* KEEP the order, do not delete or insert. Only append. */ |
106 | enum drbd_ret_code { | 120 | enum drbd_ret_code { |
107 | ERR_CODE_BASE = 100, | 121 | ERR_CODE_BASE = 100, |
@@ -122,7 +136,7 @@ enum drbd_ret_code { | |||
122 | ERR_AUTH_ALG = 120, | 136 | ERR_AUTH_ALG = 120, |
123 | ERR_AUTH_ALG_ND = 121, | 137 | ERR_AUTH_ALG_ND = 121, |
124 | ERR_NOMEM = 122, | 138 | ERR_NOMEM = 122, |
125 | ERR_DISCARD = 123, | 139 | ERR_DISCARD_IMPOSSIBLE = 123, |
126 | ERR_DISK_CONFIGURED = 124, | 140 | ERR_DISK_CONFIGURED = 124, |
127 | ERR_NET_CONFIGURED = 125, | 141 | ERR_NET_CONFIGURED = 125, |
128 | ERR_MANDATORY_TAG = 126, | 142 | ERR_MANDATORY_TAG = 126, |
@@ -130,8 +144,8 @@ enum drbd_ret_code { | |||
130 | ERR_INTR = 129, /* EINTR */ | 144 | ERR_INTR = 129, /* EINTR */ |
131 | ERR_RESIZE_RESYNC = 130, | 145 | ERR_RESIZE_RESYNC = 130, |
132 | ERR_NO_PRIMARY = 131, | 146 | ERR_NO_PRIMARY = 131, |
133 | ERR_SYNC_AFTER = 132, | 147 | ERR_RESYNC_AFTER = 132, |
134 | ERR_SYNC_AFTER_CYCLE = 133, | 148 | ERR_RESYNC_AFTER_CYCLE = 133, |
135 | ERR_PAUSE_IS_SET = 134, | 149 | ERR_PAUSE_IS_SET = 134, |
136 | ERR_PAUSE_IS_CLEAR = 135, | 150 | ERR_PAUSE_IS_CLEAR = 135, |
137 | ERR_PACKET_NR = 137, | 151 | ERR_PACKET_NR = 137, |
@@ -155,6 +169,14 @@ enum drbd_ret_code { | |||
155 | ERR_CONG_NOT_PROTO_A = 155, | 169 | ERR_CONG_NOT_PROTO_A = 155, |
156 | ERR_PIC_AFTER_DEP = 156, | 170 | ERR_PIC_AFTER_DEP = 156, |
157 | ERR_PIC_PEER_DEP = 157, | 171 | ERR_PIC_PEER_DEP = 157, |
172 | ERR_RES_NOT_KNOWN = 158, | ||
173 | ERR_RES_IN_USE = 159, | ||
174 | ERR_MINOR_CONFIGURED = 160, | ||
175 | ERR_MINOR_EXISTS = 161, | ||
176 | ERR_INVALID_REQUEST = 162, | ||
177 | ERR_NEED_APV_100 = 163, | ||
178 | ERR_NEED_ALLOW_TWO_PRI = 164, | ||
179 | ERR_MD_UNCLEAN = 165, | ||
158 | 180 | ||
159 | /* insert new ones above this line */ | 181 | /* insert new ones above this line */ |
160 | AFTER_LAST_ERR_CODE | 182 | AFTER_LAST_ERR_CODE |
@@ -296,7 +318,8 @@ enum drbd_state_rv { | |||
296 | SS_NOT_SUPPORTED = -17, /* drbd-8.2 only */ | 318 | SS_NOT_SUPPORTED = -17, /* drbd-8.2 only */ |
297 | SS_IN_TRANSIENT_STATE = -18, /* Retry after the next state change */ | 319 | SS_IN_TRANSIENT_STATE = -18, /* Retry after the next state change */ |
298 | SS_CONCURRENT_ST_CHG = -19, /* Concurrent cluster side state change! */ | 320 | SS_CONCURRENT_ST_CHG = -19, /* Concurrent cluster side state change! */ |
299 | SS_AFTER_LAST_ERROR = -20, /* Keep this at bottom */ | 321 | SS_O_VOL_PEER_PRI = -20, |
322 | SS_AFTER_LAST_ERROR = -21, /* Keep this at bottom */ | ||
300 | }; | 323 | }; |
301 | 324 | ||
302 | /* from drbd_strings.c */ | 325 | /* from drbd_strings.c */ |
@@ -313,7 +336,9 @@ extern const char *drbd_set_st_err_str(enum drbd_state_rv); | |||
313 | #define MDF_FULL_SYNC (1 << 3) | 336 | #define MDF_FULL_SYNC (1 << 3) |
314 | #define MDF_WAS_UP_TO_DATE (1 << 4) | 337 | #define MDF_WAS_UP_TO_DATE (1 << 4) |
315 | #define MDF_PEER_OUT_DATED (1 << 5) | 338 | #define MDF_PEER_OUT_DATED (1 << 5) |
316 | #define MDF_CRASHED_PRIMARY (1 << 6) | 339 | #define MDF_CRASHED_PRIMARY (1 << 6) |
340 | #define MDF_AL_CLEAN (1 << 7) | ||
341 | #define MDF_AL_DISABLED (1 << 8) | ||
317 | 342 | ||
318 | enum drbd_uuid_index { | 343 | enum drbd_uuid_index { |
319 | UI_CURRENT, | 344 | UI_CURRENT, |
@@ -333,37 +358,23 @@ enum drbd_timeout_flag { | |||
333 | 358 | ||
334 | #define UUID_JUST_CREATED ((__u64)4) | 359 | #define UUID_JUST_CREATED ((__u64)4) |
335 | 360 | ||
361 | /* magic numbers used in meta data and network packets */ | ||
336 | #define DRBD_MAGIC 0x83740267 | 362 | #define DRBD_MAGIC 0x83740267 |
337 | #define BE_DRBD_MAGIC __constant_cpu_to_be32(DRBD_MAGIC) | ||
338 | #define DRBD_MAGIC_BIG 0x835a | 363 | #define DRBD_MAGIC_BIG 0x835a |
339 | #define BE_DRBD_MAGIC_BIG __constant_cpu_to_be16(DRBD_MAGIC_BIG) | 364 | #define DRBD_MAGIC_100 0x8620ec20 |
365 | |||
366 | #define DRBD_MD_MAGIC_07 (DRBD_MAGIC+3) | ||
367 | #define DRBD_MD_MAGIC_08 (DRBD_MAGIC+4) | ||
368 | #define DRBD_MD_MAGIC_84_UNCLEAN (DRBD_MAGIC+5) | ||
369 | |||
370 | |||
371 | /* how I came up with this magic? | ||
372 | * base64 decode "actlog==" ;) */ | ||
373 | #define DRBD_AL_MAGIC 0x69cb65a2 | ||
340 | 374 | ||
341 | /* these are of type "int" */ | 375 | /* these are of type "int" */ |
342 | #define DRBD_MD_INDEX_INTERNAL -1 | 376 | #define DRBD_MD_INDEX_INTERNAL -1 |
343 | #define DRBD_MD_INDEX_FLEX_EXT -2 | 377 | #define DRBD_MD_INDEX_FLEX_EXT -2 |
344 | #define DRBD_MD_INDEX_FLEX_INT -3 | 378 | #define DRBD_MD_INDEX_FLEX_INT -3 |
345 | 379 | ||
346 | /* Start of the new netlink/connector stuff */ | ||
347 | |||
348 | #define DRBD_NL_CREATE_DEVICE 0x01 | ||
349 | #define DRBD_NL_SET_DEFAULTS 0x02 | ||
350 | |||
351 | |||
352 | /* For searching a vacant cn_idx value */ | ||
353 | #define CN_IDX_STEP 6977 | ||
354 | |||
355 | struct drbd_nl_cfg_req { | ||
356 | int packet_type; | ||
357 | unsigned int drbd_minor; | ||
358 | int flags; | ||
359 | unsigned short tag_list[]; | ||
360 | }; | ||
361 | |||
362 | struct drbd_nl_cfg_reply { | ||
363 | int packet_type; | ||
364 | unsigned int minor; | ||
365 | int ret_code; /* enum ret_code or set_st_err_t */ | ||
366 | unsigned short tag_list[]; /* only used with get_* calls */ | ||
367 | }; | ||
368 | |||
369 | #endif | 380 | #endif |
diff --git a/include/linux/drbd_genl.h b/include/linux/drbd_genl.h new file mode 100644 index 000000000000..d0d8fac8a6e4 --- /dev/null +++ b/include/linux/drbd_genl.h | |||
@@ -0,0 +1,378 @@ | |||
1 | /* | ||
2 | * General overview: | ||
3 | * full generic netlink message: | ||
4 | * |nlmsghdr|genlmsghdr|<payload> | ||
5 | * | ||
6 | * payload: | ||
7 | * |optional fixed size family header|<sequence of netlink attributes> | ||
8 | * | ||
9 | * sequence of netlink attributes: | ||
10 | * I chose to have all "top level" attributes NLA_NESTED, | ||
11 | * corresponding to some real struct. | ||
12 | * So we have a sequence of |tla, len|<nested nla sequence> | ||
13 | * | ||
14 | * nested nla sequence: | ||
15 | * may be empty, or contain a sequence of netlink attributes | ||
16 | * representing the struct fields. | ||
17 | * | ||
18 | * The tag number of any field (regardless of containing struct) | ||
19 | * will be available as T_ ## field_name, | ||
20 | * so you cannot have the same field name in two differnt structs. | ||
21 | * | ||
22 | * The tag numbers themselves are per struct, though, | ||
23 | * so should always begin at 1 (not 0, that is the special "NLA_UNSPEC" type, | ||
24 | * which we won't use here). | ||
25 | * The tag numbers are used as index in the respective nla_policy array. | ||
26 | * | ||
27 | * GENL_struct(tag_name, tag_number, struct name, struct fields) - struct and policy | ||
28 | * genl_magic_struct.h | ||
29 | * generates the struct declaration, | ||
30 | * generates an entry in the tla enum, | ||
31 | * genl_magic_func.h | ||
32 | * generates an entry in the static tla policy | ||
33 | * with .type = NLA_NESTED | ||
34 | * generates the static <struct_name>_nl_policy definition, | ||
35 | * and static conversion functions | ||
36 | * | ||
37 | * genl_magic_func.h | ||
38 | * | ||
39 | * GENL_mc_group(group) | ||
40 | * genl_magic_struct.h | ||
41 | * does nothing | ||
42 | * genl_magic_func.h | ||
43 | * defines and registers the mcast group, | ||
44 | * and provides a send helper | ||
45 | * | ||
46 | * GENL_notification(op_name, op_num, mcast_group, tla list) | ||
47 | * These are notifications to userspace. | ||
48 | * | ||
49 | * genl_magic_struct.h | ||
50 | * generates an entry in the genl_ops enum, | ||
51 | * genl_magic_func.h | ||
52 | * does nothing | ||
53 | * | ||
54 | * mcast group: the name of the mcast group this notification should be | ||
55 | * expected on | ||
56 | * tla list: the list of expected top level attributes, | ||
57 | * for documentation and sanity checking. | ||
58 | * | ||
59 | * GENL_op(op_name, op_num, flags and handler, tla list) - "genl operations" | ||
60 | * These are requests from userspace. | ||
61 | * | ||
62 | * _op and _notification share the same "number space", | ||
63 | * op_nr will be assigned to "genlmsghdr->cmd" | ||
64 | * | ||
65 | * genl_magic_struct.h | ||
66 | * generates an entry in the genl_ops enum, | ||
67 | * genl_magic_func.h | ||
68 | * generates an entry in the static genl_ops array, | ||
69 | * and static register/unregister functions to | ||
70 | * genl_register_family_with_ops(). | ||
71 | * | ||
72 | * flags and handler: | ||
73 | * GENL_op_init( .doit = x, .dumpit = y, .flags = something) | ||
74 | * GENL_doit(x) => .dumpit = NULL, .flags = GENL_ADMIN_PERM | ||
75 | * tla list: the list of expected top level attributes, | ||
76 | * for documentation and sanity checking. | ||
77 | */ | ||
78 | |||
79 | /* | ||
80 | * STRUCTS | ||
81 | */ | ||
82 | |||
83 | /* this is sent kernel -> userland on various error conditions, and contains | ||
84 | * informational textual info, which is supposedly human readable. | ||
85 | * The computer relevant return code is in the drbd_genlmsghdr. | ||
86 | */ | ||
87 | GENL_struct(DRBD_NLA_CFG_REPLY, 1, drbd_cfg_reply, | ||
88 | /* "arbitrary" size strings, nla_policy.len = 0 */ | ||
89 | __str_field(1, DRBD_GENLA_F_MANDATORY, info_text, 0) | ||
90 | ) | ||
91 | |||
92 | /* Configuration requests typically need a context to operate on. | ||
93 | * Possible keys are device minor (fits in the drbd_genlmsghdr), | ||
94 | * the replication link (aka connection) name, | ||
95 | * and/or the replication group (aka resource) name, | ||
96 | * and the volume id within the resource. */ | ||
97 | GENL_struct(DRBD_NLA_CFG_CONTEXT, 2, drbd_cfg_context, | ||
98 | __u32_field(1, DRBD_GENLA_F_MANDATORY, ctx_volume) | ||
99 | __str_field(2, DRBD_GENLA_F_MANDATORY, ctx_resource_name, 128) | ||
100 | __bin_field(3, DRBD_GENLA_F_MANDATORY, ctx_my_addr, 128) | ||
101 | __bin_field(4, DRBD_GENLA_F_MANDATORY, ctx_peer_addr, 128) | ||
102 | ) | ||
103 | |||
104 | GENL_struct(DRBD_NLA_DISK_CONF, 3, disk_conf, | ||
105 | __str_field(1, DRBD_F_REQUIRED | DRBD_F_INVARIANT, backing_dev, 128) | ||
106 | __str_field(2, DRBD_F_REQUIRED | DRBD_F_INVARIANT, meta_dev, 128) | ||
107 | __s32_field(3, DRBD_F_REQUIRED | DRBD_F_INVARIANT, meta_dev_idx) | ||
108 | |||
109 | /* use the resize command to try and change the disk_size */ | ||
110 | __u64_field(4, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, disk_size) | ||
111 | /* we could change the max_bio_bvecs, | ||
112 | * but it won't propagate through the stack */ | ||
113 | __u32_field(5, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, max_bio_bvecs) | ||
114 | |||
115 | __u32_field_def(6, DRBD_GENLA_F_MANDATORY, on_io_error, DRBD_ON_IO_ERROR_DEF) | ||
116 | __u32_field_def(7, DRBD_GENLA_F_MANDATORY, fencing, DRBD_FENCING_DEF) | ||
117 | |||
118 | __u32_field_def(8, DRBD_GENLA_F_MANDATORY, resync_rate, DRBD_RESYNC_RATE_DEF) | ||
119 | __s32_field_def(9, DRBD_GENLA_F_MANDATORY, resync_after, DRBD_MINOR_NUMBER_DEF) | ||
120 | __u32_field_def(10, DRBD_GENLA_F_MANDATORY, al_extents, DRBD_AL_EXTENTS_DEF) | ||
121 | __u32_field_def(11, DRBD_GENLA_F_MANDATORY, c_plan_ahead, DRBD_C_PLAN_AHEAD_DEF) | ||
122 | __u32_field_def(12, DRBD_GENLA_F_MANDATORY, c_delay_target, DRBD_C_DELAY_TARGET_DEF) | ||
123 | __u32_field_def(13, DRBD_GENLA_F_MANDATORY, c_fill_target, DRBD_C_FILL_TARGET_DEF) | ||
124 | __u32_field_def(14, DRBD_GENLA_F_MANDATORY, c_max_rate, DRBD_C_MAX_RATE_DEF) | ||
125 | __u32_field_def(15, DRBD_GENLA_F_MANDATORY, c_min_rate, DRBD_C_MIN_RATE_DEF) | ||
126 | |||
127 | __flg_field_def(16, DRBD_GENLA_F_MANDATORY, disk_barrier, DRBD_DISK_BARRIER_DEF) | ||
128 | __flg_field_def(17, DRBD_GENLA_F_MANDATORY, disk_flushes, DRBD_DISK_FLUSHES_DEF) | ||
129 | __flg_field_def(18, DRBD_GENLA_F_MANDATORY, disk_drain, DRBD_DISK_DRAIN_DEF) | ||
130 | __flg_field_def(19, DRBD_GENLA_F_MANDATORY, md_flushes, DRBD_MD_FLUSHES_DEF) | ||
131 | __u32_field_def(20, DRBD_GENLA_F_MANDATORY, disk_timeout, DRBD_DISK_TIMEOUT_DEF) | ||
132 | __u32_field_def(21, 0 /* OPTIONAL */, read_balancing, DRBD_READ_BALANCING_DEF) | ||
133 | /* 9: __u32_field_def(22, DRBD_GENLA_F_MANDATORY, unplug_watermark, DRBD_UNPLUG_WATERMARK_DEF) */ | ||
134 | __flg_field_def(23, 0 /* OPTIONAL */, al_updates, DRBD_AL_UPDATES_DEF) | ||
135 | ) | ||
136 | |||
137 | GENL_struct(DRBD_NLA_RESOURCE_OPTS, 4, res_opts, | ||
138 | __str_field_def(1, DRBD_GENLA_F_MANDATORY, cpu_mask, 32) | ||
139 | __u32_field_def(2, DRBD_GENLA_F_MANDATORY, on_no_data, DRBD_ON_NO_DATA_DEF) | ||
140 | ) | ||
141 | |||
142 | GENL_struct(DRBD_NLA_NET_CONF, 5, net_conf, | ||
143 | __str_field_def(1, DRBD_GENLA_F_MANDATORY | DRBD_F_SENSITIVE, | ||
144 | shared_secret, SHARED_SECRET_MAX) | ||
145 | __str_field_def(2, DRBD_GENLA_F_MANDATORY, cram_hmac_alg, SHARED_SECRET_MAX) | ||
146 | __str_field_def(3, DRBD_GENLA_F_MANDATORY, integrity_alg, SHARED_SECRET_MAX) | ||
147 | __str_field_def(4, DRBD_GENLA_F_MANDATORY, verify_alg, SHARED_SECRET_MAX) | ||
148 | __str_field_def(5, DRBD_GENLA_F_MANDATORY, csums_alg, SHARED_SECRET_MAX) | ||
149 | __u32_field_def(6, DRBD_GENLA_F_MANDATORY, wire_protocol, DRBD_PROTOCOL_DEF) | ||
150 | __u32_field_def(7, DRBD_GENLA_F_MANDATORY, connect_int, DRBD_CONNECT_INT_DEF) | ||
151 | __u32_field_def(8, DRBD_GENLA_F_MANDATORY, timeout, DRBD_TIMEOUT_DEF) | ||
152 | __u32_field_def(9, DRBD_GENLA_F_MANDATORY, ping_int, DRBD_PING_INT_DEF) | ||
153 | __u32_field_def(10, DRBD_GENLA_F_MANDATORY, ping_timeo, DRBD_PING_TIMEO_DEF) | ||
154 | __u32_field_def(11, DRBD_GENLA_F_MANDATORY, sndbuf_size, DRBD_SNDBUF_SIZE_DEF) | ||
155 | __u32_field_def(12, DRBD_GENLA_F_MANDATORY, rcvbuf_size, DRBD_RCVBUF_SIZE_DEF) | ||
156 | __u32_field_def(13, DRBD_GENLA_F_MANDATORY, ko_count, DRBD_KO_COUNT_DEF) | ||
157 | __u32_field_def(14, DRBD_GENLA_F_MANDATORY, max_buffers, DRBD_MAX_BUFFERS_DEF) | ||
158 | __u32_field_def(15, DRBD_GENLA_F_MANDATORY, max_epoch_size, DRBD_MAX_EPOCH_SIZE_DEF) | ||
159 | __u32_field_def(16, DRBD_GENLA_F_MANDATORY, unplug_watermark, DRBD_UNPLUG_WATERMARK_DEF) | ||
160 | __u32_field_def(17, DRBD_GENLA_F_MANDATORY, after_sb_0p, DRBD_AFTER_SB_0P_DEF) | ||
161 | __u32_field_def(18, DRBD_GENLA_F_MANDATORY, after_sb_1p, DRBD_AFTER_SB_1P_DEF) | ||
162 | __u32_field_def(19, DRBD_GENLA_F_MANDATORY, after_sb_2p, DRBD_AFTER_SB_2P_DEF) | ||
163 | __u32_field_def(20, DRBD_GENLA_F_MANDATORY, rr_conflict, DRBD_RR_CONFLICT_DEF) | ||
164 | __u32_field_def(21, DRBD_GENLA_F_MANDATORY, on_congestion, DRBD_ON_CONGESTION_DEF) | ||
165 | __u32_field_def(22, DRBD_GENLA_F_MANDATORY, cong_fill, DRBD_CONG_FILL_DEF) | ||
166 | __u32_field_def(23, DRBD_GENLA_F_MANDATORY, cong_extents, DRBD_CONG_EXTENTS_DEF) | ||
167 | __flg_field_def(24, DRBD_GENLA_F_MANDATORY, two_primaries, DRBD_ALLOW_TWO_PRIMARIES_DEF) | ||
168 | __flg_field(25, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, discard_my_data) | ||
169 | __flg_field_def(26, DRBD_GENLA_F_MANDATORY, tcp_cork, DRBD_TCP_CORK_DEF) | ||
170 | __flg_field_def(27, DRBD_GENLA_F_MANDATORY, always_asbp, DRBD_ALWAYS_ASBP_DEF) | ||
171 | __flg_field(28, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, tentative) | ||
172 | __flg_field_def(29, DRBD_GENLA_F_MANDATORY, use_rle, DRBD_USE_RLE_DEF) | ||
173 | /* 9: __u32_field_def(30, DRBD_GENLA_F_MANDATORY, fencing_policy, DRBD_FENCING_DEF) */ | ||
174 | ) | ||
175 | |||
176 | GENL_struct(DRBD_NLA_SET_ROLE_PARMS, 6, set_role_parms, | ||
177 | __flg_field(1, DRBD_GENLA_F_MANDATORY, assume_uptodate) | ||
178 | ) | ||
179 | |||
180 | GENL_struct(DRBD_NLA_RESIZE_PARMS, 7, resize_parms, | ||
181 | __u64_field(1, DRBD_GENLA_F_MANDATORY, resize_size) | ||
182 | __flg_field(2, DRBD_GENLA_F_MANDATORY, resize_force) | ||
183 | __flg_field(3, DRBD_GENLA_F_MANDATORY, no_resync) | ||
184 | ) | ||
185 | |||
186 | GENL_struct(DRBD_NLA_STATE_INFO, 8, state_info, | ||
187 | /* the reason of the broadcast, | ||
188 | * if this is an event triggered broadcast. */ | ||
189 | __u32_field(1, DRBD_GENLA_F_MANDATORY, sib_reason) | ||
190 | __u32_field(2, DRBD_F_REQUIRED, current_state) | ||
191 | __u64_field(3, DRBD_GENLA_F_MANDATORY, capacity) | ||
192 | __u64_field(4, DRBD_GENLA_F_MANDATORY, ed_uuid) | ||
193 | |||
194 | /* These are for broadcast from after state change work. | ||
195 | * prev_state and new_state are from the moment the state change took | ||
196 | * place, new_state is not neccessarily the same as current_state, | ||
197 | * there may have been more state changes since. Which will be | ||
198 | * broadcasted soon, in their respective after state change work. */ | ||
199 | __u32_field(5, DRBD_GENLA_F_MANDATORY, prev_state) | ||
200 | __u32_field(6, DRBD_GENLA_F_MANDATORY, new_state) | ||
201 | |||
202 | /* if we have a local disk: */ | ||
203 | __bin_field(7, DRBD_GENLA_F_MANDATORY, uuids, (UI_SIZE*sizeof(__u64))) | ||
204 | __u32_field(8, DRBD_GENLA_F_MANDATORY, disk_flags) | ||
205 | __u64_field(9, DRBD_GENLA_F_MANDATORY, bits_total) | ||
206 | __u64_field(10, DRBD_GENLA_F_MANDATORY, bits_oos) | ||
207 | /* and in case resync or online verify is active */ | ||
208 | __u64_field(11, DRBD_GENLA_F_MANDATORY, bits_rs_total) | ||
209 | __u64_field(12, DRBD_GENLA_F_MANDATORY, bits_rs_failed) | ||
210 | |||
211 | /* for pre and post notifications of helper execution */ | ||
212 | __str_field(13, DRBD_GENLA_F_MANDATORY, helper, 32) | ||
213 | __u32_field(14, DRBD_GENLA_F_MANDATORY, helper_exit_code) | ||
214 | |||
215 | __u64_field(15, 0, send_cnt) | ||
216 | __u64_field(16, 0, recv_cnt) | ||
217 | __u64_field(17, 0, read_cnt) | ||
218 | __u64_field(18, 0, writ_cnt) | ||
219 | __u64_field(19, 0, al_writ_cnt) | ||
220 | __u64_field(20, 0, bm_writ_cnt) | ||
221 | __u32_field(21, 0, ap_bio_cnt) | ||
222 | __u32_field(22, 0, ap_pending_cnt) | ||
223 | __u32_field(23, 0, rs_pending_cnt) | ||
224 | ) | ||
225 | |||
226 | GENL_struct(DRBD_NLA_START_OV_PARMS, 9, start_ov_parms, | ||
227 | __u64_field(1, DRBD_GENLA_F_MANDATORY, ov_start_sector) | ||
228 | __u64_field(2, DRBD_GENLA_F_MANDATORY, ov_stop_sector) | ||
229 | ) | ||
230 | |||
231 | GENL_struct(DRBD_NLA_NEW_C_UUID_PARMS, 10, new_c_uuid_parms, | ||
232 | __flg_field(1, DRBD_GENLA_F_MANDATORY, clear_bm) | ||
233 | ) | ||
234 | |||
235 | GENL_struct(DRBD_NLA_TIMEOUT_PARMS, 11, timeout_parms, | ||
236 | __u32_field(1, DRBD_F_REQUIRED, timeout_type) | ||
237 | ) | ||
238 | |||
239 | GENL_struct(DRBD_NLA_DISCONNECT_PARMS, 12, disconnect_parms, | ||
240 | __flg_field(1, DRBD_GENLA_F_MANDATORY, force_disconnect) | ||
241 | ) | ||
242 | |||
243 | GENL_struct(DRBD_NLA_DETACH_PARMS, 13, detach_parms, | ||
244 | __flg_field(1, DRBD_GENLA_F_MANDATORY, force_detach) | ||
245 | ) | ||
246 | |||
247 | /* | ||
248 | * Notifications and commands (genlmsghdr->cmd) | ||
249 | */ | ||
250 | GENL_mc_group(events) | ||
251 | |||
252 | /* kernel -> userspace announcement of changes */ | ||
253 | GENL_notification( | ||
254 | DRBD_EVENT, 1, events, | ||
255 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
256 | GENL_tla_expected(DRBD_NLA_STATE_INFO, DRBD_F_REQUIRED) | ||
257 | GENL_tla_expected(DRBD_NLA_NET_CONF, DRBD_GENLA_F_MANDATORY) | ||
258 | GENL_tla_expected(DRBD_NLA_DISK_CONF, DRBD_GENLA_F_MANDATORY) | ||
259 | GENL_tla_expected(DRBD_NLA_SYNCER_CONF, DRBD_GENLA_F_MANDATORY) | ||
260 | ) | ||
261 | |||
262 | /* query kernel for specific or all info */ | ||
263 | GENL_op( | ||
264 | DRBD_ADM_GET_STATUS, 2, | ||
265 | GENL_op_init( | ||
266 | .doit = drbd_adm_get_status, | ||
267 | .dumpit = drbd_adm_get_status_all, | ||
268 | /* anyone may ask for the status, | ||
269 | * it is broadcasted anyways */ | ||
270 | ), | ||
271 | /* To select the object .doit. | ||
272 | * Or a subset of objects in .dumpit. */ | ||
273 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_GENLA_F_MANDATORY) | ||
274 | ) | ||
275 | |||
276 | /* add DRBD minor devices as volumes to resources */ | ||
277 | GENL_op(DRBD_ADM_NEW_MINOR, 5, GENL_doit(drbd_adm_add_minor), | ||
278 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
279 | GENL_op(DRBD_ADM_DEL_MINOR, 6, GENL_doit(drbd_adm_delete_minor), | ||
280 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
281 | |||
282 | /* add or delete resources */ | ||
283 | GENL_op(DRBD_ADM_NEW_RESOURCE, 7, GENL_doit(drbd_adm_new_resource), | ||
284 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
285 | GENL_op(DRBD_ADM_DEL_RESOURCE, 8, GENL_doit(drbd_adm_del_resource), | ||
286 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
287 | |||
288 | GENL_op(DRBD_ADM_RESOURCE_OPTS, 9, | ||
289 | GENL_doit(drbd_adm_resource_opts), | ||
290 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
291 | GENL_tla_expected(DRBD_NLA_RESOURCE_OPTS, DRBD_GENLA_F_MANDATORY) | ||
292 | ) | ||
293 | |||
294 | GENL_op( | ||
295 | DRBD_ADM_CONNECT, 10, | ||
296 | GENL_doit(drbd_adm_connect), | ||
297 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
298 | GENL_tla_expected(DRBD_NLA_NET_CONF, DRBD_F_REQUIRED) | ||
299 | ) | ||
300 | |||
301 | GENL_op( | ||
302 | DRBD_ADM_CHG_NET_OPTS, 29, | ||
303 | GENL_doit(drbd_adm_net_opts), | ||
304 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
305 | GENL_tla_expected(DRBD_NLA_NET_CONF, DRBD_F_REQUIRED) | ||
306 | ) | ||
307 | |||
308 | GENL_op(DRBD_ADM_DISCONNECT, 11, GENL_doit(drbd_adm_disconnect), | ||
309 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
310 | |||
311 | GENL_op(DRBD_ADM_ATTACH, 12, | ||
312 | GENL_doit(drbd_adm_attach), | ||
313 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
314 | GENL_tla_expected(DRBD_NLA_DISK_CONF, DRBD_F_REQUIRED) | ||
315 | ) | ||
316 | |||
317 | GENL_op(DRBD_ADM_CHG_DISK_OPTS, 28, | ||
318 | GENL_doit(drbd_adm_disk_opts), | ||
319 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
320 | GENL_tla_expected(DRBD_NLA_DISK_OPTS, DRBD_F_REQUIRED) | ||
321 | ) | ||
322 | |||
323 | GENL_op( | ||
324 | DRBD_ADM_RESIZE, 13, | ||
325 | GENL_doit(drbd_adm_resize), | ||
326 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
327 | GENL_tla_expected(DRBD_NLA_RESIZE_PARMS, DRBD_GENLA_F_MANDATORY) | ||
328 | ) | ||
329 | |||
330 | GENL_op( | ||
331 | DRBD_ADM_PRIMARY, 14, | ||
332 | GENL_doit(drbd_adm_set_role), | ||
333 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
334 | GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, DRBD_F_REQUIRED) | ||
335 | ) | ||
336 | |||
337 | GENL_op( | ||
338 | DRBD_ADM_SECONDARY, 15, | ||
339 | GENL_doit(drbd_adm_set_role), | ||
340 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
341 | GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, DRBD_F_REQUIRED) | ||
342 | ) | ||
343 | |||
344 | GENL_op( | ||
345 | DRBD_ADM_NEW_C_UUID, 16, | ||
346 | GENL_doit(drbd_adm_new_c_uuid), | ||
347 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
348 | GENL_tla_expected(DRBD_NLA_NEW_C_UUID_PARMS, DRBD_GENLA_F_MANDATORY) | ||
349 | ) | ||
350 | |||
351 | GENL_op( | ||
352 | DRBD_ADM_START_OV, 17, | ||
353 | GENL_doit(drbd_adm_start_ov), | ||
354 | GENL_tla_expected(DRBD_NLA_START_OV_PARMS, DRBD_GENLA_F_MANDATORY) | ||
355 | ) | ||
356 | |||
357 | GENL_op(DRBD_ADM_DETACH, 18, GENL_doit(drbd_adm_detach), | ||
358 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED) | ||
359 | GENL_tla_expected(DRBD_NLA_DETACH_PARMS, DRBD_GENLA_F_MANDATORY)) | ||
360 | |||
361 | GENL_op(DRBD_ADM_INVALIDATE, 19, GENL_doit(drbd_adm_invalidate), | ||
362 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
363 | GENL_op(DRBD_ADM_INVAL_PEER, 20, GENL_doit(drbd_adm_invalidate_peer), | ||
364 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
365 | GENL_op(DRBD_ADM_PAUSE_SYNC, 21, GENL_doit(drbd_adm_pause_sync), | ||
366 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
367 | GENL_op(DRBD_ADM_RESUME_SYNC, 22, GENL_doit(drbd_adm_resume_sync), | ||
368 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
369 | GENL_op(DRBD_ADM_SUSPEND_IO, 23, GENL_doit(drbd_adm_suspend_io), | ||
370 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
371 | GENL_op(DRBD_ADM_RESUME_IO, 24, GENL_doit(drbd_adm_resume_io), | ||
372 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
373 | GENL_op(DRBD_ADM_OUTDATE, 25, GENL_doit(drbd_adm_outdate), | ||
374 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
375 | GENL_op(DRBD_ADM_GET_TIMEOUT_TYPE, 26, GENL_doit(drbd_adm_get_timeout_type), | ||
376 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
377 | GENL_op(DRBD_ADM_DOWN, 27, GENL_doit(drbd_adm_down), | ||
378 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)) | ||
diff --git a/include/linux/drbd_genl_api.h b/include/linux/drbd_genl_api.h new file mode 100644 index 000000000000..9ef50d51e34e --- /dev/null +++ b/include/linux/drbd_genl_api.h | |||
@@ -0,0 +1,55 @@ | |||
1 | #ifndef DRBD_GENL_STRUCT_H | ||
2 | #define DRBD_GENL_STRUCT_H | ||
3 | |||
4 | /** | ||
5 | * struct drbd_genlmsghdr - DRBD specific header used in NETLINK_GENERIC requests | ||
6 | * @minor: | ||
7 | * For admin requests (user -> kernel): which minor device to operate on. | ||
8 | * For (unicast) replies or informational (broadcast) messages | ||
9 | * (kernel -> user): which minor device the information is about. | ||
10 | * If we do not operate on minors, but on connections or resources, | ||
11 | * the minor value shall be (~0), and the attribute DRBD_NLA_CFG_CONTEXT | ||
12 | * is used instead. | ||
13 | * @flags: possible operation modifiers (relevant only for user->kernel): | ||
14 | * DRBD_GENL_F_SET_DEFAULTS | ||
15 | * @volume: | ||
16 | * When creating a new minor (adding it to a resource), the resource needs | ||
17 | * to know which volume number within the resource this is supposed to be. | ||
18 | * The volume number corresponds to the same volume number on the remote side, | ||
19 | * whereas the minor number on the remote side may be different | ||
20 | * (union with flags). | ||
21 | * @ret_code: kernel->userland unicast cfg reply return code (union with flags); | ||
22 | */ | ||
23 | struct drbd_genlmsghdr { | ||
24 | __u32 minor; | ||
25 | union { | ||
26 | __u32 flags; | ||
27 | __s32 ret_code; | ||
28 | }; | ||
29 | }; | ||
30 | |||
31 | /* To be used in drbd_genlmsghdr.flags */ | ||
32 | enum { | ||
33 | DRBD_GENL_F_SET_DEFAULTS = 1, | ||
34 | }; | ||
35 | |||
36 | enum drbd_state_info_bcast_reason { | ||
37 | SIB_GET_STATUS_REPLY = 1, | ||
38 | SIB_STATE_CHANGE = 2, | ||
39 | SIB_HELPER_PRE = 3, | ||
40 | SIB_HELPER_POST = 4, | ||
41 | SIB_SYNC_PROGRESS = 5, | ||
42 | }; | ||
43 | |||
44 | /* hack around predefined gcc/cpp "linux=1", | ||
45 | * we cannot possibly include <1/drbd_genl.h> */ | ||
46 | #undef linux | ||
47 | |||
48 | #include <linux/drbd.h> | ||
49 | #define GENL_MAGIC_VERSION API_VERSION | ||
50 | #define GENL_MAGIC_FAMILY drbd | ||
51 | #define GENL_MAGIC_FAMILY_HDRSZ sizeof(struct drbd_genlmsghdr) | ||
52 | #define GENL_MAGIC_INCLUDE_FILE <linux/drbd_genl.h> | ||
53 | #include <linux/genl_magic_struct.h> | ||
54 | |||
55 | #endif | ||
diff --git a/include/linux/drbd_limits.h b/include/linux/drbd_limits.h index fb670bf603f7..1fa19c5f5e64 100644 --- a/include/linux/drbd_limits.h +++ b/include/linux/drbd_limits.h | |||
@@ -16,29 +16,37 @@ | |||
16 | #define DEBUG_RANGE_CHECK 0 | 16 | #define DEBUG_RANGE_CHECK 0 |
17 | 17 | ||
18 | #define DRBD_MINOR_COUNT_MIN 1 | 18 | #define DRBD_MINOR_COUNT_MIN 1 |
19 | #define DRBD_MINOR_COUNT_MAX 256 | 19 | #define DRBD_MINOR_COUNT_MAX 255 |
20 | #define DRBD_MINOR_COUNT_DEF 32 | 20 | #define DRBD_MINOR_COUNT_DEF 32 |
21 | #define DRBD_MINOR_COUNT_SCALE '1' | ||
22 | |||
23 | #define DRBD_VOLUME_MAX 65535 | ||
21 | 24 | ||
22 | #define DRBD_DIALOG_REFRESH_MIN 0 | 25 | #define DRBD_DIALOG_REFRESH_MIN 0 |
23 | #define DRBD_DIALOG_REFRESH_MAX 600 | 26 | #define DRBD_DIALOG_REFRESH_MAX 600 |
27 | #define DRBD_DIALOG_REFRESH_SCALE '1' | ||
24 | 28 | ||
25 | /* valid port number */ | 29 | /* valid port number */ |
26 | #define DRBD_PORT_MIN 1 | 30 | #define DRBD_PORT_MIN 1 |
27 | #define DRBD_PORT_MAX 0xffff | 31 | #define DRBD_PORT_MAX 0xffff |
32 | #define DRBD_PORT_SCALE '1' | ||
28 | 33 | ||
29 | /* startup { */ | 34 | /* startup { */ |
30 | /* if you want more than 3.4 days, disable */ | 35 | /* if you want more than 3.4 days, disable */ |
31 | #define DRBD_WFC_TIMEOUT_MIN 0 | 36 | #define DRBD_WFC_TIMEOUT_MIN 0 |
32 | #define DRBD_WFC_TIMEOUT_MAX 300000 | 37 | #define DRBD_WFC_TIMEOUT_MAX 300000 |
33 | #define DRBD_WFC_TIMEOUT_DEF 0 | 38 | #define DRBD_WFC_TIMEOUT_DEF 0 |
39 | #define DRBD_WFC_TIMEOUT_SCALE '1' | ||
34 | 40 | ||
35 | #define DRBD_DEGR_WFC_TIMEOUT_MIN 0 | 41 | #define DRBD_DEGR_WFC_TIMEOUT_MIN 0 |
36 | #define DRBD_DEGR_WFC_TIMEOUT_MAX 300000 | 42 | #define DRBD_DEGR_WFC_TIMEOUT_MAX 300000 |
37 | #define DRBD_DEGR_WFC_TIMEOUT_DEF 0 | 43 | #define DRBD_DEGR_WFC_TIMEOUT_DEF 0 |
44 | #define DRBD_DEGR_WFC_TIMEOUT_SCALE '1' | ||
38 | 45 | ||
39 | #define DRBD_OUTDATED_WFC_TIMEOUT_MIN 0 | 46 | #define DRBD_OUTDATED_WFC_TIMEOUT_MIN 0 |
40 | #define DRBD_OUTDATED_WFC_TIMEOUT_MAX 300000 | 47 | #define DRBD_OUTDATED_WFC_TIMEOUT_MAX 300000 |
41 | #define DRBD_OUTDATED_WFC_TIMEOUT_DEF 0 | 48 | #define DRBD_OUTDATED_WFC_TIMEOUT_DEF 0 |
49 | #define DRBD_OUTDATED_WFC_TIMEOUT_SCALE '1' | ||
42 | /* }*/ | 50 | /* }*/ |
43 | 51 | ||
44 | /* net { */ | 52 | /* net { */ |
@@ -47,75 +55,91 @@ | |||
47 | #define DRBD_TIMEOUT_MIN 1 | 55 | #define DRBD_TIMEOUT_MIN 1 |
48 | #define DRBD_TIMEOUT_MAX 600 | 56 | #define DRBD_TIMEOUT_MAX 600 |
49 | #define DRBD_TIMEOUT_DEF 60 /* 6 seconds */ | 57 | #define DRBD_TIMEOUT_DEF 60 /* 6 seconds */ |
58 | #define DRBD_TIMEOUT_SCALE '1' | ||
50 | 59 | ||
51 | /* If backing disk takes longer than disk_timeout, mark the disk as failed */ | 60 | /* If backing disk takes longer than disk_timeout, mark the disk as failed */ |
52 | #define DRBD_DISK_TIMEOUT_MIN 0 /* 0 = disabled */ | 61 | #define DRBD_DISK_TIMEOUT_MIN 0 /* 0 = disabled */ |
53 | #define DRBD_DISK_TIMEOUT_MAX 6000 /* 10 Minutes */ | 62 | #define DRBD_DISK_TIMEOUT_MAX 6000 /* 10 Minutes */ |
54 | #define DRBD_DISK_TIMEOUT_DEF 0 /* disabled */ | 63 | #define DRBD_DISK_TIMEOUT_DEF 0 /* disabled */ |
64 | #define DRBD_DISK_TIMEOUT_SCALE '1' | ||
55 | 65 | ||
56 | /* active connection retries when C_WF_CONNECTION */ | 66 | /* active connection retries when C_WF_CONNECTION */ |
57 | #define DRBD_CONNECT_INT_MIN 1 | 67 | #define DRBD_CONNECT_INT_MIN 1 |
58 | #define DRBD_CONNECT_INT_MAX 120 | 68 | #define DRBD_CONNECT_INT_MAX 120 |
59 | #define DRBD_CONNECT_INT_DEF 10 /* seconds */ | 69 | #define DRBD_CONNECT_INT_DEF 10 /* seconds */ |
70 | #define DRBD_CONNECT_INT_SCALE '1' | ||
60 | 71 | ||
61 | /* keep-alive probes when idle */ | 72 | /* keep-alive probes when idle */ |
62 | #define DRBD_PING_INT_MIN 1 | 73 | #define DRBD_PING_INT_MIN 1 |
63 | #define DRBD_PING_INT_MAX 120 | 74 | #define DRBD_PING_INT_MAX 120 |
64 | #define DRBD_PING_INT_DEF 10 | 75 | #define DRBD_PING_INT_DEF 10 |
76 | #define DRBD_PING_INT_SCALE '1' | ||
65 | 77 | ||
66 | /* timeout for the ping packets.*/ | 78 | /* timeout for the ping packets.*/ |
67 | #define DRBD_PING_TIMEO_MIN 1 | 79 | #define DRBD_PING_TIMEO_MIN 1 |
68 | #define DRBD_PING_TIMEO_MAX 300 | 80 | #define DRBD_PING_TIMEO_MAX 300 |
69 | #define DRBD_PING_TIMEO_DEF 5 | 81 | #define DRBD_PING_TIMEO_DEF 5 |
82 | #define DRBD_PING_TIMEO_SCALE '1' | ||
70 | 83 | ||
71 | /* max number of write requests between write barriers */ | 84 | /* max number of write requests between write barriers */ |
72 | #define DRBD_MAX_EPOCH_SIZE_MIN 1 | 85 | #define DRBD_MAX_EPOCH_SIZE_MIN 1 |
73 | #define DRBD_MAX_EPOCH_SIZE_MAX 20000 | 86 | #define DRBD_MAX_EPOCH_SIZE_MAX 20000 |
74 | #define DRBD_MAX_EPOCH_SIZE_DEF 2048 | 87 | #define DRBD_MAX_EPOCH_SIZE_DEF 2048 |
88 | #define DRBD_MAX_EPOCH_SIZE_SCALE '1' | ||
75 | 89 | ||
76 | /* I don't think that a tcp send buffer of more than 10M is useful */ | 90 | /* I don't think that a tcp send buffer of more than 10M is useful */ |
77 | #define DRBD_SNDBUF_SIZE_MIN 0 | 91 | #define DRBD_SNDBUF_SIZE_MIN 0 |
78 | #define DRBD_SNDBUF_SIZE_MAX (10<<20) | 92 | #define DRBD_SNDBUF_SIZE_MAX (10<<20) |
79 | #define DRBD_SNDBUF_SIZE_DEF 0 | 93 | #define DRBD_SNDBUF_SIZE_DEF 0 |
94 | #define DRBD_SNDBUF_SIZE_SCALE '1' | ||
80 | 95 | ||
81 | #define DRBD_RCVBUF_SIZE_MIN 0 | 96 | #define DRBD_RCVBUF_SIZE_MIN 0 |
82 | #define DRBD_RCVBUF_SIZE_MAX (10<<20) | 97 | #define DRBD_RCVBUF_SIZE_MAX (10<<20) |
83 | #define DRBD_RCVBUF_SIZE_DEF 0 | 98 | #define DRBD_RCVBUF_SIZE_DEF 0 |
99 | #define DRBD_RCVBUF_SIZE_SCALE '1' | ||
84 | 100 | ||
85 | /* @4k PageSize -> 128kB - 512MB */ | 101 | /* @4k PageSize -> 128kB - 512MB */ |
86 | #define DRBD_MAX_BUFFERS_MIN 32 | 102 | #define DRBD_MAX_BUFFERS_MIN 32 |
87 | #define DRBD_MAX_BUFFERS_MAX 131072 | 103 | #define DRBD_MAX_BUFFERS_MAX 131072 |
88 | #define DRBD_MAX_BUFFERS_DEF 2048 | 104 | #define DRBD_MAX_BUFFERS_DEF 2048 |
105 | #define DRBD_MAX_BUFFERS_SCALE '1' | ||
89 | 106 | ||
90 | /* @4k PageSize -> 4kB - 512MB */ | 107 | /* @4k PageSize -> 4kB - 512MB */ |
91 | #define DRBD_UNPLUG_WATERMARK_MIN 1 | 108 | #define DRBD_UNPLUG_WATERMARK_MIN 1 |
92 | #define DRBD_UNPLUG_WATERMARK_MAX 131072 | 109 | #define DRBD_UNPLUG_WATERMARK_MAX 131072 |
93 | #define DRBD_UNPLUG_WATERMARK_DEF (DRBD_MAX_BUFFERS_DEF/16) | 110 | #define DRBD_UNPLUG_WATERMARK_DEF (DRBD_MAX_BUFFERS_DEF/16) |
111 | #define DRBD_UNPLUG_WATERMARK_SCALE '1' | ||
94 | 112 | ||
95 | /* 0 is disabled. | 113 | /* 0 is disabled. |
96 | * 200 should be more than enough even for very short timeouts */ | 114 | * 200 should be more than enough even for very short timeouts */ |
97 | #define DRBD_KO_COUNT_MIN 0 | 115 | #define DRBD_KO_COUNT_MIN 0 |
98 | #define DRBD_KO_COUNT_MAX 200 | 116 | #define DRBD_KO_COUNT_MAX 200 |
99 | #define DRBD_KO_COUNT_DEF 0 | 117 | #define DRBD_KO_COUNT_DEF 7 |
118 | #define DRBD_KO_COUNT_SCALE '1' | ||
100 | /* } */ | 119 | /* } */ |
101 | 120 | ||
102 | /* syncer { */ | 121 | /* syncer { */ |
103 | /* FIXME allow rate to be zero? */ | 122 | /* FIXME allow rate to be zero? */ |
104 | #define DRBD_RATE_MIN 1 | 123 | #define DRBD_RESYNC_RATE_MIN 1 |
105 | /* channel bonding 10 GbE, or other hardware */ | 124 | /* channel bonding 10 GbE, or other hardware */ |
106 | #define DRBD_RATE_MAX (4 << 20) | 125 | #define DRBD_RESYNC_RATE_MAX (4 << 20) |
107 | #define DRBD_RATE_DEF 250 /* kb/second */ | 126 | #define DRBD_RESYNC_RATE_DEF 250 |
127 | #define DRBD_RESYNC_RATE_SCALE 'k' /* kilobytes */ | ||
108 | 128 | ||
109 | /* less than 7 would hit performance unnecessarily. | 129 | /* less than 7 would hit performance unnecessarily. |
110 | * 3833 is the largest prime that still does fit | 130 | * 919 slots context information per transaction, |
111 | * into 64 sectors of activity log */ | 131 | * 32k activity log, 4k transaction size, |
132 | * one transaction in flight: | ||
133 | * 919 * 7 = 6433 */ | ||
112 | #define DRBD_AL_EXTENTS_MIN 7 | 134 | #define DRBD_AL_EXTENTS_MIN 7 |
113 | #define DRBD_AL_EXTENTS_MAX 3833 | 135 | #define DRBD_AL_EXTENTS_MAX 6433 |
114 | #define DRBD_AL_EXTENTS_DEF 127 | 136 | #define DRBD_AL_EXTENTS_DEF 1237 |
137 | #define DRBD_AL_EXTENTS_SCALE '1' | ||
115 | 138 | ||
116 | #define DRBD_AFTER_MIN -1 | 139 | #define DRBD_MINOR_NUMBER_MIN -1 |
117 | #define DRBD_AFTER_MAX 255 | 140 | #define DRBD_MINOR_NUMBER_MAX ((1 << 20) - 1) |
118 | #define DRBD_AFTER_DEF -1 | 141 | #define DRBD_MINOR_NUMBER_DEF -1 |
142 | #define DRBD_MINOR_NUMBER_SCALE '1' | ||
119 | 143 | ||
120 | /* } */ | 144 | /* } */ |
121 | 145 | ||
@@ -124,11 +148,12 @@ | |||
124 | * the upper limit with 64bit kernel, enough ram and flexible meta data | 148 | * the upper limit with 64bit kernel, enough ram and flexible meta data |
125 | * is 1 PiB, currently. */ | 149 | * is 1 PiB, currently. */ |
126 | /* DRBD_MAX_SECTORS */ | 150 | /* DRBD_MAX_SECTORS */ |
127 | #define DRBD_DISK_SIZE_SECT_MIN 0 | 151 | #define DRBD_DISK_SIZE_MIN 0 |
128 | #define DRBD_DISK_SIZE_SECT_MAX (1 * (2LLU << 40)) | 152 | #define DRBD_DISK_SIZE_MAX (1 * (2LLU << 40)) |
129 | #define DRBD_DISK_SIZE_SECT_DEF 0 /* = disabled = no user size... */ | 153 | #define DRBD_DISK_SIZE_DEF 0 /* = disabled = no user size... */ |
154 | #define DRBD_DISK_SIZE_SCALE 's' /* sectors */ | ||
130 | 155 | ||
131 | #define DRBD_ON_IO_ERROR_DEF EP_PASS_ON | 156 | #define DRBD_ON_IO_ERROR_DEF EP_DETACH |
132 | #define DRBD_FENCING_DEF FP_DONT_CARE | 157 | #define DRBD_FENCING_DEF FP_DONT_CARE |
133 | #define DRBD_AFTER_SB_0P_DEF ASB_DISCONNECT | 158 | #define DRBD_AFTER_SB_0P_DEF ASB_DISCONNECT |
134 | #define DRBD_AFTER_SB_1P_DEF ASB_DISCONNECT | 159 | #define DRBD_AFTER_SB_1P_DEF ASB_DISCONNECT |
@@ -136,38 +161,59 @@ | |||
136 | #define DRBD_RR_CONFLICT_DEF ASB_DISCONNECT | 161 | #define DRBD_RR_CONFLICT_DEF ASB_DISCONNECT |
137 | #define DRBD_ON_NO_DATA_DEF OND_IO_ERROR | 162 | #define DRBD_ON_NO_DATA_DEF OND_IO_ERROR |
138 | #define DRBD_ON_CONGESTION_DEF OC_BLOCK | 163 | #define DRBD_ON_CONGESTION_DEF OC_BLOCK |
164 | #define DRBD_READ_BALANCING_DEF RB_PREFER_LOCAL | ||
139 | 165 | ||
140 | #define DRBD_MAX_BIO_BVECS_MIN 0 | 166 | #define DRBD_MAX_BIO_BVECS_MIN 0 |
141 | #define DRBD_MAX_BIO_BVECS_MAX 128 | 167 | #define DRBD_MAX_BIO_BVECS_MAX 128 |
142 | #define DRBD_MAX_BIO_BVECS_DEF 0 | 168 | #define DRBD_MAX_BIO_BVECS_DEF 0 |
169 | #define DRBD_MAX_BIO_BVECS_SCALE '1' | ||
143 | 170 | ||
144 | #define DRBD_C_PLAN_AHEAD_MIN 0 | 171 | #define DRBD_C_PLAN_AHEAD_MIN 0 |
145 | #define DRBD_C_PLAN_AHEAD_MAX 300 | 172 | #define DRBD_C_PLAN_AHEAD_MAX 300 |
146 | #define DRBD_C_PLAN_AHEAD_DEF 0 /* RS rate controller disabled by default */ | 173 | #define DRBD_C_PLAN_AHEAD_DEF 20 |
174 | #define DRBD_C_PLAN_AHEAD_SCALE '1' | ||
147 | 175 | ||
148 | #define DRBD_C_DELAY_TARGET_MIN 1 | 176 | #define DRBD_C_DELAY_TARGET_MIN 1 |
149 | #define DRBD_C_DELAY_TARGET_MAX 100 | 177 | #define DRBD_C_DELAY_TARGET_MAX 100 |
150 | #define DRBD_C_DELAY_TARGET_DEF 10 | 178 | #define DRBD_C_DELAY_TARGET_DEF 10 |
179 | #define DRBD_C_DELAY_TARGET_SCALE '1' | ||
151 | 180 | ||
152 | #define DRBD_C_FILL_TARGET_MIN 0 | 181 | #define DRBD_C_FILL_TARGET_MIN 0 |
153 | #define DRBD_C_FILL_TARGET_MAX (1<<20) /* 500MByte in sec */ | 182 | #define DRBD_C_FILL_TARGET_MAX (1<<20) /* 500MByte in sec */ |
154 | #define DRBD_C_FILL_TARGET_DEF 0 /* By default disabled -> controlled by delay_target */ | 183 | #define DRBD_C_FILL_TARGET_DEF 100 /* Try to place 50KiB in socket send buffer during resync */ |
184 | #define DRBD_C_FILL_TARGET_SCALE 's' /* sectors */ | ||
155 | 185 | ||
156 | #define DRBD_C_MAX_RATE_MIN 250 /* kByte/sec */ | 186 | #define DRBD_C_MAX_RATE_MIN 250 |
157 | #define DRBD_C_MAX_RATE_MAX (4 << 20) | 187 | #define DRBD_C_MAX_RATE_MAX (4 << 20) |
158 | #define DRBD_C_MAX_RATE_DEF 102400 | 188 | #define DRBD_C_MAX_RATE_DEF 102400 |
189 | #define DRBD_C_MAX_RATE_SCALE 'k' /* kilobytes */ | ||
159 | 190 | ||
160 | #define DRBD_C_MIN_RATE_MIN 0 /* kByte/sec */ | 191 | #define DRBD_C_MIN_RATE_MIN 0 |
161 | #define DRBD_C_MIN_RATE_MAX (4 << 20) | 192 | #define DRBD_C_MIN_RATE_MAX (4 << 20) |
162 | #define DRBD_C_MIN_RATE_DEF 4096 | 193 | #define DRBD_C_MIN_RATE_DEF 250 |
194 | #define DRBD_C_MIN_RATE_SCALE 'k' /* kilobytes */ | ||
163 | 195 | ||
164 | #define DRBD_CONG_FILL_MIN 0 | 196 | #define DRBD_CONG_FILL_MIN 0 |
165 | #define DRBD_CONG_FILL_MAX (10<<21) /* 10GByte in sectors */ | 197 | #define DRBD_CONG_FILL_MAX (10<<21) /* 10GByte in sectors */ |
166 | #define DRBD_CONG_FILL_DEF 0 | 198 | #define DRBD_CONG_FILL_DEF 0 |
199 | #define DRBD_CONG_FILL_SCALE 's' /* sectors */ | ||
167 | 200 | ||
168 | #define DRBD_CONG_EXTENTS_MIN DRBD_AL_EXTENTS_MIN | 201 | #define DRBD_CONG_EXTENTS_MIN DRBD_AL_EXTENTS_MIN |
169 | #define DRBD_CONG_EXTENTS_MAX DRBD_AL_EXTENTS_MAX | 202 | #define DRBD_CONG_EXTENTS_MAX DRBD_AL_EXTENTS_MAX |
170 | #define DRBD_CONG_EXTENTS_DEF DRBD_AL_EXTENTS_DEF | 203 | #define DRBD_CONG_EXTENTS_DEF DRBD_AL_EXTENTS_DEF |
204 | #define DRBD_CONG_EXTENTS_SCALE DRBD_AL_EXTENTS_SCALE | ||
205 | |||
206 | #define DRBD_PROTOCOL_DEF DRBD_PROT_C | ||
207 | |||
208 | #define DRBD_DISK_BARRIER_DEF 0 | ||
209 | #define DRBD_DISK_FLUSHES_DEF 1 | ||
210 | #define DRBD_DISK_DRAIN_DEF 1 | ||
211 | #define DRBD_MD_FLUSHES_DEF 1 | ||
212 | #define DRBD_TCP_CORK_DEF 1 | ||
213 | #define DRBD_AL_UPDATES_DEF 1 | ||
214 | |||
215 | #define DRBD_ALLOW_TWO_PRIMARIES_DEF 0 | ||
216 | #define DRBD_ALWAYS_ASBP_DEF 0 | ||
217 | #define DRBD_USE_RLE_DEF 1 | ||
171 | 218 | ||
172 | #undef RANGE | ||
173 | #endif | 219 | #endif |
diff --git a/include/linux/drbd_nl.h b/include/linux/drbd_nl.h deleted file mode 100644 index a8706f08ab36..000000000000 --- a/include/linux/drbd_nl.h +++ /dev/null | |||
@@ -1,163 +0,0 @@ | |||
1 | /* | ||
2 | PAKET( name, | ||
3 | TYPE ( pn, pr, member ) | ||
4 | ... | ||
5 | ) | ||
6 | |||
7 | You may never reissue one of the pn arguments | ||
8 | */ | ||
9 | |||
10 | #if !defined(NL_PACKET) || !defined(NL_STRING) || !defined(NL_INTEGER) || !defined(NL_BIT) || !defined(NL_INT64) | ||
11 | #error "The macros NL_PACKET, NL_STRING, NL_INTEGER, NL_INT64 and NL_BIT needs to be defined" | ||
12 | #endif | ||
13 | |||
14 | NL_PACKET(primary, 1, | ||
15 | NL_BIT( 1, T_MAY_IGNORE, primary_force) | ||
16 | ) | ||
17 | |||
18 | NL_PACKET(secondary, 2, ) | ||
19 | |||
20 | NL_PACKET(disk_conf, 3, | ||
21 | NL_INT64( 2, T_MAY_IGNORE, disk_size) | ||
22 | NL_STRING( 3, T_MANDATORY, backing_dev, 128) | ||
23 | NL_STRING( 4, T_MANDATORY, meta_dev, 128) | ||
24 | NL_INTEGER( 5, T_MANDATORY, meta_dev_idx) | ||
25 | NL_INTEGER( 6, T_MAY_IGNORE, on_io_error) | ||
26 | NL_INTEGER( 7, T_MAY_IGNORE, fencing) | ||
27 | NL_BIT( 37, T_MAY_IGNORE, use_bmbv) | ||
28 | NL_BIT( 53, T_MAY_IGNORE, no_disk_flush) | ||
29 | NL_BIT( 54, T_MAY_IGNORE, no_md_flush) | ||
30 | /* 55 max_bio_size was available in 8.2.6rc2 */ | ||
31 | NL_INTEGER( 56, T_MAY_IGNORE, max_bio_bvecs) | ||
32 | NL_BIT( 57, T_MAY_IGNORE, no_disk_barrier) | ||
33 | NL_BIT( 58, T_MAY_IGNORE, no_disk_drain) | ||
34 | NL_INTEGER( 89, T_MAY_IGNORE, disk_timeout) | ||
35 | ) | ||
36 | |||
37 | NL_PACKET(detach, 4, | ||
38 | NL_BIT( 88, T_MANDATORY, detach_force) | ||
39 | ) | ||
40 | |||
41 | NL_PACKET(net_conf, 5, | ||
42 | NL_STRING( 8, T_MANDATORY, my_addr, 128) | ||
43 | NL_STRING( 9, T_MANDATORY, peer_addr, 128) | ||
44 | NL_STRING( 10, T_MAY_IGNORE, shared_secret, SHARED_SECRET_MAX) | ||
45 | NL_STRING( 11, T_MAY_IGNORE, cram_hmac_alg, SHARED_SECRET_MAX) | ||
46 | NL_STRING( 44, T_MAY_IGNORE, integrity_alg, SHARED_SECRET_MAX) | ||
47 | NL_INTEGER( 14, T_MAY_IGNORE, timeout) | ||
48 | NL_INTEGER( 15, T_MANDATORY, wire_protocol) | ||
49 | NL_INTEGER( 16, T_MAY_IGNORE, try_connect_int) | ||
50 | NL_INTEGER( 17, T_MAY_IGNORE, ping_int) | ||
51 | NL_INTEGER( 18, T_MAY_IGNORE, max_epoch_size) | ||
52 | NL_INTEGER( 19, T_MAY_IGNORE, max_buffers) | ||
53 | NL_INTEGER( 20, T_MAY_IGNORE, unplug_watermark) | ||
54 | NL_INTEGER( 21, T_MAY_IGNORE, sndbuf_size) | ||
55 | NL_INTEGER( 22, T_MAY_IGNORE, ko_count) | ||
56 | NL_INTEGER( 24, T_MAY_IGNORE, after_sb_0p) | ||
57 | NL_INTEGER( 25, T_MAY_IGNORE, after_sb_1p) | ||
58 | NL_INTEGER( 26, T_MAY_IGNORE, after_sb_2p) | ||
59 | NL_INTEGER( 39, T_MAY_IGNORE, rr_conflict) | ||
60 | NL_INTEGER( 40, T_MAY_IGNORE, ping_timeo) | ||
61 | NL_INTEGER( 67, T_MAY_IGNORE, rcvbuf_size) | ||
62 | NL_INTEGER( 81, T_MAY_IGNORE, on_congestion) | ||
63 | NL_INTEGER( 82, T_MAY_IGNORE, cong_fill) | ||
64 | NL_INTEGER( 83, T_MAY_IGNORE, cong_extents) | ||
65 | /* 59 addr_family was available in GIT, never released */ | ||
66 | NL_BIT( 60, T_MANDATORY, mind_af) | ||
67 | NL_BIT( 27, T_MAY_IGNORE, want_lose) | ||
68 | NL_BIT( 28, T_MAY_IGNORE, two_primaries) | ||
69 | NL_BIT( 41, T_MAY_IGNORE, always_asbp) | ||
70 | NL_BIT( 61, T_MAY_IGNORE, no_cork) | ||
71 | NL_BIT( 62, T_MANDATORY, auto_sndbuf_size) | ||
72 | NL_BIT( 70, T_MANDATORY, dry_run) | ||
73 | ) | ||
74 | |||
75 | NL_PACKET(disconnect, 6, | ||
76 | NL_BIT( 84, T_MAY_IGNORE, force) | ||
77 | ) | ||
78 | |||
79 | NL_PACKET(resize, 7, | ||
80 | NL_INT64( 29, T_MAY_IGNORE, resize_size) | ||
81 | NL_BIT( 68, T_MAY_IGNORE, resize_force) | ||
82 | NL_BIT( 69, T_MANDATORY, no_resync) | ||
83 | ) | ||
84 | |||
85 | NL_PACKET(syncer_conf, 8, | ||
86 | NL_INTEGER( 30, T_MAY_IGNORE, rate) | ||
87 | NL_INTEGER( 31, T_MAY_IGNORE, after) | ||
88 | NL_INTEGER( 32, T_MAY_IGNORE, al_extents) | ||
89 | /* NL_INTEGER( 71, T_MAY_IGNORE, dp_volume) | ||
90 | * NL_INTEGER( 72, T_MAY_IGNORE, dp_interval) | ||
91 | * NL_INTEGER( 73, T_MAY_IGNORE, throttle_th) | ||
92 | * NL_INTEGER( 74, T_MAY_IGNORE, hold_off_th) | ||
93 | * feature will be reimplemented differently with 8.3.9 */ | ||
94 | NL_STRING( 52, T_MAY_IGNORE, verify_alg, SHARED_SECRET_MAX) | ||
95 | NL_STRING( 51, T_MAY_IGNORE, cpu_mask, 32) | ||
96 | NL_STRING( 64, T_MAY_IGNORE, csums_alg, SHARED_SECRET_MAX) | ||
97 | NL_BIT( 65, T_MAY_IGNORE, use_rle) | ||
98 | NL_INTEGER( 75, T_MAY_IGNORE, on_no_data) | ||
99 | NL_INTEGER( 76, T_MAY_IGNORE, c_plan_ahead) | ||
100 | NL_INTEGER( 77, T_MAY_IGNORE, c_delay_target) | ||
101 | NL_INTEGER( 78, T_MAY_IGNORE, c_fill_target) | ||
102 | NL_INTEGER( 79, T_MAY_IGNORE, c_max_rate) | ||
103 | NL_INTEGER( 80, T_MAY_IGNORE, c_min_rate) | ||
104 | ) | ||
105 | |||
106 | NL_PACKET(invalidate, 9, ) | ||
107 | NL_PACKET(invalidate_peer, 10, ) | ||
108 | NL_PACKET(pause_sync, 11, ) | ||
109 | NL_PACKET(resume_sync, 12, ) | ||
110 | NL_PACKET(suspend_io, 13, ) | ||
111 | NL_PACKET(resume_io, 14, ) | ||
112 | NL_PACKET(outdate, 15, ) | ||
113 | NL_PACKET(get_config, 16, ) | ||
114 | NL_PACKET(get_state, 17, | ||
115 | NL_INTEGER( 33, T_MAY_IGNORE, state_i) | ||
116 | ) | ||
117 | |||
118 | NL_PACKET(get_uuids, 18, | ||
119 | NL_STRING( 34, T_MAY_IGNORE, uuids, (UI_SIZE*sizeof(__u64))) | ||
120 | NL_INTEGER( 35, T_MAY_IGNORE, uuids_flags) | ||
121 | ) | ||
122 | |||
123 | NL_PACKET(get_timeout_flag, 19, | ||
124 | NL_BIT( 36, T_MAY_IGNORE, use_degraded) | ||
125 | ) | ||
126 | |||
127 | NL_PACKET(call_helper, 20, | ||
128 | NL_STRING( 38, T_MAY_IGNORE, helper, 32) | ||
129 | ) | ||
130 | |||
131 | /* Tag nr 42 already allocated in drbd-8.1 development. */ | ||
132 | |||
133 | NL_PACKET(sync_progress, 23, | ||
134 | NL_INTEGER( 43, T_MAY_IGNORE, sync_progress) | ||
135 | ) | ||
136 | |||
137 | NL_PACKET(dump_ee, 24, | ||
138 | NL_STRING( 45, T_MAY_IGNORE, dump_ee_reason, 32) | ||
139 | NL_STRING( 46, T_MAY_IGNORE, seen_digest, SHARED_SECRET_MAX) | ||
140 | NL_STRING( 47, T_MAY_IGNORE, calc_digest, SHARED_SECRET_MAX) | ||
141 | NL_INT64( 48, T_MAY_IGNORE, ee_sector) | ||
142 | NL_INT64( 49, T_MAY_IGNORE, ee_block_id) | ||
143 | NL_STRING( 50, T_MAY_IGNORE, ee_data, 32 << 10) | ||
144 | ) | ||
145 | |||
146 | NL_PACKET(start_ov, 25, | ||
147 | NL_INT64( 66, T_MAY_IGNORE, start_sector) | ||
148 | ) | ||
149 | |||
150 | NL_PACKET(new_c_uuid, 26, | ||
151 | NL_BIT( 63, T_MANDATORY, clear_bm) | ||
152 | ) | ||
153 | |||
154 | #ifdef NL_RESPONSE | ||
155 | NL_RESPONSE(return_code_only, 27) | ||
156 | #endif | ||
157 | |||
158 | #undef NL_PACKET | ||
159 | #undef NL_INTEGER | ||
160 | #undef NL_INT64 | ||
161 | #undef NL_BIT | ||
162 | #undef NL_STRING | ||
163 | #undef NL_RESPONSE | ||
diff --git a/include/linux/drbd_tag_magic.h b/include/linux/drbd_tag_magic.h deleted file mode 100644 index 82de1f9e48b1..000000000000 --- a/include/linux/drbd_tag_magic.h +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | #ifndef DRBD_TAG_MAGIC_H | ||
2 | #define DRBD_TAG_MAGIC_H | ||
3 | |||
4 | #define TT_END 0 | ||
5 | #define TT_REMOVED 0xE000 | ||
6 | |||
7 | /* declare packet_type enums */ | ||
8 | enum packet_types { | ||
9 | #define NL_PACKET(name, number, fields) P_ ## name = number, | ||
10 | #define NL_RESPONSE(name, number) P_ ## name = number, | ||
11 | #define NL_INTEGER(pn, pr, member) | ||
12 | #define NL_INT64(pn, pr, member) | ||
13 | #define NL_BIT(pn, pr, member) | ||
14 | #define NL_STRING(pn, pr, member, len) | ||
15 | #include <linux/drbd_nl.h> | ||
16 | P_nl_after_last_packet, | ||
17 | }; | ||
18 | |||
19 | /* These struct are used to deduce the size of the tag lists: */ | ||
20 | #define NL_PACKET(name, number, fields) \ | ||
21 | struct name ## _tag_len_struct { fields }; | ||
22 | #define NL_INTEGER(pn, pr, member) \ | ||
23 | int member; int tag_and_len ## member; | ||
24 | #define NL_INT64(pn, pr, member) \ | ||
25 | __u64 member; int tag_and_len ## member; | ||
26 | #define NL_BIT(pn, pr, member) \ | ||
27 | unsigned char member:1; int tag_and_len ## member; | ||
28 | #define NL_STRING(pn, pr, member, len) \ | ||
29 | unsigned char member[len]; int member ## _len; \ | ||
30 | int tag_and_len ## member; | ||
31 | #include <linux/drbd_nl.h> | ||
32 | |||
33 | /* declare tag-list-sizes */ | ||
34 | static const int tag_list_sizes[] = { | ||
35 | #define NL_PACKET(name, number, fields) 2 fields , | ||
36 | #define NL_INTEGER(pn, pr, member) + 4 + 4 | ||
37 | #define NL_INT64(pn, pr, member) + 4 + 8 | ||
38 | #define NL_BIT(pn, pr, member) + 4 + 1 | ||
39 | #define NL_STRING(pn, pr, member, len) + 4 + (len) | ||
40 | #include <linux/drbd_nl.h> | ||
41 | }; | ||
42 | |||
43 | /* The two highest bits are used for the tag type */ | ||
44 | #define TT_MASK 0xC000 | ||
45 | #define TT_INTEGER 0x0000 | ||
46 | #define TT_INT64 0x4000 | ||
47 | #define TT_BIT 0x8000 | ||
48 | #define TT_STRING 0xC000 | ||
49 | /* The next bit indicates if processing of the tag is mandatory */ | ||
50 | #define T_MANDATORY 0x2000 | ||
51 | #define T_MAY_IGNORE 0x0000 | ||
52 | #define TN_MASK 0x1fff | ||
53 | /* The remaining 13 bits are used to enumerate the tags */ | ||
54 | |||
55 | #define tag_type(T) ((T) & TT_MASK) | ||
56 | #define tag_number(T) ((T) & TN_MASK) | ||
57 | |||
58 | /* declare tag enums */ | ||
59 | #define NL_PACKET(name, number, fields) fields | ||
60 | enum drbd_tags { | ||
61 | #define NL_INTEGER(pn, pr, member) T_ ## member = pn | TT_INTEGER | pr , | ||
62 | #define NL_INT64(pn, pr, member) T_ ## member = pn | TT_INT64 | pr , | ||
63 | #define NL_BIT(pn, pr, member) T_ ## member = pn | TT_BIT | pr , | ||
64 | #define NL_STRING(pn, pr, member, len) T_ ## member = pn | TT_STRING | pr , | ||
65 | #include <linux/drbd_nl.h> | ||
66 | }; | ||
67 | |||
68 | struct tag { | ||
69 | const char *name; | ||
70 | int type_n_flags; | ||
71 | int max_len; | ||
72 | }; | ||
73 | |||
74 | /* declare tag names */ | ||
75 | #define NL_PACKET(name, number, fields) fields | ||
76 | static const struct tag tag_descriptions[] = { | ||
77 | #define NL_INTEGER(pn, pr, member) [ pn ] = { #member, TT_INTEGER | pr, sizeof(int) }, | ||
78 | #define NL_INT64(pn, pr, member) [ pn ] = { #member, TT_INT64 | pr, sizeof(__u64) }, | ||
79 | #define NL_BIT(pn, pr, member) [ pn ] = { #member, TT_BIT | pr, sizeof(int) }, | ||
80 | #define NL_STRING(pn, pr, member, len) [ pn ] = { #member, TT_STRING | pr, (len) }, | ||
81 | #include <linux/drbd_nl.h> | ||
82 | }; | ||
83 | |||
84 | #endif | ||
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 4f440b3e89fe..79b8bba19363 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -88,10 +88,14 @@ struct disk_stats { | |||
88 | }; | 88 | }; |
89 | 89 | ||
90 | #define PARTITION_META_INFO_VOLNAMELTH 64 | 90 | #define PARTITION_META_INFO_VOLNAMELTH 64 |
91 | #define PARTITION_META_INFO_UUIDLTH 16 | 91 | /* |
92 | * Enough for the string representation of any kind of UUID plus NULL. | ||
93 | * EFI UUID is 36 characters. MSDOS UUID is 11 characters. | ||
94 | */ | ||
95 | #define PARTITION_META_INFO_UUIDLTH 37 | ||
92 | 96 | ||
93 | struct partition_meta_info { | 97 | struct partition_meta_info { |
94 | u8 uuid[PARTITION_META_INFO_UUIDLTH]; /* always big endian */ | 98 | char uuid[PARTITION_META_INFO_UUIDLTH]; |
95 | u8 volname[PARTITION_META_INFO_VOLNAMELTH]; | 99 | u8 volname[PARTITION_META_INFO_VOLNAMELTH]; |
96 | }; | 100 | }; |
97 | 101 | ||
diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h new file mode 100644 index 000000000000..023bc346b877 --- /dev/null +++ b/include/linux/genl_magic_func.h | |||
@@ -0,0 +1,422 @@ | |||
1 | #ifndef GENL_MAGIC_FUNC_H | ||
2 | #define GENL_MAGIC_FUNC_H | ||
3 | |||
4 | #include <linux/genl_magic_struct.h> | ||
5 | |||
6 | /* | ||
7 | * Magic: declare tla policy {{{1 | ||
8 | * Magic: declare nested policies | ||
9 | * {{{2 | ||
10 | */ | ||
11 | #undef GENL_mc_group | ||
12 | #define GENL_mc_group(group) | ||
13 | |||
14 | #undef GENL_notification | ||
15 | #define GENL_notification(op_name, op_num, mcast_group, tla_list) | ||
16 | |||
17 | #undef GENL_op | ||
18 | #define GENL_op(op_name, op_num, handler, tla_list) | ||
19 | |||
20 | #undef GENL_struct | ||
21 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
22 | [tag_name] = { .type = NLA_NESTED }, | ||
23 | |||
24 | static struct nla_policy CONCAT_(GENL_MAGIC_FAMILY, _tla_nl_policy)[] = { | ||
25 | #include GENL_MAGIC_INCLUDE_FILE | ||
26 | }; | ||
27 | |||
28 | #undef GENL_struct | ||
29 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
30 | static struct nla_policy s_name ## _nl_policy[] __read_mostly = \ | ||
31 | { s_fields }; | ||
32 | |||
33 | #undef __field | ||
34 | #define __field(attr_nr, attr_flag, name, nla_type, _type, __get, \ | ||
35 | __put, __is_signed) \ | ||
36 | [attr_nr] = { .type = nla_type }, | ||
37 | |||
38 | #undef __array | ||
39 | #define __array(attr_nr, attr_flag, name, nla_type, _type, maxlen, \ | ||
40 | __get, __put, __is_signed) \ | ||
41 | [attr_nr] = { .type = nla_type, \ | ||
42 | .len = maxlen - (nla_type == NLA_NUL_STRING) }, | ||
43 | |||
44 | #include GENL_MAGIC_INCLUDE_FILE | ||
45 | |||
46 | #ifndef __KERNEL__ | ||
47 | #ifndef pr_info | ||
48 | #define pr_info(args...) fprintf(stderr, args); | ||
49 | #endif | ||
50 | #endif | ||
51 | |||
52 | #ifdef GENL_MAGIC_DEBUG | ||
53 | static void dprint_field(const char *dir, int nla_type, | ||
54 | const char *name, void *valp) | ||
55 | { | ||
56 | __u64 val = valp ? *(__u32 *)valp : 1; | ||
57 | switch (nla_type) { | ||
58 | case NLA_U8: val = (__u8)val; | ||
59 | case NLA_U16: val = (__u16)val; | ||
60 | case NLA_U32: val = (__u32)val; | ||
61 | pr_info("%s attr %s: %d 0x%08x\n", dir, | ||
62 | name, (int)val, (unsigned)val); | ||
63 | break; | ||
64 | case NLA_U64: | ||
65 | val = *(__u64*)valp; | ||
66 | pr_info("%s attr %s: %lld 0x%08llx\n", dir, | ||
67 | name, (long long)val, (unsigned long long)val); | ||
68 | break; | ||
69 | case NLA_FLAG: | ||
70 | if (val) | ||
71 | pr_info("%s attr %s: set\n", dir, name); | ||
72 | break; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | static void dprint_array(const char *dir, int nla_type, | ||
77 | const char *name, const char *val, unsigned len) | ||
78 | { | ||
79 | switch (nla_type) { | ||
80 | case NLA_NUL_STRING: | ||
81 | if (len && val[len-1] == '\0') | ||
82 | len--; | ||
83 | pr_info("%s attr %s: [len:%u] '%s'\n", dir, name, len, val); | ||
84 | break; | ||
85 | default: | ||
86 | /* we can always show 4 byte, | ||
87 | * thats what nlattr are aligned to. */ | ||
88 | pr_info("%s attr %s: [len:%u] %02x%02x%02x%02x ...\n", | ||
89 | dir, name, len, val[0], val[1], val[2], val[3]); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | #define DPRINT_TLA(a, op, b) pr_info("%s %s %s\n", a, op, b); | ||
94 | |||
95 | /* Name is a member field name of the struct s. | ||
96 | * If s is NULL (only parsing, no copy requested in *_from_attrs()), | ||
97 | * nla is supposed to point to the attribute containing the information | ||
98 | * corresponding to that struct member. */ | ||
99 | #define DPRINT_FIELD(dir, nla_type, name, s, nla) \ | ||
100 | do { \ | ||
101 | if (s) \ | ||
102 | dprint_field(dir, nla_type, #name, &s->name); \ | ||
103 | else if (nla) \ | ||
104 | dprint_field(dir, nla_type, #name, \ | ||
105 | (nla_type == NLA_FLAG) ? NULL \ | ||
106 | : nla_data(nla)); \ | ||
107 | } while (0) | ||
108 | |||
109 | #define DPRINT_ARRAY(dir, nla_type, name, s, nla) \ | ||
110 | do { \ | ||
111 | if (s) \ | ||
112 | dprint_array(dir, nla_type, #name, \ | ||
113 | s->name, s->name ## _len); \ | ||
114 | else if (nla) \ | ||
115 | dprint_array(dir, nla_type, #name, \ | ||
116 | nla_data(nla), nla_len(nla)); \ | ||
117 | } while (0) | ||
118 | #else | ||
119 | #define DPRINT_TLA(a, op, b) do {} while (0) | ||
120 | #define DPRINT_FIELD(dir, nla_type, name, s, nla) do {} while (0) | ||
121 | #define DPRINT_ARRAY(dir, nla_type, name, s, nla) do {} while (0) | ||
122 | #endif | ||
123 | |||
124 | /* | ||
125 | * Magic: provide conversion functions {{{1 | ||
126 | * populate struct from attribute table: | ||
127 | * {{{2 | ||
128 | */ | ||
129 | |||
130 | /* processing of generic netlink messages is serialized. | ||
131 | * use one static buffer for parsing of nested attributes */ | ||
132 | static struct nlattr *nested_attr_tb[128]; | ||
133 | |||
134 | #ifndef BUILD_BUG_ON | ||
135 | /* Force a compilation error if condition is true */ | ||
136 | #define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition)) | ||
137 | /* Force a compilation error if condition is true, but also produce a | ||
138 | result (of value 0 and type size_t), so the expression can be used | ||
139 | e.g. in a structure initializer (or where-ever else comma expressions | ||
140 | aren't permitted). */ | ||
141 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) | ||
142 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) | ||
143 | #endif | ||
144 | |||
145 | #undef GENL_struct | ||
146 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
147 | /* *_from_attrs functions are static, but potentially unused */ \ | ||
148 | static int __ ## s_name ## _from_attrs(struct s_name *s, \ | ||
149 | struct genl_info *info, bool exclude_invariants) \ | ||
150 | { \ | ||
151 | const int maxtype = ARRAY_SIZE(s_name ## _nl_policy)-1; \ | ||
152 | struct nlattr *tla = info->attrs[tag_number]; \ | ||
153 | struct nlattr **ntb = nested_attr_tb; \ | ||
154 | struct nlattr *nla; \ | ||
155 | int err; \ | ||
156 | BUILD_BUG_ON(ARRAY_SIZE(s_name ## _nl_policy) > ARRAY_SIZE(nested_attr_tb)); \ | ||
157 | if (!tla) \ | ||
158 | return -ENOMSG; \ | ||
159 | DPRINT_TLA(#s_name, "<=-", #tag_name); \ | ||
160 | err = drbd_nla_parse_nested(ntb, maxtype, tla, s_name ## _nl_policy); \ | ||
161 | if (err) \ | ||
162 | return err; \ | ||
163 | \ | ||
164 | s_fields \ | ||
165 | return 0; \ | ||
166 | } __attribute__((unused)) \ | ||
167 | static int s_name ## _from_attrs(struct s_name *s, \ | ||
168 | struct genl_info *info) \ | ||
169 | { \ | ||
170 | return __ ## s_name ## _from_attrs(s, info, false); \ | ||
171 | } __attribute__((unused)) \ | ||
172 | static int s_name ## _from_attrs_for_change(struct s_name *s, \ | ||
173 | struct genl_info *info) \ | ||
174 | { \ | ||
175 | return __ ## s_name ## _from_attrs(s, info, true); \ | ||
176 | } __attribute__((unused)) \ | ||
177 | |||
178 | #define __assign(attr_nr, attr_flag, name, nla_type, type, assignment...) \ | ||
179 | nla = ntb[attr_nr]; \ | ||
180 | if (nla) { \ | ||
181 | if (exclude_invariants && ((attr_flag) & DRBD_F_INVARIANT)) { \ | ||
182 | pr_info("<< must not change invariant attr: %s\n", #name); \ | ||
183 | return -EEXIST; \ | ||
184 | } \ | ||
185 | assignment; \ | ||
186 | } else if (exclude_invariants && ((attr_flag) & DRBD_F_INVARIANT)) { \ | ||
187 | /* attribute missing from payload, */ \ | ||
188 | /* which was expected */ \ | ||
189 | } else if ((attr_flag) & DRBD_F_REQUIRED) { \ | ||
190 | pr_info("<< missing attr: %s\n", #name); \ | ||
191 | return -ENOMSG; \ | ||
192 | } | ||
193 | |||
194 | #undef __field | ||
195 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \ | ||
196 | __is_signed) \ | ||
197 | __assign(attr_nr, attr_flag, name, nla_type, type, \ | ||
198 | if (s) \ | ||
199 | s->name = __get(nla); \ | ||
200 | DPRINT_FIELD("<<", nla_type, name, s, nla)) | ||
201 | |||
202 | /* validate_nla() already checked nla_len <= maxlen appropriately. */ | ||
203 | #undef __array | ||
204 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \ | ||
205 | __get, __put, __is_signed) \ | ||
206 | __assign(attr_nr, attr_flag, name, nla_type, type, \ | ||
207 | if (s) \ | ||
208 | s->name ## _len = \ | ||
209 | __get(s->name, nla, maxlen); \ | ||
210 | DPRINT_ARRAY("<<", nla_type, name, s, nla)) | ||
211 | |||
212 | #include GENL_MAGIC_INCLUDE_FILE | ||
213 | |||
214 | #undef GENL_struct | ||
215 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) | ||
216 | |||
217 | /* | ||
218 | * Magic: define op number to op name mapping {{{1 | ||
219 | * {{{2 | ||
220 | */ | ||
221 | const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd) | ||
222 | { | ||
223 | switch (cmd) { | ||
224 | #undef GENL_op | ||
225 | #define GENL_op(op_name, op_num, handler, tla_list) \ | ||
226 | case op_num: return #op_name; | ||
227 | #include GENL_MAGIC_INCLUDE_FILE | ||
228 | default: | ||
229 | return "unknown"; | ||
230 | } | ||
231 | } | ||
232 | |||
233 | #ifdef __KERNEL__ | ||
234 | #include <linux/stringify.h> | ||
235 | /* | ||
236 | * Magic: define genl_ops {{{1 | ||
237 | * {{{2 | ||
238 | */ | ||
239 | |||
240 | #undef GENL_op | ||
241 | #define GENL_op(op_name, op_num, handler, tla_list) \ | ||
242 | { \ | ||
243 | handler \ | ||
244 | .cmd = op_name, \ | ||
245 | .policy = CONCAT_(GENL_MAGIC_FAMILY, _tla_nl_policy), \ | ||
246 | }, | ||
247 | |||
248 | #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops) | ||
249 | static struct genl_ops ZZZ_genl_ops[] __read_mostly = { | ||
250 | #include GENL_MAGIC_INCLUDE_FILE | ||
251 | }; | ||
252 | |||
253 | #undef GENL_op | ||
254 | #define GENL_op(op_name, op_num, handler, tla_list) | ||
255 | |||
256 | /* | ||
257 | * Define the genl_family, multicast groups, {{{1 | ||
258 | * and provide register/unregister functions. | ||
259 | * {{{2 | ||
260 | */ | ||
261 | #define ZZZ_genl_family CONCAT_(GENL_MAGIC_FAMILY, _genl_family) | ||
262 | static struct genl_family ZZZ_genl_family __read_mostly = { | ||
263 | .id = GENL_ID_GENERATE, | ||
264 | .name = __stringify(GENL_MAGIC_FAMILY), | ||
265 | .version = GENL_MAGIC_VERSION, | ||
266 | #ifdef GENL_MAGIC_FAMILY_HDRSZ | ||
267 | .hdrsize = NLA_ALIGN(GENL_MAGIC_FAMILY_HDRSZ), | ||
268 | #endif | ||
269 | .maxattr = ARRAY_SIZE(drbd_tla_nl_policy)-1, | ||
270 | }; | ||
271 | |||
272 | /* | ||
273 | * Magic: define multicast groups | ||
274 | * Magic: define multicast group registration helper | ||
275 | */ | ||
276 | #undef GENL_mc_group | ||
277 | #define GENL_mc_group(group) \ | ||
278 | static struct genl_multicast_group \ | ||
279 | CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group) __read_mostly = { \ | ||
280 | .name = #group, \ | ||
281 | }; \ | ||
282 | static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \ | ||
283 | struct sk_buff *skb, gfp_t flags) \ | ||
284 | { \ | ||
285 | unsigned int group_id = \ | ||
286 | CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group).id; \ | ||
287 | if (!group_id) \ | ||
288 | return -EINVAL; \ | ||
289 | return genlmsg_multicast(skb, 0, group_id, flags); \ | ||
290 | } | ||
291 | |||
292 | #include GENL_MAGIC_INCLUDE_FILE | ||
293 | |||
294 | int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void) | ||
295 | { | ||
296 | int err = genl_register_family_with_ops(&ZZZ_genl_family, | ||
297 | ZZZ_genl_ops, ARRAY_SIZE(ZZZ_genl_ops)); | ||
298 | if (err) | ||
299 | return err; | ||
300 | #undef GENL_mc_group | ||
301 | #define GENL_mc_group(group) \ | ||
302 | err = genl_register_mc_group(&ZZZ_genl_family, \ | ||
303 | &CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group)); \ | ||
304 | if (err) \ | ||
305 | goto fail; \ | ||
306 | else \ | ||
307 | pr_info("%s: mcg %s: %u\n", #group, \ | ||
308 | __stringify(GENL_MAGIC_FAMILY), \ | ||
309 | CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group).id); | ||
310 | |||
311 | #include GENL_MAGIC_INCLUDE_FILE | ||
312 | |||
313 | #undef GENL_mc_group | ||
314 | #define GENL_mc_group(group) | ||
315 | return 0; | ||
316 | fail: | ||
317 | genl_unregister_family(&ZZZ_genl_family); | ||
318 | return err; | ||
319 | } | ||
320 | |||
321 | void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void) | ||
322 | { | ||
323 | genl_unregister_family(&ZZZ_genl_family); | ||
324 | } | ||
325 | |||
326 | /* | ||
327 | * Magic: provide conversion functions {{{1 | ||
328 | * populate skb from struct. | ||
329 | * {{{2 | ||
330 | */ | ||
331 | |||
332 | #undef GENL_op | ||
333 | #define GENL_op(op_name, op_num, handler, tla_list) | ||
334 | |||
335 | #undef GENL_struct | ||
336 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
337 | static int s_name ## _to_skb(struct sk_buff *skb, struct s_name *s, \ | ||
338 | const bool exclude_sensitive) \ | ||
339 | { \ | ||
340 | struct nlattr *tla = nla_nest_start(skb, tag_number); \ | ||
341 | if (!tla) \ | ||
342 | goto nla_put_failure; \ | ||
343 | DPRINT_TLA(#s_name, "-=>", #tag_name); \ | ||
344 | s_fields \ | ||
345 | nla_nest_end(skb, tla); \ | ||
346 | return 0; \ | ||
347 | \ | ||
348 | nla_put_failure: \ | ||
349 | if (tla) \ | ||
350 | nla_nest_cancel(skb, tla); \ | ||
351 | return -EMSGSIZE; \ | ||
352 | } \ | ||
353 | static inline int s_name ## _to_priv_skb(struct sk_buff *skb, \ | ||
354 | struct s_name *s) \ | ||
355 | { \ | ||
356 | return s_name ## _to_skb(skb, s, 0); \ | ||
357 | } \ | ||
358 | static inline int s_name ## _to_unpriv_skb(struct sk_buff *skb, \ | ||
359 | struct s_name *s) \ | ||
360 | { \ | ||
361 | return s_name ## _to_skb(skb, s, 1); \ | ||
362 | } | ||
363 | |||
364 | |||
365 | #undef __field | ||
366 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \ | ||
367 | __is_signed) \ | ||
368 | if (!exclude_sensitive || !((attr_flag) & DRBD_F_SENSITIVE)) { \ | ||
369 | DPRINT_FIELD(">>", nla_type, name, s, NULL); \ | ||
370 | if (__put(skb, attr_nr, s->name)) \ | ||
371 | goto nla_put_failure; \ | ||
372 | } | ||
373 | |||
374 | #undef __array | ||
375 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \ | ||
376 | __get, __put, __is_signed) \ | ||
377 | if (!exclude_sensitive || !((attr_flag) & DRBD_F_SENSITIVE)) { \ | ||
378 | DPRINT_ARRAY(">>",nla_type, name, s, NULL); \ | ||
379 | if (__put(skb, attr_nr, min_t(int, maxlen, \ | ||
380 | s->name ## _len + (nla_type == NLA_NUL_STRING)),\ | ||
381 | s->name)) \ | ||
382 | goto nla_put_failure; \ | ||
383 | } | ||
384 | |||
385 | #include GENL_MAGIC_INCLUDE_FILE | ||
386 | |||
387 | |||
388 | /* Functions for initializing structs to default values. */ | ||
389 | |||
390 | #undef __field | ||
391 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \ | ||
392 | __is_signed) | ||
393 | #undef __array | ||
394 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \ | ||
395 | __get, __put, __is_signed) | ||
396 | #undef __u32_field_def | ||
397 | #define __u32_field_def(attr_nr, attr_flag, name, default) \ | ||
398 | x->name = default; | ||
399 | #undef __s32_field_def | ||
400 | #define __s32_field_def(attr_nr, attr_flag, name, default) \ | ||
401 | x->name = default; | ||
402 | #undef __flg_field_def | ||
403 | #define __flg_field_def(attr_nr, attr_flag, name, default) \ | ||
404 | x->name = default; | ||
405 | #undef __str_field_def | ||
406 | #define __str_field_def(attr_nr, attr_flag, name, maxlen) \ | ||
407 | memset(x->name, 0, sizeof(x->name)); \ | ||
408 | x->name ## _len = 0; | ||
409 | #undef GENL_struct | ||
410 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
411 | static void set_ ## s_name ## _defaults(struct s_name *x) __attribute__((unused)); \ | ||
412 | static void set_ ## s_name ## _defaults(struct s_name *x) { \ | ||
413 | s_fields \ | ||
414 | } | ||
415 | |||
416 | #include GENL_MAGIC_INCLUDE_FILE | ||
417 | |||
418 | #endif /* __KERNEL__ */ | ||
419 | |||
420 | /* }}}1 */ | ||
421 | #endif /* GENL_MAGIC_FUNC_H */ | ||
422 | /* vim: set foldmethod=marker foldlevel=1 nofoldenable : */ | ||
diff --git a/include/linux/genl_magic_struct.h b/include/linux/genl_magic_struct.h new file mode 100644 index 000000000000..eecd19b37001 --- /dev/null +++ b/include/linux/genl_magic_struct.h | |||
@@ -0,0 +1,277 @@ | |||
1 | #ifndef GENL_MAGIC_STRUCT_H | ||
2 | #define GENL_MAGIC_STRUCT_H | ||
3 | |||
4 | #ifndef GENL_MAGIC_FAMILY | ||
5 | # error "you need to define GENL_MAGIC_FAMILY before inclusion" | ||
6 | #endif | ||
7 | |||
8 | #ifndef GENL_MAGIC_VERSION | ||
9 | # error "you need to define GENL_MAGIC_VERSION before inclusion" | ||
10 | #endif | ||
11 | |||
12 | #ifndef GENL_MAGIC_INCLUDE_FILE | ||
13 | # error "you need to define GENL_MAGIC_INCLUDE_FILE before inclusion" | ||
14 | #endif | ||
15 | |||
16 | #include <linux/genetlink.h> | ||
17 | #include <linux/types.h> | ||
18 | |||
19 | #define CONCAT__(a,b) a ## b | ||
20 | #define CONCAT_(a,b) CONCAT__(a,b) | ||
21 | |||
22 | extern int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void); | ||
23 | extern void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void); | ||
24 | |||
25 | /* | ||
26 | * Extension of genl attribute validation policies {{{2 | ||
27 | */ | ||
28 | |||
29 | /* | ||
30 | * @DRBD_GENLA_F_MANDATORY: By default, netlink ignores attributes it does not | ||
31 | * know about. This flag can be set in nlattr->nla_type to indicate that this | ||
32 | * attribute must not be ignored. | ||
33 | * | ||
34 | * We check and remove this flag in drbd_nla_check_mandatory() before | ||
35 | * validating the attribute types and lengths via nla_parse_nested(). | ||
36 | */ | ||
37 | #define DRBD_GENLA_F_MANDATORY (1 << 14) | ||
38 | |||
39 | /* | ||
40 | * Flags specific to drbd and not visible at the netlink layer, used in | ||
41 | * <struct>_from_attrs and <struct>_to_skb: | ||
42 | * | ||
43 | * @DRBD_F_REQUIRED: Attribute is required; a request without this attribute is | ||
44 | * invalid. | ||
45 | * | ||
46 | * @DRBD_F_SENSITIVE: Attribute includes sensitive information and must not be | ||
47 | * included in unpriviledged get requests or broadcasts. | ||
48 | * | ||
49 | * @DRBD_F_INVARIANT: Attribute is set when an object is initially created, but | ||
50 | * cannot subsequently be changed. | ||
51 | */ | ||
52 | #define DRBD_F_REQUIRED (1 << 0) | ||
53 | #define DRBD_F_SENSITIVE (1 << 1) | ||
54 | #define DRBD_F_INVARIANT (1 << 2) | ||
55 | |||
56 | #define __nla_type(x) ((__u16)((x) & NLA_TYPE_MASK & ~DRBD_GENLA_F_MANDATORY)) | ||
57 | |||
58 | /* }}}1 | ||
59 | * MAGIC | ||
60 | * multi-include macro expansion magic starts here | ||
61 | */ | ||
62 | |||
63 | /* MAGIC helpers {{{2 */ | ||
64 | |||
65 | /* possible field types */ | ||
66 | #define __flg_field(attr_nr, attr_flag, name) \ | ||
67 | __field(attr_nr, attr_flag, name, NLA_U8, char, \ | ||
68 | nla_get_u8, nla_put_u8, false) | ||
69 | #define __u8_field(attr_nr, attr_flag, name) \ | ||
70 | __field(attr_nr, attr_flag, name, NLA_U8, unsigned char, \ | ||
71 | nla_get_u8, nla_put_u8, false) | ||
72 | #define __u16_field(attr_nr, attr_flag, name) \ | ||
73 | __field(attr_nr, attr_flag, name, NLA_U16, __u16, \ | ||
74 | nla_get_u16, nla_put_u16, false) | ||
75 | #define __u32_field(attr_nr, attr_flag, name) \ | ||
76 | __field(attr_nr, attr_flag, name, NLA_U32, __u32, \ | ||
77 | nla_get_u32, nla_put_u32, false) | ||
78 | #define __s32_field(attr_nr, attr_flag, name) \ | ||
79 | __field(attr_nr, attr_flag, name, NLA_U32, __s32, \ | ||
80 | nla_get_u32, nla_put_u32, true) | ||
81 | #define __u64_field(attr_nr, attr_flag, name) \ | ||
82 | __field(attr_nr, attr_flag, name, NLA_U64, __u64, \ | ||
83 | nla_get_u64, nla_put_u64, false) | ||
84 | #define __str_field(attr_nr, attr_flag, name, maxlen) \ | ||
85 | __array(attr_nr, attr_flag, name, NLA_NUL_STRING, char, maxlen, \ | ||
86 | nla_strlcpy, nla_put, false) | ||
87 | #define __bin_field(attr_nr, attr_flag, name, maxlen) \ | ||
88 | __array(attr_nr, attr_flag, name, NLA_BINARY, char, maxlen, \ | ||
89 | nla_memcpy, nla_put, false) | ||
90 | |||
91 | /* fields with default values */ | ||
92 | #define __flg_field_def(attr_nr, attr_flag, name, default) \ | ||
93 | __flg_field(attr_nr, attr_flag, name) | ||
94 | #define __u32_field_def(attr_nr, attr_flag, name, default) \ | ||
95 | __u32_field(attr_nr, attr_flag, name) | ||
96 | #define __s32_field_def(attr_nr, attr_flag, name, default) \ | ||
97 | __s32_field(attr_nr, attr_flag, name) | ||
98 | #define __str_field_def(attr_nr, attr_flag, name, maxlen) \ | ||
99 | __str_field(attr_nr, attr_flag, name, maxlen) | ||
100 | |||
101 | #define GENL_op_init(args...) args | ||
102 | #define GENL_doit(handler) \ | ||
103 | .doit = handler, \ | ||
104 | .flags = GENL_ADMIN_PERM, | ||
105 | #define GENL_dumpit(handler) \ | ||
106 | .dumpit = handler, \ | ||
107 | .flags = GENL_ADMIN_PERM, | ||
108 | |||
109 | /* }}}1 | ||
110 | * Magic: define the enum symbols for genl_ops | ||
111 | * Magic: define the enum symbols for top level attributes | ||
112 | * Magic: define the enum symbols for nested attributes | ||
113 | * {{{2 | ||
114 | */ | ||
115 | |||
116 | #undef GENL_struct | ||
117 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) | ||
118 | |||
119 | #undef GENL_mc_group | ||
120 | #define GENL_mc_group(group) | ||
121 | |||
122 | #undef GENL_notification | ||
123 | #define GENL_notification(op_name, op_num, mcast_group, tla_list) \ | ||
124 | op_name = op_num, | ||
125 | |||
126 | #undef GENL_op | ||
127 | #define GENL_op(op_name, op_num, handler, tla_list) \ | ||
128 | op_name = op_num, | ||
129 | |||
130 | enum { | ||
131 | #include GENL_MAGIC_INCLUDE_FILE | ||
132 | }; | ||
133 | |||
134 | #undef GENL_notification | ||
135 | #define GENL_notification(op_name, op_num, mcast_group, tla_list) | ||
136 | |||
137 | #undef GENL_op | ||
138 | #define GENL_op(op_name, op_num, handler, attr_list) | ||
139 | |||
140 | #undef GENL_struct | ||
141 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
142 | tag_name = tag_number, | ||
143 | |||
144 | enum { | ||
145 | #include GENL_MAGIC_INCLUDE_FILE | ||
146 | }; | ||
147 | |||
148 | #undef GENL_struct | ||
149 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
150 | enum { \ | ||
151 | s_fields \ | ||
152 | }; | ||
153 | |||
154 | #undef __field | ||
155 | #define __field(attr_nr, attr_flag, name, nla_type, type, \ | ||
156 | __get, __put, __is_signed) \ | ||
157 | T_ ## name = (__u16)(attr_nr | ((attr_flag) & DRBD_GENLA_F_MANDATORY)), | ||
158 | |||
159 | #undef __array | ||
160 | #define __array(attr_nr, attr_flag, name, nla_type, type, \ | ||
161 | maxlen, __get, __put, __is_signed) \ | ||
162 | T_ ## name = (__u16)(attr_nr | ((attr_flag) & DRBD_GENLA_F_MANDATORY)), | ||
163 | |||
164 | #include GENL_MAGIC_INCLUDE_FILE | ||
165 | |||
166 | /* }}}1 | ||
167 | * Magic: compile time assert unique numbers for operations | ||
168 | * Magic: -"- unique numbers for top level attributes | ||
169 | * Magic: -"- unique numbers for nested attributes | ||
170 | * {{{2 | ||
171 | */ | ||
172 | |||
173 | #undef GENL_struct | ||
174 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) | ||
175 | |||
176 | #undef GENL_op | ||
177 | #define GENL_op(op_name, op_num, handler, attr_list) \ | ||
178 | case op_name: | ||
179 | |||
180 | #undef GENL_notification | ||
181 | #define GENL_notification(op_name, op_num, mcast_group, tla_list) \ | ||
182 | case op_name: | ||
183 | |||
184 | static inline void ct_assert_unique_operations(void) | ||
185 | { | ||
186 | switch (0) { | ||
187 | #include GENL_MAGIC_INCLUDE_FILE | ||
188 | ; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | #undef GENL_op | ||
193 | #define GENL_op(op_name, op_num, handler, attr_list) | ||
194 | |||
195 | #undef GENL_notification | ||
196 | #define GENL_notification(op_name, op_num, mcast_group, tla_list) | ||
197 | |||
198 | #undef GENL_struct | ||
199 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
200 | case tag_number: | ||
201 | |||
202 | static inline void ct_assert_unique_top_level_attributes(void) | ||
203 | { | ||
204 | switch (0) { | ||
205 | #include GENL_MAGIC_INCLUDE_FILE | ||
206 | ; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | #undef GENL_struct | ||
211 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
212 | static inline void ct_assert_unique_ ## s_name ## _attributes(void) \ | ||
213 | { \ | ||
214 | switch (0) { \ | ||
215 | s_fields \ | ||
216 | ; \ | ||
217 | } \ | ||
218 | } | ||
219 | |||
220 | #undef __field | ||
221 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \ | ||
222 | __is_signed) \ | ||
223 | case attr_nr: | ||
224 | |||
225 | #undef __array | ||
226 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \ | ||
227 | __get, __put, __is_signed) \ | ||
228 | case attr_nr: | ||
229 | |||
230 | #include GENL_MAGIC_INCLUDE_FILE | ||
231 | |||
232 | /* }}}1 | ||
233 | * Magic: declare structs | ||
234 | * struct <name> { | ||
235 | * fields | ||
236 | * }; | ||
237 | * {{{2 | ||
238 | */ | ||
239 | |||
240 | #undef GENL_struct | ||
241 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
242 | struct s_name { s_fields }; | ||
243 | |||
244 | #undef __field | ||
245 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \ | ||
246 | __is_signed) \ | ||
247 | type name; | ||
248 | |||
249 | #undef __array | ||
250 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \ | ||
251 | __get, __put, __is_signed) \ | ||
252 | type name[maxlen]; \ | ||
253 | __u32 name ## _len; | ||
254 | |||
255 | #include GENL_MAGIC_INCLUDE_FILE | ||
256 | |||
257 | #undef GENL_struct | ||
258 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
259 | enum { \ | ||
260 | s_fields \ | ||
261 | }; | ||
262 | |||
263 | #undef __field | ||
264 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \ | ||
265 | is_signed) \ | ||
266 | F_ ## name ## _IS_SIGNED = is_signed, | ||
267 | |||
268 | #undef __array | ||
269 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \ | ||
270 | __get, __put, is_signed) \ | ||
271 | F_ ## name ## _IS_SIGNED = is_signed, | ||
272 | |||
273 | #include GENL_MAGIC_INCLUDE_FILE | ||
274 | |||
275 | /* }}}1 */ | ||
276 | #endif /* GENL_MAGIC_STRUCT_H */ | ||
277 | /* vim: set foldmethod=marker nofoldenable : */ | ||
diff --git a/include/linux/idr.h b/include/linux/idr.h index 87259a44c251..de7e190f1af4 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h | |||
@@ -152,4 +152,15 @@ void ida_simple_remove(struct ida *ida, unsigned int id); | |||
152 | 152 | ||
153 | void __init idr_init_cache(void); | 153 | void __init idr_init_cache(void); |
154 | 154 | ||
155 | /** | ||
156 | * idr_for_each_entry - iterate over an idr's elements of a given type | ||
157 | * @idp: idr handle | ||
158 | * @entry: the type * to use as cursor | ||
159 | * @id: id entry's key | ||
160 | */ | ||
161 | #define idr_for_each_entry(idp, entry, id) \ | ||
162 | for (id = 0, entry = (typeof(entry))idr_get_next((idp), &(id)); \ | ||
163 | entry != NULL; \ | ||
164 | ++id, entry = (typeof(entry))idr_get_next((idp), &(id))) | ||
165 | |||
155 | #endif /* __IDR_H__ */ | 166 | #endif /* __IDR_H__ */ |
diff --git a/include/linux/loop.h b/include/linux/loop.h index 6492181bcb1d..460b60fa7adf 100644 --- a/include/linux/loop.h +++ b/include/linux/loop.h | |||
@@ -53,10 +53,13 @@ struct loop_device { | |||
53 | 53 | ||
54 | spinlock_t lo_lock; | 54 | spinlock_t lo_lock; |
55 | struct bio_list lo_bio_list; | 55 | struct bio_list lo_bio_list; |
56 | unsigned int lo_bio_count; | ||
56 | int lo_state; | 57 | int lo_state; |
57 | struct mutex lo_ctl_mutex; | 58 | struct mutex lo_ctl_mutex; |
58 | struct task_struct *lo_thread; | 59 | struct task_struct *lo_thread; |
59 | wait_queue_head_t lo_event; | 60 | wait_queue_head_t lo_event; |
61 | /* wait queue for incoming requests */ | ||
62 | wait_queue_head_t lo_req_wait; | ||
60 | 63 | ||
61 | struct request_queue *lo_queue; | 64 | struct request_queue *lo_queue; |
62 | struct gendisk *lo_disk; | 65 | struct gendisk *lo_disk; |
diff --git a/include/linux/lru_cache.h b/include/linux/lru_cache.h index cafc7f99e124..4019013c6593 100644 --- a/include/linux/lru_cache.h +++ b/include/linux/lru_cache.h | |||
@@ -166,9 +166,11 @@ struct lc_element { | |||
166 | /* if we want to track a larger set of objects, | 166 | /* if we want to track a larger set of objects, |
167 | * it needs to become arch independend u64 */ | 167 | * it needs to become arch independend u64 */ |
168 | unsigned lc_number; | 168 | unsigned lc_number; |
169 | |||
170 | /* special label when on free list */ | 169 | /* special label when on free list */ |
171 | #define LC_FREE (~0U) | 170 | #define LC_FREE (~0U) |
171 | |||
172 | /* for pending changes */ | ||
173 | unsigned lc_new_number; | ||
172 | }; | 174 | }; |
173 | 175 | ||
174 | struct lru_cache { | 176 | struct lru_cache { |
@@ -176,6 +178,7 @@ struct lru_cache { | |||
176 | struct list_head lru; | 178 | struct list_head lru; |
177 | struct list_head free; | 179 | struct list_head free; |
178 | struct list_head in_use; | 180 | struct list_head in_use; |
181 | struct list_head to_be_changed; | ||
179 | 182 | ||
180 | /* the pre-created kmem cache to allocate the objects from */ | 183 | /* the pre-created kmem cache to allocate the objects from */ |
181 | struct kmem_cache *lc_cache; | 184 | struct kmem_cache *lc_cache; |
@@ -186,7 +189,7 @@ struct lru_cache { | |||
186 | size_t element_off; | 189 | size_t element_off; |
187 | 190 | ||
188 | /* number of elements (indices) */ | 191 | /* number of elements (indices) */ |
189 | unsigned int nr_elements; | 192 | unsigned int nr_elements; |
190 | /* Arbitrary limit on maximum tracked objects. Practical limit is much | 193 | /* Arbitrary limit on maximum tracked objects. Practical limit is much |
191 | * lower due to allocation failures, probably. For typical use cases, | 194 | * lower due to allocation failures, probably. For typical use cases, |
192 | * nr_elements should be a few thousand at most. | 195 | * nr_elements should be a few thousand at most. |
@@ -194,18 +197,19 @@ struct lru_cache { | |||
194 | * 8 high bits of .lc_index to be overloaded with flags in the future. */ | 197 | * 8 high bits of .lc_index to be overloaded with flags in the future. */ |
195 | #define LC_MAX_ACTIVE (1<<24) | 198 | #define LC_MAX_ACTIVE (1<<24) |
196 | 199 | ||
200 | /* allow to accumulate a few (index:label) changes, | ||
201 | * but no more than max_pending_changes */ | ||
202 | unsigned int max_pending_changes; | ||
203 | /* number of elements currently on to_be_changed list */ | ||
204 | unsigned int pending_changes; | ||
205 | |||
197 | /* statistics */ | 206 | /* statistics */ |
198 | unsigned used; /* number of lelements currently on in_use list */ | 207 | unsigned used; /* number of elements currently on in_use list */ |
199 | unsigned long hits, misses, starving, dirty, changed; | 208 | unsigned long hits, misses, starving, locked, changed; |
200 | 209 | ||
201 | /* see below: flag-bits for lru_cache */ | 210 | /* see below: flag-bits for lru_cache */ |
202 | unsigned long flags; | 211 | unsigned long flags; |
203 | 212 | ||
204 | /* when changing the label of an index element */ | ||
205 | unsigned int new_number; | ||
206 | |||
207 | /* for paranoia when changing the label of an index element */ | ||
208 | struct lc_element *changing_element; | ||
209 | 213 | ||
210 | void *lc_private; | 214 | void *lc_private; |
211 | const char *name; | 215 | const char *name; |
@@ -221,10 +225,15 @@ enum { | |||
221 | /* debugging aid, to catch concurrent access early. | 225 | /* debugging aid, to catch concurrent access early. |
222 | * user needs to guarantee exclusive access by proper locking! */ | 226 | * user needs to guarantee exclusive access by proper locking! */ |
223 | __LC_PARANOIA, | 227 | __LC_PARANOIA, |
224 | /* if we need to change the set, but currently there is a changing | 228 | |
225 | * transaction pending, we are "dirty", and must deferr further | 229 | /* annotate that the set is "dirty", possibly accumulating further |
226 | * changing requests */ | 230 | * changes, until a transaction is finally triggered */ |
227 | __LC_DIRTY, | 231 | __LC_DIRTY, |
232 | |||
233 | /* Locked, no further changes allowed. | ||
234 | * Also used to serialize changing transactions. */ | ||
235 | __LC_LOCKED, | ||
236 | |||
228 | /* if we need to change the set, but currently there is no free nor | 237 | /* if we need to change the set, but currently there is no free nor |
229 | * unused element available, we are "starving", and must not give out | 238 | * unused element available, we are "starving", and must not give out |
230 | * further references, to guarantee that eventually some refcnt will | 239 | * further references, to guarantee that eventually some refcnt will |
@@ -236,9 +245,11 @@ enum { | |||
236 | }; | 245 | }; |
237 | #define LC_PARANOIA (1<<__LC_PARANOIA) | 246 | #define LC_PARANOIA (1<<__LC_PARANOIA) |
238 | #define LC_DIRTY (1<<__LC_DIRTY) | 247 | #define LC_DIRTY (1<<__LC_DIRTY) |
248 | #define LC_LOCKED (1<<__LC_LOCKED) | ||
239 | #define LC_STARVING (1<<__LC_STARVING) | 249 | #define LC_STARVING (1<<__LC_STARVING) |
240 | 250 | ||
241 | extern struct lru_cache *lc_create(const char *name, struct kmem_cache *cache, | 251 | extern struct lru_cache *lc_create(const char *name, struct kmem_cache *cache, |
252 | unsigned max_pending_changes, | ||
242 | unsigned e_count, size_t e_size, size_t e_off); | 253 | unsigned e_count, size_t e_size, size_t e_off); |
243 | extern void lc_reset(struct lru_cache *lc); | 254 | extern void lc_reset(struct lru_cache *lc); |
244 | extern void lc_destroy(struct lru_cache *lc); | 255 | extern void lc_destroy(struct lru_cache *lc); |
@@ -249,7 +260,7 @@ extern struct lc_element *lc_try_get(struct lru_cache *lc, unsigned int enr); | |||
249 | extern struct lc_element *lc_find(struct lru_cache *lc, unsigned int enr); | 260 | extern struct lc_element *lc_find(struct lru_cache *lc, unsigned int enr); |
250 | extern struct lc_element *lc_get(struct lru_cache *lc, unsigned int enr); | 261 | extern struct lc_element *lc_get(struct lru_cache *lc, unsigned int enr); |
251 | extern unsigned int lc_put(struct lru_cache *lc, struct lc_element *e); | 262 | extern unsigned int lc_put(struct lru_cache *lc, struct lc_element *e); |
252 | extern void lc_changed(struct lru_cache *lc, struct lc_element *e); | 263 | extern void lc_committed(struct lru_cache *lc); |
253 | 264 | ||
254 | struct seq_file; | 265 | struct seq_file; |
255 | extern size_t lc_seq_printf_stats(struct seq_file *seq, struct lru_cache *lc); | 266 | extern size_t lc_seq_printf_stats(struct seq_file *seq, struct lru_cache *lc); |
@@ -258,32 +269,40 @@ extern void lc_seq_dump_details(struct seq_file *seq, struct lru_cache *lc, char | |||
258 | void (*detail) (struct seq_file *, struct lc_element *)); | 269 | void (*detail) (struct seq_file *, struct lc_element *)); |
259 | 270 | ||
260 | /** | 271 | /** |
261 | * lc_try_lock - can be used to stop lc_get() from changing the tracked set | 272 | * lc_try_lock_for_transaction - can be used to stop lc_get() from changing the tracked set |
262 | * @lc: the lru cache to operate on | 273 | * @lc: the lru cache to operate on |
263 | * | 274 | * |
264 | * Note that the reference counts and order on the active and lru lists may | 275 | * Allows (expects) the set to be "dirty". Note that the reference counts and |
265 | * still change. Returns true if we acquired the lock. | 276 | * order on the active and lru lists may still change. Used to serialize |
277 | * changing transactions. Returns true if we aquired the lock. | ||
266 | */ | 278 | */ |
267 | static inline int lc_try_lock(struct lru_cache *lc) | 279 | static inline int lc_try_lock_for_transaction(struct lru_cache *lc) |
268 | { | 280 | { |
269 | return !test_and_set_bit(__LC_DIRTY, &lc->flags); | 281 | return !test_and_set_bit(__LC_LOCKED, &lc->flags); |
270 | } | 282 | } |
271 | 283 | ||
272 | /** | 284 | /** |
285 | * lc_try_lock - variant to stop lc_get() from changing the tracked set | ||
286 | * @lc: the lru cache to operate on | ||
287 | * | ||
288 | * Note that the reference counts and order on the active and lru lists may | ||
289 | * still change. Only works on a "clean" set. Returns true if we aquired the | ||
290 | * lock, which means there are no pending changes, and any further attempt to | ||
291 | * change the set will not succeed until the next lc_unlock(). | ||
292 | */ | ||
293 | extern int lc_try_lock(struct lru_cache *lc); | ||
294 | |||
295 | /** | ||
273 | * lc_unlock - unlock @lc, allow lc_get() to change the set again | 296 | * lc_unlock - unlock @lc, allow lc_get() to change the set again |
274 | * @lc: the lru cache to operate on | 297 | * @lc: the lru cache to operate on |
275 | */ | 298 | */ |
276 | static inline void lc_unlock(struct lru_cache *lc) | 299 | static inline void lc_unlock(struct lru_cache *lc) |
277 | { | 300 | { |
278 | clear_bit(__LC_DIRTY, &lc->flags); | 301 | clear_bit(__LC_DIRTY, &lc->flags); |
279 | smp_mb__after_clear_bit(); | 302 | clear_bit_unlock(__LC_LOCKED, &lc->flags); |
280 | } | 303 | } |
281 | 304 | ||
282 | static inline int lc_is_used(struct lru_cache *lc, unsigned int enr) | 305 | extern bool lc_is_used(struct lru_cache *lc, unsigned int enr); |
283 | { | ||
284 | struct lc_element *e = lc_find(lc, enr); | ||
285 | return e && e->refcnt; | ||
286 | } | ||
287 | 306 | ||
288 | #define lc_entry(ptr, type, member) \ | 307 | #define lc_entry(ptr, type, member) \ |
289 | container_of(ptr, type, member) | 308 | container_of(ptr, type, member) |
diff --git a/include/linux/wait.h b/include/linux/wait.h index 168dfe122dd3..7cb64d4b499d 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h | |||
@@ -550,6 +550,170 @@ do { \ | |||
550 | __ret; \ | 550 | __ret; \ |
551 | }) | 551 | }) |
552 | 552 | ||
553 | |||
554 | #define __wait_event_lock_irq(wq, condition, lock, cmd) \ | ||
555 | do { \ | ||
556 | DEFINE_WAIT(__wait); \ | ||
557 | \ | ||
558 | for (;;) { \ | ||
559 | prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \ | ||
560 | if (condition) \ | ||
561 | break; \ | ||
562 | spin_unlock_irq(&lock); \ | ||
563 | cmd; \ | ||
564 | schedule(); \ | ||
565 | spin_lock_irq(&lock); \ | ||
566 | } \ | ||
567 | finish_wait(&wq, &__wait); \ | ||
568 | } while (0) | ||
569 | |||
570 | /** | ||
571 | * wait_event_lock_irq_cmd - sleep until a condition gets true. The | ||
572 | * condition is checked under the lock. This | ||
573 | * is expected to be called with the lock | ||
574 | * taken. | ||
575 | * @wq: the waitqueue to wait on | ||
576 | * @condition: a C expression for the event to wait for | ||
577 | * @lock: a locked spinlock_t, which will be released before cmd | ||
578 | * and schedule() and reacquired afterwards. | ||
579 | * @cmd: a command which is invoked outside the critical section before | ||
580 | * sleep | ||
581 | * | ||
582 | * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the | ||
583 | * @condition evaluates to true. The @condition is checked each time | ||
584 | * the waitqueue @wq is woken up. | ||
585 | * | ||
586 | * wake_up() has to be called after changing any variable that could | ||
587 | * change the result of the wait condition. | ||
588 | * | ||
589 | * This is supposed to be called while holding the lock. The lock is | ||
590 | * dropped before invoking the cmd and going to sleep and is reacquired | ||
591 | * afterwards. | ||
592 | */ | ||
593 | #define wait_event_lock_irq_cmd(wq, condition, lock, cmd) \ | ||
594 | do { \ | ||
595 | if (condition) \ | ||
596 | break; \ | ||
597 | __wait_event_lock_irq(wq, condition, lock, cmd); \ | ||
598 | } while (0) | ||
599 | |||
600 | /** | ||
601 | * wait_event_lock_irq - sleep until a condition gets true. The | ||
602 | * condition is checked under the lock. This | ||
603 | * is expected to be called with the lock | ||
604 | * taken. | ||
605 | * @wq: the waitqueue to wait on | ||
606 | * @condition: a C expression for the event to wait for | ||
607 | * @lock: a locked spinlock_t, which will be released before schedule() | ||
608 | * and reacquired afterwards. | ||
609 | * | ||
610 | * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the | ||
611 | * @condition evaluates to true. The @condition is checked each time | ||
612 | * the waitqueue @wq is woken up. | ||
613 | * | ||
614 | * wake_up() has to be called after changing any variable that could | ||
615 | * change the result of the wait condition. | ||
616 | * | ||
617 | * This is supposed to be called while holding the lock. The lock is | ||
618 | * dropped before going to sleep and is reacquired afterwards. | ||
619 | */ | ||
620 | #define wait_event_lock_irq(wq, condition, lock) \ | ||
621 | do { \ | ||
622 | if (condition) \ | ||
623 | break; \ | ||
624 | __wait_event_lock_irq(wq, condition, lock, ); \ | ||
625 | } while (0) | ||
626 | |||
627 | |||
628 | #define __wait_event_interruptible_lock_irq(wq, condition, \ | ||
629 | lock, ret, cmd) \ | ||
630 | do { \ | ||
631 | DEFINE_WAIT(__wait); \ | ||
632 | \ | ||
633 | for (;;) { \ | ||
634 | prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \ | ||
635 | if (condition) \ | ||
636 | break; \ | ||
637 | if (signal_pending(current)) { \ | ||
638 | ret = -ERESTARTSYS; \ | ||
639 | break; \ | ||
640 | } \ | ||
641 | spin_unlock_irq(&lock); \ | ||
642 | cmd; \ | ||
643 | schedule(); \ | ||
644 | spin_lock_irq(&lock); \ | ||
645 | } \ | ||
646 | finish_wait(&wq, &__wait); \ | ||
647 | } while (0) | ||
648 | |||
649 | /** | ||
650 | * wait_event_interruptible_lock_irq_cmd - sleep until a condition gets true. | ||
651 | * The condition is checked under the lock. This is expected to | ||
652 | * be called with the lock taken. | ||
653 | * @wq: the waitqueue to wait on | ||
654 | * @condition: a C expression for the event to wait for | ||
655 | * @lock: a locked spinlock_t, which will be released before cmd and | ||
656 | * schedule() and reacquired afterwards. | ||
657 | * @cmd: a command which is invoked outside the critical section before | ||
658 | * sleep | ||
659 | * | ||
660 | * The process is put to sleep (TASK_INTERRUPTIBLE) until the | ||
661 | * @condition evaluates to true or a signal is received. The @condition is | ||
662 | * checked each time the waitqueue @wq is woken up. | ||
663 | * | ||
664 | * wake_up() has to be called after changing any variable that could | ||
665 | * change the result of the wait condition. | ||
666 | * | ||
667 | * This is supposed to be called while holding the lock. The lock is | ||
668 | * dropped before invoking the cmd and going to sleep and is reacquired | ||
669 | * afterwards. | ||
670 | * | ||
671 | * The macro will return -ERESTARTSYS if it was interrupted by a signal | ||
672 | * and 0 if @condition evaluated to true. | ||
673 | */ | ||
674 | #define wait_event_interruptible_lock_irq_cmd(wq, condition, lock, cmd) \ | ||
675 | ({ \ | ||
676 | int __ret = 0; \ | ||
677 | \ | ||
678 | if (!(condition)) \ | ||
679 | __wait_event_interruptible_lock_irq(wq, condition, \ | ||
680 | lock, __ret, cmd); \ | ||
681 | __ret; \ | ||
682 | }) | ||
683 | |||
684 | /** | ||
685 | * wait_event_interruptible_lock_irq - sleep until a condition gets true. | ||
686 | * The condition is checked under the lock. This is expected | ||
687 | * to be called with the lock taken. | ||
688 | * @wq: the waitqueue to wait on | ||
689 | * @condition: a C expression for the event to wait for | ||
690 | * @lock: a locked spinlock_t, which will be released before schedule() | ||
691 | * and reacquired afterwards. | ||
692 | * | ||
693 | * The process is put to sleep (TASK_INTERRUPTIBLE) until the | ||
694 | * @condition evaluates to true or signal is received. The @condition is | ||
695 | * checked each time the waitqueue @wq is woken up. | ||
696 | * | ||
697 | * wake_up() has to be called after changing any variable that could | ||
698 | * change the result of the wait condition. | ||
699 | * | ||
700 | * This is supposed to be called while holding the lock. The lock is | ||
701 | * dropped before going to sleep and is reacquired afterwards. | ||
702 | * | ||
703 | * The macro will return -ERESTARTSYS if it was interrupted by a signal | ||
704 | * and 0 if @condition evaluated to true. | ||
705 | */ | ||
706 | #define wait_event_interruptible_lock_irq(wq, condition, lock) \ | ||
707 | ({ \ | ||
708 | int __ret = 0; \ | ||
709 | \ | ||
710 | if (!(condition)) \ | ||
711 | __wait_event_interruptible_lock_irq(wq, condition, \ | ||
712 | lock, __ret, ); \ | ||
713 | __ret; \ | ||
714 | }) | ||
715 | |||
716 | |||
553 | /* | 717 | /* |
554 | * These are the old interfaces to sleep waiting for an event. | 718 | * These are the old interfaces to sleep waiting for an event. |
555 | * They are racy. DO NOT use them, use the wait_event* interfaces above. | 719 | * They are racy. DO NOT use them, use the wait_event* interfaces above. |