aboutsummaryrefslogtreecommitdiffstats
path: root/fs/befs/btree.c
diff options
context:
space:
mode:
authorLuis de Bethencourt <luisbg@osg.samsung.com>2016-08-08 10:21:20 -0400
committerLuis de Bethencourt <luisbg@osg.samsung.com>2016-10-08 05:01:26 -0400
commit672a8515ee7ce3931daba8ed24f43de476d8e29a (patch)
treeb70b8ceab95dd1db32d38df86c64a36b5c1b667f /fs/befs/btree.c
parent33c712b4fcf23fba57cb9a8d947d9ab41e363b08 (diff)
befs: remove unused BEFS_BT_PARMATCH
befs_btree_find(), the only caller of befs_find_key(), only cares about if the return from that function is BEFS_BT_MATCH or not. It never uses the partial match given with BEFS_BT_PARMATCH. Make the overflow return clearer by having BEFS_BT_OVERFLOW instead of BEFS_BT_PARMATCH. Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com> Signed-off-by: Salah Triki <salah.triki@gmail.com>
Diffstat (limited to 'fs/befs/btree.c')
-rw-r--r--fs/befs/btree.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 3f1a39166d89..5670d845b2ef 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -281,9 +281,9 @@ befs_btree_find(struct super_block *sb, const befs_data_stream *ds,
281 281
282 while (!befs_leafnode(this_node)) { 282 while (!befs_leafnode(this_node)) {
283 res = befs_find_key(sb, this_node, key, &node_off); 283 res = befs_find_key(sb, this_node, key, &node_off);
284 if (res == BEFS_BT_NOT_FOUND) 284 /* if no key set, try the overflow node */
285 if (res == BEFS_BT_OVERFLOW)
285 node_off = this_node->head.overflow; 286 node_off = this_node->head.overflow;
286 /* if no match, go to overflow node */
287 if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) { 287 if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) {
288 befs_error(sb, "befs_btree_find() failed to read " 288 befs_error(sb, "befs_btree_find() failed to read "
289 "node at %llu", node_off); 289 "node at %llu", node_off);
@@ -291,8 +291,7 @@ befs_btree_find(struct super_block *sb, const befs_data_stream *ds,
291 } 291 }
292 } 292 }
293 293
294 /* at the correct leaf node now */ 294 /* at a leaf node now, check if it is correct */
295
296 res = befs_find_key(sb, this_node, key, value); 295 res = befs_find_key(sb, this_node, key, value);
297 296
298 brelse(this_node->bh); 297 brelse(this_node->bh);
@@ -323,16 +322,12 @@ befs_btree_find(struct super_block *sb, const befs_data_stream *ds,
323 * @findkey: Keystring to search for 322 * @findkey: Keystring to search for
324 * @value: If key is found, the value stored with the key is put here 323 * @value: If key is found, the value stored with the key is put here
325 * 324 *
326 * finds exact match if one exists, and returns BEFS_BT_MATCH 325 * Finds exact match if one exists, and returns BEFS_BT_MATCH.
327 * If no exact match, finds first key in node that is greater 326 * If there is no match and node's value array is too small for key, return
328 * (alphabetically) than the search key and returns BEFS_BT_PARMATCH 327 * BEFS_BT_OVERFLOW.
329 * (for partial match, I guess). Can you think of something better to 328 * If no match and node should countain this key, return BEFS_BT_NOT_FOUND.
330 * call it?
331 *
332 * If no key was a match or greater than the search key, return
333 * BEFS_BT_NOT_FOUND.
334 * 329 *
335 * Use binary search instead of a linear. 330 * Uses binary search instead of a linear.
336 */ 331 */
337static int 332static int
338befs_find_key(struct super_block *sb, struct befs_btree_node *node, 333befs_find_key(struct super_block *sb, struct befs_btree_node *node,
@@ -355,9 +350,8 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node,
355 350
356 eq = befs_compare_strings(thiskey, keylen, findkey, findkey_len); 351 eq = befs_compare_strings(thiskey, keylen, findkey, findkey_len);
357 if (eq < 0) { 352 if (eq < 0) {
358 befs_error(sb, "<--- %s %s not found", __func__, findkey); 353 befs_debug(sb, "<--- node can't contain %s", findkey);
359 befs_debug(sb, "<--- %s ERROR", __func__); 354 return BEFS_BT_OVERFLOW;
360 return BEFS_BT_NOT_FOUND;
361 } 355 }
362 356
363 valarray = befs_bt_valarray(node); 357 valarray = befs_bt_valarray(node);
@@ -385,12 +379,15 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node,
385 else 379 else
386 first = mid + 1; 380 first = mid + 1;
387 } 381 }
382
383 /* return an existing value so caller can arrive to a leaf node */
388 if (eq < 0) 384 if (eq < 0)
389 *value = fs64_to_cpu(sb, valarray[mid + 1]); 385 *value = fs64_to_cpu(sb, valarray[mid + 1]);
390 else 386 else
391 *value = fs64_to_cpu(sb, valarray[mid]); 387 *value = fs64_to_cpu(sb, valarray[mid]);
392 befs_debug(sb, "<--- %s found %s at %d", __func__, thiskey, mid); 388 befs_error(sb, "<--- %s %s not found", __func__, findkey);
393 return BEFS_BT_PARMATCH; 389 befs_debug(sb, "<--- %s ERROR", __func__);
390 return BEFS_BT_NOT_FOUND;
394} 391}
395 392
396/** 393/**