Commit 5c45cd10 authored by Mike Snitzer's avatar Mike Snitzer

dm vdo index: fix various small nits

Add braces around multi-line while loops and if statements. Also
remove excess newlines.
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
Signed-off-by: default avatarChung Chung <cchung@redhat.com>
Signed-off-by: default avatarMatthew Sakai <msakai@redhat.com>
parent ac9ae576
......@@ -386,9 +386,10 @@ static void define_sub_index_nonce(struct index_layout *layout)
encode_u64_le(buffer, &offset, sil->sub_index.start_block);
encode_u16_le(buffer, &offset, 0);
sil->nonce = generate_secondary_nonce(primary_nonce, buffer, sizeof(buffer));
if (sil->nonce == 0)
if (sil->nonce == 0) {
sil->nonce = generate_secondary_nonce(~primary_nonce + 1, buffer,
sizeof(buffer));
}
}
static void setup_sub_index(struct index_layout *layout, u64 start_block,
......@@ -651,10 +652,11 @@ static int discard_index_state_data(struct index_layout *layout)
saved_result = result;
}
if (saved_result != UDS_SUCCESS)
if (saved_result != UDS_SUCCESS) {
return uds_log_error_strerror(result,
"%s: cannot destroy all index saves",
__func__);
}
return UDS_SUCCESS;
}
......@@ -1242,9 +1244,7 @@ static int __must_check read_super_block_data(struct buffered_reader *reader,
"unknown superblock magic label");
if ((super->version < SUPER_VERSION_MINIMUM) ||
(super->version == 4) ||
(super->version == 5) ||
(super->version == 6) ||
(super->version == 4) || (super->version == 5) || (super->version == 6) ||
(super->version > SUPER_VERSION_MAXIMUM)) {
return uds_log_error_strerror(UDS_UNSUPPORTED_VERSION,
"unknown superblock version number %u",
......
......@@ -100,8 +100,7 @@ void uds_get_list_number_bounds(const struct index_page_map *map, u32 chapter_nu
u32 slot = chapter_number * map->entries_per_chapter;
*lowest_list = ((index_page_number == 0) ?
0 :
map->entries[slot + index_page_number - 1] + 1);
0 : map->entries[slot + index_page_number - 1] + 1);
*highest_list = ((index_page_number < map->entries_per_chapter) ?
map->entries[slot + index_page_number] :
map->geometry->delta_lists_per_chapter - 1);
......
......@@ -392,9 +392,10 @@ int uds_open_index(enum uds_open_index_type open_type,
static void wait_for_no_requests_in_progress(struct uds_index_session *index_session)
{
uds_lock_mutex(&index_session->request_mutex);
while (index_session->request_count > 0)
while (index_session->request_count > 0) {
uds_wait_cond(&index_session->request_cond,
&index_session->request_mutex);
}
uds_unlock_mutex(&index_session->request_mutex);
}
......@@ -619,9 +620,10 @@ int uds_close_index(struct uds_index_session *index_session)
/* Wait for any current index state change to complete. */
uds_lock_mutex(&index_session->request_mutex);
while ((index_session->state & IS_FLAG_WAITING) ||
(index_session->state & IS_FLAG_CLOSING))
(index_session->state & IS_FLAG_CLOSING)) {
uds_wait_cond(&index_session->request_cond,
&index_session->request_mutex);
}
if (index_session->state & IS_FLAG_SUSPENDED) {
uds_log_info("Index session is suspended");
......@@ -660,9 +662,10 @@ int uds_destroy_index_session(struct uds_index_session *index_session)
/* Wait for any current index state change to complete. */
uds_lock_mutex(&index_session->request_mutex);
while ((index_session->state & IS_FLAG_WAITING) ||
(index_session->state & IS_FLAG_CLOSING))
(index_session->state & IS_FLAG_CLOSING)) {
uds_wait_cond(&index_session->request_cond,
&index_session->request_mutex);
}
if (index_session->state & IS_FLAG_DESTROYING) {
uds_unlock_mutex(&index_session->request_mutex);
......@@ -686,9 +689,10 @@ int uds_destroy_index_session(struct uds_index_session *index_session)
/* Wait until the load exits before proceeding. */
uds_lock_mutex(&index_session->request_mutex);
while (index_session->state & IS_FLAG_LOADING)
while (index_session->state & IS_FLAG_LOADING) {
uds_wait_cond(&index_session->request_cond,
&index_session->request_mutex);
}
uds_unlock_mutex(&index_session->request_mutex);
}
......
......@@ -1330,8 +1330,7 @@ int uds_save_index(struct uds_index *index)
uds_wait_for_idle_index(index);
index->prev_save = index->last_save;
index->last_save = ((index->newest_virtual_chapter == 0) ?
NO_LAST_SAVE :
index->newest_virtual_chapter - 1);
NO_LAST_SAVE : index->newest_virtual_chapter - 1);
uds_log_info("beginning save (vcn %llu)", (unsigned long long) index->last_save);
result = uds_save_index_state(index->layout, index);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment