Skip to content

Commit

Permalink
ceph: adding protection for showing cap reservation info
Browse files Browse the repository at this point in the history
Adding spinlock protection during getting cap reservation
ralated fields so that the numbers match below BUG_ON condition
in the code.

BUG_ON(mdsc->caps_total_count != mdsc->caps_use_count +
				 mdsc->caps_reserve_count +
				 mdsc->caps_avail_count);

Signed-off-by: Chengguang Xu <cgxu519@icloud.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
  • Loading branch information
Chengguang Xu authored and Ilya Dryomov committed Apr 2, 2018
1 parent f2f8787 commit b884014
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/ceph/caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ void ceph_reservation_status(struct ceph_fs_client *fsc,
{
struct ceph_mds_client *mdsc = fsc->mdsc;

spin_lock(&mdsc->caps_list_lock);

if (total)
*total = mdsc->caps_total_count;
if (avail)
Expand All @@ -351,6 +353,8 @@ void ceph_reservation_status(struct ceph_fs_client *fsc,
*reserved = mdsc->caps_reserve_count;
if (min)
*min = mdsc->caps_min_count;

spin_unlock(&mdsc->caps_list_lock);
}

/*
Expand Down

0 comments on commit b884014

Please sign in to comment.