Skip to content

Instrument buffer head reaper and add deferred reclaim queue#3

Open
JoneKone wants to merge 1 commit intomasterfrom
codex/instrument-ext2bhreaperthread-for-tracing
Open

Instrument buffer head reaper and add deferred reclaim queue#3
JoneKone wants to merge 1 commit intomasterfrom
codex/instrument-ext2bhreaperthread-for-tracing

Conversation

@JoneKone
Copy link
Owner

Summary

  • add a deferred buffer head queue and initialize it with the device metadata so reaper logic can track busy entries
  • instrument Ext2QueryUnusedBH/Ext2bhReaperThread to log busy buffer heads, counts, and reclaim events before freeing
  • update buffer cache teardown to honor the deferred queue so active buffer heads are not freed prematurely

Testing

  • not run (reason: manual testing of kernel driver changes is not available in this environment)

https://chatgpt.com/codex/tasks/task_e_68fcbf19346083338e47737dc3926c22

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +299 to +303

InsertTailList(&Vcb->bd.bd_bh_deferred, &bh->b_link);

if (busy) {
break;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Detaching busy buffer heads while dropping VCB

When Ext2DropBH sees a buffer head with a non‑zero b_count, it now re‑queues the node onto bd_bh_deferred and breaks out of the loop. Ext2DestroyVcb frees bd_bh_lock, the buffer‑head slab cache, and eventually the VCB itself immediately after calling Ext2DropBH, so any busy buffer head left on bd_bh_deferred keeps list links and lock pointers that refer to freed memory. If the last reference to that buffer is released later (e.g. via __brelse), the code will acquire a deleted resource and run RemoveEntryList against the stale list head, risking a crash. The previous implementation detached busy entries by reinitializing the list head so delayed release was harmless. The drop routine should either keep busy entries detached or delay VCB teardown until the deferred list drains.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant