• Jeff Layton's avatar
    ceph: cancel delayed work instead of flushing on mdsc teardown · b4002173
    Jeff Layton authored
    The first thing metric_delayed_work does is check mdsc->stopping,
    and then return immediately if it's set. That's good since we would
    have already torn down the metric structures at this point, otherwise,
    but there is no locking around mdsc->stopping.
    
    It's possible that the ceph_metric_destroy call could race with the
    delayed_work, in which case we could end up with the delayed_work
    accessing destroyed percpu variables.
    
    At this point in the mdsc teardown, the "stopping" flag has already been
    set, so there's no benefit to flushing the work. Move the work
    cancellation in ceph_metric_destroy ahead of the percpu variable
    destruction, and eliminate the flush_delayed_work call in
    ceph_mdsc_destroy.
    
    Fixes: 18f473b3 ("ceph: periodically send perf metrics to MDSes")
    Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
    Reviewed-by: default avatarXiubo Li <xiubli@redhat.com>
    Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
    b4002173
metric.c 11.5 KB