Lines Matching +full:layers +full:- +full:configurable

1 /* SPDX-License-Identifier: GPL-2.0-only */
7 Copyright (C) 2001-2008, LINBIT Information Technologies GmbH.
8 Copyright (C) 1999-2008, Philipp Reisner <philipp.reisner@linbit.com>.
9 Copyright (C) 2002-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
29 #include <linux/backing-dev.h>
63 #define ID_SYNCER (-1ULL)
125 /* statistics; index: (h->command == P_BITMAP) */
143 c->word_offset = c->bit_offset >> 6; in bm_xfer_ctx_bit_to_word_offset()
145 c->word_offset = c->bit_offset >> 5; in bm_xfer_ctx_bit_to_word_offset()
146 c->word_offset &= ~(1UL); in bm_xfer_ctx_bit_to_word_offset()
178 * --lge */ in get_t_state()
181 return thi->t_state; in get_t_state()
340 ((peer_req)->opf & REQ_OP_MASK)
346 * non-atomic modification to ee->flags is ok.
354 /* explicit zero-out requested, or
417 USE_DEGR_WFC_T, /* degr-wfc-timeout instead of wfc-timeout. */
432 FORCE_DETACH, /* Force-detach from local disk, aborting any pending local IO */
438 AHEAD_TO_SYNC_SOURCE, /* Ahead -> SyncSource queued */
443 FLUSH_PENDING, /* if set, device->flush_jif is when we submitted that flush
447 GOING_DISKLESS, /* Disk is being detached, because of io-error, or admin request. */
472 * and still allow all non-bulk operations */
480 * requires sending of "out-of-sync" information, though. */
516 /* cached value of bdev->disk_conf->meta_dev_idx (see below) */
531 struct disk_conf *disk_conf; /* RCU, for updates: resource->conf_update */
597 struct mutex conf_update; /* mutex for ready-copy-update of net_conf and disk_conf */
652 …pto_shash *integrity_tfm; /* checksums we compute, updates protected by connection->data->mutex */
676 * protected by resource->req_lock */
701 * with req->epoch == current_epoch_nr.
712 has_net_conf = rcu_dereference(connection->net_conf); in has_net_conf()
725 __update_timing_details(c->w_timing_details, &c->w_cb_nr, cb, __func__ , __LINE__ )
727 __update_timing_details(c->r_timing_details, &c->r_cb_nr, cb, __func__ , __LINE__ )
733 /* protected by ..->resource->req_lock */
829 /* block not up-to-date at mark [unit BM_BLOCK_SIZE] */
844 /* size of out-of-sync range in sectors. */
865 struct list_head net_ee; /* zero-copy network send in progress */
886 …struct mutex *state_mutex; /* either own_state_mutex or first_peer_device(device)->connection->cst…
894 …struct fifo_buffer *rs_plan_s; /* correction values of resync planer (RCU, connection->conn_update…
901 * are deferred to this single-threaded work queue */
907 struct list_head list; /* on device->pending_bitmap_io */;
925 #define VOLUME_UNSPECIFIED (-1U)
949 return list_first_entry_or_null(&device->peer_devices, struct drbd_peer_device, peer_devices); in first_peer_device()
955 return idr_find(&connection->peer_devices, volume_number); in conn_peer_device()
968 list_for_each_entry(connection, &resource->connections, connections)
971 list_for_each_entry_rcu(connection, &resource->connections, connections)
974 list_for_each_entry_safe(connection, tmp, &resource->connections, connections)
977 list_for_each_entry(peer_device, &device->peer_devices, peer_devices)
980 list_for_each_entry_rcu(peer_device, &device->peer_devices, peer_devices)
983 list_for_each_entry_safe(peer_device, tmp, &device->peer_devices, peer_devices)
987 return device->minor; in device_to_minor()
1094 * |----------- md_size_sect ------------------|
1098 * ==> bitmap sectors = md_size_sect - bm_offset
1104 * |----------- md_size_sect ------------------|
1107 * | bm_offset = al_offset - Y |
1108 * ==> bitmap sectors = Y = al_offset - bm_offset
1114 * which are written in a ring-buffer, or striped ring-buffer like fashion,
1116 * but is about to become configurable.
1130 /* We could make these currently hardcoded constants configurable
1131 * variables at create-md time (or even re-configurable at runtime?).
1145 #define AL_CONTEXT_PER_TRANSACTION 919 // (4096 - 36 - 6*64)/4
1197 #define BM_SECT_TO_BIT(x) ((x)>>(BM_BLOCK_SHIFT-9))
1198 #define BM_BIT_TO_SECT(x) ((sector_t)(x)<<(BM_BLOCK_SHIFT-9))
1202 #define Bit2KB(bits) ((bits)<<(BM_BLOCK_SHIFT-10))
1206 #define BM_SECT_TO_EXT(x) ((x)>>(BM_EXT_SHIFT-9))
1207 #define BM_BIT_TO_EXT(x) ((x) >> (BM_EXT_SHIFT - BM_BLOCK_SHIFT))
1210 #define BM_EXT_TO_SECT(x) ((sector_t)(x) << (BM_EXT_SHIFT-9))
1214 #define BM_BITS_PER_EXT (1UL << (BM_EXT_SHIFT - BM_BLOCK_SHIFT))
1216 #define BM_BLOCKS_PER_BM_EXT_MASK (BM_BITS_PER_EXT - 1)
1220 #define AL_EXT_PER_BM_SECT (1 << (BM_EXT_SHIFT - AL_EXTENT_SHIFT))
1227 * bit 0 bit 37 bit 38 bit (512*8)-1
1229 * sect. 0 `296 `304 ^(512*8*8)-1
1237 /* we have a certain meta data variant that has a fixed on-disk size of 128
1243 ((MD_128MB_SECT - MD_32kB_SECT - MD_4kB_SECT) * (1LL<<(BM_EXT_SHIFT-9)))
1259 * Since we may live in a mixed-platform cluster,
1355 /* We also need a standard (emergency-reserve backed) page pool
1406 DS_ERROR_SHRINK = -3,
1407 DS_ERROR_SPACE_MD = -2,
1408 DS_ERROR = -1,
1452 struct drbd_device *device = peer_device->device; in ov_out_of_sync_print()
1454 if (device->ov_last_oos_size) { in ov_out_of_sync_print()
1456 (unsigned long long)device->ov_last_oos_start, in ov_out_of_sync_print()
1457 (unsigned long)device->ov_last_oos_size); in ov_out_of_sync_print()
1459 device->ov_last_oos_size = 0; in ov_out_of_sync_print()
1521 if (!bio->bi_bdev) { in drbd_submit_bio_noacct()
1522 drbd_err(device, "drbd_submit_bio_noacct: bio->bi_bdev == NULL\n"); in drbd_submit_bio_noacct()
1523 bio->bi_status = BLK_STS_IOERR; in drbd_submit_bio_noacct()
1627 struct page *page = peer_req->pages; in drbd_peer_req_has_active_page()
1637 struct drbd_resource *resource = device->resource; in drbd_read_state()
1640 rv.i = device->state.i; in drbd_read_state()
1641 rv.susp = resource->susp; in drbd_read_state()
1642 rv.susp_nod = resource->susp_nod; in drbd_read_state()
1643 rv.susp_fen = resource->susp_fen; in drbd_read_state()
1663 ep = rcu_dereference(device->ldev->disk_conf)->on_io_error; in __drbd_chk_io_error_()
1670 if (device->state.disk > D_INCONSISTENT) in __drbd_chk_io_error_()
1683 * blocks, which triggers block re-allocation in lower layers. in __drbd_chk_io_error_()
1688 * Force-detach is not really an IO error, but rather a in __drbd_chk_io_error_()
1697 set_bit(WAS_IO_ERROR, &device->flags); in __drbd_chk_io_error_()
1699 set_bit(WAS_READ_ERROR, &device->flags); in __drbd_chk_io_error_()
1701 set_bit(FORCE_DETACH, &device->flags); in __drbd_chk_io_error_()
1702 if (device->state.disk > D_FAILED) { in __drbd_chk_io_error_()
1725 spin_lock_irqsave(&device->resource->req_lock, flags); in drbd_chk_io_error_()
1727 spin_unlock_irqrestore(&device->resource->req_lock, flags); in drbd_chk_io_error_()
1733 * drbd_md_first_sector() - Returns the first sector number of the meta data area
1741 switch (bdev->md.meta_dev_idx) { in drbd_md_first_sector()
1744 return bdev->md.md_offset + bdev->md.bm_offset; in drbd_md_first_sector()
1747 return bdev->md.md_offset; in drbd_md_first_sector()
1752 * drbd_md_last_sector() - Return the last sector number of the meta data area
1757 switch (bdev->md.meta_dev_idx) { in drbd_md_last_sector()
1760 return bdev->md.md_offset + MD_4kB_SECT -1; in drbd_md_last_sector()
1763 return bdev->md.md_offset + bdev->md.md_size_sect -1; in drbd_md_last_sector()
1774 * drbd_get_max_capacity() - Returns the capacity we announce to out peer
1785 switch (bdev->md.meta_dev_idx) { in drbd_get_max_capacity()
1788 s = drbd_get_capacity(bdev->backing_bdev) in drbd_get_max_capacity()
1795 drbd_get_capacity(bdev->backing_bdev)); in drbd_get_max_capacity()
1798 BM_EXT_TO_SECT(bdev->md.md_size_sect in drbd_get_max_capacity()
1799 - bdev->md.bm_offset)); in drbd_get_max_capacity()
1803 drbd_get_capacity(bdev->backing_bdev)); in drbd_get_max_capacity()
1809 * drbd_md_ss() - Return the sector number of our meta data super block
1814 const int meta_dev_idx = bdev->md.meta_dev_idx; in drbd_md_ss()
1823 return (drbd_get_capacity(bdev->backing_bdev) & ~7ULL) - 8; in drbd_md_ss()
1826 return MD_128MB_SECT * bdev->md.meta_dev_idx; in drbd_md_ss()
1833 spin_lock_irqsave(&q->q_lock, flags); in drbd_queue_work()
1834 list_add_tail(&w->list, &q->q); in drbd_queue_work()
1835 spin_unlock_irqrestore(&q->q_lock, flags); in drbd_queue_work()
1836 wake_up(&q->q_wait); in drbd_queue_work()
1843 spin_lock_irqsave(&q->q_lock, flags); in drbd_queue_work_if_unqueued()
1844 if (list_empty_careful(&w->list)) in drbd_queue_work_if_unqueued()
1845 list_add_tail(&w->list, &q->q); in drbd_queue_work_if_unqueued()
1846 spin_unlock_irqrestore(&q->q_lock, flags); in drbd_queue_work_if_unqueued()
1847 wake_up(&q->q_wait); in drbd_queue_work_if_unqueued()
1853 if (!test_and_set_bit(work_bit, &device->flags)) { in drbd_device_post_work()
1855 first_peer_device(device)->connection; in drbd_device_post_work()
1856 struct drbd_work_queue *q = &connection->sender_work; in drbd_device_post_work()
1857 if (!test_and_set_bit(DEVICE_WORK_PENDING, &connection->flags)) in drbd_device_post_work()
1858 wake_up(&q->q_wait); in drbd_device_post_work()
1865 * so it can change its sk_rcvtimeo from idle- to ping-timeout,
1870 struct task_struct *task = connection->ack_receiver.task; in wake_ack_receiver()
1871 if (task && get_t_state(&connection->ack_receiver) == RUNNING) in wake_ack_receiver()
1877 set_bit(SEND_PING, &connection->flags); in request_ping()
1918 * (drbd_make_request_common; recovery path on read io-error)
1934 atomic_inc(&device->ap_pending_cnt); in inc_ap_pending()
1940 int ap_pending_cnt = atomic_dec_return(&device->ap_pending_cnt); in __dec_ap_pending()
1943 wake_up(&device->misc_wait); in __dec_ap_pending()
1947 /* counts how many resync-related answers we still expect from the peer
1955 atomic_inc(&peer_device->device->rs_pending_cnt); in inc_rs_pending()
1962 return atomic_dec_return(&peer_device->device->rs_pending_cnt); in __dec_rs_pending()
1976 atomic_inc(&device->unacked_cnt); in inc_unacked()
1982 return atomic_dec_return(&device->unacked_cnt); in __dec_unacked()
1988 return atomic_sub_return(n, &device->unacked_cnt); in __sub_unacked()
2010 * get_ldev() - Increase the ref count on device->ldev. Returns 0 if there is no ldev
2014 * You have to call put_ldev() when finished working with device->ldev.
2023 enum drbd_disk_state disk_state = device->state.disk; in put_ldev()
2028 int i = atomic_dec_return(&device->local_cnt); in put_ldev()
2041 if (!test_and_set_bit(GOING_DISKLESS, &device->flags)) in put_ldev()
2043 wake_up(&device->misc_wait); in put_ldev()
2053 if (device->state.disk == D_DISKLESS) in _get_ldev_if_state()
2056 atomic_inc(&device->local_cnt); in _get_ldev_if_state()
2057 io_allowed = (device->state.disk >= mins); in _get_ldev_if_state()
2066 /* this throttles on-the-fly application requests
2068 * maybe re-implement using semaphores? */
2075 nc = rcu_dereference(first_peer_device(device)->connection->net_conf); in drbd_get_max_buffers()
2076 mxb = nc ? nc->max_buffers : 1000000; /* arbitrary limit on open requests */ in drbd_get_max_buffers()
2084 union drbd_dev_state s = device->state; in drbd_state_is_stable()
2118 if (first_peer_device(device)->connection->agreed_pro_version < 96) in drbd_state_is_stable()
2154 struct drbd_resource *resource = device->resource; in drbd_suspended()
2156 return resource->susp || resource->susp_fen || resource->susp_nod; in drbd_suspended()
2165 if (atomic_read(&device->suspend_cnt)) in may_inc_ap_bio()
2178 if (atomic_read(&device->ap_bio_cnt) > mxb) in may_inc_ap_bio()
2180 if (test_bit(BITMAP_IO, &device->flags)) in may_inc_ap_bio()
2189 spin_lock_irq(&device->resource->req_lock); in inc_ap_bio_cond()
2192 atomic_inc(&device->ap_bio_cnt); in inc_ap_bio_cond()
2193 spin_unlock_irq(&device->resource->req_lock); in inc_ap_bio_cond()
2208 wait_event(device->misc_wait, inc_ap_bio_cond(device)); in inc_ap_bio()
2214 int ap_bio = atomic_dec_return(&device->ap_bio_cnt); in dec_ap_bio()
2218 if (ap_bio == 0 && test_bit(BITMAP_IO, &device->flags)) { in dec_ap_bio()
2219 if (!test_and_set_bit(BITMAP_IO_QUEUED, &device->flags)) in dec_ap_bio()
2220 drbd_queue_work(&first_peer_device(device)-> in dec_ap_bio()
2221 connection->sender_work, in dec_ap_bio()
2222 &device->bm_io_work.w); in dec_ap_bio()
2229 wake_up(&device->misc_wait); in dec_ap_bio()
2234 return first_peer_device(device)->connection->agreed_pro_version >= 97 && in verify_can_do_stop_sector()
2235 first_peer_device(device)->connection->agreed_pro_version != 100; in verify_can_do_stop_sector()
2240 int changed = device->ed_uuid != val; in drbd_set_ed_uuid()
2241 device->ed_uuid = val; in drbd_set_ed_uuid()
2257 return list_first_entry_or_null(&resource->connections, in first_connection()