ceph: adding protection for showing cap reservation info
authorChengguang Xu <cgxu519@icloud.com>
Fri, 23 Feb 2018 09:09:38 +0000 (17:09 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 2 Apr 2018 08:12:46 +0000 (10:12 +0200)
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>
fs/ceph/caps.c

index 0e5bd3e3344e7983e6bdf38dba1adfba17500eba..1d02648788e38e7e9906da5354baef4c5d39815e 100644 (file)
@@ -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);
 }
 
 /*