Lines Matching +full:disk +full:- +full:activity

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
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>
72 #define ID_SYNCER (-1ULL)
80 dev_printk(level, disk_to_dev((device)->vdisk), fmt, ## args)
82 dev_printk(level, disk_to_dev((peer_device)->device->vdisk), fmt, ## args)
84 printk(level "drbd %s: " fmt, (resource)->name, ## args)
86 printk(level "drbd %s: " fmt, (connection)->resource->name, ## args)
124 dynamic_dev_dbg(disk_to_dev(device->vdisk), fmt, ## args)
132 * expect - Make an assertion
198 /* statistics; index: (h->command == P_BITMAP) */
216 c->word_offset = c->bit_offset >> 6; in bm_xfer_ctx_bit_to_word_offset()
218 c->word_offset = c->bit_offset >> 5; in bm_xfer_ctx_bit_to_word_offset()
219 c->word_offset &= ~(1UL); in bm_xfer_ctx_bit_to_word_offset()
251 * --lge */ in get_t_state()
254 return thi->t_state; in get_t_state()
308 /* Minimal set of time stamps to determine if we wait for activity log
309 * transactions, local disk or peer. 32 bit "jiffies" are good enough,
316 /* local disk */
332 * how long did we wait for activity log transactions
414 * non-atomic modification to ee->flags is ok.
422 /* explicit zero-out requested, or
484 MD_DIRTY, /* current uuids and flags not yet on disk */
485 USE_DEGR_WFC_T, /* degr-wfc-timeout instead of wfc-timeout. */
498 WAS_IO_ERROR, /* Local disk failed, returned IO error */
499 WAS_READ_ERROR, /* Local disk READ failed (set additionally to the above) */
500 FORCE_DETACH, /* Force-detach from local disk, aborting any pending local IO */
505 AL_SUSPENDED, /* Activity logging is currently suspended. */
506 AHEAD_TO_SYNC_SOURCE, /* Ahead -> SyncSource queued */
511 FLUSH_PENDING, /* if set, device->flush_jif is when we submitted that flush
515 GOING_DISKLESS, /* Disk is being detached, because of io-error, or admin request. */
540 * and still allow all non-bulk operations */
548 * requires sending of "out-of-sync" information, though. */
581 s32 al_offset; /* signed relative sector offset to activity log */
584 /* cached value of bdev->disk_conf->meta_dev_idx (see below) */
597 struct disk_conf *disk_conf; /* RCU, for updates: resource->conf_update */
665 struct mutex conf_update; /* mutex for ready-copy-update of net_conf and disk_conf */
720 …pto_shash *integrity_tfm; /* checksums we compute, updates protected by connection->data->mutex */
744 * protected by resource->req_lock */
769 * with req->epoch == current_epoch_nr.
780 has_net_conf = rcu_dereference(connection->net_conf); in has_net_conf()
793 __update_timing_details(c->w_timing_details, &c->w_cb_nr, cb, __func__ , __LINE__ )
795 __update_timing_details(c->r_timing_details, &c->r_cb_nr, cb, __func__ , __LINE__ )
801 /* protected by ..->resource->req_lock */
836 /* things that are stored as / read from meta data on disk */
842 sector_t p_size; /* partner's disk size */
854 /* Used after attach while negotiating new disk state. */
867 atomic_t ap_actlog_cnt; /* Requests waiting for activity log */
897 /* block not up-to-date at mark [unit BM_BLOCK_SIZE] */
912 /* size of out-of-sync range in sectors. */
929 struct list_head active_ee; /* IO in progress (P_DATA gets written to disk) */
930 struct list_head sync_ee; /* IO in progress (P_RS_DATA_REPLY gets written to disk) */
933 struct list_head net_ee; /* zero-copy network send in progress */
943 struct lru_cache *act_log; /* activity log */
954 …struct mutex *state_mutex; /* either own_state_mutex or first_peer_device(device)->connection->cst…
962 …struct fifo_buffer *rs_plan_s; /* correction values of resync planer (RCU, connection->conn_update…
969 * are deferred to this single-threaded work queue */
975 struct list_head list; /* on device->pending_bitmap_io */;
993 #define VOLUME_UNSPECIFIED (-1U)
1017 return list_first_entry_or_null(&device->peer_devices, struct drbd_peer_device, peer_devices); in first_peer_device()
1023 return idr_find(&connection->peer_devices, volume_number); in conn_peer_device()
1036 list_for_each_entry(connection, &resource->connections, connections)
1039 list_for_each_entry_rcu(connection, &resource->connections, connections)
1042 list_for_each_entry_safe(connection, tmp, &resource->connections, connections)
1045 list_for_each_entry(peer_device, &device->peer_devices, peer_devices)
1048 list_for_each_entry_rcu(peer_device, &device->peer_devices, peer_devices)
1051 list_for_each_entry_safe(peer_device, tmp, &device->peer_devices, peer_devices)
1055 return device->minor; in device_to_minor()
1157 * |----------- md_size_sect ------------------|
1158 * [ 4k superblock ][ activity log ][ Bitmap ]
1161 * ==> bitmap sectors = md_size_sect - bm_offset
1167 * |----------- md_size_sect ------------------|
1168 * [data.....][ Bitmap ][ activity log ][ 4k superblock ][padding*]
1170 * | bm_offset = al_offset - Y |
1171 * ==> bitmap sectors = Y = al_offset - bm_offset
1176 * The activity log consists of 4k transaction blocks,
1177 * which are written in a ring-buffer, or striped ring-buffer like fashion,
1189 /* One activity log extent represents 4M of storage */
1194 * variables at create-md time (or even re-configurable at runtime?).
1208 #define AL_CONTEXT_PER_TRANSACTION 919 // (4096 - 36 - 6*64)/4
1238 * Example: 1GB disk @ 4096 byte blocks ==> we need 32 KB bitmap.
1260 #define BM_SECT_TO_BIT(x) ((x)>>(BM_BLOCK_SHIFT-9))
1261 #define BM_BIT_TO_SECT(x) ((sector_t)(x)<<(BM_BLOCK_SHIFT-9))
1265 #define Bit2KB(bits) ((bits)<<(BM_BLOCK_SHIFT-10))
1269 #define BM_SECT_TO_EXT(x) ((x)>>(BM_EXT_SHIFT-9))
1270 #define BM_BIT_TO_EXT(x) ((x) >> (BM_EXT_SHIFT - BM_BLOCK_SHIFT))
1273 #define BM_EXT_TO_SECT(x) ((sector_t)(x) << (BM_EXT_SHIFT-9))
1277 #define BM_BITS_PER_EXT (1UL << (BM_EXT_SHIFT - BM_BLOCK_SHIFT))
1279 #define BM_BLOCKS_PER_BM_EXT_MASK (BM_BITS_PER_EXT - 1)
1283 #define AL_EXT_PER_BM_SECT (1 << (BM_EXT_SHIFT - AL_EXTENT_SHIFT))
1285 /* the extent in "PER_EXTENT" below is an activity log extent
1290 * bit 0 bit 37 bit 38 bit (512*8)-1
1292 * sect. 0 `296 `304 ^(512*8*8)-1
1300 /* we have a certain meta data variant that has a fixed on-disk size of 128
1301 * MiB, of which 4k are our "superblock", and 32k are the fixed size activity
1306 ((MD_128MB_SECT - MD_32kB_SECT - MD_4kB_SECT) * (1LL<<(BM_EXT_SHIFT-9)))
1322 * Since we may live in a mixed-platform cluster,
1336 * activity log transaction to be discarded in one go. We may need to rework
1392 extern struct kmem_cache *drbd_al_ext_cache; /* activity log extents */
1414 /* We also need a standard (emergency-reserve backed) page pool
1415 * for meta data IO (activity log, bitmap).
1465 DS_ERROR_SHRINK = -3,
1466 DS_ERROR_SPACE_MD = -2,
1467 DS_ERROR = -1,
1510 if (device->ov_last_oos_size) { in ov_out_of_sync_print()
1512 (unsigned long long)device->ov_last_oos_start, in ov_out_of_sync_print()
1513 (unsigned long)device->ov_last_oos_size); in ov_out_of_sync_print()
1515 device->ov_last_oos_size = 0; in ov_out_of_sync_print()
1580 if (!bio->bi_bdev) { in drbd_submit_bio_noacct()
1581 drbd_err(device, "drbd_submit_bio_noacct: bio->bi_bdev == NULL\n"); in drbd_submit_bio_noacct()
1582 bio->bi_status = BLK_STS_IOERR; in drbd_submit_bio_noacct()
1686 struct page *page = peer_req->pages; in drbd_peer_req_has_active_page()
1696 struct drbd_resource *resource = device->resource; in drbd_read_state()
1699 rv.i = device->state.i; in drbd_read_state()
1700 rv.susp = resource->susp; in drbd_read_state()
1701 rv.susp_nod = resource->susp_nod; in drbd_read_state()
1702 rv.susp_fen = resource->susp_fen; in drbd_read_state()
1722 ep = rcu_dereference(device->ldev->disk_conf)->on_io_error; in __drbd_chk_io_error_()
1729 if (device->state.disk > D_INCONSISTENT) in __drbd_chk_io_error_()
1730 _drbd_set_state(_NS(device, disk, D_INCONSISTENT), CS_HARD, NULL); in __drbd_chk_io_error_()
1739 * by the activity log. in __drbd_chk_io_error_()
1742 * blocks, which triggers block re-allocation in lower layers. in __drbd_chk_io_error_()
1747 * Force-detach is not really an IO error, but rather a in __drbd_chk_io_error_()
1756 set_bit(WAS_IO_ERROR, &device->flags); in __drbd_chk_io_error_()
1758 set_bit(WAS_READ_ERROR, &device->flags); in __drbd_chk_io_error_()
1760 set_bit(FORCE_DETACH, &device->flags); in __drbd_chk_io_error_()
1761 if (device->state.disk > D_FAILED) { in __drbd_chk_io_error_()
1762 _drbd_set_state(_NS(device, disk, D_FAILED), CS_HARD, NULL); in __drbd_chk_io_error_()
1776 * See also drbd_main.c:after_state_ch() if (os.disk > D_FAILED && ns.disk == D_FAILED)
1784 spin_lock_irqsave(&device->resource->req_lock, flags); in drbd_chk_io_error_()
1786 spin_unlock_irqrestore(&device->resource->req_lock, flags); in drbd_chk_io_error_()
1792 * drbd_md_first_sector() - Returns the first sector number of the meta data area
1800 switch (bdev->md.meta_dev_idx) { in drbd_md_first_sector()
1803 return bdev->md.md_offset + bdev->md.bm_offset; in drbd_md_first_sector()
1806 return bdev->md.md_offset; in drbd_md_first_sector()
1811 * drbd_md_last_sector() - Return the last sector number of the meta data area
1816 switch (bdev->md.meta_dev_idx) { in drbd_md_last_sector()
1819 return bdev->md.md_offset + MD_4kB_SECT -1; in drbd_md_last_sector()
1822 return bdev->md.md_offset + bdev->md.md_size_sect -1; in drbd_md_last_sector()
1829 /* return bdev ? get_capacity(bdev->bd_disk) : 0; */ in drbd_get_capacity()
1830 return bdev ? i_size_read(bdev->bd_inode) >> 9 : 0; in drbd_get_capacity()
1834 * drbd_get_max_capacity() - Returns the capacity we announce to out peer
1845 switch (bdev->md.meta_dev_idx) { in drbd_get_max_capacity()
1848 s = drbd_get_capacity(bdev->backing_bdev) in drbd_get_max_capacity()
1855 drbd_get_capacity(bdev->backing_bdev)); in drbd_get_max_capacity()
1858 BM_EXT_TO_SECT(bdev->md.md_size_sect in drbd_get_max_capacity()
1859 - bdev->md.bm_offset)); in drbd_get_max_capacity()
1863 drbd_get_capacity(bdev->backing_bdev)); in drbd_get_max_capacity()
1869 * drbd_md_ss() - Return the sector number of our meta data super block
1874 const int meta_dev_idx = bdev->md.meta_dev_idx; in drbd_md_ss()
1883 return (drbd_get_capacity(bdev->backing_bdev) & ~7ULL) - 8; in drbd_md_ss()
1886 return MD_128MB_SECT * bdev->md.meta_dev_idx; in drbd_md_ss()
1893 spin_lock_irqsave(&q->q_lock, flags); in drbd_queue_work()
1894 list_add_tail(&w->list, &q->q); in drbd_queue_work()
1895 spin_unlock_irqrestore(&q->q_lock, flags); in drbd_queue_work()
1896 wake_up(&q->q_wait); in drbd_queue_work()
1903 spin_lock_irqsave(&q->q_lock, flags); in drbd_queue_work_if_unqueued()
1904 if (list_empty_careful(&w->list)) in drbd_queue_work_if_unqueued()
1905 list_add_tail(&w->list, &q->q); in drbd_queue_work_if_unqueued()
1906 spin_unlock_irqrestore(&q->q_lock, flags); in drbd_queue_work_if_unqueued()
1907 wake_up(&q->q_wait); in drbd_queue_work_if_unqueued()
1913 if (!test_and_set_bit(work_bit, &device->flags)) { in drbd_device_post_work()
1915 first_peer_device(device)->connection; in drbd_device_post_work()
1916 struct drbd_work_queue *q = &connection->sender_work; in drbd_device_post_work()
1917 if (!test_and_set_bit(DEVICE_WORK_PENDING, &connection->flags)) in drbd_device_post_work()
1918 wake_up(&q->q_wait); in drbd_device_post_work()
1925 * so it can change its sk_rcvtimeo from idle- to ping-timeout,
1930 struct task_struct *task = connection->ack_receiver.task; in wake_ack_receiver()
1931 if (task && get_t_state(&connection->ack_receiver) == RUNNING) in wake_ack_receiver()
1937 set_bit(SEND_PING, &connection->flags); in request_ping()
1978 * (drbd_make_request_common; recovery path on read io-error)
1994 atomic_inc(&device->ap_pending_cnt); in inc_ap_pending()
1998 if (atomic_read(&device->which) < 0) \
2001 atomic_read(&device->which))
2006 if (atomic_dec_and_test(&device->ap_pending_cnt)) in _dec_ap_pending()
2007 wake_up(&device->misc_wait); in _dec_ap_pending()
2011 /* counts how many resync-related answers we still expect from the peer
2019 atomic_inc(&device->rs_pending_cnt); in inc_rs_pending()
2025 atomic_dec(&device->rs_pending_cnt); in _dec_rs_pending()
2040 atomic_inc(&device->unacked_cnt); in inc_unacked()
2046 atomic_dec(&device->unacked_cnt); in _dec_unacked()
2053 atomic_sub(n, &device->unacked_cnt); in _sub_unacked()
2076 * get_ldev() - Increase the ref count on device->ldev. Returns 0 if there is no ldev
2080 * You have to call put_ldev() when finished working with device->ldev.
2089 enum drbd_disk_state disk_state = device->state.disk; in put_ldev()
2094 int i = atomic_dec_return(&device->local_cnt); in put_ldev()
2107 if (!test_and_set_bit(GOING_DISKLESS, &device->flags)) in put_ldev()
2109 wake_up(&device->misc_wait); in put_ldev()
2119 if (device->state.disk == D_DISKLESS) in _get_ldev_if_state()
2122 atomic_inc(&device->local_cnt); in _get_ldev_if_state()
2123 io_allowed = (device->state.disk >= mins); in _get_ldev_if_state()
2132 /* this throttles on-the-fly application requests
2134 * maybe re-implement using semaphores? */
2141 nc = rcu_dereference(first_peer_device(device)->connection->net_conf); in drbd_get_max_buffers()
2142 mxb = nc ? nc->max_buffers : 1000000; /* arbitrary limit on open requests */ in drbd_get_max_buffers()
2150 union drbd_dev_state s = device->state; in drbd_state_is_stable()
2184 if (first_peer_device(device)->connection->agreed_pro_version < 96) in drbd_state_is_stable()
2196 switch ((enum drbd_disk_state)s.disk) { in drbd_state_is_stable()
2203 /* disk state is stable as well. */ in drbd_state_is_stable()
2220 struct drbd_resource *resource = device->resource; in drbd_suspended()
2222 return resource->susp || resource->susp_fen || resource->susp_nod; in drbd_suspended()
2231 if (atomic_read(&device->suspend_cnt)) in may_inc_ap_bio()
2238 /* no new io accepted when attaching or detaching the disk */ in may_inc_ap_bio()
2244 if (atomic_read(&device->ap_bio_cnt) > mxb) in may_inc_ap_bio()
2246 if (test_bit(BITMAP_IO, &device->flags)) in may_inc_ap_bio()
2255 spin_lock_irq(&device->resource->req_lock); in inc_ap_bio_cond()
2258 atomic_inc(&device->ap_bio_cnt); in inc_ap_bio_cond()
2259 spin_unlock_irq(&device->resource->req_lock); in inc_ap_bio_cond()
2274 wait_event(device->misc_wait, inc_ap_bio_cond(device)); in inc_ap_bio()
2280 int ap_bio = atomic_dec_return(&device->ap_bio_cnt); in dec_ap_bio()
2284 if (ap_bio == 0 && test_bit(BITMAP_IO, &device->flags)) { in dec_ap_bio()
2285 if (!test_and_set_bit(BITMAP_IO_QUEUED, &device->flags)) in dec_ap_bio()
2286 drbd_queue_work(&first_peer_device(device)-> in dec_ap_bio()
2287 connection->sender_work, in dec_ap_bio()
2288 &device->bm_io_work.w); in dec_ap_bio()
2295 wake_up(&device->misc_wait); in dec_ap_bio()
2300 return first_peer_device(device)->connection->agreed_pro_version >= 97 && in verify_can_do_stop_sector()
2301 first_peer_device(device)->connection->agreed_pro_version != 100; in verify_can_do_stop_sector()
2306 int changed = device->ed_uuid != val; in drbd_set_ed_uuid()
2307 device->ed_uuid = val; in drbd_set_ed_uuid()
2323 return list_first_entry_or_null(&resource->connections, in first_connection()