master - device: Keep the last data buffer read off each device.
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bd0967a4b1ac3dc6402b0e9ad8bc2f85f4f7af1c Commit: bd0967a4b1ac3dc6402b0e9ad8bc2f85f4f7af1c Parent: bacc94233368cf136b55e2574e969e7f53b31c6c Author: Alasdair G Kergon <[email protected]> AuthorDate: Wed Jan 10 02:09:06 2018 +0000 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Wed Jan 10 15:48:03 2018 +0000
device: Keep the last data buffer read off each device.
If there's a second metadata area on device, we record that separately.
Note that the memory requirements aren't restricted yet.
--- lib/device/dev-cache.c | 10 +++ lib/device/dev-io.c | 156 +++++++++++++++++++++++++++++++----------------- lib/device/device.h | 31 ++++++++-- 3 files changed, 137 insertions(+), 60 deletions(-)
lib/device/dev-cache.c +10 -0
@@ -1247,12 +1247,22 @@ int dev_cache_check_for_open_devices(void)int dev_cache_exit (void ) { +struct btree_iter *b;int num_open =0 ;if (_cache.names)if ((num_open =_check_for_open_devices (1 )) >0 )log_error (INTERNAL_ERROR "%d device(s) were left open and have been closed." , num_open); +if (_cache.devices) { +/* FIXME Replace with structured devbuf cache */ + b =btree_first (_cache.devices); +while (b) { +devbufs_release (btree_get_data (b)); + b =btree_next (b); + } + } +if (_cache.mem)dm_pool_destroy (_cache.mem);
lib/device/dev-io.c +102 -54
231 lines not on this page · raw message
lib/device/device.h +25 -6
@@ -56,6 +56,22 @@ struct dev_ext {void *handle; }; +struct device_area { +struct device *dev; +uint64_t start;/* Bytes */ +uint64_t size;/* Bytes */ +}; + +struct device_buffer { +void *data;/* Location of start of requested data (inside buf) */ + +/* Private */ +void *malloc_address;/* Start of allocated memory */ +void *buf;/* Aligned buffer that contains data within it */ +struct device_area where;/* Location of buf */ +unsigned write:1 ;/* 1 if write; 0 if read */ +}; +/* * All devices in LVM will be represented by one of these. * pointer comparisons are valid.
@@ -78,6 +94,8 @@ struct device {uint64_t end;struct dm_list open_list;struct dev_ext ext; +struct device_buffer last_devbuf;/* Last data buffer read from the device */ +struct device_buffer last_extra_devbuf;/* Last data buffer read from the device for extra metadata area */ const char *vgid;/* if device is an LV */ const char *lvid;/* if device is an LV */
@@ -102,17 +120,16 @@ typedef enum dev_io_reason { DEV_IO_LOG /* Logging messages */ } dev_io_reason_t; +/* +* Is this I/O for a device's extra metadata area? +*/ +#define EXTRA_IO (reason) ((reason) == DEV_IO_MDA_EXTRA_HEADER || (reason) == DEV_IO_MDA_EXTRA_CONTENT) +struct device_list {struct dm_list list;struct device *dev; }; -struct device_area { -struct device *dev; -uint64_t start;/* Bytes */ -uint64_t size;/* Bytes */ -}; -/* * Support for external device info. */
@@ -174,6 +191,8 @@ struct device *dev_create_file(const char *filename, struct device *dev, struct dm_str_list *alias, int use_malloc);void dev_destroy_file (struct device *dev); +void devbufs_release (struct device *dev); +/* Return a valid device name from the alias list; NULL otherwise */ const char *dev_name_confirmed (struct device *dev,int quiet);