sysprog21 / simplefs

A simple native file system for Linux kernel
Other
362 stars 91 forks source link

Use binary search for searching extent #42

Closed baekrang256 closed 4 months ago

RoyWFHuang commented 4 months ago

These are some bugs in this function. I dump the kernel message and it shows: [ 333.089632] BUG: unable to handle page fault for address: ffff94e6dcb34ff8 [ 333.099146] RIP: 0010:simplefs_ext_search.cold+0x46/0xa5 [simplefs]

By the information 0x46, we can find 46: 41 8b 78 04 mov 0x4(%r8),%edi uint32_t len = index->extents[mid].ee_len; it seems that the "mid" is out of range, so you may need to check when the "end" is 0 and assign to "boundary", which will make "end" reach to unsinged max

Another thing, you should also consider when the "end" is MAX_EXTENTS and ee_start != 0, this will also cause the same error.

baekrang256 commented 4 months ago

There were indeed some corner cases mentioned by @RoyWFHuang that was not handled. Thanks for the review.

I've fixed the code and tried the CI test in my local environment, checked the output comes out as expected according to other CI test outputs from other pr. I think you can try out the github action workflow again.

One additional question : should I rebase the branch again before the merge?

jserv commented 4 months ago

One additional question : should I rebase the branch again before the merge?

Yes, please go ahead.

baekrang256 commented 4 months ago

Finished rebasing.

jserv commented 4 months ago

Thank @baekrang256 for contributing!