lkml.org 
[lkml]   [2016]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] af_unix: Fix splice-bind deadlock
Date
Hannes Frederic Sowa <hannes@stressinduktion.org> writes:
> On Sun, Jan 3, 2016, at 19:03, Rainer Weikusat wrote:

[reorder i_mutex and readlock locking]

> I was concerned because of the comment in skb_socket_splice:
>
> /* Drop the socket lock, otherwise we have reverse
> * locking dependencies between sk_lock and i_mutex
> * here as compared to sendfile(). We enter here
> * with the socket lock held, and splice_to_pipe() will
> * grab the pipe inode lock. For sendfile() emulation,
> * we call into ->sendpage() with the i_mutex lock held
> * and networking will grab the socket lock.
> */

AFAICT, this comment is "a bit misleading": sendfile (from file to
socket) is internally implemented as 'splice from file to pipe' +
'splice from pipe to socket'. The later acquires the pipe lock of the
pipe and then invokes the sendpage method of the socket which acquires
the appropiate socket lock (for an AF_UNIX socket, it's
u->readlock). But 'pipe lock' and 'i_mutex' are two completely
different things: The former is the mutex in a struct pipe_inode_info
(pipe_fs_u.h), the latter is the i_mutex in a struct inode (fs.h).

"Code explains comment" :-)


\
 
 \ /
  Last update: 2016-01-06 16:01    [W:0.168 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site