]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
client: fix race in concurrent readdir
authorYan, Zheng <zyan@redhat.com>
Fri, 27 Apr 2018 01:13:51 +0000 (09:13 +0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Mon, 7 May 2018 22:55:05 +0000 (15:55 -0700)
commit9ab67039204a36d1d3ce5696a885db44a108b62b
tree7ac1bb8a54d06ea588e2628348e0eee7b6b03975
parent6383ecab93b25dd6ed2bbadbb57eaebca897cdd3
client: fix race in concurrent readdir

For a large directory, program needs to issue multiple readdir
syscalls to get all dentries. When there are multiple programs
read the directory concurrently. Following sequence of events
can happen.

 - program calls readdir with pos = 2. ceph sends readdir request
   to mds. The reply contains N1 entries. ceph adds these N1 entries
   to readdir cache.
 - program calls readdir with pos = N1+2. The readdir is satisfied
   by the readdir cache, N2 entries are returned. (Other program
   calls readdir in the middle, which fills the cache)
 - program calls readdir with pos = N1+N2+2. ceph sends readdir
   request to mds. The reply contains N3 entries and it reaches
   directory end. ceph adds these N3 entries to the readdir cache
   and marks directory complete.

The second readdir call does not update dirp->cache_index. ceph adds
the last N3 entries to wrong places.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
Fixes: http://tracker.ceph.com/issues/23894
(cherry picked from commit 01e23c178d068a3983c58cf115d57f6e1cc06255)
src/client/Client.cc