Fix first_seg() call for empty segment list.
PATCH 1/1 Fix first_seg() call for empty segment list.
The seg variable is temporary variable for list iterator, code cannot expect that after iteration it remains NULL (it contains non-NULL pointer here id list is empty).
Patch fixes first_seg function so it now correctly returns NULL for empty segment list.
--- WHATS_NEW | 1 + lib/metadata/metadata.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.46 - ================================ + Fix first_seg() call for empty segment list. Fix PV datalignment for values starting prior to MDA area. (2.02.45) Add sparse devices: lvcreate -s --virtualoriginsize (hidden zero origin). Add lvs origin_size field.
lib/metadata/metadata.c +3 -3
@@ -1108,12 +1108,12 @@ struct lv_segment *find_seg_by_le(const struct logical_volume *lv, uint32_t le)struct lv_segment *first_seg (const struct logical_volume *lv) { -struct lv_segment *seg =NULL ; +struct lv_segment *seg; dm_list_iterate_items(seg, &lv->segments) - break; +return seg; -return seg; +return NULL ; }/* Find segment at a given physical extent in a PV */
Signature · 1 line
1.6.2.4
PATCH 1/1 Use readahead of underlying device and not default (smaller) one.
When we are stacking LV over device, which has for some reason increased read_ahead (e.g. MD RAID), the read_ahead hint for libdevmapper is wrong (it is zero).
If the calculated read_ahead hint is zero, patch uses read_ahead of underlying device (if first segment is PV) when setting DM_READ_AHEAD_MINIMUM_FLAG.
Because we are using dev-cache, it also store this value to cache for future use (if several LVs are over one PV, BLKRAGET is called only once for underlying device.)
This should fix all the reamining problems with readahead mismatch reported for DM over MD configurations (and similar cases).
--- WHATS_NEW | 1 + lib/activate/dev_manager.c | 3 ++ lib/device/dev-cache.c | 2 + lib/device/dev-io.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ lib/device/device.h | 2 + test/t-read-ahead.sh | 18 +++++++++----- 6 files changed, 72 insertions(+), 7 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.46 - ================================ + Inherit read ahead from underlying device. Fix first_seg() call for empty segment list. Fix PV datalignment for values starting prior to MDA area. (2.02.45) Add sparse devices: lvcreate -s --virtualoriginsize (hidden zero origin).
lib/activate/dev_manager.c +3 -0
@@ -1021,6 +1021,9 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,if (read_ahead ==DM_READ_AHEAD_AUTO ) {/* we need RA at least twice a whole stripe - see the comment in md/raid0.c */ read_ahead = max_stripe_size *2 ; + seg =first_seg (lv); +if (!read_ahead && seg &&seg_type (seg,0 ) ==AREA_PV ) +dev_get_read_ahead (seg_pv (seg,0 )->dev, &read_ahead); read_ahead_flags =DM_READ_AHEAD_MINIMUM_FLAG ; }
lib/device/dev-cache.c +2 -0
@@ -104,6 +104,7 @@ struct device *dev_create_file(const char *filename, struct device *dev, dev->fd =-1 ; dev->open_count =0 ; dev->block_size =-1 ; + dev->read_ahead =-1 ;memset (dev->pvid,0 ,sizeof (dev->pvid));dm_list_init (&dev->open_list);
@@ -124,6 +125,7 @@ static struct device *_dev_create(dev_t d) dev->fd =-1 ; dev->open_count =0 ; dev->block_size =-1 ; + dev->read_ahead =-1 ; dev->end =UINT64_C (0 );memset (dev->pvid,0 ,sizeof (dev->pvid));dm_list_init (&dev->open_list);
lib/device/dev-io.c +53 -0
65 lines not on this page · raw message
lib/device/device.h +2 -0
@@ -40,6 +40,7 @@ struct device {int fd;int open_count;int block_size; +int read_ahead;uint32_t flags;uint64_t end;struct dm_list open_list;
@@ -64,6 +65,7 @@ struct device_area {*/ int dev_get_size (const struct device *dev,uint64_t *size);int dev_get_sectsize (struct device *dev,uint32_t *size); +int dev_get_read_ahead (struct device *dev,uint32_t *read_ahead);/* Use quiet version if device number could change e.g. when opening LV */ int dev_open (struct device *dev);
test/t-read-ahead.sh +11 -7
@@ -32,14 +32,18 @@ check_lvs_() { aux prepare_vg 5 #COMM "test various read ahead settings (bz450922)" -lvcreate -n "$lv" -l 100%FREE -i5 -I256 "$vg" +lvcreate -n "$lv" -l 100%FREE -i5 -I256 "$vg" ra="$(get_lvs_ lv_kernel_read_ahead)" test "$(( ( $ra / 5 ) * 5 ))" -eq $ra -lvdisplay "$vg"/"$lv" -lvchange -r auto "$vg"/"$lv" 2>&1 | grep auto -check_lvs_ lv_read_ahead auto -check_lvs_ lv_kernel_read_ahead 5120 -lvchange -r 400 "$vg/$lv" -check_lvs_ lv_read_ahead 400 +lvdisplay "$vg"/"$lv" +lvchange -r auto "$vg"/"$lv" 2>&1 | grep auto +check_lvs_ lv_read_ahead auto +check_lvs_ lv_kernel_read_ahead 5120 +lvchange -r 400 "$vg/$lv" +check_lvs_ lv_read_ahead 400 lvremove -ff "$vg" +#COMM "read ahead is properly inherited from underlying PV" +blockdev --setra 768 $dev1 +lvcreate -n $lv -L4M $vg $dev1 +test $(blockdev --getra $G_dev_/$vg/$lv) -eq 768
Signature · 1 line
1.6.2.4
PATCH v2 1/1 Use readahead of underlying device and not default (smaller) one.
When we are stacking LV over device, which has for some reason increased read_ahead (e.g. MD RAID), the read_ahead hint for libdevmapper is wrong (it is zero).
If the calculated read_ahead hint is zero, patch uses read_ahead of underlying device (if first segment is PV) when setting DM_READ_AHEAD_MINIMUM_FLAG.
Because we are using dev-cache, it also store this value to cache for future use (if several LVs are over one PV, BLKRAGET is called only once for underlying device.)
This should fix all the reamining problems with readahead mismatch reported for DM over MD configurations (and similar cases).
--- WHATS_NEW | 1 + lib/activate/activate.c | 5 +++++ lib/activate/dev_manager.c | 2 ++ lib/device/dev-cache.c | 2 ++ lib/device/dev-io.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ lib/device/device.h | 2 ++ lib/metadata/metadata.c | 30 ++++++++++++++++++++++++++++++ lib/metadata/metadata.h | 5 +++++ test/t-read-ahead.sh | 18 +++++++++++------- 9 files changed, 102 insertions(+), 7 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.46 - ================================ + Inherit read ahead from underlying device. Fix first_seg() call for empty segment list. Add make install_lvm2 as complement to device-mapper install. Reject missing PVs from allocation in toollib.
lib/activate/activate.c +5 -0
@@ -469,6 +469,11 @@ static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv, in info->live_table = dminfo.live_table; info->inactive_table = dminfo.inactive_table; +/* +* Cache read ahead value for PV devices now (before possible suspend) +*/ + (void )lv_calculate_readhead (lv); +if (name)dm_pool_free (cmd->mem, name);
lib/activate/dev_manager.c +2 -0
@@ -1021,6 +1021,8 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,if (read_ahead ==DM_READ_AHEAD_AUTO ) {/* we need RA at least twice a whole stripe - see the comment in md/raid0.c */ read_ahead = max_stripe_size *2 ; +if (!read_ahead) + read_ahead =lv_calculate_readhead (lv); read_ahead_flags =DM_READ_AHEAD_MINIMUM_FLAG ; }
lib/device/dev-cache.c +2 -0
@@ -104,6 +104,7 @@ struct device *dev_create_file(const char *filename, struct device *dev, dev->fd =-1 ; dev->open_count =0 ; dev->block_size =-1 ; + dev->read_ahead =-1 ;memset (dev->pvid,0 ,sizeof (dev->pvid));dm_list_init (&dev->open_list);
@@ -124,6 +125,7 @@ static struct device *_dev_create(dev_t d) dev->fd =-1 ; dev->open_count =0 ; dev->block_size =-1 ; + dev->read_ahead =-1 ; dev->end =UINT64_C (0 );memset (dev->pvid,0 ,sizeof (dev->pvid));dm_list_init (&dev->open_list);
lib/device/dev-io.c +44 -0
56 lines not on this page · raw message
lib/device/device.h +2 -0
@@ -40,6 +40,7 @@ struct device {int fd;int open_count;int block_size; +int read_ahead;uint32_t flags;uint64_t end;struct dm_list open_list;
@@ -64,6 +65,7 @@ struct device_area {*/ int dev_get_size (const struct device *dev,uint64_t *size);int dev_get_sectsize (struct device *dev,uint32_t *size); +int dev_get_read_ahead (struct device *dev,uint32_t *read_ahead);/* Use quiet version if device number could change e.g. when opening LV */ int dev_open (struct device *dev);
lib/metadata/metadata.c +30 -0
@@ -1386,6 +1386,7 @@ static int _lv_mark_if_partial(struct logical_volume *lv)return _lv_postorder (lv, _lv_mark_if_partial_single,NULL ); } +/* * Mark LVs with missing PVs using PARTIAL_LV status flag. The flag is * propagated transitively, so LVs referencing other LVs are marked
@@ -1404,6 +1405,35 @@ static int _vg_mark_partial_lvs(struct volume_group *vg)return 1 ; } +/* +* Be sure that all PV devices have cached read ahead in dev-cache +* Currently it takes read_ahead from first PV segment only +*/ +static int _lv_read_ahead_single (struct logical_volume *lv,void *data) +{ +struct lv_segment *seg =first_seg (lv); +uint32_t seg_read_ahead =0 , *read_ahead = data; + +if (seg &&seg_type (seg,0 ) ==AREA_PV ) +dev_get_read_ahead (seg_pv (seg,0 )->dev, &seg_read_ahead); + +if (seg_read_ahead > *read_ahead) + *read_ahead = seg_read_ahead; + +return 1 ; +} + +uint32_t lv_calculate_readhead (const struct logical_volume *lv) +{ +uint32_t read_ahead =0 ; + +if (lv->read_ahead ==DM_READ_AHEAD_AUTO ) +_lv_postorder ((struct logical_volume *)lv, _lv_read_ahead_single, &read_ahead); + +log_debug ("Calculated readahead of LV %s is %u" , lv->name, read_ahead); +return read_ahead; +} +int vg_validate (struct volume_group *vg) {struct pv_list *pvl, *pvl2;
lib/metadata/metadata.h +5 -0
@@ -345,6 +345,11 @@ struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv);unsigned displayable_lvs_in_vg (const struct volume_group *vg);/* +* Calculate readahead from underlying PV devices +*/ +uint32_t lv_calculate_readhead (const struct logical_volume *lv); + +/* * For internal metadata caching. */ int export_vg_to_buffer (struct volume_group *vg,char **buf);
test/t-read-ahead.sh +11 -7
@@ -32,14 +32,18 @@ check_lvs_() { aux prepare_vg 5 #COMM "test various read ahead settings (bz450922)" -lvcreate -n "$lv" -l 100%FREE -i5 -I256 "$vg" +lvcreate -n "$lv" -l 100%FREE -i5 -I256 "$vg" ra="$(get_lvs_ lv_kernel_read_ahead)" test "$(( ( $ra / 5 ) * 5 ))" -eq $ra -lvdisplay "$vg"/"$lv" -lvchange -r auto "$vg"/"$lv" 2>&1 | grep auto -check_lvs_ lv_read_ahead auto -check_lvs_ lv_kernel_read_ahead 5120 -lvchange -r 400 "$vg/$lv" -check_lvs_ lv_read_ahead 400 +lvdisplay "$vg"/"$lv" +lvchange -r auto "$vg"/"$lv" 2>&1 | grep auto +check_lvs_ lv_read_ahead auto +check_lvs_ lv_kernel_read_ahead 5120 +lvchange -r 400 "$vg/$lv" +check_lvs_ lv_read_ahead 400 lvremove -ff "$vg" +#COMM "read ahead is properly inherited from underlying PV" +blockdev --setra 768 $dev1 +lvcreate -n $lv -L4M $vg $dev1 +test $(blockdev --getra $G_dev_/$vg/$lv) -eq 768
Signature · 1 line
1.6.2.4
PATCH 1/1 Do not use generic install if running install_device-mapper.
In reply to Milan BrozIt propagates into subdirs which includes DSOs which requires lvm2 build (only install_device-mapper should propagate there).
--- daemons/dmeventd/Makefile.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
daemons/dmeventd/Makefile.in +1 -1
@@ -63,7 +63,7 @@ endif install: $(INSTALL_TYPE) install_include install_dmeventd -install_device-mapper: install +install_device-mapper: $(INSTALL_TYPE) install_include install_dmeventd install_include: $(INSTALL) -D $(OWNER) $(GROUP) -m 444 libdevmapper-event.h \
Signature · 1 line
1.6.2.4
PATCH 1/1 Fix device-mapper static build targets.
In reply to Milan Brozdmsetup.static is not built and cleaned properly
if running only device-mapper install/build.
--- tools/Makefile.in | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
tools/Makefile.in +6 -3
@@ -66,12 +66,15 @@ TARGETS =\ .commands \ lvm +TARGETS_DM = dmsetup + INSTALL_LVM_TARGETS = install_tools_dynamic INSTALL_DMSETUP_TARGETS = install_dmsetup_dynamic INSTALL_CMDLIB_TARGETS = install_cmdlib_dynamic ifeq ("@STATIC_LINK@", "yes") - TARGETS += lvm.static dmsetup.static + TARGETS += lvm.static + TARGETS_DM += dmsetup.static INSTALL_LVM_TARGETS += install_tools_static INSTALL_DMSETUP_TARGETS += install_dmsetup_static INSTALL_CMDLIB_TARGETS += install_cmdlib_static
@@ -82,7 +85,7 @@ LVMLIBS = -llvm-internal CLEAN_TARGETS = liblvm2cmd.$(LIB_SUFFIX) liblvm2cmd.a liblvm2cmd-static.a lvm lvm.o \ lvm2cmd.o lvm2cmd-static.o lvm2cmdlib.o lvm.static \ lvm.cflow lvm.xref lvm.tree lvm.rxref lvm.rtree \ - lvmcmdlib.o lvm-static.o dmsetup.o dmsetup + lvmcmdlib.o lvm-static.o dmsetup.o $(TARGETS_DM) ifeq ("@CMDLIB@", "yes") TARGETS += liblvm2cmd.$(LIB_SUFFIX)
@@ -99,7 +102,7 @@ DEFS += -DLVM_SHARED_PATH=\"$(exec_prefix)/sbin/lvm\" include $(top_srcdir)/make.tmpl -device-mapper: dmsetup +device-mapper: $(TARGETS_DM) dmsetup: dmsetup.o $(top_srcdir)/libdm/libdevmapper.$(LIB_SUFFIX) $(CC) -o $@ dmsetup.o $(CFLAGS) $(LDFLAGS) \
Signature · 1 line
1.6.2.4
PATCH 1/1 Introduce lvm2_install target.
In reply to Milan BrozBuildsystem support device-mapper only install, but generic install tagret includes both dm+lvm2.
For distribution which uses separate install_device-mapper, there is no way how to install lvm2 only
(so after installing lvm2 for packaging purposes built system must remove installed device-mapper files).
Fix it by allowing lvm2_install target, similarily like install_cluster for clvmd.
(install = install_device-mapper + install_lvm2)
--- WHATS_NEW | 1 + daemons/dmeventd/plugins/mirror/Makefile.in | 4 +++- daemons/dmeventd/plugins/snapshot/Makefile.in | 4 +++- doc/Makefile.in | 4 +++- include/Makefile.in | 2 ++ make.tmpl.in | 7 ++++++- man/Makefile.in | 4 +++- scripts/Makefile.in | 2 ++ tools/Makefile.in | 4 +++- 9 files changed, 26 insertions(+), 6 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.46 - ================================ + Add make install_lvm2 as complement to device-mapper install. Inherit read ahead from underlying device. Fix first_seg() call for empty segment list. Fix PV datalignment for values starting prior to MDA area. (2.02.45)
daemons/dmeventd/plugins/mirror/Makefile.in +3 -1
@@ -31,7 +31,9 @@ LIB_VERSION = $(LIB_VERSION_LVM) include $(top_srcdir)/make.tmpl -install: libdevmapper-event-lvm2mirror.$(LIB_SUFFIX) +install: install_lvm2 + +install_lvm2: libdevmapper-event-lvm2mirror.$(LIB_SUFFIX) $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ $(libdir)/$<.$(LIB_VERSION) $(LN_S) -f $<.$(LIB_VERSION) $(libdir)/$<
daemons/dmeventd/plugins/snapshot/Makefile.in +3 -1
@@ -31,7 +31,9 @@ LIB_VERSION = $(LIB_VERSION_LVM) include $(top_srcdir)/make.tmpl -install: libdevmapper-event-lvm2snapshot.$(LIB_SUFFIX) +install: install_lvm2 + +install_lvm2: libdevmapper-event-lvm2snapshot.$(LIB_SUFFIX) $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ $(libdir)/$<.$(LIB_VERSION) $(LN_S) -f $<.$(LIB_VERSION) $(libdir)/$<
doc/Makefile.in +3 -1
@@ -20,7 +20,9 @@ CONFDEST=lvm.conf include $(top_srcdir)/make.tmpl -install: +install: install_lvm2 + +install_lvm2: @if [ ! -e $(confdir)/$(CONFDEST) ]; then \ echo "Installing $(CONFSRC) as $(confdir)/$(CONFDEST)"; \ @INSTALL@ -D $(OWNER) $(GROUP) -m 644 $(CONFSRC) \
include/Makefile.in +2 -0
@@ -45,5 +45,7 @@ install_cluster: install_device-mapper: +install_lvm2: + cflow:
make.tmpl.in +6 -1
@@ -126,7 +126,7 @@ OBJECTS = $(SOURCES:%.c=%.o) POTFILES = $(SOURCES:%.c=%.pot) .PHONY: all install install_cluster pofile distclean clean cflow device-mapper -.PHONY: install_device-mapper +.PHONY: install_device-mapper install_lvm2 .PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean) .PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow) .PHONY: $(SUBDIRS.device-mapper) $(SUBDIRS.install-device-mapper)
@@ -135,6 +135,7 @@ SUBDIRS.device-mapper := $(SUBDIRS:=.device-mapper) SUBDIRS.install := $(SUBDIRS:=.install) SUBDIRS.install_cluster := $(SUBDIRS:=.install_cluster) SUBDIRS.install_device-mapper := $(SUBDIRS:=.install_device-mapper) +SUBDIRS.install_lvm2 := $(SUBDIRS:=.install_lvm2) SUBDIRS.pofile := $(SUBDIRS:=.pofile) SUBDIRS.cflow := $(SUBDIRS:=.cflow) SUBDIRS.clean := $(SUBDIRS:=.clean)
@@ -147,6 +148,7 @@ all: $(SUBDIRS) $(TARGETS) install: all $(SUBDIRS.install) install_cluster: all $(SUBDIRS.install_cluster) install_device-mapper: $(SUBDIRS.install_device-mapper) +install_lvm2: $(SUBDIRS.install_lvm2) $(SUBDIRS): $(SUBDIRS.device-mapper) $(MAKE) -C $@
@@ -163,6 +165,9 @@ $(SUBDIRS.install_cluster): $(SUBDIRS) $(SUBDIRS.install_device-mapper): device-mapper $(MAKE) -C $(@:.install_device-mapper=) install_device-mapper +$(SUBDIRS.install_lvm2): $(SUBDIRS) + $(MAKE) -C $(@:.install_lvm2=) install_lvm2 + $(SUBDIRS.clean): -$(MAKE) -C $(@:.clean=) clean
man/Makefile.in +3 -1
@@ -57,7 +57,9 @@ $(MAN5) $(MAN8) $(MAN8CLUSTER): Makefile %: %.in $(SED) -e "s/#VERSION#/$(LVM_VERSION)/" $< > $@ -install: install_device-mapper +install: install_lvm2 install_device-mapper + +install_lvm2: @echo "Installing $(MAN8) in $(MAN8DIR)" @for f in $(MAN8); \ do \
scripts/Makefile.in +2 -0
@@ -17,6 +17,8 @@ VPATH = @srcdir@ include $(top_srcdir)/make.tmpl +install_lvm2: install + install: $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) lvm_dump.sh \ $(sbindir)/lvmdump
tools/Makefile.in +3 -1
@@ -195,4 +195,6 @@ install_dmsetup_static: dmsetup.static install_device-mapper: $(INSTALL_DMSETUP_TARGETS) -install: $(INSTALL_LVM_TARGETS) install_device-mapper +install_lvm2: $(INSTALL_LVM_TARGETS) + +install: install_lvm2 install_device-mapper
Signature · 1 line
1.6.2.4