master - bcache: squash some warnings on rhel6
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bfc61a9543f3fc669d2...
Commit: bfc61a9543f3fc669d265d9b6e384cef0ab78ef2
Parent: de042fa13ddaecc9b4512ceb4196b2a2345f1f90
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Tue May 1 13:21:53 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Tue May 1 13:21:53 2018 +0100
bcache: squash some warnings on rhel6
---
lib/device/bcache.c | 50 +++++++++++++++++++++++++-------------------------
1 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 2464e59..68d2e53 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -36,9 +36,9 @@
//----------------------------------------------------------------
-static void log_sys_warn(const char *syscall)
+static void log_sys_warn(const char *call)
{
- log_warn("%s failed: %s", syscall, strerror(errno));
+ log_warn("%s failed: %s", call, strerror(errno));
}
// Assumes the list is not empty.
@@ -164,7 +164,7 @@ static bool _async_issue(struct io_engine *ioe, enum dir d, int fd,
struct control_block *cb;
struct async_engine *e = _to_async(ioe);
- if (((uint64_t) data) & (PAGE_SIZE - 1)) {
+ if (((uintptr_t) data) & (PAGE_SIZE - 1)) {
log_warn("misaligned data buffer");
return false;
}
@@ -366,22 +366,22 @@ struct bcache {
//----------------------------------------------------------------
/* 2^63 + 2^61 - 2^57 + 2^54 - 2^51 - 2^18 + 1 */
-#define GOLDEN_RATIO_PRIME_64 0x9e37fffffffc0001UL
+#define GOLDEN_RATIO_PRIME_64 0x9e37fffffffc0001ULL
-static unsigned _hash(struct bcache *cache, int fd, uint64_t index)
+static unsigned _hash(struct bcache *cache, int fd, uint64_t i)
{
- uint64_t h = (index << 10) & fd;
+ uint64_t h = (i << 10) & fd;
h *= GOLDEN_RATIO_PRIME_64;
return h & cache->hash_mask;
}
-static struct block *_hash_lookup(struct bcache *cache, int fd, uint64_t index)
+static struct block *_hash_lookup(struct bcache *cache, int fd, uint64_t i)
{
struct block *b;
- unsigned h = _hash(cache, fd, index);
+ unsigned h = _hash(cache, fd, i);
dm_list_iterate_items_gen (b, cache->buckets + h, hash)
- if (b->fd == fd && b->index == index)
+ if (b->fd == fd && b->index == i)
return b;
return NULL;
@@ -641,7 +641,7 @@ static struct block *_find_unused_clean_block(struct bcache *cache)
return NULL;
}
-static struct block *_new_block(struct bcache *cache, int fd, block_address index, bool can_wait)
+static struct block *_new_block(struct bcache *cache, int fd, block_address i, bool can_wait)
{
struct block *b;
@@ -655,7 +655,7 @@ static struct block *_new_block(struct bcache *cache, int fd, block_address inde
_wait_io(cache);
} else {
log_error("bcache no new blocks for fd %d index %u",
- fd, (uint32_t)index);
+ fd, (uint32_t) i);
return NULL;
}
}
@@ -666,7 +666,7 @@ static struct block *_new_block(struct bcache *cache, int fd, block_address inde
dm_list_init(&b->hash);
b->flags = 0;
b->fd = fd;
- b->index = index;
+ b->index = i;
b->ref_count = 0;
b->error = 0;
@@ -677,7 +677,7 @@ static struct block *_new_block(struct bcache *cache, int fd, block_address inde
if (!b) {
log_error("bcache no new blocks for fd %d index %u "
"clean %u free %u dirty %u pending %u nr_data_blocks %u nr_cache_blocks %u",
- fd, (uint32_t)index,
+ fd, (uint32_t) i,
dm_list_size(&cache->clean),
dm_list_size(&cache->free),
dm_list_size(&cache->dirty),
@@ -721,10 +721,10 @@ static void _miss(struct bcache *cache, unsigned flags)
}
static struct block *_lookup_or_read_block(struct bcache *cache,
- int fd, block_address index,
+ int fd, block_address i,
unsigned flags)
{
- struct block *b = _hash_lookup(cache, fd, index);
+ struct block *b = _hash_lookup(cache, fd, i);
if (b) {
// FIXME: this is insufficient. We need to also catch a read
@@ -749,7 +749,7 @@ static struct block *_lookup_or_read_block(struct bcache *cache,
} else {
_miss(cache, flags);
- b = _new_block(cache, fd, index, true);
+ b = _new_block(cache, fd, i, true);
if (b) {
if (flags & GF_ZERO)
_zero_block(b);
@@ -873,13 +873,13 @@ unsigned bcache_max_prefetches(struct bcache *cache)
return cache->max_io;
}
-void bcache_prefetch(struct bcache *cache, int fd, block_address index)
+void bcache_prefetch(struct bcache *cache, int fd, block_address i)
{
- struct block *b = _hash_lookup(cache, fd, index);
+ struct block *b = _hash_lookup(cache, fd, i);
if (!b) {
if (cache->nr_io_pending < cache->max_io) {
- b = _new_block(cache, fd, index, false);
+ b = _new_block(cache, fd, i, false);
if (b) {
cache->prefetches++;
_issue_read(b);
@@ -895,12 +895,12 @@ static void _recycle_block(struct bcache *cache, struct block *b)
dm_list_add(&cache->free, &b->list);
}
-bool bcache_get(struct bcache *cache, int fd, block_address index,
+bool bcache_get(struct bcache *cache, int fd, block_address i,
unsigned flags, struct block **result, int *error)
{
struct block *b;
- b = _lookup_or_read_block(cache, fd, index, flags);
+ b = _lookup_or_read_block(cache, fd, i, flags);
if (b) {
if (b->error) {
*error = b->error;
@@ -926,7 +926,7 @@ bool bcache_get(struct bcache *cache, int fd, block_address index,
if (error)
*error = -BCACHE_NO_BLOCK;
- log_error("bcache failed to get block %u fd %d", (uint32_t)index, fd);
+ log_error("bcache failed to get block %u fd %d", (uint32_t) i, fd);
return false;
}
@@ -985,7 +985,7 @@ static bool _invalidate_block(struct bcache *cache, struct block *b)
if (b->ref_count) {
log_warn("bcache_invalidate: block (%d, %llu) still held",
- b->fd, (unsigned long long) index);
+ b->fd, (unsigned long long) b->index);
return false;
}
@@ -1002,9 +1002,9 @@ static bool _invalidate_block(struct bcache *cache, struct block *b)
return true;
}
-bool bcache_invalidate(struct bcache *cache, int fd, block_address index)
+bool bcache_invalidate(struct bcache *cache, int fd, block_address i)
{
- return _invalidate_block(cache, _hash_lookup(cache, fd, index));
+ return _invalidate_block(cache, _hash_lookup(cache, fd, i));
}
// FIXME: switch to a trie, or maybe 1 hash table per fd? To save iterating
5 years, 12 months
master - unit-test/bcache_t: Use a stripped down fixture for some tests
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=de042fa13ddaecc9b45...
Commit: de042fa13ddaecc9b4512ceb4196b2a2345f1f90
Parent: 61153d90e55309cd6bca9c8d1a1e7a7421464663
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Tue May 1 12:54:57 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Tue May 1 12:54:57 2018 +0100
unit-test/bcache_t: Use a stripped down fixture for some tests
---
test/unit/bcache_t.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/test/unit/bcache_t.c b/test/unit/bcache_t.c
index 85bb321..bb1db29 100644
--- a/test/unit/bcache_t.c
+++ b/test/unit/bcache_t.c
@@ -834,9 +834,9 @@ static void test_invalidate_held_block(void *context)
*--------------------------------------------------------------*/
#define T(path, desc, fn) register_test(ts, "/base/device/bcache/" path, desc, fn)
-static struct test_suite *_small_tests(void)
+static struct test_suite *_tiny_tests(void)
{
- struct test_suite *ts = test_suite_create(_small_fixture_init, _small_fixture_exit);
+ struct test_suite *ts = test_suite_create(NULL, NULL);
if (!ts) {
fprintf(stderr, "out of memory\n");
exit(1);
@@ -846,6 +846,18 @@ static struct test_suite *_small_tests(void)
T("cache-blocks-positive", "nr cache blocks must be positive", test_nr_cache_blocks_must_be_positive);
T("block-size-positive", "block size must be positive", test_block_size_must_be_positive);
T("block-size-multiple-page", "block size must be a multiple of page size", test_block_size_must_be_multiple_of_page_size);
+
+ return ts;
+}
+
+static struct test_suite *_small_tests(void)
+{
+ struct test_suite *ts = test_suite_create(_small_fixture_init, _small_fixture_exit);
+ if (!ts) {
+ fprintf(stderr, "out of memory\n");
+ exit(1);
+ }
+
T("get-reads", "bcache_get() triggers read", test_get_triggers_read);
T("reads-cached", "repeated reads are cached", test_repeated_reads_are_cached);
T("blocks-get-evicted", "block get evicted with many reads", test_block_gets_evicted_with_many_reads);
@@ -884,6 +896,7 @@ static struct test_suite *_large_tests(void)
void bcache_tests(struct dm_list *all_tests)
{
+ dm_list_add(all_tests, &_tiny_tests()->list);
dm_list_add(all_tests, &_small_tests()->list);
dm_list_add(all_tests, &_large_tests()->list);
}
5 years, 12 months
master - build: update ./configure and configure.h.in
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=61153d90e55309cd6bc...
Commit: 61153d90e55309cd6bca9c8d1a1e7a7421464663
Parent: f564e78d98747266c7add85906309f773de42061
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Tue May 1 12:12:07 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Tue May 1 12:12:07 2018 +0100
build: update ./configure and configure.h.in
Fallout from Dave's removal of format1 and pool.
---
configure | 93 +-----------------------------------------------
include/configure.h.in | 14 -------
2 files changed, 1 insertions(+), 106 deletions(-)
diff --git a/configure b/configure
index f2e946e..844e628 100755
--- a/configure
+++ b/configure
@@ -676,7 +676,6 @@ PYTHON_BINDINGS
PYTHON3
PTHREAD_LIBS
M_LIBS
-POOL
PKGCONFIG
ODIRECT
OCFDIR
@@ -691,8 +690,6 @@ LVM_MINOR
LVM_MAJOR
LVM_LIBAPI
LVM_VERSION
-LVM1_FALLBACK
-LVM1
LIB_SUFFIX
LDDEPS
JOBS
@@ -720,7 +717,6 @@ DEFAULT_RAID10_SEGTYPE
DEFAULT_PROFILE_SUBDIR
DEFAULT_PID_DIR
DEFAULT_MIRROR_SEGTYPE
-DEFAULT_FALLBACK_TO_LVM1
DEFAULT_LOCK_DIR
DEFAULT_DM_RUN_DIR
DEFAULT_DATA_ALIGNMENT
@@ -913,9 +909,6 @@ with_device_gid
with_device_mode
with_device_nodes_on
with_default_name_mangling
-enable_lvm1_fallback
-with_lvm1
-with_pool
with_cluster
with_snapshots
with_mirrors
@@ -1682,8 +1675,6 @@ Optional Features:
speeds up one-time build.
--enable-static_link use this to link the tools to their libraries
statically (default is dynamic linking
- --enable-lvm1_fallback use this to fall back and use LVM1 binaries if
- device-mapper is missing from the kernel
--disable-thin_check_needs_check
required if thin_check version is < 0.3.0
--disable-cache_check_needs_check
@@ -1750,10 +1741,6 @@ Optional Packages:
create nodes on resume or create [ON=resume]
--with-default-name-mangling=MANGLING
default name mangling: auto/none/hex [auto]
- --with-lvm1=TYPE LVM1 metadata support: internal/shared/none
- [internal]
- --with-pool=TYPE GFS pool read-only support: internal/shared/none
- [internal]
--with-cluster=TYPE cluster LVM locking support: internal/shared/none
[internal]
--with-snapshots=TYPE snapshot support: internal/shared/none [internal]
@@ -8388,78 +8375,6 @@ _ACEOF
################################################################################
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable lvm1 fallback" >&5
-$as_echo_n "checking whether to enable lvm1 fallback... " >&6; }
-# Check whether --enable-lvm1_fallback was given.
-if test "${enable_lvm1_fallback+set}" = set; then :
- enableval=$enable_lvm1_fallback; LVM1_FALLBACK=$enableval
-else
- LVM1_FALLBACK=no
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LVM1_FALLBACK" >&5
-$as_echo "$LVM1_FALLBACK" >&6; }
-
-if test "$LVM1_FALLBACK" = yes; then
- DEFAULT_FALLBACK_TO_LVM1=1
-
-$as_echo "#define LVM1_FALLBACK 1" >>confdefs.h
-
-else
- DEFAULT_FALLBACK_TO_LVM1=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define DEFAULT_FALLBACK_TO_LVM1 $DEFAULT_FALLBACK_TO_LVM1
-_ACEOF
-
-
-################################################################################
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to include support for lvm1 metadata" >&5
-$as_echo_n "checking whether to include support for lvm1 metadata... " >&6; }
-
-# Check whether --with-lvm1 was given.
-if test "${with_lvm1+set}" = set; then :
- withval=$with_lvm1; LVM1=$withval
-else
- LVM1=internal
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LVM1" >&5
-$as_echo "$LVM1" >&6; }
-
-case "$LVM1" in
- none|shared) ;;
- internal)
-$as_echo "#define LVM1_INTERNAL 1" >>confdefs.h
- ;;
- *) as_fn_error $? "--with-lvm1 parameter invalid" "$LINENO" 5 ;;
-esac
-
-################################################################################
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to include support for GFS pool metadata" >&5
-$as_echo_n "checking whether to include support for GFS pool metadata... " >&6; }
-
-# Check whether --with-pool was given.
-if test "${with_pool+set}" = set; then :
- withval=$with_pool; POOL=$withval
-else
- POOL=internal
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $POOL" >&5
-$as_echo "$POOL" >&6; }
-
-case "$POOL" in
- none|shared) ;;
- internal)
-$as_echo "#define POOL_INTERNAL 1" >>confdefs.h
- ;;
- *) as_fn_error $? "--with-pool parameter invalid" "$LINENO" 5
-esac
-
-################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to include support for cluster locking" >&5
$as_echo_n "checking whether to include support for cluster locking... " >&6; }
@@ -15667,12 +15582,8 @@ _ACEOF
-
-
-
-
################################################################################
-ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/dmfilemapd/Makefile daemons/lvmdbusd/Makefile daemons/lvmdbusd/lvmdbusd daemons/lvmdbusd/lvmdb.py daemons/lvmdbusd/lvm_shell_proxy.py daemons/lvmdbusd/path.py daemons/lvmetad/Makefile daemons/lvmpolld/Makefile daemons/lvmlockd/Makefile conf/Makefile conf/example.conf conf/lvmlocal.conf conf/command_profile_template.profile conf/metadata_profile_template.profile include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile include/lvm-version.h libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile l
ibdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile python/Makefile python/setup.py scripts/blkdeactivate.sh scripts/blk_availability_init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/com.redhat.lvmdbus1.service scripts/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cluster_activation_red_hat.sh scripts/lvm2_cluster_activation_systemd_red_hat.service scripts/lvm2_clvmd_systemd_red_hat.service scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmdbusd_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_hat.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_lvmlocking_systemd_red_hat.service scripts/lvm2_monito
ring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_tmpfiles_red_hat.conf scripts/lvmdump.sh scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile"
+ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/dmfilemapd/Makefile daemons/lvmdbusd/Makefile daemons/lvmdbusd/lvmdbusd daemons/lvmdbusd/lvmdb.py daemons/lvmdbusd/lvm_shell_proxy.py daemons/lvmdbusd/path.py daemons/lvmetad/Makefile daemons/lvmpolld/Makefile daemons/lvmlockd/Makefile conf/Makefile conf/example.conf conf/lvmlocal.conf conf/command_profile_template.profile conf/metadata_profile_template.profile include/Makefile lib/Makefile lib/locking/Makefile include/lvm-version.h libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/li
blvm2app.pc man/Makefile po/Makefile python/Makefile python/setup.py scripts/blkdeactivate.sh scripts/blk_availability_init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/com.redhat.lvmdbus1.service scripts/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cluster_activation_red_hat.sh scripts/lvm2_cluster_activation_systemd_red_hat.service scripts/lvm2_clvmd_systemd_red_hat.service scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmdbusd_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_hat.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_lvmlocking_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_syst
emd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_tmpfiles_red_hat.conf scripts/lvmdump.sh scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -16396,8 +16307,6 @@ do
"conf/metadata_profile_template.profile") CONFIG_FILES="$CONFIG_FILES conf/metadata_profile_template.profile" ;;
"include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
"lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
- "lib/format1/Makefile") CONFIG_FILES="$CONFIG_FILES lib/format1/Makefile" ;;
- "lib/format_pool/Makefile") CONFIG_FILES="$CONFIG_FILES lib/format_pool/Makefile" ;;
"lib/locking/Makefile") CONFIG_FILES="$CONFIG_FILES lib/locking/Makefile" ;;
"include/lvm-version.h") CONFIG_FILES="$CONFIG_FILES include/lvm-version.h" ;;
"libdaemon/Makefile") CONFIG_FILES="$CONFIG_FILES libdaemon/Makefile" ;;
diff --git a/include/configure.h.in b/include/configure.h.in
index 89f7a22..66cc27c 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -72,10 +72,6 @@
/* Default system configuration directory. */
#undef DEFAULT_ETC_DIR
-/* Fall back to LVM1 by default if device-mapper is missing from the kernel.
- */
-#undef DEFAULT_FALLBACK_TO_LVM1
-
/* Name of default locking directory. */
#undef DEFAULT_LOCK_DIR
@@ -617,13 +613,6 @@
slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
-/* Define to 1 if 'lvm' should fall back to using LVM1 binaries if
- device-mapper is missing from the kernel */
-#undef LVM1_FALLBACK
-
-/* Define to 1 to include built-in support for LVM1 metadata. */
-#undef LVM1_INTERNAL
-
/* Path to lvmetad pidfile. */
#undef LVMETAD_PIDFILE
@@ -686,9 +675,6 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* Define to 1 to include built-in support for GFS pool metadata. */
-#undef POOL_INTERNAL
-
/* Define to 1 to include built-in support for raid. */
#undef RAID_INTERNAL
5 years, 12 months
master - bcache: rewrite bcache_{write,zero}_bytes
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f564e78d98747266c7a...
Commit: f564e78d98747266c7add85906309f773de42061
Parent: c863c9581dead8f41e30c66df38017bef2229a90
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Tue May 1 12:07:33 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Tue May 1 12:07:33 2018 +0100
bcache: rewrite bcache_{write,zero}_bytes
These are utility functions so should only use the public interface.
Also write_bytes was flushing, which will kill performance.
---
lib/device/bcache.c | 68 +++++++++++++++++++++++-----------------------
test/unit/bcache_t.c | 7 +++++
test/unit/io_engine_t.c | 6 ++--
3 files changed, 44 insertions(+), 37 deletions(-)
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 0995ba9..2464e59 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -1056,6 +1056,9 @@ static off_t _min(off_t lhs, off_t rhs)
return lhs;
}
+// These functions are all utilities, they should only use the public
+// interface to bcache.
+// FIXME: there's common code that can be factored out of these 3
bool bcache_read_bytes(struct bcache *cache, int fd, off_t start, size_t len, void *data)
{
struct block *b;
@@ -1070,7 +1073,7 @@ bool bcache_read_bytes(struct bcache *cache, int fd, off_t start, size_t len, vo
for (i = bb; i < be; i++) {
if (!bcache_get(cache, fd, i, 0, &b, NULL)) {
- log_error("bcache_read failed to get block %u fd %d bb %u be %u",
+ log_error("bcache_read_bytes failed to get block %u fd %d bb %u be %u",
(uint32_t)i, fd, (uint32_t)bb, (uint32_t)be);
errors++;
continue;
@@ -1108,11 +1111,11 @@ bool bcache_write_bytes(struct bcache *cache, int fd, off_t start, size_t len, v
bcache_prefetch(cache, fd, i);
for (i = bb; i < be; i++) {
- if (!bcache_get(cache, fd, i, 0, &b, NULL)) {
- log_error("bcache_write failed to get block %u fd %d bb %u be %u",
+ if (!bcache_get(cache, fd, i, GF_DIRTY, &b, NULL)) {
+ log_error("bcache_write_bytes failed to get block %u fd %d bb %u be %u",
(uint32_t)i, fd, (uint32_t)bb, (uint32_t)be);
errors++;
- break;
+ continue;
}
if (i == bb) {
@@ -1128,49 +1131,46 @@ bool bcache_write_bytes(struct bcache *cache, int fd, off_t start, size_t len, v
udata += blen;
}
- _set_flags(b, BF_DIRTY);
- _unlink_block(b);
- _link_block(b);
- _put_ref(b);
+ bcache_put(b);
}
- if (!bcache_flush(cache))
- errors++;
-
return errors ? false : true;
}
-#define ZERO_BUF_LEN 4096
-
bool bcache_write_zeros(struct bcache *cache, int fd, off_t start, size_t len)
{
- char zerobuf[ZERO_BUF_LEN];
- size_t plen;
- size_t poff;
-
- memset(zerobuf, 0, sizeof(zerobuf));
-
- if (len <= ZERO_BUF_LEN)
- return bcache_write_bytes(cache, fd, start, len, &zerobuf);
-
- poff = 0;
- plen = ZERO_BUF_LEN;
+ struct block *b;
+ block_address bb, be, i;
+ off_t block_size = cache->block_sectors << SECTOR_SHIFT;
+ int errors = 0;
- while (1) {
- if (!bcache_write_bytes(cache, fd, start + poff, plen, &zerobuf))
- return false;
+ byte_range_to_block_range(cache, start, len, &bb, &be);
+ for (i = bb; i < be; i++)
+ bcache_prefetch(cache, fd, i);
- poff += plen;
- len -= plen;
+ for (i = bb; i < be; i++) {
+ if (!bcache_get(cache, fd, i, GF_DIRTY, &b, NULL)) {
+ log_error("bcache_write_bytes failed to get block %u fd %d bb %u be %u",
+ (uint32_t)i, fd, (uint32_t)bb, (uint32_t)be);
+ errors++;
+ continue;
+ }
- if (!len)
- break;
+ if (i == bb) {
+ off_t block_offset = start % block_size;
+ size_t blen = _min(block_size - block_offset, len);
+ memset(((unsigned char *) b->data) + block_offset, 0, blen);
+ len -= blen;
+ } else {
+ size_t blen = _min(block_size, len);
+ memset(b->data, 0, blen);
+ len -= blen;
+ }
- if (len < ZERO_BUF_LEN)
- plen = len;
+ bcache_put(b);
}
- return true;
+ return errors ? false : true;
}
diff --git a/test/unit/bcache_t.c b/test/unit/bcache_t.c
index ecbe07b..85bb321 100644
--- a/test/unit/bcache_t.c
+++ b/test/unit/bcache_t.c
@@ -428,6 +428,13 @@ static void test_get_triggers_read(void *context)
_expect(f->me, E_WAIT);
T_ASSERT(bcache_get(f->cache, fd, 0, 0, &b, &err));
bcache_put(b);
+
+ _expect_read(f->me, fd, 1);
+ _expect(f->me, E_WAIT);
+ T_ASSERT(bcache_get(f->cache, fd, 1, GF_DIRTY, &b, &err));
+ _expect_write(f->me, fd, 1);
+ _expect(f->me, E_WAIT);
+ bcache_put(b);
}
static void test_repeated_reads_are_cached(void *context)
diff --git a/test/unit/io_engine_t.c b/test/unit/io_engine_t.c
index 822789a..01f659e 100644
--- a/test/unit/io_engine_t.c
+++ b/test/unit/io_engine_t.c
@@ -92,7 +92,7 @@ static void *_fix_init(void)
f->fd = mkostemp(f->fname, O_RDWR | O_CREAT | O_EXCL);
T_ASSERT(f->fd >= 0);
- _fill_buffer(f->data, 123, sizeof(f->data));
+ _fill_buffer(f->data, 123, SECTOR_SIZE * BLOCK_SIZE_SECTORS);
write(f->fd, f->data, SECTOR_SIZE * BLOCK_SIZE_SECTORS);
lseek(f->fd, 0, SEEK_SET);
@@ -198,8 +198,8 @@ static struct test_suite *_tests(void)
}
T("create-destroy", "simple create/destroy", _test_create);
- T("create-read", "read sanity check", _test_read);
- T("create-write", "write sanity check", _test_write);
+ T("read", "read sanity check", _test_read);
+ T("write", "write sanity check", _test_write);
T("bcache-write-bytes", "test the utility fns", _test_write_bytes);
return ts;
5 years, 12 months
master - Merge branch 'master' of git+ssh://sourceware.org/git/lvm2
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c863c9581dead8f41e3...
Commit: c863c9581dead8f41e30c66df38017bef2229a90
Parent: 7aba7fe68b6da2ca8ec7b01f5730396d64426fb0 c1cd18f21ef233fa19e948cf130e97c005a349ad
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Tue May 1 10:48:42 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Tue May 1 10:48:42 2018 +0100
Merge branch 'master' of git+ssh://sourceware.org/git/lvm2
configure.ac | 58 ---
daemons/clvmd/clvmd-command.c | 1 -
daemons/clvmd/lvm-functions.c | 10 -
daemons/clvmd/lvm-functions.h | 1 -
daemons/lvmetad/lvmetad-client.h | 1 -
daemons/lvmetad/lvmetad-core.c | 9 +-
lib/Makefile.in | 29 --
lib/activate/activate.c | 13 -
lib/activate/activate.h | 1 -
lib/cache/lvmcache.c | 10 +-
lib/cache/lvmetad.c | 23 +-
lib/commands/toolcontext.c | 22 -
lib/config/config_settings.h | 20 +-
lib/display/display.c | 9 +-
lib/format1/.exported_symbols | 1 -
lib/format1/Makefile.in | 33 --
lib/format1/disk-rep.c | 761 -------------------------------------
lib/format1/disk-rep.h | 250 ------------
lib/format1/format1.c | 631 ------------------------------
lib/format1/format1.h | 29 --
lib/format1/import-export.c | 680 ---------------------------------
lib/format1/import-extents.c | 377 ------------------
lib/format1/layout.c | 172 ---------
lib/format1/lvm1-label.c | 129 -------
lib/format1/lvm1-label.h | 23 --
lib/format1/vg_number.c | 60 ---
lib/format_pool/.exported_symbols | 1 -
lib/format_pool/Makefile.in | 30 --
lib/format_pool/disk_rep.c | 409 --------------------
lib/format_pool/disk_rep.h | 156 --------
lib/format_pool/format_pool.c | 338 ----------------
lib/format_pool/format_pool.h | 28 --
lib/format_pool/import_export.c | 285 --------------
lib/format_pool/pool_label.c | 104 -----
lib/format_pool/pool_label.h | 23 --
lib/format_pool/sptype_names.h | 42 --
lib/format_text/export.c | 2 -
lib/format_text/format-text.c | 4 +-
lib/format_text/import_vsn1.c | 9 +-
lib/locking/locking.c | 40 --
lib/metadata/lv_manip.c | 26 --
lib/metadata/metadata-exported.h | 10 +-
lib/metadata/metadata.c | 27 +-
lib/metadata/segtype.h | 2 +-
lib/metadata/snapshot_manip.c | 11 -
lib/metadata/vg.c | 17 +-
lib/metadata/vg.h | 1 -
lib/report/report.c | 4 +-
lib/striped/striped.c | 2 +-
man/vgconvert.8_des | 7 +-
test/lib/aux.sh | 4 -
test/shell/format-lvm1.sh | 38 --
test/shell/lvm1-basic.sh | 36 --
test/shell/snapshot-lvm1.sh | 35 --
tools/args.h | 3 +-
tools/lvconvert.c | 5 -
tools/lvmcmdline.c | 58 +---
tools/pvscan.c | 5 +-
tools/stub.h | 1 -
tools/toollib.c | 29 +--
tools/vals.h | 4 +-
tools/vgchange.c | 10 -
tools/vgconvert.c | 53 +--
tools/vgscan.c | 4 +-
64 files changed, 62 insertions(+), 5154 deletions(-)
5 years, 12 months
master - unit-test/io_engine_t: add a little test for bcache_{read, write}_bytes
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7aba7fe68b6da2ca8ec...
Commit: 7aba7fe68b6da2ca8ec7b01f5730396d64426fb0
Parent: f6459757af0f255fe6cc89a05b614e7512ab1bca
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Tue May 1 10:47:40 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Tue May 1 10:47:40 2018 +0100
unit-test/io_engine_t: add a little test for bcache_{read,write}_bytes
---
test/unit/bcache_t.c | 1 +
test/unit/io_engine_t.c | 84 ++++++++++++++++++++++++++++++++++++++--------
2 files changed, 70 insertions(+), 15 deletions(-)
diff --git a/test/unit/bcache_t.c b/test/unit/bcache_t.c
index ce159cd..ecbe07b 100644
--- a/test/unit/bcache_t.c
+++ b/test/unit/bcache_t.c
@@ -821,6 +821,7 @@ static void test_invalidate_held_block(void *context)
bcache_put(b);
}
+
/*----------------------------------------------------------------
* Top level
*--------------------------------------------------------------*/
diff --git a/test/unit/io_engine_t.c b/test/unit/io_engine_t.c
index 3a70265..822789a 100644
--- a/test/unit/io_engine_t.c
+++ b/test/unit/io_engine_t.c
@@ -29,7 +29,8 @@
//----------------------------------------------------------------
#define SECTOR_SIZE 512
-#define BLOCK_SIZE_SECTORS 64
+#define BLOCK_SIZE_SECTORS 8
+#define NR_BLOCKS 64
struct fixture {
struct io_engine *e;
@@ -39,10 +40,46 @@ struct fixture {
int fd;
};
-static void *_fix_init(void)
+static void _fill_buffer(uint8_t *buffer, uint8_t seed, size_t count)
{
- uint8_t b = 123;
unsigned i;
+ uint8_t b = seed;
+
+ for (i = 0; i < count; i++) {
+ buffer[i] = b;
+ b = ((b << 5) + b) + i;
+ }
+}
+
+static void _check_buffer(uint8_t *buffer, uint8_t seed, size_t count)
+{
+ unsigned i;
+ uint8_t b = seed;
+
+ for (i = 0; i < count; i++) {
+ T_ASSERT_EQUAL(buffer[i], b);
+ b = ((b << 5) + b) + i;
+ }
+}
+
+static void _print_buffer(const char *name, uint8_t *buffer, size_t count)
+{
+ unsigned col;
+
+ fprintf(stderr, "%s:\n", name);
+ while (count) {
+ for (col = 0; count && col < 20; col++) {
+ fprintf(stderr, "%x, ", (unsigned) *buffer);
+ col++;
+ buffer++;
+ count--;
+ }
+ fprintf(stderr, "\n");
+ }
+}
+
+static void *_fix_init(void)
+{
struct fixture *f = malloc(sizeof(*f));
T_ASSERT(f);
@@ -55,10 +92,7 @@ static void *_fix_init(void)
f->fd = mkostemp(f->fname, O_RDWR | O_CREAT | O_EXCL);
T_ASSERT(f->fd >= 0);
- for (i = 0; i < SECTOR_SIZE * BLOCK_SIZE_SECTORS; i++) {
- f->data[i] = b;
- b = ((b << 5) + b) + i;
- }
+ _fill_buffer(f->data, 123, sizeof(f->data));
write(f->fd, f->data, SECTOR_SIZE * BLOCK_SIZE_SECTORS);
lseek(f->fd, 0, SEEK_SET);
@@ -72,7 +106,8 @@ static void _fix_exit(void *fixture)
close(f->fd);
unlink(f->fname);
free(f->data);
- f->e->destroy(f->e);
+ if (f->e)
+ f->e->destroy(f->e);
free(f);
}
@@ -103,8 +138,6 @@ static void _test_read(void *fixture)
{
struct fixture *f = fixture;
- uint8_t b = 123;
- unsigned i;
struct io io;
_io_init(&io);
@@ -112,11 +145,8 @@ static void _test_read(void *fixture)
T_ASSERT(f->e->wait(f->e, _complete_io));
T_ASSERT(io.completed);
T_ASSERT(!io.error);
-
- for (i = 0; i < SECTOR_SIZE * BLOCK_SIZE_SECTORS; i++) {
- T_ASSERT_EQUAL(f->data[i], b);
- b = ((b << 5) + b) + i;
- }
+
+ _check_buffer(f->data, 123, sizeof(f->data));
}
static void _test_write(void *fixture)
@@ -132,6 +162,29 @@ static void _test_write(void *fixture)
T_ASSERT(!io.error);
}
+static void _test_write_bytes(void *fixture)
+{
+ struct fixture *f = fixture;
+
+ unsigned offset = 345;
+ char buf_out[32];
+ char buf_in[32];
+ struct bcache *cache = bcache_create(8, BLOCK_SIZE_SECTORS, f->e);
+ T_ASSERT(cache);
+
+ // T_ASSERT(bcache_read_bytes(cache, f->fd, offset, sizeof(buf_in), buf_in));
+ _fill_buffer((uint8_t *) buf_out, 234, sizeof(buf_out));
+ T_ASSERT(bcache_write_bytes(cache, f->fd, offset, sizeof(buf_out), buf_out));
+ T_ASSERT(bcache_read_bytes(cache, f->fd, offset, sizeof(buf_in), buf_in));
+
+ _print_buffer("buf_out", (uint8_t *) buf_out, sizeof(buf_out));
+ _print_buffer("buf_in", (uint8_t *) buf_in, sizeof(buf_in));
+ T_ASSERT(!memcmp(buf_out, buf_in, sizeof(buf_out)));
+
+ bcache_destroy(cache);
+ f->e = NULL; // already destroyed
+}
+
//----------------------------------------------------------------
#define T(path, desc, fn) register_test(ts, "/base/device/bcache/io-engine/" path, desc, fn)
@@ -147,6 +200,7 @@ static struct test_suite *_tests(void)
T("create-destroy", "simple create/destroy", _test_create);
T("create-read", "read sanity check", _test_read);
T("create-write", "write sanity check", _test_write);
+ T("bcache-write-bytes", "test the utility fns", _test_write_bytes);
return ts;
}
5 years, 12 months
master - unit-test/bcache_t: fixup a test.
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f6459757af0f255fe6c...
Commit: f6459757af0f255fe6cc89a05b614e7512ab1bca
Parent: 39f24a169c7cdec5e927a20aacb774e88407d31a
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Tue May 1 09:17:55 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Tue May 1 09:17:55 2018 +0100
unit-test/bcache_t: fixup a test.
Problem found with valgrind.
---
test/unit/bcache_t.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/test/unit/bcache_t.c b/test/unit/bcache_t.c
index d06d5fe..ce159cd 100644
--- a/test/unit/bcache_t.c
+++ b/test/unit/bcache_t.c
@@ -100,6 +100,16 @@ static void _expect_read(struct mock_engine *e, int fd, block_address b)
dm_list_add(&e->expected_calls, &mc->list);
}
+static void _expect_read_any(struct mock_engine *e)
+{
+ struct mock_call *mc = malloc(sizeof(*mc));
+ mc->m = E_ISSUE;
+ mc->match_args = false;
+ mc->issue_r = true;
+ mc->wait_r = true;
+ dm_list_add(&e->expected_calls, &mc->list);
+}
+
static void _expect_write(struct mock_engine *e, int fd, block_address b)
{
struct mock_call *mc = malloc(sizeof(*mc));
@@ -466,7 +476,7 @@ static void test_block_gets_evicted_with_many_reads(void *context)
// Now if we run through we should find one block has been
// evicted. We go backwards because the oldest is normally
// evicted first.
- _expect(me, E_ISSUE);
+ _expect_read_any(me);
_expect(me, E_WAIT);
for (i = nr_cache_blocks; i; i--) {
T_ASSERT(bcache_get(cache, fd, i - 1, 0, &b, &err));
5 years, 12 months