Dave Chinner 9f54180109 xfs: concurrent readdir hangs on data buffer locks
There's a three-process deadlock involving shared/exclusive barriers
and inverted lock orders in the directory readdir implementation.
It's a pre-existing problem with lock ordering, exposed by the
VFS parallelisation code.

process 1               process 2               process 3
---------               ---------               ---------
readdir
iolock(shared)
  get_leaf_dents
    iterate entries
       ilock(shared)
       map, lock and read buffer
       iunlock(shared)
       process entries in buffer
       .....
                                                readdir
                                                iolock(shared)
                                                  get_leaf_dents
                                                    iterate entries
                                                      ilock(shared)
                                                      map, lock buffer
                                                      <blocks>
                        finish ->iterate_shared
                        file_accessed()
                          ->update_time
                            start transaction
                            ilock(excl)
                            <blocks>
        .....
        finishes processing buffer
        get next buffer
          ilock(shared)
          <blocks>

And that's the deadlock.

Fix this by dropping the current buffer lock in process 1 before
trying to map the next buffer. This means we keep the lock order of
ilock -> buffer lock intact and hence will allow process 3 to make
progress and drop it's ilock(shared) once it is done.

Reported-by: Xiong Zhou <xzhou@redhat.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-05-18 13:20:21 -04:00
..
2014-07-30 09:12:05 +10:00
2016-03-18 11:42:53 -04:00
2013-05-07 18:45:36 -05:00
2011-08-12 16:21:35 -05:00
2012-11-19 20:11:24 -06:00
2016-03-31 00:30:15 -04:00
2016-03-21 11:53:05 -07:00
2013-08-12 16:53:39 -05:00
2016-02-10 15:01:30 +11:00
2011-08-12 16:21:35 -05:00
2015-06-22 09:44:02 +10:00
2011-08-12 16:21:35 -05:00
2016-02-09 16:54:58 +11:00
2013-08-12 16:56:06 -05:00
2016-02-09 16:54:58 +11:00
2016-03-11 10:21:32 -08:00
2013-05-07 18:45:36 -05:00
2016-03-18 11:42:53 -04:00
2013-05-07 18:45:36 -05:00