4

I am using an lvm cache in the most usual combination (small, fast ssd before a huge, slow hdd). It is simply awesome.

However, I have not found a way to know, how many blocks are actually cached and how. What is particularly interesting:

  1. Size of the read cache. These are the blocks on the ssd which are the same as the corresponding hdd block.

  2. Size of the write cache. These blocks are the result if a write operation to the merged device, they are different on the ssd as on the hdd, and once (as there will be resources for that) will need to be synced out.

My research found that lvm-cache is using device mapper below, more exactly the dm-cache driver. A dmsetup table command is enough to get some numbers, but there is no way to know, exactly which number means what. I think, there should exist some lvm-level solution for the task.

1

1 Answer 1

0

I'm not sure if this will give you the exact data you're looking for, but a lot of information can be collected using lvs, for example:

sudo lvs -o +cache_used_blocks,writecache_total_blocks,cache_read_hits,cache_read_misses,cache_write_hits,cache_write_misses 

You can get the list of all options with lvs -o help:

 Logical Volume Fields --------------------- lv_all - All fields in this section. lv_uuid - Unique identifier. lv_name - Name. LVs created for internal use are enclosed in brackets. lv_full_name - Full name of LV including its VG, namely VG/LV. lv_path - Full pathname for LV. Blank for internal LVs. lv_dm_path - Internal device-mapper pathname for LV (in /dev/mapper directory). lv_parent - For LVs that are components of another LV, the parent LV. lv_layout - LV layout. lv_role - LV role. lv_initial_image_sync - Set if mirror/RAID images underwent initial resynchronization. lv_image_synced - Set if mirror/RAID image is synchronized. lv_merging - Set if snapshot LV is being merged to origin. lv_converting - Set if LV is being converted. lv_allocation_policy - LV allocation policy. lv_allocation_locked - Set if LV is locked against allocation changes. lv_fixed_minor - Set if LV has fixed minor number assigned. lv_skip_activation - Set if LV is skipped on activation. lv_autoactivation - Set if LV autoactivation is enabled. lv_when_full - For thin pools, behavior when full. lv_active - Active state of the LV. lv_active_locally - Set if the LV is active locally. lv_active_remotely - Set if the LV is active remotely. lv_active_exclusively - Set if the LV is active exclusively. lv_major - Persistent major number or -1 if not persistent. lv_minor - Persistent minor number or -1 if not persistent. lv_read_ahead - Read ahead setting in current units. lv_size - Size of LV in current units. lv_metadata_size - For thin and cache pools, the size of the LV that holds the metadata. seg_count - Number of segments in LV. origin - For snapshots and thins, the origin device of this LV. origin_uuid - For snapshots and thins, the UUID of origin device of this LV. origin_size - For snapshots, the size of the origin device of this LV. lv_ancestors - LV ancestors ignoring any stored history of the ancestry chain. lv_full_ancestors - LV ancestors including stored history of the ancestry chain. lv_descendants - LV descendants ignoring any stored history of the ancestry chain. lv_full_descendants - LV descendants including stored history of the ancestry chain. raid_mismatch_count - For RAID, number of mismatches found or repaired. raid_sync_action - For RAID, the current synchronization action being performed. raid_write_behind - For RAID1, the number of outstanding writes allowed to writemostly devices. raid_min_recovery_rate - For RAID1, the minimum recovery I/O load in kiB/sec/disk. raid_max_recovery_rate - For RAID1, the maximum recovery I/O load in kiB/sec/disk. raidintegritymode - The integrity mode raidintegrityblocksize - The integrity block size integritymismatches - The number of integrity mismatches. move_pv - For pvmove, Source PV of temporary LV created by pvmove. move_pv_uuid - For pvmove, the UUID of Source PV of temporary LV created by pvmove. convert_lv - For lvconvert, Name of temporary LV created by lvconvert. convert_lv_uuid - For lvconvert, UUID of temporary LV created by lvconvert. mirror_log - For mirrors, the LV holding the synchronisation log. mirror_log_uuid - For mirrors, the UUID of the LV holding the synchronisation log. data_lv - For cache/thin/vdo pools, the LV holding the associated data. data_lv_uuid - For cache/thin/vdo pools, the UUID of the LV holding the associated data. metadata_lv - For cache/thin pools, the LV holding the associated metadata. metadata_lv_uuid - For cache/thin pools, the UUID of the LV holding the associated metadata. pool_lv - For cache/thin/vdo volumes, the cache/thin/vdo pool LV for this volume. pool_lv_uuid - For cache/thin/vdo volumes, the UUID of the cache/thin/vdo pool LV for this volume. lv_tags - Tags, if any. lv_profile - Configuration profile attached to this LV. lv_lockargs - Lock args of the LV used by lvmlockd. lv_time - Creation time of the LV, if known lv_time_removed - Removal time of the LV, if known lv_host - Creation host of the LV, if known. lv_modules - Kernel device-mapper modules required for this LV. lv_historical - Set if the LV is historical. writecache_block_size - The writecache block size Logical Volume Device Info Fields --------------------------------- lv_all - All fields in this section. lv_kernel_major - Currently assigned major number or -1 if LV is not active. lv_kernel_minor - Currently assigned minor number or -1 if LV is not active. lv_kernel_read_ahead - Currently-in-use read ahead setting in current units. lv_permissions - LV permissions. lv_suspended - Set if LV is suspended. lv_live_table - Set if LV has live table present. lv_inactive_table - Set if LV has inactive table present. lv_device_open - Set if LV device is open. Logical Volume Device Status Fields ----------------------------------- lv_all - All fields in this section. data_percent - For snapshot, cache and thin pools and volumes, the percentage full if LV is active. snap_percent - For snapshots, the percentage full if LV is active. metadata_percent - For cache and thin pools, the percentage of metadata full if LV is active. copy_percent - For Cache, RAID, mirrors and pvmove, current percentage in-sync. sync_percent - For Cache, RAID, mirrors and pvmove, current percentage in-sync. cache_total_blocks - Total cache blocks. cache_used_blocks - Used cache blocks. cache_dirty_blocks - Dirty cache blocks. cache_read_hits - Cache read hits. cache_read_misses - Cache read misses. cache_write_hits - Cache write hits. cache_write_misses - Cache write misses. kernel_cache_settings - Cache settings/parameters as set in kernel, including default values (cached segments only). kernel_cache_policy - Cache policy used in kernel. kernel_metadata_format - Cache metadata format used in kernel. lv_health_status - LV health status. kernel_discards - For thin pools, how discards are handled in kernel. lv_check_needed - For thin pools and cache volumes, whether metadata check is needed. lv_merge_failed - Set if snapshot merge failed. lv_snapshot_invalid - Set if snapshot LV is invalid. vdo_operating_mode - For vdo pools, its current operating mode. vdo_compression_state - For vdo pools, whether compression is running. vdo_index_state - For vdo pools, state of index for deduplication. vdo_used_size - For vdo pools, currently used space. vdo_saving_percent - For vdo pools, percentage of saved space. writecache_total_blocks - Total writecache blocks. writecache_free_blocks - Total writecache free blocks. writecache_writeback_blocks - Total writecache writeback blocks. writecache_error - Total writecache errors. Logical Volume Device Info and Status Combined Fields ----------------------------------------------------- lv_all - All fields in this section. lv_attr - Various attributes - see man page. Physical Volume Label Fields ---------------------------- pv_all - All fields in this section. pv_fmt - Type of metadata. pv_uuid - Unique identifier. dev_size - Size of underlying device in current units. pv_name - Name. pv_major - Device major number. pv_minor - Device minor number. pv_mda_free - Free metadata area space on this device in current units. pv_mda_size - Size of smallest metadata area on this device in current units. pv_ext_vsn - PV header extension version. Physical Volume Fields ---------------------- pv_all - All fields in this section. pe_start - Offset to the start of data on the underlying device. pv_size - Size of PV in current units. pv_free - Total amount of unallocated space in current units. pv_used - Total amount of allocated space in current units. pv_attr - Various attributes - see man page. pv_allocatable - Set if this device can be used for allocation. pv_exported - Set if this device is exported. pv_missing - Set if this device is missing in system. pv_pe_count - Total number of Physical Extents. pv_pe_alloc_count - Total number of allocated Physical Extents. pv_tags - Tags, if any. pv_mda_count - Number of metadata areas on this device. pv_mda_used_count - Number of metadata areas in use on this device. pv_ba_start - Offset to the start of PV Bootloader Area on the underlying device in current units. pv_ba_size - Size of PV Bootloader Area in current units. pv_in_use - Set if PV is used. pv_duplicate - Set if PV is an unchosen duplicate. pv_device_id - Device ID such as the WWID. pv_device_id_type - Type of device ID such as WWID. Volume Group Fields ------------------- vg_all - All fields in this section. vg_fmt - Type of metadata. vg_uuid - Unique identifier. vg_name - Name. vg_attr - Various attributes - see man page. vg_permissions - VG permissions. vg_extendable - Set if VG is extendable. vg_exported - Set if VG is exported. vg_autoactivation - Set if VG autoactivation is enabled. vg_partial - Set if VG is partial. vg_allocation_policy - VG allocation policy. vg_clustered - Set if VG is clustered. vg_shared - Set if VG is shared. vg_size - Total size of VG in current units. vg_free - Total amount of free space in current units. vg_sysid - System ID of the VG indicating which host owns it. vg_systemid - System ID of the VG indicating which host owns it. vg_lock_type - Lock type of the VG used by lvmlockd. vg_lock_args - Lock args of the VG used by lvmlockd. vg_extent_size - Size of Physical Extents in current units. vg_extent_count - Total number of Physical Extents. vg_free_count - Total number of unallocated Physical Extents. max_lv - Maximum number of LVs allowed in VG or 0 if unlimited. max_pv - Maximum number of PVs allowed in VG or 0 if unlimited. pv_count - Number of PVs in VG. vg_missing_pv_count - Number of PVs in VG which are missing. lv_count - Number of LVs. snap_count - Number of snapshots. vg_seqno - Revision number of internal metadata. Incremented whenever it changes. vg_tags - Tags, if any. vg_profile - Configuration profile attached to this VG. vg_mda_count - Number of metadata areas on this VG. vg_mda_used_count - Number of metadata areas in use on this VG. vg_mda_free - Free metadata area space for this VG in current units. vg_mda_size - Size of smallest metadata area for this VG in current units. vg_mda_copies - Target number of in use metadata areas in the VG. Logical Volume Segment Fields ----------------------------- seg_all - All fields in this section. segtype - Type of LV segment. stripes - Number of stripes or mirror/raid1 legs. data_stripes - Number of data stripes or mirror/raid1 legs. reshape_len - Size of out-of-place reshape space in current units. reshape_len_le - Size of out-of-place reshape space in logical extents. data_copies - Number of data copies. data_offset - Data offset on each image device. new_data_offset - New data offset after any reshape on each image device. parity_chunks - Number of (rotating) parity chunks. stripe_size - For stripes, amount of data placed on one device before switching to the next. region_size - For mirrors/raids, the unit of data per leg when synchronizing devices. chunk_size - For snapshots, the unit of data used when tracking changes. thin_count - For thin pools, the number of thin volumes in this pool. discards - For thin pools, how discards are handled. cache_metadata_format - For cache, metadata format in use. cache_mode - For cache, how writes are cached. zero - For thin pools and volumes, if zeroing is enabled. transaction_id - For thin pools, the transaction id and creation transaction id for thins. thin_id - For thin volume, the thin device id. seg_start - Offset within the LV to the start of the segment in current units. seg_start_pe - Offset within the LV to the start of the segment in physical extents. seg_size - Size of segment in current units. seg_size_pe - Size of segment in physical extents. seg_tags - Tags, if any. seg_pe_ranges - Ranges of Physical Extents of underlying devices in command line format (deprecated, use seg_le_ranges for common format). seg_le_ranges - Ranges of Logical Extents of underlying devices in command line format. seg_metadata_le_ranges - Ranges of Logical Extents of underlying metadata devices in command line format. devices - Underlying devices used with starting extent numbers. metadata_devices - Underlying metadata devices used with starting extent numbers. seg_monitor - Dmeventd monitoring status of the segment. cache_policy - The cache policy (cached segments only). cache_settings - Cache settings/parameters (cached segments only). vdo_compression - Set for compressed LV (vdopool). vdo_deduplication - Set for deduplicated LV (vdopool). vdo_use_metadata_hints - Use REQ_SYNC for writes (vdopool). vdo_minimum_io_size - Minimum acceptable IO size (vdopool). vdo_block_map_cache_size - Allocated caching size (vdopool). vdo_block_map_era_length - Speed of cache writes (vdopool). vdo_use_sparse_index - Sparse indexing (vdopool). vdo_index_memory_size - Allocated indexing memory (vdopool). vdo_slab_size - Increment size for growing (vdopool). vdo_ack_threads - Acknowledging threads (vdopool). vdo_bio_threads - IO submitting threads (vdopool). vdo_bio_rotation - IO enqueue (vdopool). vdo_cpu_threads - CPU threads for compression and hashing (vdopool). vdo_hash_zone_threads - Threads for subdivide parts (vdopool). vdo_logical_threads - Logical threads for subdivide parts (vdopool). vdo_physical_threads - Physical threads for subdivide parts (vdopool). vdo_max_discard - Maximum discard size volume can recieve (vdopool). vdo_write_policy - Specified write policy (vdopool). vdo_header_size - Header size at front of vdopool. Physical Volume Segment Fields ------------------------------ pvseg_all - All fields in this section. pvseg_start - Physical Extent number of start of segment. pvseg_size - Number of extents in segment. Special Fields -------------- selected - Set if item passes selection criteria. help - Show help. ? - Show help. 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.