Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf34d04

Browse files
committed
Merge tag 'befs-v4.9-rc1' of git://github.com/luisbg/linux-befs
Pull befs fixes from Luis de Bethencourt: "I recently took maintainership of the befs file system [0]. This is the first time I send you a git pull request, so please let me know if all the below is OK. Salah Triki and myself have been cleaning the code and fixing a few small bugs. Sorry I couldn't send this sooner in the merge window, I was waiting to have my GPG key signed by kernel members at ELCE in Berlin a few days ago."[0]https://lkml.org/lkml/2016/7/27/502* tag 'befs-v4.9-rc1' of git://github.com/luisbg/linux-befs: (39 commits) befs: befs: fix style issues in datastream.c befs: improve documentation in datastream.c befs: fix typos in datastream.c befs: fix typos in btree.c befs: fix style issues in super.c befs: fix comment style befs: add check for ag_shift in superblock befs: dump inode_size superblock information befs: remove unnecessary initialization befs: fix typo in befs_sb_info befs: add flags field to validate superblock state befs: fix typo in befs_find_key befs: remove unused BEFS_BT_PARMATCH fs: befs: remove ret variable fs: befs: remove in vain variable assignment fs: befs: remove unnecessary *befs_sb variable fs: befs: remove useless initialization to zero fs: befs: remove in vain variable assignment fs: befs: Insert NULL inode to dentry fs: befs: Remove useless calls to brelse in befs_find_brun_dblindirect ...
2 parents9ffc669 +a17e7d2 commitdf34d04

File tree

8 files changed

+244
-283
lines changed

8 files changed

+244
-283
lines changed

‎fs/befs/befs.h‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ struct befs_sb_info {
4343
u32ag_shift;
4444
u32num_ags;
4545

46-
/* jornal log entry */
46+
/* State of the superblock */
47+
u32flags;
48+
49+
/* Journal log entry */
4750
befs_block_runlog_blocks;
4851
befs_off_tlog_start;
4952
befs_off_tlog_end;
@@ -79,7 +82,7 @@ enum befs_err {
7982
BEFS_BT_END,
8083
BEFS_BT_EMPTY,
8184
BEFS_BT_MATCH,
82-
BEFS_BT_PARMATCH,
85+
BEFS_BT_OVERFLOW,
8386
BEFS_BT_NOT_FOUND
8487
};
8588

@@ -140,18 +143,6 @@ befs_iaddrs_per_block(struct super_block *sb)
140143
returnBEFS_SB(sb)->block_size /sizeof (befs_disk_inode_addr);
141144
}
142145

143-
staticinlineint
144-
befs_iaddr_is_empty(constbefs_inode_addr*iaddr)
145-
{
146-
return (!iaddr->allocation_group)&& (!iaddr->start)&& (!iaddr->len);
147-
}
148-
149-
staticinlinesize_t
150-
befs_brun_size(structsuper_block*sb,befs_block_runrun)
151-
{
152-
returnBEFS_SB(sb)->block_size*run.len;
153-
}
154-
155146
#include"endian.h"
156147

157148
#endif/* _LINUX_BEFS_H */

‎fs/befs/btree.c‎

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct befs_btree_node {
8585
};
8686

8787
/* local constants */
88-
staticconstbefs_off_tbefs_bt_inval=0xffffffffffffffffULL;
88+
staticconstbefs_off_tBEFS_BT_INVAL=0xffffffffffffffffULL;
8989

9090
/* local functions */
9191
staticintbefs_btree_seekleaf(structsuper_block*sb,constbefs_data_stream*ds,
@@ -156,8 +156,6 @@ befs_bt_read_super(struct super_block *sb, const befs_data_stream *ds,
156156
sup->max_depth=fs32_to_cpu(sb,od_sup->max_depth);
157157
sup->data_type=fs32_to_cpu(sb,od_sup->data_type);
158158
sup->root_node_ptr=fs64_to_cpu(sb,od_sup->root_node_ptr);
159-
sup->free_node_ptr=fs64_to_cpu(sb,od_sup->free_node_ptr);
160-
sup->max_size=fs64_to_cpu(sb,od_sup->max_size);
161159

162160
brelse(bh);
163161
if (sup->magic!=BEFS_BTREE_MAGIC) {
@@ -183,8 +181,8 @@ befs_bt_read_super(struct super_block *sb, const befs_data_stream *ds,
183181
* Calls befs_read_datastream to read in the indicated btree node and
184182
* makes sure its header fields are in cpu byteorder, byteswapping if
185183
* necessary.
186-
* Note: node->bh must be NULL when this function called first
187-
*time.Don't forget brelse(node->bh) after last call.
184+
* Note: node->bh must be NULL when this functioniscalledthefirst time.
185+
* Don't forget brelse(node->bh) after last call.
188186
*
189187
* On success, returns BEFS_OK and *@node contains the btree node that
190188
* starts at @node_off, with the node->head fields in cpu byte order.
@@ -244,7 +242,7 @@ befs_bt_read_node(struct super_block *sb, const befs_data_stream *ds,
244242
* Read the superblock and rootnode of the b+tree.
245243
* Drill down through the interior nodes using befs_find_key().
246244
* Once at the correct leaf node, use befs_find_key() again to get the
247-
*actuall value stored with the key.
245+
*actual value stored with the key.
248246
*/
249247
int
250248
befs_btree_find(structsuper_block*sb,constbefs_data_stream*ds,
@@ -283,25 +281,25 @@ befs_btree_find(struct super_block *sb, const befs_data_stream *ds,
283281

284282
while (!befs_leafnode(this_node)) {
285283
res=befs_find_key(sb,this_node,key,&node_off);
286-
if (res==BEFS_BT_NOT_FOUND)
284+
/* if no key set, try the overflow node */
285+
if (res==BEFS_BT_OVERFLOW)
287286
node_off=this_node->head.overflow;
288-
/* if no match, go to overflow node */
289287
if (befs_bt_read_node(sb,ds,this_node,node_off)!=BEFS_OK) {
290288
befs_error(sb,"befs_btree_find() failed to read "
291289
"node at %llu",node_off);
292290
gotoerror_alloc;
293291
}
294292
}
295293

296-
/* at the correct leaf node now */
297-
294+
/* at a leaf node now, check if it is correct */
298295
res=befs_find_key(sb,this_node,key,value);
299296

300297
brelse(this_node->bh);
301298
kfree(this_node);
302299

303300
if (res!=BEFS_BT_MATCH) {
304-
befs_debug(sb,"<--- %s Key %s not found",__func__,key);
301+
befs_error(sb,"<--- %s Key %s not found",__func__,key);
302+
befs_debug(sb,"<--- %s ERROR",__func__);
305303
*value=0;
306304
returnBEFS_BT_NOT_FOUND;
307305
}
@@ -324,16 +322,12 @@ befs_btree_find(struct super_block *sb, const befs_data_stream *ds,
324322
* @findkey: Keystring to search for
325323
* @value: If key is found, the value stored with the key is put here
326324
*
327-
* finds exact match if one exists, and returns BEFS_BT_MATCH
328-
* If no exact match, finds first key in node that is greater
329-
* (alphabetically) than the search key and returns BEFS_BT_PARMATCH
330-
* (for partial match, I guess). Can you think of something better to
331-
* call it?
332-
*
333-
* If no key was a match or greater than the search key, return
334-
* BEFS_BT_NOT_FOUND.
325+
* Finds exact match if one exists, and returns BEFS_BT_MATCH.
326+
* If there is no match and node's value array is too small for key, return
327+
* BEFS_BT_OVERFLOW.
328+
* If no match and node should countain this key, return BEFS_BT_NOT_FOUND.
335329
*
336-
*Use binary search instead of a linear.
330+
*Uses binary search instead of a linear.
337331
*/
338332
staticint
339333
befs_find_key(structsuper_block*sb,structbefs_btree_node*node,
@@ -348,18 +342,16 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node,
348342

349343
befs_debug(sb,"---> %s %s",__func__,findkey);
350344

351-
*value=0;
352-
353345
findkey_len=strlen(findkey);
354346

355-
/* if node can not contain key, justskeep this node */
347+
/* if node can not contain key, justskip this node */
356348
last=node->head.all_key_count-1;
357349
thiskey=befs_bt_get_key(sb,node,last,&keylen);
358350

359351
eq=befs_compare_strings(thiskey,keylen,findkey,findkey_len);
360352
if (eq<0) {
361-
befs_debug(sb,"<---%s %s not found",__func__,findkey);
362-
returnBEFS_BT_NOT_FOUND;
353+
befs_debug(sb,"<---node can't contain %s",findkey);
354+
returnBEFS_BT_OVERFLOW;
363355
}
364356

365357
valarray=befs_bt_valarray(node);
@@ -387,12 +379,15 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node,
387379
else
388380
first=mid+1;
389381
}
382+
383+
/* return an existing value so caller can arrive to a leaf node */
390384
if (eq<0)
391385
*value=fs64_to_cpu(sb,valarray[mid+1]);
392386
else
393387
*value=fs64_to_cpu(sb,valarray[mid]);
394-
befs_debug(sb,"<--- %s found %s at %d",__func__,thiskey,mid);
395-
returnBEFS_BT_PARMATCH;
388+
befs_error(sb,"<--- %s %s not found",__func__,findkey);
389+
befs_debug(sb,"<--- %s ERROR",__func__);
390+
returnBEFS_BT_NOT_FOUND;
396391
}
397392

398393
/**
@@ -405,7 +400,7 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node,
405400
* @keysize: Length of the returned key
406401
* @value: Value stored with the returned key
407402
*
408-
*Heres how it works: Key_no is the index of the key/value pair to
403+
*Here's how it works: Key_no is the index of the key/value pair to
409404
* return in keybuf/value.
410405
* Bufsize is the size of keybuf (BEFS_NAME_LEN+1 is a good size). Keysize is
411406
* the number of characters in the key (just a convenience).
@@ -422,7 +417,7 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds,
422417
{
423418
structbefs_btree_node*this_node;
424419
befs_btree_superbt_super;
425-
befs_off_tnode_off=0;
420+
befs_off_tnode_off;
426421
intcur_key;
427422
fs64*valarray;
428423
char*keystart;
@@ -467,7 +462,7 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds,
467462
while (key_sum+this_node->head.all_key_count <=key_no) {
468463

469464
/* no more nodes to look in: key_no is too large */
470-
if (this_node->head.right==befs_bt_inval) {
465+
if (this_node->head.right==BEFS_BT_INVAL) {
471466
*keysize=0;
472467
*value=0;
473468
befs_debug(sb,
@@ -541,7 +536,6 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds,
541536
* @node_off: Pointer to offset of current node within datastream. Modified
542537
* by the function.
543538
*
544-
*
545539
* Helper function for btree traverse. Moves the current position to the
546540
* start of the first leaf node.
547541
*
@@ -608,7 +602,7 @@ static int
608602
befs_leafnode(structbefs_btree_node*node)
609603
{
610604
/* all interior nodes (and only interior nodes) have an overflow node */
611-
if (node->head.overflow==befs_bt_inval)
605+
if (node->head.overflow==BEFS_BT_INVAL)
612606
return1;
613607
else
614608
return0;
@@ -715,7 +709,7 @@ befs_bt_get_key(struct super_block *sb, struct befs_btree_node *node,
715709
*
716710
* Returns 0 if @key1 and @key2 are equal.
717711
* Returns >0 if @key1 is greater.
718-
* Returns <0 if @key2 is greater..
712+
* Returns <0 if @key2 is greater.
719713
*/
720714
staticint
721715
befs_compare_strings(constvoid*key1,intkeylen1,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp