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).
1467 DS_ERROR_SHRINK = -3,
1468 DS_ERROR_SPACE_MD = -2,
1469 DS_ERROR = -1,
1512 if (device->ov_last_oos_size) { in ov_out_of_sync_print()
1514 (unsigned long long)device->ov_last_oos_start, in ov_out_of_sync_print()
1515 (unsigned long)device->ov_last_oos_size); in ov_out_of_sync_print()
1517 device->ov_last_oos_size = 0; in ov_out_of_sync_print()
1582 if (!bio->bi_disk) { in drbd_submit_bio_noacct()
1583 drbd_err(device, "drbd_submit_bio_noacct: bio->bi_disk == NULL\n"); in drbd_submit_bio_noacct()
1584 bio->bi_status = BLK_STS_IOERR; in drbd_submit_bio_noacct()
1688 struct page *page = peer_req->pages; in drbd_peer_req_has_active_page()
1698 struct drbd_resource *resource = device->resource; in drbd_read_state()
1701 rv.i = device->state.i; in drbd_read_state()
1702 rv.susp = resource->susp; in drbd_read_state()
1703 rv.susp_nod = resource->susp_nod; in drbd_read_state()
1704 rv.susp_fen = resource->susp_fen; in drbd_read_state()
1724 ep = rcu_dereference(device->ldev->disk_conf)->on_io_error; in __drbd_chk_io_error_()
1731 if (device->state.disk > D_INCONSISTENT) in __drbd_chk_io_error_()
1732 _drbd_set_state(_NS(device, disk, D_INCONSISTENT), CS_HARD, NULL); in __drbd_chk_io_error_()
1741 * by the activity log. in __drbd_chk_io_error_()
1744 * blocks, which triggers block re-allocation in lower layers. in __drbd_chk_io_error_()
1749 * Force-detach is not really an IO error, but rather a in __drbd_chk_io_error_()
1758 set_bit(WAS_IO_ERROR, &device->flags); in __drbd_chk_io_error_()
1760 set_bit(WAS_READ_ERROR, &device->flags); in __drbd_chk_io_error_()
1762 set_bit(FORCE_DETACH, &device->flags); in __drbd_chk_io_error_()
1763 if (device->state.disk > D_FAILED) { in __drbd_chk_io_error_()
1764 _drbd_set_state(_NS(device, disk, D_FAILED), CS_HARD, NULL); in __drbd_chk_io_error_()
1778 * See also drbd_main.c:after_state_ch() if (os.disk > D_FAILED && ns.disk == D_FAILED)
1786 spin_lock_irqsave(&device->resource->req_lock, flags); in drbd_chk_io_error_()
1788 spin_unlock_irqrestore(&device->resource->req_lock, flags); in drbd_chk_io_error_()
1794 * drbd_md_first_sector() - Returns the first sector number of the meta data area
1802 switch (bdev->md.meta_dev_idx) { in drbd_md_first_sector()
1805 return bdev->md.md_offset + bdev->md.bm_offset; in drbd_md_first_sector()
1808 return bdev->md.md_offset; in drbd_md_first_sector()
1813 * drbd_md_last_sector() - Return the last sector number of the meta data area
1818 switch (bdev->md.meta_dev_idx) { in drbd_md_last_sector()
1821 return bdev->md.md_offset + MD_4kB_SECT -1; in drbd_md_last_sector()
1824 return bdev->md.md_offset + bdev->md.md_size_sect -1; in drbd_md_last_sector()
1831 /* return bdev ? get_capacity(bdev->bd_disk) : 0; */ in drbd_get_capacity()
1832 return bdev ? i_size_read(bdev->bd_inode) >> 9 : 0; in drbd_get_capacity()
1836 * drbd_get_max_capacity() - Returns the capacity we announce to out peer
1847 switch (bdev->md.meta_dev_idx) { in drbd_get_max_capacity()
1850 s = drbd_get_capacity(bdev->backing_bdev) in drbd_get_max_capacity()
1857 drbd_get_capacity(bdev->backing_bdev)); in drbd_get_max_capacity()
1860 BM_EXT_TO_SECT(bdev->md.md_size_sect in drbd_get_max_capacity()
1861 - bdev->md.bm_offset)); in drbd_get_max_capacity()
1865 drbd_get_capacity(bdev->backing_bdev)); in drbd_get_max_capacity()
1871 * drbd_md_ss() - Return the sector number of our meta data super block
1876 const int meta_dev_idx = bdev->md.meta_dev_idx; in drbd_md_ss()
1885 return (drbd_get_capacity(bdev->backing_bdev) & ~7ULL) - 8; in drbd_md_ss()
1888 return MD_128MB_SECT * bdev->md.meta_dev_idx; in drbd_md_ss()
1895 spin_lock_irqsave(&q->q_lock, flags); in drbd_queue_work()
1896 list_add_tail(&w->list, &q->q); in drbd_queue_work()
1897 spin_unlock_irqrestore(&q->q_lock, flags); in drbd_queue_work()
1898 wake_up(&q->q_wait); in drbd_queue_work()
1905 spin_lock_irqsave(&q->q_lock, flags); in drbd_queue_work_if_unqueued()
1906 if (list_empty_careful(&w->list)) in drbd_queue_work_if_unqueued()
1907 list_add_tail(&w->list, &q->q); in drbd_queue_work_if_unqueued()
1908 spin_unlock_irqrestore(&q->q_lock, flags); in drbd_queue_work_if_unqueued()
1909 wake_up(&q->q_wait); in drbd_queue_work_if_unqueued()
1915 if (!test_and_set_bit(work_bit, &device->flags)) { in drbd_device_post_work()
1917 first_peer_device(device)->connection; in drbd_device_post_work()
1918 struct drbd_work_queue *q = &connection->sender_work; in drbd_device_post_work()
1919 if (!test_and_set_bit(DEVICE_WORK_PENDING, &connection->flags)) in drbd_device_post_work()
1920 wake_up(&q->q_wait); in drbd_device_post_work()
1927 * so it can change its sk_rcvtimeo from idle- to ping-timeout,
1932 struct task_struct *task = connection->ack_receiver.task; in wake_ack_receiver()
1933 if (task && get_t_state(&connection->ack_receiver) == RUNNING) in wake_ack_receiver()
1939 set_bit(SEND_PING, &connection->flags); in request_ping()
1980 * (drbd_make_request_common; recovery path on read io-error)
1996 atomic_inc(&device->ap_pending_cnt); in inc_ap_pending()
2000 if (atomic_read(&device->which) < 0) \
2003 atomic_read(&device->which))
2008 if (atomic_dec_and_test(&device->ap_pending_cnt)) in _dec_ap_pending()
2009 wake_up(&device->misc_wait); in _dec_ap_pending()
2013 /* counts how many resync-related answers we still expect from the peer
2021 atomic_inc(&device->rs_pending_cnt); in inc_rs_pending()
2027 atomic_dec(&device->rs_pending_cnt); in _dec_rs_pending()
2042 atomic_inc(&device->unacked_cnt); in inc_unacked()
2048 atomic_dec(&device->unacked_cnt); in _dec_unacked()
2055 atomic_sub(n, &device->unacked_cnt); in _sub_unacked()
2078 * get_ldev() - Increase the ref count on device->ldev. Returns 0 if there is no ldev
2082 * You have to call put_ldev() when finished working with device->ldev.
2091 enum drbd_disk_state disk_state = device->state.disk; in put_ldev()
2096 int i = atomic_dec_return(&device->local_cnt); in put_ldev()
2109 if (!test_and_set_bit(GOING_DISKLESS, &device->flags)) in put_ldev()
2111 wake_up(&device->misc_wait); in put_ldev()
2121 if (device->state.disk == D_DISKLESS) in _get_ldev_if_state()
2124 atomic_inc(&device->local_cnt); in _get_ldev_if_state()
2125 io_allowed = (device->state.disk >= mins); in _get_ldev_if_state()
2134 /* this throttles on-the-fly application requests
2136 * maybe re-implement using semaphores? */
2143 nc = rcu_dereference(first_peer_device(device)->connection->net_conf); in drbd_get_max_buffers()
2144 mxb = nc ? nc->max_buffers : 1000000; /* arbitrary limit on open requests */ in drbd_get_max_buffers()
2152 union drbd_dev_state s = device->state; in drbd_state_is_stable()
2186 if (first_peer_device(device)->connection->agreed_pro_version < 96) in drbd_state_is_stable()
2198 switch ((enum drbd_disk_state)s.disk) { in drbd_state_is_stable()
2205 /* disk state is stable as well. */ in drbd_state_is_stable()
2222 struct drbd_resource *resource = device->resource; in drbd_suspended()
2224 return resource->susp || resource->susp_fen || resource->susp_nod; in drbd_suspended()
2233 if (atomic_read(&device->suspend_cnt)) in may_inc_ap_bio()
2240 /* no new io accepted when attaching or detaching the disk */ in may_inc_ap_bio()
2246 if (atomic_read(&device->ap_bio_cnt) > mxb) in may_inc_ap_bio()
2248 if (test_bit(BITMAP_IO, &device->flags)) in may_inc_ap_bio()
2257 spin_lock_irq(&device->resource->req_lock); in inc_ap_bio_cond()
2260 atomic_inc(&device->ap_bio_cnt); in inc_ap_bio_cond()
2261 spin_unlock_irq(&device->resource->req_lock); in inc_ap_bio_cond()
2276 wait_event(device->misc_wait, inc_ap_bio_cond(device)); in inc_ap_bio()
2282 int ap_bio = atomic_dec_return(&device->ap_bio_cnt); in dec_ap_bio()
2286 if (ap_bio == 0 && test_bit(BITMAP_IO, &device->flags)) { in dec_ap_bio()
2287 if (!test_and_set_bit(BITMAP_IO_QUEUED, &device->flags)) in dec_ap_bio()
2288 drbd_queue_work(&first_peer_device(device)-> in dec_ap_bio()
2289 connection->sender_work, in dec_ap_bio()
2290 &device->bm_io_work.w); in dec_ap_bio()
2297 wake_up(&device->misc_wait); in dec_ap_bio()
2302 return first_peer_device(device)->connection->agreed_pro_version >= 97 && in verify_can_do_stop_sector()
2303 first_peer_device(device)->connection->agreed_pro_version != 100; in verify_can_do_stop_sector()
2308 int changed = device->ed_uuid != val; in drbd_set_ed_uuid()
2309 device->ed_uuid = val; in drbd_set_ed_uuid()
2325 return list_first_entry_or_null(&resource->connections, in first_connection()