hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/block/drbd/drbd_nl.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 drbd_nl.c
34
....@@ -7,19 +8,6 @@
78 Copyright (C) 1999-2008, Philipp Reisner <philipp.reisner@linbit.com>.
89 Copyright (C) 2002-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
910
10
- drbd is free software; you can redistribute it and/or modify
11
- it under the terms of the GNU General Public License as published by
12
- the Free Software Foundation; either version 2, or (at your option)
13
- any later version.
14
-
15
- drbd is distributed in the hope that it will be useful,
16
- but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- GNU General Public License for more details.
19
-
20
- You should have received a copy of the GNU General Public License
21
- along with drbd; see the file COPYING. If not, write to
22
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
2311
2412 */
2513
....@@ -114,7 +102,7 @@
114102 if (!info || !info[0])
115103 return 0;
116104
117
- nla = nla_nest_start(skb, DRBD_NLA_CFG_REPLY);
105
+ nla = nla_nest_start_noflag(skb, DRBD_NLA_CFG_REPLY);
118106 if (!nla)
119107 return err;
120108
....@@ -124,6 +112,35 @@
124112 return err;
125113 } else
126114 nla_nest_end(skb, nla);
115
+ return 0;
116
+}
117
+
118
+__printf(2, 3)
119
+static int drbd_msg_sprintf_info(struct sk_buff *skb, const char *fmt, ...)
120
+{
121
+ va_list args;
122
+ struct nlattr *nla, *txt;
123
+ int err = -EMSGSIZE;
124
+ int len;
125
+
126
+ nla = nla_nest_start_noflag(skb, DRBD_NLA_CFG_REPLY);
127
+ if (!nla)
128
+ return err;
129
+
130
+ txt = nla_reserve(skb, T_info_text, 256);
131
+ if (!txt) {
132
+ nla_nest_cancel(skb, nla);
133
+ return err;
134
+ }
135
+ va_start(args, fmt);
136
+ len = vscnprintf(nla_data(txt), 256, fmt, args);
137
+ va_end(args);
138
+
139
+ /* maybe: retry with larger reserve, if truncated */
140
+ txt->nla_len = nla_attr_size(len+1);
141
+ nlmsg_trim(skb, (char*)txt + NLA_ALIGN(txt->nla_len));
142
+ nla_nest_end(skb, nla);
143
+
127144 return 0;
128145 }
129146
....@@ -251,19 +268,18 @@
251268 /* some more paranoia, if the request was over-determined */
252269 if (adm_ctx->device && adm_ctx->resource &&
253270 adm_ctx->device->resource != adm_ctx->resource) {
254
- pr_warning("request: minor=%u, resource=%s; but that minor belongs to resource %s\n",
255
- adm_ctx->minor, adm_ctx->resource->name,
256
- adm_ctx->device->resource->name);
271
+ pr_warn("request: minor=%u, resource=%s; but that minor belongs to resource %s\n",
272
+ adm_ctx->minor, adm_ctx->resource->name,
273
+ adm_ctx->device->resource->name);
257274 drbd_msg_put_info(adm_ctx->reply_skb, "minor exists in different resource");
258275 return ERR_INVALID_REQUEST;
259276 }
260277 if (adm_ctx->device &&
261278 adm_ctx->volume != VOLUME_UNSPECIFIED &&
262279 adm_ctx->volume != adm_ctx->device->vnr) {
263
- pr_warning("request: minor=%u, volume=%u; but that minor is volume %u in %s\n",
264
- adm_ctx->minor, adm_ctx->volume,
265
- adm_ctx->device->vnr,
266
- adm_ctx->device->resource->name);
280
+ pr_warn("request: minor=%u, volume=%u; but that minor is volume %u in %s\n",
281
+ adm_ctx->minor, adm_ctx->volume,
282
+ adm_ctx->device->vnr, adm_ctx->device->resource->name);
267283 drbd_msg_put_info(adm_ctx->reply_skb, "minor exists as different volume");
268284 return ERR_INVALID_REQUEST;
269285 }
....@@ -582,7 +598,7 @@
582598 struct task_struct *opa;
583599
584600 kref_get(&connection->kref);
585
- /* We may just have force_sig()'ed this thread
601
+ /* We may have just sent a signal to this thread
586602 * to get it out of some blocking network function.
587603 * Clear signals; otherwise kthread_run(), which internally uses
588604 * wait_on_completion_killable(), will mistake our pending signal
....@@ -774,9 +790,11 @@
774790 mutex_lock(&adm_ctx.resource->adm_mutex);
775791
776792 if (info->genlhdr->cmd == DRBD_ADM_PRIMARY)
777
- retcode = drbd_set_role(adm_ctx.device, R_PRIMARY, parms.assume_uptodate);
793
+ retcode = (enum drbd_ret_code)drbd_set_role(adm_ctx.device,
794
+ R_PRIMARY, parms.assume_uptodate);
778795 else
779
- retcode = drbd_set_role(adm_ctx.device, R_SECONDARY, 0);
796
+ retcode = (enum drbd_ret_code)drbd_set_role(adm_ctx.device,
797
+ R_SECONDARY, 0);
780798
781799 mutex_unlock(&adm_ctx.resource->adm_mutex);
782800 genl_lock();
....@@ -922,7 +940,6 @@
922940 } prev;
923941 sector_t u_size, size;
924942 struct drbd_md *md = &device->ldev->md;
925
- char ppb[10];
926943 void *buffer;
927944
928945 int md_moved, la_size_changed;
....@@ -981,7 +998,7 @@
981998 goto err_out;
982999 }
9831000
984
- if (drbd_get_capacity(device->this_bdev) != size ||
1001
+ if (get_capacity(device->vdisk) != size ||
9851002 drbd_bm_capacity(device) != size) {
9861003 int err;
9871004 err = drbd_bm_resize(device, size, !(flags & DDSF_NO_RESYNC));
....@@ -1000,8 +1017,6 @@
10001017 /* racy, see comments above. */
10011018 drbd_set_my_capacity(device, size);
10021019 md->la_size_sect = size;
1003
- drbd_info(device, "size = %s (%llu KB)\n", ppsize(ppb, size>>1),
1004
- (unsigned long long)size>>1);
10051020 }
10061021 if (rv <= DS_ERROR)
10071022 goto err_out;
....@@ -1235,6 +1250,21 @@
12351250 }
12361251 }
12371252
1253
+static void fixup_write_zeroes(struct drbd_device *device, struct request_queue *q)
1254
+{
1255
+ /* Fixup max_write_zeroes_sectors after blk_stack_limits():
1256
+ * if we can handle "zeroes" efficiently on the protocol,
1257
+ * we want to do that, even if our backend does not announce
1258
+ * max_write_zeroes_sectors itself. */
1259
+ struct drbd_connection *connection = first_peer_device(device)->connection;
1260
+ /* If the peer announces WZEROES support, use it. Otherwise, rather
1261
+ * send explicit zeroes than rely on some discard-zeroes-data magic. */
1262
+ if (connection->agreed_features & DRBD_FF_WZEROES)
1263
+ q->limits.max_write_zeroes_sectors = DRBD_MAX_BBIO_SECTORS;
1264
+ else
1265
+ q->limits.max_write_zeroes_sectors = 0;
1266
+}
1267
+
12381268 static void decide_on_write_same_support(struct drbd_device *device,
12391269 struct request_queue *q,
12401270 struct request_queue *b, struct o_qlim *o,
....@@ -1333,18 +1363,11 @@
13331363 decide_on_write_same_support(device, q, b, o, disable_write_same);
13341364
13351365 if (b) {
1336
- blk_queue_stack_limits(q, b);
1337
-
1338
- if (q->backing_dev_info->ra_pages !=
1339
- b->backing_dev_info->ra_pages) {
1340
- drbd_info(device, "Adjusting my ra_pages to backing device's (%lu -> %lu)\n",
1341
- q->backing_dev_info->ra_pages,
1342
- b->backing_dev_info->ra_pages);
1343
- q->backing_dev_info->ra_pages =
1344
- b->backing_dev_info->ra_pages;
1345
- }
1366
+ blk_stack_limits(&q->limits, &b->limits, 0);
1367
+ blk_queue_update_readahead(q);
13461368 }
13471369 fixup_discard_if_not_supported(q);
1370
+ fixup_write_zeroes(device, q);
13481371 }
13491372
13501373 void drbd_reconsider_queue_parameters(struct drbd_device *device, struct drbd_backing_dev *bdev, struct o_qlim *o)
....@@ -1546,7 +1569,8 @@
15461569 struct drbd_device *device;
15471570 struct disk_conf *new_disk_conf, *old_disk_conf;
15481571 struct fifo_buffer *old_plan = NULL, *new_plan = NULL;
1549
- int err, fifo_size;
1572
+ int err;
1573
+ unsigned int fifo_size;
15501574
15511575 retcode = drbd_adm_prepare(&adm_ctx, skb, info, DRBD_ADM_NEED_MINOR);
15521576 if (!adm_ctx.reply_skb)
....@@ -1911,8 +1935,7 @@
19111935
19121936 /* Make sure the new disk is big enough
19131937 * (we may currently be R_PRIMARY with no local disk...) */
1914
- if (drbd_get_max_capacity(nbc) <
1915
- drbd_get_capacity(device->this_bdev)) {
1938
+ if (drbd_get_max_capacity(nbc) < get_capacity(device->vdisk)) {
19161939 retcode = ERR_DISK_TOO_SMALL;
19171940 goto fail;
19181941 }
....@@ -1941,7 +1964,7 @@
19411964 drbd_flush_workqueue(&connection->sender_work);
19421965
19431966 rv = _drbd_request_state(device, NS(disk, D_ATTACHING), CS_VERBOSE);
1944
- retcode = rv; /* FIXME: Type mismatch. */
1967
+ retcode = (enum drbd_ret_code)rv;
19451968 drbd_resume_io(device);
19461969 if (rv < SS_SUCCESS)
19471970 goto fail;
....@@ -1972,11 +1995,21 @@
19721995 }
19731996
19741997 /* Prevent shrinking of consistent devices ! */
1975
- if (drbd_md_test_flag(nbc, MDF_CONSISTENT) &&
1976
- drbd_new_dev_size(device, nbc, nbc->disk_conf->disk_size, 0) < nbc->md.la_size_sect) {
1977
- drbd_warn(device, "refusing to truncate a consistent device\n");
1978
- retcode = ERR_DISK_TOO_SMALL;
1979
- goto force_diskless_dec;
1998
+ {
1999
+ unsigned long long nsz = drbd_new_dev_size(device, nbc, nbc->disk_conf->disk_size, 0);
2000
+ unsigned long long eff = nbc->md.la_size_sect;
2001
+ if (drbd_md_test_flag(nbc, MDF_CONSISTENT) && nsz < eff) {
2002
+ if (nsz == nbc->disk_conf->disk_size) {
2003
+ drbd_warn(device, "truncating a consistent device during attach (%llu < %llu)\n", nsz, eff);
2004
+ } else {
2005
+ drbd_warn(device, "refusing to truncate a consistent device (%llu < %llu)\n", nsz, eff);
2006
+ drbd_msg_sprintf_info(adm_ctx.reply_skb,
2007
+ "To-be-attached device has last effective > current size, and is consistent\n"
2008
+ "(%llu > %llu sectors). Refusing to attach.", eff, nsz);
2009
+ retcode = ERR_IMPLICIT_SHRINK;
2010
+ goto force_diskless_dec;
2011
+ }
2012
+ }
19802013 }
19812014
19822015 lock_all_resources();
....@@ -2325,10 +2358,10 @@
23252358 }
23262359
23272360 struct crypto {
2328
- struct crypto_ahash *verify_tfm;
2329
- struct crypto_ahash *csums_tfm;
2361
+ struct crypto_shash *verify_tfm;
2362
+ struct crypto_shash *csums_tfm;
23302363 struct crypto_shash *cram_hmac_tfm;
2331
- struct crypto_ahash *integrity_tfm;
2364
+ struct crypto_shash *integrity_tfm;
23322365 };
23332366
23342367 static int
....@@ -2346,36 +2379,21 @@
23462379 return NO_ERROR;
23472380 }
23482381
2349
-static int
2350
-alloc_ahash(struct crypto_ahash **tfm, char *tfm_name, int err_alg)
2351
-{
2352
- if (!tfm_name[0])
2353
- return NO_ERROR;
2354
-
2355
- *tfm = crypto_alloc_ahash(tfm_name, 0, CRYPTO_ALG_ASYNC);
2356
- if (IS_ERR(*tfm)) {
2357
- *tfm = NULL;
2358
- return err_alg;
2359
- }
2360
-
2361
- return NO_ERROR;
2362
-}
2363
-
23642382 static enum drbd_ret_code
23652383 alloc_crypto(struct crypto *crypto, struct net_conf *new_net_conf)
23662384 {
23672385 char hmac_name[CRYPTO_MAX_ALG_NAME];
23682386 enum drbd_ret_code rv;
23692387
2370
- rv = alloc_ahash(&crypto->csums_tfm, new_net_conf->csums_alg,
2388
+ rv = alloc_shash(&crypto->csums_tfm, new_net_conf->csums_alg,
23712389 ERR_CSUMS_ALG);
23722390 if (rv != NO_ERROR)
23732391 return rv;
2374
- rv = alloc_ahash(&crypto->verify_tfm, new_net_conf->verify_alg,
2392
+ rv = alloc_shash(&crypto->verify_tfm, new_net_conf->verify_alg,
23752393 ERR_VERIFY_ALG);
23762394 if (rv != NO_ERROR)
23772395 return rv;
2378
- rv = alloc_ahash(&crypto->integrity_tfm, new_net_conf->integrity_alg,
2396
+ rv = alloc_shash(&crypto->integrity_tfm, new_net_conf->integrity_alg,
23792397 ERR_INTEGRITY_ALG);
23802398 if (rv != NO_ERROR)
23812399 return rv;
....@@ -2393,9 +2411,9 @@
23932411 static void free_crypto(struct crypto *crypto)
23942412 {
23952413 crypto_free_shash(crypto->cram_hmac_tfm);
2396
- crypto_free_ahash(crypto->integrity_tfm);
2397
- crypto_free_ahash(crypto->csums_tfm);
2398
- crypto_free_ahash(crypto->verify_tfm);
2414
+ crypto_free_shash(crypto->integrity_tfm);
2415
+ crypto_free_shash(crypto->csums_tfm);
2416
+ crypto_free_shash(crypto->verify_tfm);
23992417 }
24002418
24012419 int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)
....@@ -2472,17 +2490,17 @@
24722490 rcu_assign_pointer(connection->net_conf, new_net_conf);
24732491
24742492 if (!rsr) {
2475
- crypto_free_ahash(connection->csums_tfm);
2493
+ crypto_free_shash(connection->csums_tfm);
24762494 connection->csums_tfm = crypto.csums_tfm;
24772495 crypto.csums_tfm = NULL;
24782496 }
24792497 if (!ovr) {
2480
- crypto_free_ahash(connection->verify_tfm);
2498
+ crypto_free_shash(connection->verify_tfm);
24812499 connection->verify_tfm = crypto.verify_tfm;
24822500 crypto.verify_tfm = NULL;
24832501 }
24842502
2485
- crypto_free_ahash(connection->integrity_tfm);
2503
+ crypto_free_shash(connection->integrity_tfm);
24862504 connection->integrity_tfm = crypto.integrity_tfm;
24872505 if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100)
24882506 /* Do this without trying to take connection->data.mutex again. */
....@@ -2671,7 +2689,8 @@
26712689 }
26722690 rcu_read_unlock();
26732691
2674
- retcode = conn_request_state(connection, NS(conn, C_UNCONNECTED), CS_VERBOSE);
2692
+ retcode = (enum drbd_ret_code)conn_request_state(connection,
2693
+ NS(conn, C_UNCONNECTED), CS_VERBOSE);
26752694
26762695 conn_reconfig_done(connection);
26772696 mutex_unlock(&adm_ctx.resource->adm_mutex);
....@@ -2691,8 +2710,10 @@
26912710
26922711 static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection, bool force)
26932712 {
2713
+ enum drbd_conns cstate;
26942714 enum drbd_state_rv rv;
26952715
2716
+repeat:
26962717 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING),
26972718 force ? CS_HARD : 0);
26982719
....@@ -2710,6 +2731,11 @@
27102731
27112732 break;
27122733 case SS_CW_FAILED_BY_PEER:
2734
+ spin_lock_irq(&connection->resource->req_lock);
2735
+ cstate = connection->cstate;
2736
+ spin_unlock_irq(&connection->resource->req_lock);
2737
+ if (cstate <= C_WF_CONNECTION)
2738
+ goto repeat;
27132739 /* The peer probably wants to see us outdated. */
27142740 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING,
27152741 disk, D_OUTDATED), 0);
....@@ -2777,7 +2803,7 @@
27772803 mutex_lock(&adm_ctx.resource->adm_mutex);
27782804 rv = conn_try_disconnect(connection, parms.force_disconnect);
27792805 if (rv < SS_SUCCESS)
2780
- retcode = rv; /* FIXME: Type mismatch. */
2806
+ retcode = (enum drbd_ret_code)rv;
27812807 else
27822808 retcode = NO_ERROR;
27832809 mutex_unlock(&adm_ctx.resource->adm_mutex);
....@@ -3225,7 +3251,7 @@
32253251 struct drbd_device *device)
32263252 {
32273253 struct nlattr *nla;
3228
- nla = nla_nest_start(skb, DRBD_NLA_CFG_CONTEXT);
3254
+ nla = nla_nest_start_noflag(skb, DRBD_NLA_CFG_CONTEXT);
32293255 if (!nla)
32303256 goto nla_put_failure;
32313257 if (device &&
....@@ -3338,7 +3364,6 @@
33383364 if (get_ldev(device)) {
33393365 struct drbd_md *md = &device->ldev->md;
33403366 u64 *history_uuids = (u64 *)s->history_uuids;
3341
- struct request_queue *q;
33423367 int n;
33433368
33443369 spin_lock_irq(&md->uuid_lock);
....@@ -3352,14 +3377,9 @@
33523377 spin_unlock_irq(&md->uuid_lock);
33533378
33543379 s->dev_disk_flags = md->flags;
3355
- q = bdev_get_queue(device->ldev->backing_bdev);
3356
- s->dev_lower_blocked =
3357
- bdi_congested(q->backing_dev_info,
3358
- (1 << WB_async_congested) |
3359
- (1 << WB_sync_congested));
33603380 put_ldev(device);
33613381 }
3362
- s->dev_size = drbd_get_capacity(device->this_bdev);
3382
+ s->dev_size = get_capacity(device->vdisk);
33633383 s->dev_read = device->read_cnt;
33643384 s->dev_write = device->writ_cnt;
33653385 s->dev_al_writes = device->al_writ_cnt;
....@@ -3391,7 +3411,7 @@
33913411 {
33923412 struct nlattr *resource_filter;
33933413 struct drbd_resource *resource;
3394
- struct drbd_device *uninitialized_var(device);
3414
+ struct drbd_device *device;
33953415 int minor, err, retcode;
33963416 struct drbd_genlmsghdr *dh;
33973417 struct device_info device_info;
....@@ -3480,7 +3500,7 @@
34803500 {
34813501 struct nlattr *resource_filter;
34823502 struct drbd_resource *resource = NULL, *next_resource;
3483
- struct drbd_connection *uninitialized_var(connection);
3503
+ struct drbd_connection *connection;
34843504 int err = 0, retcode;
34853505 struct drbd_genlmsghdr *dh;
34863506 struct connection_info connection_info;
....@@ -3642,7 +3662,7 @@
36423662 {
36433663 struct nlattr *resource_filter;
36443664 struct drbd_resource *resource;
3645
- struct drbd_device *uninitialized_var(device);
3665
+ struct drbd_device *device;
36463666 struct drbd_peer_device *peer_device = NULL;
36473667 int minor, err, retcode;
36483668 struct drbd_genlmsghdr *dh;
....@@ -3793,14 +3813,13 @@
37933813 if (err)
37943814 goto nla_put_failure;
37953815
3796
- nla = nla_nest_start(skb, DRBD_NLA_STATE_INFO);
3816
+ nla = nla_nest_start_noflag(skb, DRBD_NLA_STATE_INFO);
37973817 if (!nla)
37983818 goto nla_put_failure;
37993819 if (nla_put_u32(skb, T_sib_reason, sib ? sib->sib_reason : SIB_GET_STATUS_REPLY) ||
38003820 nla_put_u32(skb, T_current_state, device->state.i) ||
38013821 nla_put_u64_0pad(skb, T_ed_uuid, device->ed_uuid) ||
3802
- nla_put_u64_0pad(skb, T_capacity,
3803
- drbd_get_capacity(device->this_bdev)) ||
3822
+ nla_put_u64_0pad(skb, T_capacity, get_capacity(device->vdisk)) ||
38043823 nla_put_u64_0pad(skb, T_send_cnt, device->send_cnt) ||
38053824 nla_put_u64_0pad(skb, T_recv_cnt, device->recv_cnt) ||
38063825 nla_put_u64_0pad(skb, T_read_cnt, device->read_cnt) ||
....@@ -3851,7 +3870,7 @@
38513870 if (nla_put_u32(skb, T_helper_exit_code,
38523871 sib->helper_exit_code))
38533872 goto nla_put_failure;
3854
- /* fall through */
3873
+ fallthrough;
38553874 case SIB_HELPER_PRE:
38563875 if (nla_put_string(skb, T_helper, sib->helper_name))
38573876 goto nla_put_failure;
....@@ -4598,7 +4617,7 @@
45984617 return drbd_notification_header_to_skb(msg, &nh, true);
45994618 }
46004619
4601
-void notify_resource_state(struct sk_buff *skb,
4620
+int notify_resource_state(struct sk_buff *skb,
46024621 unsigned int seq,
46034622 struct drbd_resource *resource,
46044623 struct resource_info *resource_info,
....@@ -4640,16 +4659,17 @@
46404659 if (err && err != -ESRCH)
46414660 goto failed;
46424661 }
4643
- return;
4662
+ return 0;
46444663
46454664 nla_put_failure:
46464665 nlmsg_free(skb);
46474666 failed:
46484667 drbd_err(resource, "Error %d while broadcasting event. Event seq:%u\n",
46494668 err, seq);
4669
+ return err;
46504670 }
46514671
4652
-void notify_device_state(struct sk_buff *skb,
4672
+int notify_device_state(struct sk_buff *skb,
46534673 unsigned int seq,
46544674 struct drbd_device *device,
46554675 struct device_info *device_info,
....@@ -4689,16 +4709,17 @@
46894709 if (err && err != -ESRCH)
46904710 goto failed;
46914711 }
4692
- return;
4712
+ return 0;
46934713
46944714 nla_put_failure:
46954715 nlmsg_free(skb);
46964716 failed:
46974717 drbd_err(device, "Error %d while broadcasting event. Event seq:%u\n",
46984718 err, seq);
4719
+ return err;
46994720 }
47004721
4701
-void notify_connection_state(struct sk_buff *skb,
4722
+int notify_connection_state(struct sk_buff *skb,
47024723 unsigned int seq,
47034724 struct drbd_connection *connection,
47044725 struct connection_info *connection_info,
....@@ -4738,16 +4759,17 @@
47384759 if (err && err != -ESRCH)
47394760 goto failed;
47404761 }
4741
- return;
4762
+ return 0;
47424763
47434764 nla_put_failure:
47444765 nlmsg_free(skb);
47454766 failed:
47464767 drbd_err(connection, "Error %d while broadcasting event. Event seq:%u\n",
47474768 err, seq);
4769
+ return err;
47484770 }
47494771
4750
-void notify_peer_device_state(struct sk_buff *skb,
4772
+int notify_peer_device_state(struct sk_buff *skb,
47514773 unsigned int seq,
47524774 struct drbd_peer_device *peer_device,
47534775 struct peer_device_info *peer_device_info,
....@@ -4788,13 +4810,14 @@
47884810 if (err && err != -ESRCH)
47894811 goto failed;
47904812 }
4791
- return;
4813
+ return 0;
47924814
47934815 nla_put_failure:
47944816 nlmsg_free(skb);
47954817 failed:
47964818 drbd_err(peer_device, "Error %d while broadcasting event. Event seq:%u\n",
47974819 err, seq);
4820
+ return err;
47984821 }
47994822
48004823 void notify_helper(enum drbd_notification_type type,
....@@ -4845,7 +4868,7 @@
48454868 err, seq);
48464869 }
48474870
4848
-static void notify_initial_state_done(struct sk_buff *skb, unsigned int seq)
4871
+static int notify_initial_state_done(struct sk_buff *skb, unsigned int seq)
48494872 {
48504873 struct drbd_genlmsghdr *dh;
48514874 int err;
....@@ -4859,11 +4882,12 @@
48594882 if (nla_put_notification_header(skb, NOTIFY_EXISTS))
48604883 goto nla_put_failure;
48614884 genlmsg_end(skb, dh);
4862
- return;
4885
+ return 0;
48634886
48644887 nla_put_failure:
48654888 nlmsg_free(skb);
48664889 pr_err("Error %d sending event. Event seq:%u\n", err, seq);
4890
+ return err;
48674891 }
48684892
48694893 static void free_state_changes(struct list_head *list)
....@@ -4890,6 +4914,7 @@
48904914 unsigned int seq = cb->args[2];
48914915 unsigned int n;
48924916 enum drbd_notification_type flags = 0;
4917
+ int err = 0;
48934918
48944919 /* There is no need for taking notification_mutex here: it doesn't
48954920 matter if the initial state events mix with later state chage
....@@ -4898,32 +4923,32 @@
48984923
48994924 cb->args[5]--;
49004925 if (cb->args[5] == 1) {
4901
- notify_initial_state_done(skb, seq);
4926
+ err = notify_initial_state_done(skb, seq);
49024927 goto out;
49034928 }
49044929 n = cb->args[4]++;
49054930 if (cb->args[4] < cb->args[3])
49064931 flags |= NOTIFY_CONTINUES;
49074932 if (n < 1) {
4908
- notify_resource_state_change(skb, seq, state_change->resource,
4933
+ err = notify_resource_state_change(skb, seq, state_change->resource,
49094934 NOTIFY_EXISTS | flags);
49104935 goto next;
49114936 }
49124937 n--;
49134938 if (n < state_change->n_connections) {
4914
- notify_connection_state_change(skb, seq, &state_change->connections[n],
4939
+ err = notify_connection_state_change(skb, seq, &state_change->connections[n],
49154940 NOTIFY_EXISTS | flags);
49164941 goto next;
49174942 }
49184943 n -= state_change->n_connections;
49194944 if (n < state_change->n_devices) {
4920
- notify_device_state_change(skb, seq, &state_change->devices[n],
4945
+ err = notify_device_state_change(skb, seq, &state_change->devices[n],
49214946 NOTIFY_EXISTS | flags);
49224947 goto next;
49234948 }
49244949 n -= state_change->n_devices;
49254950 if (n < state_change->n_devices * state_change->n_connections) {
4926
- notify_peer_device_state_change(skb, seq, &state_change->peer_devices[n],
4951
+ err = notify_peer_device_state_change(skb, seq, &state_change->peer_devices[n],
49274952 NOTIFY_EXISTS | flags);
49284953 goto next;
49294954 }
....@@ -4938,7 +4963,10 @@
49384963 cb->args[4] = 0;
49394964 }
49404965 out:
4941
- return skb->len;
4966
+ if (err)
4967
+ return err;
4968
+ else
4969
+ return skb->len;
49424970 }
49434971
49444972 int drbd_adm_get_initial_state(struct sk_buff *skb, struct netlink_callback *cb)