diff options
author | Chengguang Xu <cgxu519@icloud.com> | 2018-02-23 17:09:38 +0800 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2018-04-02 10:12:46 +0200 |
commit | b884014a91a49ed0e7198d276b28887cc48363bd (patch) | |
tree | 5bef0732e3736d68dbb5c57f60bc532d3fe74d40 | |
parent | f2f87877b8f29a4aa0000a2e3cdf806ac645500e (diff) |
ceph: adding protection for showing cap reservation info
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>
-rw-r--r-- | fs/ceph/caps.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 0e5bd3e3344e..1d02648788e3 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -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) @@ -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); } /* |