summaryrefslogtreecommitdiffstats
path: root/fs/ceph/caps.c
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2016-06-06 04:01:39 -0400
committerIlya Dryomov <idryomov@gmail.com>2016-07-27 20:55:39 -0400
commit774a6a118c70f8c11fcfe636032b5016ad71a746 (patch)
tree8c1380f9b9fe2b6db6360b68f4aad373be01072b /fs/ceph/caps.c
parenta22bd5ffae2d22c054c832fe0d60976ed9e4a49d (diff)
ceph: reduce i_nr_by_mode array size
Track usage count for individual fmode bit. This can reduce the array size by half. Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r--fs/ceph/caps.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 0a9406a8a794..a08d245f16f5 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -849,12 +849,14 @@ int __ceph_caps_used(struct ceph_inode_info *ci)
849 */ 849 */
850int __ceph_caps_file_wanted(struct ceph_inode_info *ci) 850int __ceph_caps_file_wanted(struct ceph_inode_info *ci)
851{ 851{
852 int want = 0; 852 int i, bits = 0;
853 int mode; 853 for (i = 0; i < CEPH_FILE_MODE_BITS; i++) {
854 for (mode = 0; mode < CEPH_FILE_MODE_NUM; mode++) 854 if (ci->i_nr_by_mode[i])
855 if (ci->i_nr_by_mode[mode]) 855 bits |= 1 << i;
856 want |= ceph_caps_for_mode(mode); 856 }
857 return want; 857 if (bits == 0)
858 return 0;
859 return ceph_caps_for_mode(bits >> 1);
858} 860}
859 861
860/* 862/*
@@ -3682,6 +3684,16 @@ void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc)
3682 dout("flush_dirty_caps done\n"); 3684 dout("flush_dirty_caps done\n");
3683} 3685}
3684 3686
3687void __ceph_get_fmode(struct ceph_inode_info *ci, int fmode)
3688{
3689 int i;
3690 int bits = (fmode << 1) | 1;
3691 for (i = 0; i < CEPH_FILE_MODE_BITS; i++) {
3692 if (bits & (1 << i))
3693 ci->i_nr_by_mode[i]++;
3694 }
3695}
3696
3685/* 3697/*
3686 * Drop open file reference. If we were the last open file, 3698 * Drop open file reference. If we were the last open file,
3687 * we may need to release capabilities to the MDS (or schedule 3699 * we may need to release capabilities to the MDS (or schedule
@@ -3689,15 +3701,20 @@ void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc)
3689 */ 3701 */
3690void ceph_put_fmode(struct ceph_inode_info *ci, int fmode) 3702void ceph_put_fmode(struct ceph_inode_info *ci, int fmode)
3691{ 3703{
3692 struct inode *inode = &ci->vfs_inode; 3704 int i, last = 0;
3693 int last = 0; 3705 int bits = (fmode << 1) | 1;
3694
3695 spin_lock(&ci->i_ceph_lock); 3706 spin_lock(&ci->i_ceph_lock);
3696 dout("put_fmode %p fmode %d %d -> %d\n", inode, fmode, 3707 for (i = 0; i < CEPH_FILE_MODE_BITS; i++) {
3697 ci->i_nr_by_mode[fmode], ci->i_nr_by_mode[fmode]-1); 3708 if (bits & (1 << i)) {
3698 BUG_ON(ci->i_nr_by_mode[fmode] == 0); 3709 BUG_ON(ci->i_nr_by_mode[i] == 0);
3699 if (--ci->i_nr_by_mode[fmode] == 0) 3710 if (--ci->i_nr_by_mode[i] == 0)
3700 last++; 3711 last++;
3712 }
3713 }
3714 dout("put_fmode %p fmode %d {%d,%d,%d,%d}\n",
3715 &ci->vfs_inode, fmode,
3716 ci->i_nr_by_mode[0], ci->i_nr_by_mode[1],
3717 ci->i_nr_by_mode[2], ci->i_nr_by_mode[3]);
3701 spin_unlock(&ci->i_ceph_lock); 3718 spin_unlock(&ci->i_ceph_lock);
3702 3719
3703 if (last && ci->i_vino.snap == CEPH_NOSNAP) 3720 if (last && ci->i_vino.snap == CEPH_NOSNAP)