Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ceph: fix readdir vs fragmentation race

following sequence of events tigger the race

- client readdir frag 0* -> got item 'A'
- MDS merges frag 0* and frag 1*
- client send readdir request (frag 1*, offset 2, readdir_start 'A')
- MDS reply items (that are after item 'A') in frag *

Link: http://tracker.ceph.com/issues/17286
Signed-off-by: Yan, Zheng <zyan@redhat.com>

authored by

Yan, Zheng and committed by
Ilya Dryomov
f72f9455 0d7718f6

+2 -1
+2 -1
fs/ceph/inode.c
··· 1511 1511 ceph_fill_dirfrag(d_inode(parent), rinfo->dir_dir); 1512 1512 } 1513 1513 1514 - if (ceph_frag_is_leftmost(frag) && req->r_readdir_offset == 2) { 1514 + if (ceph_frag_is_leftmost(frag) && req->r_readdir_offset == 2 && 1515 + !(rinfo->hash_order && req->r_path2)) { 1515 1516 /* note dir version at start of readdir so we can tell 1516 1517 * if any dentries get dropped */ 1517 1518 req->r_dir_release_cnt = atomic64_read(&ci->i_release_count);