On Mon, Aug 19, 2019 at 08:34:12AM +0200, Jan Kara wrote:...
On Sat 17-08-19 12:26:03, Dave Chinner wrote:
On Fri, Aug 16, 2019 at 12:05:28PM -0700, Ira Weiny wrote:
On Thu, Aug 15, 2019 at 03:05:58PM +0200, Jan Kara wrote:
On Wed 14-08-19 11:08:49, Ira Weiny wrote:
On Wed, Aug 14, 2019 at 12:17:14PM +0200, Jan Kara wrote:
The last close is an interesting case because the __fput() call
actually runs from task_work() context, not where the last reference
is actually dropped. So it already has certain specific interactions
with signals and task exit processing via task_add_work() and
task_add_work() calls set_notify_resume(task), so if nothing else
triggers when returning to userspace we run this path:
It's worth noting that locks_remove_lease() does a
percpu_down_read() which means we can already block in this context
If there is a signal pending, the task work is run this way (before
the above notify path):
We can detect this case via signal_pending() and even SIGKILL via
fatal_signal_pending(), and so we can decide not to block based on
the fact the process is about to be reaped and so the lease largely
doesn't matter anymore. I'd argue that it is close and we can't
easily back out, so we'd only break the block on a fatal signal....
And then, of course, is the call path through do_exit(), which has
the PF_EXITING task flag set:
and so it's easy to avoid blocking in this case, too.
So that leaves just the normal close() syscall exit case, where the
application has full control of the order in which resources are
released. We've already established that we can block in this
context. Blocking in an interruptible state will allow fatal signal
delivery to wake us, and then we fall into the
fatal_signal_pending() case if we get a SIGKILL while blocking.
Hence I think blocking in this case would be OK - it indicates an
application bug (releasing a lease before releasing the resources)
but leaves SIGKILL available to administrators to resolve situations
involving buggy applications.
This requires applications to follow the rules: any process
that pins physical resources must have an active reference to a
layout lease, either via a duplicated fd or it's own private lease.
If the app doesn't play by the rules, it hangs in close() until it