lkml.org 
[lkml]   [2019]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v2 00/19] RDMA/FS DAX truncate proposal V1,000,002 ;-)
On Wed, Aug 21, 2019 at 11:57:03AM -0700, 'Ira Weiny' wrote:
> On Wed, Aug 21, 2019 at 03:13:43PM -0300, Jason Gunthorpe wrote:
> > On Wed, Aug 21, 2019 at 11:02:00AM -0700, Ira Weiny wrote:
> > > On Tue, Aug 20, 2019 at 08:55:15AM -0300, Jason Gunthorpe wrote:
> > > > On Tue, Aug 20, 2019 at 11:12:10AM +1000, Dave Chinner wrote:
> > > > > On Mon, Aug 19, 2019 at 09:38:41AM -0300, Jason Gunthorpe wrote:
> > > > > > On Mon, Aug 19, 2019 at 07:24:09PM +1000, Dave Chinner wrote:
> > > > > >
> > > > > > > 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.
> > > > > >
> > > > > > The major problem with RDMA is that it doesn't always wait on close() for the
> > > > > > MR holding the page pins to be destoyed. This is done to avoid a
> > > > > > deadlock of the form:
> > > > > >
> > > > > > uverbs_destroy_ufile_hw()
> > > > > > mutex_lock()
> > > > > > [..]
> > > > > > mmput()
> > > > > > exit_mmap()
> > > > > > remove_vma()
> > > > > > fput();
> > > > > > file_operations->release()
> > > > >
> > > > > I think this is wrong, and I'm pretty sure it's an example of why
> > > > > the final __fput() call is moved out of line.
> > > >
> > > > Yes, I think so too, all I can say is this *used* to happen, as we
> > > > have special code avoiding it, which is the code that is messing up
> > > > Ira's lifetime model.
> > > >
> > > > Ira, you could try unraveling the special locking, that solves your
> > > > lifetime issues?
> > >
> > > Yes I will try to prove this out... But I'm still not sure this fully solves
> > > the problem.
> > >
> > > This only ensures that the process which has the RDMA context (RDMA FD) is safe
> > > with regard to hanging the close for the "data file FD" (the file which has
> > > pinned pages) in that _same_ process. But what about the scenario.
> >
> > Oh, I didn't think we were talking about that. Hanging the close of
> > the datafile fd contingent on some other FD's closure is a recipe for
> > deadlock..
>
> The discussion between Jan and Dave was concerning what happens when a user
> calls
>
> fd = open()
> fnctl(...getlease...)
> addr = mmap(fd...)
> ib_reg_mr() <pin>
> munmap(addr...)
> close(fd)
>
> Dave suggested:
>
> "I'm of a mind to make the last close() on a file block if there's an
> active layout lease to prevent processes from zombie-ing layout
> leases like this. i.e. you can't close the fd until resources that
> pin the lease have been released."
>
> -- Dave https://lkml.org/lkml/2019/8/16/994

I think this may all be easier if there was a way to block a dup() if it comes
from an SCM_RIGHTS. Does anyone know if that is easy? I assume it would just
mean passing some flag through the dup() call chain.

Jason, if we did that would it break RDMA use cases? I personally don't know
of any. We could pass data back from vaddr_pin indicating that a file pin has
been taken and predicate the blocking of SCM_RIGHTS on that?

Of course if the user called:

fd = open()
fnctl(...getlease...)
addr = mmap(fd...)
ib_reg_mr() <pin>
munmap(addr...)
close(fd)
fork() <=== in another thread because close is hanging

Would that dup() "fd" above into the child? Or maybe that would be part of the
work to make close() hang? Ensure the fd/file is still in the FD table so it
gets dupped???

Ira


>
> >
> > IMHO the pin refcnt is held by the driver char dev FD, that is the
> > object you need to make it visible against.
>
> I'm sorry but what do you mean by "driver char dev FD"?
>
> >
> > Why not just have a single table someplace of all the layout leases
> > with the file they are held on and the FD/socket/etc that is holding
> > the pin? Make it independent of processes and FDs?
>
> If it is independent of processes how will we know which process is blocking
> the truncate? Using a global table is an interesting idea but I still believe
> the users are going to want to track this to specific processes. It's not
> clear to me how that would be done with a global table.
>
> I agree the XDP/socket case is bothersome... I was thinking that somewhere the
> fd of the socket could be hooked up in this case. But taking a look at it
> reveals that is not going to be easy. And I assume XDP has the same issue WRT
> SCM_RIGHTS and the ability to share the xdp context?
>
> Ira
>
> >
> > Jason

\
 
 \ /
  Last update: 2019-08-21 21:06    [W:0.125 / U:7.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site