Skip to content

fs/vfs/fs_lock.c: Close stale locks unconditionally#18811

Merged
xiaoxiang781216 merged 1 commit intoapache:masterfrom
tiiuae:fix_file_close_lock_upstream
Apr 28, 2026
Merged

fs/vfs/fs_lock.c: Close stale locks unconditionally#18811
xiaoxiang781216 merged 1 commit intoapache:masterfrom
tiiuae:fix_file_close_lock_upstream

Conversation

@jnippula
Copy link
Copy Markdown
Contributor

Summary

Allow to close the lock even the dying task is in signal handler context (e.g. kill).

Impact

This patch prevents file locks to stay locked/acquired by already killed task,
so the file can be locked by new task if the previous owner has been
killed.

Testing

Build target: RISC-V mpfs based custom hardware.

Test sequence:

  1. File lock acquired by task (e.g. task pid 2790)
  2. Task that has the file lock is killed (call kill 2790)
  3. Spawn new task which acquires the lock for the same file

Without this patch the file lock is still acquired by the task that
is already killed and not visible in task list anymore. New task
can't acquire the file lock anymore:

Daemon lock owner pid: 2790 (lock file: /tmp/enroll_agent.d_lock)
Polling daemon ready failed: Connection timed out

With this patch the file lock is released when the owner task is killed
and new task can acquire the file lock properly.

Allow to close the lock even the dying task is in
signal handler context. Also the file type check can
be ignored as they are already validated in create phase.

Signed-off-by: Jari Nippula <jari.nippula@tii.ae>
@jnippula jnippula requested a review from Donny9 as a code owner April 27, 2026 09:09
@github-actions github-actions Bot added Area: File System File System issues Size: XS The size of the change in this PR is very small labels Apr 27, 2026
@acassis
Copy link
Copy Markdown
Contributor

acassis commented Apr 28, 2026

@jnippula maybe more testing is needed to avoid some side effects in others applications

@xiaoxiang781216 xiaoxiang781216 merged commit 62b71c3 into apache:master Apr 28, 2026
78 of 79 checks passed
@jnippula jnippula deleted the fix_file_close_lock_upstream branch April 28, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: File System File System issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants