From 3b1d78bd57a3146abee0913a0a12a5861d01a0bc Mon Sep 17 00:00:00 2001 From: Gui Hecheng Date: Sat, 27 May 2017 10:03:59 +0800 Subject: [PATCH] rgw_file: add lock protection for readdir against gc The state.mtx protects state.events accessed both from readdir and gc. Fixes: http://tracker.ceph.com/issues/20121 Signed-off-by: Gui Hecheng --- src/rgw/rgw_file.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index cd497480f474..136bed6452e0 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -1012,6 +1012,7 @@ namespace rgw { inc_nlink(req.d_count); *eof = req.eof(); event ev(event::type::READDIR, get_key(), state.atime); + lock_guard sguard(fs->state.mtx); fs->state.push_event(ev); } } else { @@ -1026,6 +1027,7 @@ namespace rgw { inc_nlink(req.d_count); *eof = req.eof(); event ev(event::type::READDIR, get_key(), state.atime); + lock_guard sguard(fs->state.mtx); fs->state.push_event(ev); } } -- 2.47.3