| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | drbd.c |
|---|
| 3 | 4 | |
|---|
| .. | .. |
|---|
| 10 | 11 | Thanks to Carter Burden, Bart Grantham and Gennadiy Nerubayev |
|---|
| 11 | 12 | from Logicworks, Inc. for making SDP replication support possible. |
|---|
| 12 | 13 | |
|---|
| 13 | | - drbd is free software; you can redistribute it and/or modify |
|---|
| 14 | | - it under the terms of the GNU General Public License as published by |
|---|
| 15 | | - the Free Software Foundation; either version 2, or (at your option) |
|---|
| 16 | | - any later version. |
|---|
| 17 | | - |
|---|
| 18 | | - drbd is distributed in the hope that it will be useful, |
|---|
| 19 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 20 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 21 | | - GNU General Public License for more details. |
|---|
| 22 | | - |
|---|
| 23 | | - You should have received a copy of the GNU General Public License |
|---|
| 24 | | - along with drbd; see the file COPYING. If not, write to |
|---|
| 25 | | - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 26 | 14 | |
|---|
| 27 | 15 | */ |
|---|
| 28 | 16 | |
|---|
| .. | .. |
|---|
| 144 | 132 | DEFINE_RATELIMIT_STATE(drbd_ratelimit_state, 5 * HZ, 5); |
|---|
| 145 | 133 | |
|---|
| 146 | 134 | static const struct block_device_operations drbd_ops = { |
|---|
| 147 | | - .owner = THIS_MODULE, |
|---|
| 148 | | - .open = drbd_open, |
|---|
| 149 | | - .release = drbd_release, |
|---|
| 135 | + .owner = THIS_MODULE, |
|---|
| 136 | + .submit_bio = drbd_submit_bio, |
|---|
| 137 | + .open = drbd_open, |
|---|
| 138 | + .release = drbd_release, |
|---|
| 150 | 139 | }; |
|---|
| 151 | 140 | |
|---|
| 152 | 141 | struct bio *bio_alloc_drbd(gfp_t gfp_mask) |
|---|
| .. | .. |
|---|
| 195 | 184 | unsigned int set_size) |
|---|
| 196 | 185 | { |
|---|
| 197 | 186 | struct drbd_request *r; |
|---|
| 198 | | - struct drbd_request *req = NULL; |
|---|
| 187 | + struct drbd_request *req = NULL, *tmp = NULL; |
|---|
| 199 | 188 | int expect_epoch = 0; |
|---|
| 200 | 189 | int expect_size = 0; |
|---|
| 201 | 190 | |
|---|
| .. | .. |
|---|
| 249 | 238 | * to catch requests being barrier-acked "unexpectedly". |
|---|
| 250 | 239 | * It usually should find the same req again, or some READ preceding it. */ |
|---|
| 251 | 240 | list_for_each_entry(req, &connection->transfer_log, tl_requests) |
|---|
| 252 | | - if (req->epoch == expect_epoch) |
|---|
| 241 | + if (req->epoch == expect_epoch) { |
|---|
| 242 | + tmp = req; |
|---|
| 253 | 243 | break; |
|---|
| 244 | + } |
|---|
| 245 | + req = list_prepare_entry(tmp, &connection->transfer_log, tl_requests); |
|---|
| 254 | 246 | list_for_each_entry_safe_from(req, r, &connection->transfer_log, tl_requests) { |
|---|
| 255 | 247 | if (req->epoch != expect_epoch) |
|---|
| 256 | 248 | break; |
|---|
| .. | .. |
|---|
| 441 | 433 | thi->t_state = RESTARTING; |
|---|
| 442 | 434 | drbd_info(resource, "Restarting %s thread (from %s [%d])\n", |
|---|
| 443 | 435 | thi->name, current->comm, current->pid); |
|---|
| 444 | | - /* fall through */ |
|---|
| 436 | + fallthrough; |
|---|
| 445 | 437 | case RUNNING: |
|---|
| 446 | 438 | case RESTARTING: |
|---|
| 447 | 439 | default: |
|---|
| .. | .. |
|---|
| 479 | 471 | smp_mb(); |
|---|
| 480 | 472 | init_completion(&thi->stop); |
|---|
| 481 | 473 | if (thi->task != current) |
|---|
| 482 | | - force_sig(DRBD_SIGKILL, thi->task); |
|---|
| 474 | + send_sig(DRBD_SIGKILL, thi->task, 1); |
|---|
| 483 | 475 | } |
|---|
| 484 | 476 | |
|---|
| 485 | 477 | spin_unlock_irqrestore(&thi->t_lock, flags); |
|---|
| .. | .. |
|---|
| 672 | 664 | /* DRBD protocol "pings" are latency critical. |
|---|
| 673 | 665 | * This is supposed to trigger tcp_push_pending_frames() */ |
|---|
| 674 | 666 | if (!err && (cmd == P_PING || cmd == P_PING_ACK)) |
|---|
| 675 | | - drbd_tcp_nodelay(sock->socket); |
|---|
| 667 | + tcp_sock_set_nodelay(sock->socket->sk); |
|---|
| 676 | 668 | |
|---|
| 677 | 669 | return err; |
|---|
| 678 | 670 | } |
|---|
| .. | .. |
|---|
| 995 | 987 | |
|---|
| 996 | 988 | p->d_size = cpu_to_be64(d_size); |
|---|
| 997 | 989 | p->u_size = cpu_to_be64(u_size); |
|---|
| 998 | | - p->c_size = cpu_to_be64(trigger_reply ? 0 : drbd_get_capacity(device->this_bdev)); |
|---|
| 990 | + if (trigger_reply) |
|---|
| 991 | + p->c_size = 0; |
|---|
| 992 | + else |
|---|
| 993 | + p->c_size = cpu_to_be64(get_capacity(device->vdisk)); |
|---|
| 999 | 994 | p->max_bio_size = cpu_to_be32(max_bio_size); |
|---|
| 1000 | 995 | p->queue_order_type = cpu_to_be16(q_order_type); |
|---|
| 1001 | 996 | p->dds_flags = cpu_to_be16(flags); |
|---|
| .. | .. |
|---|
| 1378 | 1373 | struct p_data *dp, int data_size) |
|---|
| 1379 | 1374 | { |
|---|
| 1380 | 1375 | if (peer_device->connection->peer_integrity_tfm) |
|---|
| 1381 | | - data_size -= crypto_ahash_digestsize(peer_device->connection->peer_integrity_tfm); |
|---|
| 1376 | + data_size -= crypto_shash_digestsize(peer_device->connection->peer_integrity_tfm); |
|---|
| 1382 | 1377 | _drbd_send_ack(peer_device, cmd, dp->sector, cpu_to_be32(data_size), |
|---|
| 1383 | 1378 | dp->block_id); |
|---|
| 1384 | 1379 | } |
|---|
| .. | .. |
|---|
| 1564 | 1559 | * put_page(); and would cause either a VM_BUG directly, or |
|---|
| 1565 | 1560 | * __page_cache_release a page that would actually still be referenced |
|---|
| 1566 | 1561 | * by someone, leading to some obscure delayed Oops somewhere else. */ |
|---|
| 1567 | | - if (drbd_disable_sendpage || (page_count(page) < 1) || PageSlab(page)) |
|---|
| 1562 | + if (drbd_disable_sendpage || !sendpage_ok(page)) |
|---|
| 1568 | 1563 | return _drbd_no_send_page(peer_device, page, offset, size, msg_flags); |
|---|
| 1569 | 1564 | |
|---|
| 1570 | 1565 | msg_flags |= MSG_NOSIGNAL; |
|---|
| .. | .. |
|---|
| 1669 | 1664 | (bio->bi_opf & REQ_PREFLUSH ? DP_FLUSH : 0) | |
|---|
| 1670 | 1665 | (bio_op(bio) == REQ_OP_WRITE_SAME ? DP_WSAME : 0) | |
|---|
| 1671 | 1666 | (bio_op(bio) == REQ_OP_DISCARD ? DP_DISCARD : 0) | |
|---|
| 1672 | | - (bio_op(bio) == REQ_OP_WRITE_ZEROES ? DP_DISCARD : 0); |
|---|
| 1667 | + (bio_op(bio) == REQ_OP_WRITE_ZEROES ? |
|---|
| 1668 | + ((connection->agreed_features & DRBD_FF_WZEROES) ? |
|---|
| 1669 | + (DP_ZEROES |(!(bio->bi_opf & REQ_NOUNMAP) ? DP_DISCARD : 0)) |
|---|
| 1670 | + : DP_DISCARD) |
|---|
| 1671 | + : 0); |
|---|
| 1673 | 1672 | else |
|---|
| 1674 | 1673 | return bio->bi_opf & REQ_SYNC ? DP_RW_SYNC : 0; |
|---|
| 1675 | 1674 | } |
|---|
| 1676 | 1675 | |
|---|
| 1677 | | -/* Used to send write or TRIM aka REQ_DISCARD requests |
|---|
| 1676 | +/* Used to send write or TRIM aka REQ_OP_DISCARD requests |
|---|
| 1678 | 1677 | * R_PRIMARY -> Peer (P_DATA, P_TRIM) |
|---|
| 1679 | 1678 | */ |
|---|
| 1680 | 1679 | int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request *req) |
|---|
| .. | .. |
|---|
| 1691 | 1690 | sock = &peer_device->connection->data; |
|---|
| 1692 | 1691 | p = drbd_prepare_command(peer_device, sock); |
|---|
| 1693 | 1692 | digest_size = peer_device->connection->integrity_tfm ? |
|---|
| 1694 | | - crypto_ahash_digestsize(peer_device->connection->integrity_tfm) : 0; |
|---|
| 1693 | + crypto_shash_digestsize(peer_device->connection->integrity_tfm) : 0; |
|---|
| 1695 | 1694 | |
|---|
| 1696 | 1695 | if (!p) |
|---|
| 1697 | 1696 | return -EIO; |
|---|
| .. | .. |
|---|
| 1713 | 1712 | } |
|---|
| 1714 | 1713 | p->dp_flags = cpu_to_be32(dp_flags); |
|---|
| 1715 | 1714 | |
|---|
| 1716 | | - if (dp_flags & DP_DISCARD) { |
|---|
| 1715 | + if (dp_flags & (DP_DISCARD|DP_ZEROES)) { |
|---|
| 1716 | + enum drbd_packet cmd = (dp_flags & DP_ZEROES) ? P_ZEROES : P_TRIM; |
|---|
| 1717 | 1717 | struct p_trim *t = (struct p_trim*)p; |
|---|
| 1718 | 1718 | t->size = cpu_to_be32(req->i.size); |
|---|
| 1719 | | - err = __send_command(peer_device->connection, device->vnr, sock, P_TRIM, sizeof(*t), NULL, 0); |
|---|
| 1719 | + err = __send_command(peer_device->connection, device->vnr, sock, cmd, sizeof(*t), NULL, 0); |
|---|
| 1720 | 1720 | goto out; |
|---|
| 1721 | 1721 | } |
|---|
| 1722 | 1722 | if (dp_flags & DP_WSAME) { |
|---|
| .. | .. |
|---|
| 1797 | 1797 | p = drbd_prepare_command(peer_device, sock); |
|---|
| 1798 | 1798 | |
|---|
| 1799 | 1799 | digest_size = peer_device->connection->integrity_tfm ? |
|---|
| 1800 | | - crypto_ahash_digestsize(peer_device->connection->integrity_tfm) : 0; |
|---|
| 1800 | + crypto_shash_digestsize(peer_device->connection->integrity_tfm) : 0; |
|---|
| 1801 | 1801 | |
|---|
| 1802 | 1802 | if (!p) |
|---|
| 1803 | 1803 | return -EIO; |
|---|
| .. | .. |
|---|
| 1857 | 1857 | |
|---|
| 1858 | 1858 | /* THINK if (signal_pending) return ... ? */ |
|---|
| 1859 | 1859 | |
|---|
| 1860 | | - iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iov, 1, size); |
|---|
| 1860 | + iov_iter_kvec(&msg.msg_iter, WRITE, &iov, 1, size); |
|---|
| 1861 | 1861 | |
|---|
| 1862 | 1862 | if (sock == connection->data.socket) { |
|---|
| 1863 | 1863 | rcu_read_lock(); |
|---|
| .. | .. |
|---|
| 2035 | 2035 | device->local_max_bio_size = DRBD_MAX_BIO_SIZE_SAFE; |
|---|
| 2036 | 2036 | } |
|---|
| 2037 | 2037 | |
|---|
| 2038 | +void drbd_set_my_capacity(struct drbd_device *device, sector_t size) |
|---|
| 2039 | +{ |
|---|
| 2040 | + char ppb[10]; |
|---|
| 2041 | + |
|---|
| 2042 | + set_capacity(device->vdisk, size); |
|---|
| 2043 | + revalidate_disk_size(device->vdisk, false); |
|---|
| 2044 | + |
|---|
| 2045 | + drbd_info(device, "size = %s (%llu KB)\n", |
|---|
| 2046 | + ppsize(ppb, size>>1), (unsigned long long)size>>1); |
|---|
| 2047 | +} |
|---|
| 2048 | + |
|---|
| 2038 | 2049 | void drbd_device_cleanup(struct drbd_device *device) |
|---|
| 2039 | 2050 | { |
|---|
| 2040 | 2051 | int i; |
|---|
| .. | .. |
|---|
| 2060 | 2071 | } |
|---|
| 2061 | 2072 | D_ASSERT(device, first_peer_device(device)->connection->net_conf == NULL); |
|---|
| 2062 | 2073 | |
|---|
| 2063 | | - drbd_set_my_capacity(device, 0); |
|---|
| 2074 | + set_capacity(device->vdisk, 0); |
|---|
| 2075 | + revalidate_disk_size(device->vdisk, false); |
|---|
| 2064 | 2076 | if (device->bitmap) { |
|---|
| 2065 | 2077 | /* maybe never allocated. */ |
|---|
| 2066 | 2078 | drbd_bm_resize(device, 0, 1); |
|---|
| .. | .. |
|---|
| 2227 | 2239 | /* cleanup stuff that may have been allocated during |
|---|
| 2228 | 2240 | * device (re-)configuration or state changes */ |
|---|
| 2229 | 2241 | |
|---|
| 2230 | | - if (device->this_bdev) |
|---|
| 2231 | | - bdput(device->this_bdev); |
|---|
| 2232 | | - |
|---|
| 2233 | 2242 | drbd_backing_dev_free(device, device->ldev); |
|---|
| 2234 | 2243 | device->ldev = NULL; |
|---|
| 2235 | 2244 | |
|---|
| .. | .. |
|---|
| 2316 | 2325 | * workqueues instead. |
|---|
| 2317 | 2326 | */ |
|---|
| 2318 | 2327 | |
|---|
| 2319 | | - /* We are not just doing generic_make_request(), |
|---|
| 2328 | + /* We are not just doing submit_bio_noacct(), |
|---|
| 2320 | 2329 | * as we want to keep the start_time information. */ |
|---|
| 2321 | 2330 | inc_ap_bio(device); |
|---|
| 2322 | 2331 | __drbd_make_request(device, bio, start_jif); |
|---|
| .. | .. |
|---|
| 2404 | 2413 | idr_destroy(&drbd_devices); |
|---|
| 2405 | 2414 | |
|---|
| 2406 | 2415 | pr_info("module cleanup done.\n"); |
|---|
| 2407 | | -} |
|---|
| 2408 | | - |
|---|
| 2409 | | -/** |
|---|
| 2410 | | - * drbd_congested() - Callback for the flusher thread |
|---|
| 2411 | | - * @congested_data: User data |
|---|
| 2412 | | - * @bdi_bits: Bits the BDI flusher thread is currently interested in |
|---|
| 2413 | | - * |
|---|
| 2414 | | - * Returns 1<<WB_async_congested and/or 1<<WB_sync_congested if we are congested. |
|---|
| 2415 | | - */ |
|---|
| 2416 | | -static int drbd_congested(void *congested_data, int bdi_bits) |
|---|
| 2417 | | -{ |
|---|
| 2418 | | - struct drbd_device *device = congested_data; |
|---|
| 2419 | | - struct request_queue *q; |
|---|
| 2420 | | - char reason = '-'; |
|---|
| 2421 | | - int r = 0; |
|---|
| 2422 | | - |
|---|
| 2423 | | - if (!may_inc_ap_bio(device)) { |
|---|
| 2424 | | - /* DRBD has frozen IO */ |
|---|
| 2425 | | - r = bdi_bits; |
|---|
| 2426 | | - reason = 'd'; |
|---|
| 2427 | | - goto out; |
|---|
| 2428 | | - } |
|---|
| 2429 | | - |
|---|
| 2430 | | - if (test_bit(CALLBACK_PENDING, &first_peer_device(device)->connection->flags)) { |
|---|
| 2431 | | - r |= (1 << WB_async_congested); |
|---|
| 2432 | | - /* Without good local data, we would need to read from remote, |
|---|
| 2433 | | - * and that would need the worker thread as well, which is |
|---|
| 2434 | | - * currently blocked waiting for that usermode helper to |
|---|
| 2435 | | - * finish. |
|---|
| 2436 | | - */ |
|---|
| 2437 | | - if (!get_ldev_if_state(device, D_UP_TO_DATE)) |
|---|
| 2438 | | - r |= (1 << WB_sync_congested); |
|---|
| 2439 | | - else |
|---|
| 2440 | | - put_ldev(device); |
|---|
| 2441 | | - r &= bdi_bits; |
|---|
| 2442 | | - reason = 'c'; |
|---|
| 2443 | | - goto out; |
|---|
| 2444 | | - } |
|---|
| 2445 | | - |
|---|
| 2446 | | - if (get_ldev(device)) { |
|---|
| 2447 | | - q = bdev_get_queue(device->ldev->backing_bdev); |
|---|
| 2448 | | - r = bdi_congested(q->backing_dev_info, bdi_bits); |
|---|
| 2449 | | - put_ldev(device); |
|---|
| 2450 | | - if (r) |
|---|
| 2451 | | - reason = 'b'; |
|---|
| 2452 | | - } |
|---|
| 2453 | | - |
|---|
| 2454 | | - if (bdi_bits & (1 << WB_async_congested) && |
|---|
| 2455 | | - test_bit(NET_CONGESTED, &first_peer_device(device)->connection->flags)) { |
|---|
| 2456 | | - r |= (1 << WB_async_congested); |
|---|
| 2457 | | - reason = reason == 'b' ? 'a' : 'n'; |
|---|
| 2458 | | - } |
|---|
| 2459 | | - |
|---|
| 2460 | | -out: |
|---|
| 2461 | | - device->congestion_reason = reason; |
|---|
| 2462 | | - return r; |
|---|
| 2463 | 2416 | } |
|---|
| 2464 | 2417 | |
|---|
| 2465 | 2418 | static void drbd_init_workqueue(struct drbd_work_queue* wq) |
|---|
| .. | .. |
|---|
| 2558 | 2511 | { |
|---|
| 2559 | 2512 | drbd_free_sock(connection); |
|---|
| 2560 | 2513 | |
|---|
| 2561 | | - crypto_free_ahash(connection->csums_tfm); |
|---|
| 2562 | | - crypto_free_ahash(connection->verify_tfm); |
|---|
| 2514 | + crypto_free_shash(connection->csums_tfm); |
|---|
| 2515 | + crypto_free_shash(connection->verify_tfm); |
|---|
| 2563 | 2516 | crypto_free_shash(connection->cram_hmac_tfm); |
|---|
| 2564 | | - crypto_free_ahash(connection->integrity_tfm); |
|---|
| 2565 | | - crypto_free_ahash(connection->peer_integrity_tfm); |
|---|
| 2517 | + crypto_free_shash(connection->integrity_tfm); |
|---|
| 2518 | + crypto_free_shash(connection->peer_integrity_tfm); |
|---|
| 2566 | 2519 | kfree(connection->int_dig_in); |
|---|
| 2567 | 2520 | kfree(connection->int_dig_vv); |
|---|
| 2568 | 2521 | |
|---|
| .. | .. |
|---|
| 2767 | 2720 | enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsigned int minor) |
|---|
| 2768 | 2721 | { |
|---|
| 2769 | 2722 | struct drbd_resource *resource = adm_ctx->resource; |
|---|
| 2770 | | - struct drbd_connection *connection; |
|---|
| 2723 | + struct drbd_connection *connection, *n; |
|---|
| 2771 | 2724 | struct drbd_device *device; |
|---|
| 2772 | 2725 | struct drbd_peer_device *peer_device, *tmp_peer_device; |
|---|
| 2773 | 2726 | struct gendisk *disk; |
|---|
| .. | .. |
|---|
| 2793 | 2746 | |
|---|
| 2794 | 2747 | drbd_init_set_defaults(device); |
|---|
| 2795 | 2748 | |
|---|
| 2796 | | - q = blk_alloc_queue_node(GFP_KERNEL, NUMA_NO_NODE, &resource->req_lock); |
|---|
| 2749 | + q = blk_alloc_queue(NUMA_NO_NODE); |
|---|
| 2797 | 2750 | if (!q) |
|---|
| 2798 | 2751 | goto out_no_q; |
|---|
| 2799 | 2752 | device->rq_queue = q; |
|---|
| 2800 | | - q->queuedata = device; |
|---|
| 2801 | 2753 | |
|---|
| 2802 | 2754 | disk = alloc_disk(1); |
|---|
| 2803 | 2755 | if (!disk) |
|---|
| .. | .. |
|---|
| 2813 | 2765 | sprintf(disk->disk_name, "drbd%d", minor); |
|---|
| 2814 | 2766 | disk->private_data = device; |
|---|
| 2815 | 2767 | |
|---|
| 2816 | | - device->this_bdev = bdget(MKDEV(DRBD_MAJOR, minor)); |
|---|
| 2817 | | - /* we have no partitions. we contain only ourselves. */ |
|---|
| 2818 | | - device->this_bdev->bd_contains = device->this_bdev; |
|---|
| 2819 | | - |
|---|
| 2820 | | - q->backing_dev_info->congested_fn = drbd_congested; |
|---|
| 2821 | | - q->backing_dev_info->congested_data = device; |
|---|
| 2822 | | - |
|---|
| 2823 | | - blk_queue_make_request(q, drbd_make_request); |
|---|
| 2824 | 2768 | blk_queue_write_cache(q, true, true); |
|---|
| 2825 | 2769 | /* Setting the max_hw_sectors to an odd value of 8kibyte here |
|---|
| 2826 | 2770 | This triggers a max_bio_size message upon first attach or connect */ |
|---|
| .. | .. |
|---|
| 2875 | 2819 | |
|---|
| 2876 | 2820 | if (init_submitter(device)) { |
|---|
| 2877 | 2821 | err = ERR_NOMEM; |
|---|
| 2878 | | - goto out_idr_remove_vol; |
|---|
| 2822 | + goto out_idr_remove_from_resource; |
|---|
| 2879 | 2823 | } |
|---|
| 2880 | 2824 | |
|---|
| 2881 | 2825 | add_disk(disk); |
|---|
| .. | .. |
|---|
| 2892 | 2836 | drbd_debugfs_device_add(device); |
|---|
| 2893 | 2837 | return NO_ERROR; |
|---|
| 2894 | 2838 | |
|---|
| 2895 | | -out_idr_remove_vol: |
|---|
| 2896 | | - idr_remove(&connection->peer_devices, vnr); |
|---|
| 2897 | 2839 | out_idr_remove_from_resource: |
|---|
| 2898 | | - for_each_connection(connection, resource) { |
|---|
| 2840 | + for_each_connection_safe(connection, n, resource) { |
|---|
| 2899 | 2841 | peer_device = idr_remove(&connection->peer_devices, vnr); |
|---|
| 2900 | 2842 | if (peer_device) |
|---|
| 2901 | 2843 | kref_put(&connection->kref, drbd_destroy_connection); |
|---|
| .. | .. |
|---|
| 3002 | 2944 | spin_lock_init(&retry.lock); |
|---|
| 3003 | 2945 | INIT_LIST_HEAD(&retry.writes); |
|---|
| 3004 | 2946 | |
|---|
| 3005 | | - if (drbd_debugfs_init()) |
|---|
| 3006 | | - pr_notice("failed to initialize debugfs -- will not be available\n"); |
|---|
| 2947 | + drbd_debugfs_init(); |
|---|
| 3007 | 2948 | |
|---|
| 3008 | 2949 | pr_info("initialized. " |
|---|
| 3009 | 2950 | "Version: " REL_VERSION " (api:%d/proto:%d-%d)\n", |
|---|
| .. | .. |
|---|
| 3097 | 3038 | |
|---|
| 3098 | 3039 | memset(buffer, 0, sizeof(*buffer)); |
|---|
| 3099 | 3040 | |
|---|
| 3100 | | - buffer->la_size_sect = cpu_to_be64(drbd_get_capacity(device->this_bdev)); |
|---|
| 3041 | + buffer->la_size_sect = cpu_to_be64(get_capacity(device->vdisk)); |
|---|
| 3101 | 3042 | for (i = UI_CURRENT; i < UI_SIZE; i++) |
|---|
| 3102 | 3043 | buffer->uuid[i] = cpu_to_be64(device->ldev->md.uuid[i]); |
|---|
| 3103 | 3044 | buffer->flags = cpu_to_be32(device->ldev->md.flags); |
|---|
| .. | .. |
|---|
| 3155 | 3096 | |
|---|
| 3156 | 3097 | /* Update device->ldev->md.la_size_sect, |
|---|
| 3157 | 3098 | * since we updated it on metadata. */ |
|---|
| 3158 | | - device->ldev->md.la_size_sect = drbd_get_capacity(device->this_bdev); |
|---|
| 3099 | + device->ldev->md.la_size_sect = get_capacity(device->vdisk); |
|---|
| 3159 | 3100 | |
|---|
| 3160 | 3101 | drbd_md_put_buffer(device); |
|---|
| 3161 | 3102 | out: |
|---|
| .. | .. |
|---|
| 3407 | 3348 | * the meta-data super block. This function sets MD_DIRTY, and starts a |
|---|
| 3408 | 3349 | * timer that ensures that within five seconds you have to call drbd_md_sync(). |
|---|
| 3409 | 3350 | */ |
|---|
| 3410 | | -#ifdef DEBUG |
|---|
| 3411 | | -void drbd_md_mark_dirty_(struct drbd_device *device, unsigned int line, const char *func) |
|---|
| 3412 | | -{ |
|---|
| 3413 | | - if (!test_and_set_bit(MD_DIRTY, &device->flags)) { |
|---|
| 3414 | | - mod_timer(&device->md_sync_timer, jiffies + HZ); |
|---|
| 3415 | | - device->last_md_mark_dirty.line = line; |
|---|
| 3416 | | - device->last_md_mark_dirty.func = func; |
|---|
| 3417 | | - } |
|---|
| 3418 | | -} |
|---|
| 3419 | | -#else |
|---|
| 3420 | 3351 | void drbd_md_mark_dirty(struct drbd_device *device) |
|---|
| 3421 | 3352 | { |
|---|
| 3422 | 3353 | if (!test_and_set_bit(MD_DIRTY, &device->flags)) |
|---|
| 3423 | 3354 | mod_timer(&device->md_sync_timer, jiffies + 5*HZ); |
|---|
| 3424 | 3355 | } |
|---|
| 3425 | | -#endif |
|---|
| 3426 | 3356 | |
|---|
| 3427 | 3357 | void drbd_uuid_move_history(struct drbd_device *device) __must_hold(local) |
|---|
| 3428 | 3358 | { |
|---|
| .. | .. |
|---|
| 3699 | 3629 | * when we want to support more than |
|---|
| 3700 | 3630 | * one PRO_VERSION */ |
|---|
| 3701 | 3631 | static const char *cmdnames[] = { |
|---|
| 3632 | + |
|---|
| 3702 | 3633 | [P_DATA] = "Data", |
|---|
| 3703 | | - [P_WSAME] = "WriteSame", |
|---|
| 3704 | | - [P_TRIM] = "Trim", |
|---|
| 3705 | 3634 | [P_DATA_REPLY] = "DataReply", |
|---|
| 3706 | 3635 | [P_RS_DATA_REPLY] = "RSDataReply", |
|---|
| 3707 | 3636 | [P_BARRIER] = "Barrier", |
|---|
| .. | .. |
|---|
| 3712 | 3641 | [P_DATA_REQUEST] = "DataRequest", |
|---|
| 3713 | 3642 | [P_RS_DATA_REQUEST] = "RSDataRequest", |
|---|
| 3714 | 3643 | [P_SYNC_PARAM] = "SyncParam", |
|---|
| 3715 | | - [P_SYNC_PARAM89] = "SyncParam89", |
|---|
| 3716 | 3644 | [P_PROTOCOL] = "ReportProtocol", |
|---|
| 3717 | 3645 | [P_UUIDS] = "ReportUUIDs", |
|---|
| 3718 | 3646 | [P_SIZES] = "ReportSizes", |
|---|
| .. | .. |
|---|
| 3720 | 3648 | [P_SYNC_UUID] = "ReportSyncUUID", |
|---|
| 3721 | 3649 | [P_AUTH_CHALLENGE] = "AuthChallenge", |
|---|
| 3722 | 3650 | [P_AUTH_RESPONSE] = "AuthResponse", |
|---|
| 3651 | + [P_STATE_CHG_REQ] = "StateChgRequest", |
|---|
| 3723 | 3652 | [P_PING] = "Ping", |
|---|
| 3724 | 3653 | [P_PING_ACK] = "PingAck", |
|---|
| 3725 | 3654 | [P_RECV_ACK] = "RecvAck", |
|---|
| .. | .. |
|---|
| 3730 | 3659 | [P_NEG_DREPLY] = "NegDReply", |
|---|
| 3731 | 3660 | [P_NEG_RS_DREPLY] = "NegRSDReply", |
|---|
| 3732 | 3661 | [P_BARRIER_ACK] = "BarrierAck", |
|---|
| 3733 | | - [P_STATE_CHG_REQ] = "StateChgRequest", |
|---|
| 3734 | 3662 | [P_STATE_CHG_REPLY] = "StateChgReply", |
|---|
| 3735 | 3663 | [P_OV_REQUEST] = "OVRequest", |
|---|
| 3736 | 3664 | [P_OV_REPLY] = "OVReply", |
|---|
| 3737 | 3665 | [P_OV_RESULT] = "OVResult", |
|---|
| 3738 | 3666 | [P_CSUM_RS_REQUEST] = "CsumRSRequest", |
|---|
| 3739 | 3667 | [P_RS_IS_IN_SYNC] = "CsumRSIsInSync", |
|---|
| 3668 | + [P_SYNC_PARAM89] = "SyncParam89", |
|---|
| 3740 | 3669 | [P_COMPRESSED_BITMAP] = "CBitmap", |
|---|
| 3741 | 3670 | [P_DELAY_PROBE] = "DelayProbe", |
|---|
| 3742 | 3671 | [P_OUT_OF_SYNC] = "OutOfSync", |
|---|
| 3743 | | - [P_RETRY_WRITE] = "RetryWrite", |
|---|
| 3744 | 3672 | [P_RS_CANCEL] = "RSCancel", |
|---|
| 3745 | 3673 | [P_CONN_ST_CHG_REQ] = "conn_st_chg_req", |
|---|
| 3746 | 3674 | [P_CONN_ST_CHG_REPLY] = "conn_st_chg_reply", |
|---|
| 3747 | 3675 | [P_RETRY_WRITE] = "retry_write", |
|---|
| 3748 | 3676 | [P_PROTOCOL_UPDATE] = "protocol_update", |
|---|
| 3677 | + [P_TRIM] = "Trim", |
|---|
| 3749 | 3678 | [P_RS_THIN_REQ] = "rs_thin_req", |
|---|
| 3750 | 3679 | [P_RS_DEALLOCATED] = "rs_deallocated", |
|---|
| 3680 | + [P_WSAME] = "WriteSame", |
|---|
| 3681 | + [P_ZEROES] = "Zeroes", |
|---|
| 3751 | 3682 | |
|---|
| 3752 | 3683 | /* enum drbd_packet, but not commands - obsoleted flags: |
|---|
| 3753 | 3684 | * P_MAY_IGNORE |
|---|