Re: [RFC PATCH v5] ntfs: serialize attribute-list replacement with lookups

From: Hyunchul Lee

Date: Tue Jul 07 2026 - 21:15:03 EST


Hi Cen,

This approach introduces too many changes. I apologize as I originally
recommended this design.

Therefore, I am now considering alternative approaches:

Design A:
* Eliminates the raw pointer (ctx->al_entry) entirely from search_ctx.
* Instead, it tracks the cursor using 'al_cursor.off' (offset within
the buffer) and 'al_cursor.gen' (generation counter matching
base_ni->attr_list_gen).
* If the generation counter changes, the lookup detects this and
restarts safely using an exact search key (al_exact).
* Since we no longer carry raw pointers, attr_list_lock only needs to
be held briefly during in-memory list operations.
* To strictly maintain the lock order (runlist.lock -> attr_list_lock)
and prevent deadlocks, functions that previously held attr_list_lock
while calling runlist-locking operations must be refactored.
* Pros:
- Short-lived locks.
- Narrow lock scope makes it easy to maintain codes.
* Cons:
- More complex implementation.

Design B (runlist.lock style):
* Retains ctx->al_entry (raw pointers), but manages attr_list_lock as
a top-level coarse-grained lock similar to runlist.lock.
* We must establish a strict global lock hierarchy: runlist.lock ->
attr_list_lock.
* Pros:
- Simpler implementation.
* Cons:
- Could reduce performance.
- Wide lock scope makes it difficult to maintain codes.
- May introduce a lot of '_nolock' helper functions to avoid
self-deadlock.

Which approaches do you think would be better, or other approaches?
And please let me know if you would like me to implement it.