summaryrefslogtreecommitdiff
path: root/lib/locking
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2018-12-21 12:08:10 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2018-12-21 21:42:30 +0100
commit7832d3566868408ebf6d4c5d708e3efab3d48a67 (patch)
treee8764decf38555ab86bdc04fa929dde95750a9e4 /lib/locking
parent98924e4703bd798f4e872fbc7e6c6e32a199e102 (diff)
downloadlvm2-7832d3566868408ebf6d4c5d708e3efab3d48a67.tar.gz
lvmlockd: fix error return code for _init_vg_sanlock
In few cases error paths from initialization were returned as 'success == 1'. Also assing num_mb with single compare checking valid sector_size. For dumb compiler make num_mb always defined.
Diffstat (limited to 'lib/locking')
-rw-r--r--lib/locking/lvmlockd.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 530378ca6..9fb7b364b 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -632,7 +632,7 @@ static int _init_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg, in
struct device *sector_dev;
uint32_t sector_size = 0;
unsigned int phys_block_size, block_size;
- int num_mb;
+ int num_mb = 0;
int result;
int ret;
@@ -655,25 +655,20 @@ static int _init_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg, in
sector_size = phys_block_size;
sector_dev = pvl->pv->dev;
} else if (sector_size != phys_block_size) {
- log_warn("Inconsistent sector sizes for %s and %s.",
- dev_name(pvl->pv->dev), dev_name(sector_dev));
- return 1;
+ log_error("Inconsistent sector sizes for %s and %s.",
+ dev_name(pvl->pv->dev), dev_name(sector_dev));
+ return 0;
}
}
- if ((sector_size != 512) && (sector_size != 4096)) {
- log_error("Unknown sector size.");
- return 1;
- }
-
log_debug("Using sector size %u for sanlock LV", sector_size);
/* Base starting size of sanlock LV is 256MB/1GB for 512/4K sectors */
- if (sector_size == 512)
- num_mb = 256;
- else if (sector_size == 4096)
- num_mb = 1024;
-
+ switch (sector_size) {
+ case 512: num_mb = 256; break;
+ case 4096: num_mb = 1024; break;
+ default: log_error("Unknown sector size %u.", sector_size); return 0;
+ }
/*
* Creating the sanlock LV writes the VG containing the new lvmlock