diff options
author | Yan, Zheng <zyan@redhat.com> | 2017-01-12 04:18:00 -0500 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2017-02-20 06:16:06 -0500 |
commit | eb65b919b914e65485fd8134912066f4fafc4f1e (patch) | |
tree | 85f61deab3e050c1003787b6a00146d2c97e1411 /fs/ceph/caps.c | |
parent | 7c94ba27903c3c46c5829e96efb7c2a8ab7510e9 (diff) |
ceph: avoid updating mds_wanted too frequently
user space may open/close single file frequently. It's not good
to send a clientcaps message to mds for each open/close syscall.
Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r-- | fs/ceph/caps.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index e3a2a3f32568..d941c48e8bff 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -1184,6 +1184,13 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, | |||
1184 | delayed = 1; | 1184 | delayed = 1; |
1185 | } | 1185 | } |
1186 | ci->i_ceph_flags &= ~(CEPH_I_NODELAY | CEPH_I_FLUSH); | 1186 | ci->i_ceph_flags &= ~(CEPH_I_NODELAY | CEPH_I_FLUSH); |
1187 | if (want & ~cap->mds_wanted) { | ||
1188 | /* user space may open/close single file frequently. | ||
1189 | * This avoids droping mds_wanted immediately after | ||
1190 | * requesting new mds_wanted. | ||
1191 | */ | ||
1192 | __cap_set_timeouts(mdsc, ci); | ||
1193 | } | ||
1187 | 1194 | ||
1188 | cap->issued &= retain; /* drop bits we don't want */ | 1195 | cap->issued &= retain; /* drop bits we don't want */ |
1189 | if (cap->implemented & ~cap->issued) { | 1196 | if (cap->implemented & ~cap->issued) { |
@@ -2485,15 +2492,14 @@ again: | |||
2485 | goto out_unlock; | 2492 | goto out_unlock; |
2486 | } | 2493 | } |
2487 | mds_wanted = __ceph_caps_mds_wanted(ci); | 2494 | mds_wanted = __ceph_caps_mds_wanted(ci); |
2488 | if ((mds_wanted & need) != need) { | 2495 | if (need & ~(mds_wanted & need)) { |
2489 | dout("get_cap_refs %p caps were dropped" | 2496 | dout("get_cap_refs %p caps were dropped" |
2490 | " (session killed?)\n", inode); | 2497 | " (session killed?)\n", inode); |
2491 | *err = -ESTALE; | 2498 | *err = -ESTALE; |
2492 | ret = 1; | 2499 | ret = 1; |
2493 | goto out_unlock; | 2500 | goto out_unlock; |
2494 | } | 2501 | } |
2495 | if ((mds_wanted & file_wanted) == | 2502 | if (!(file_wanted & ~mds_wanted)) |
2496 | (file_wanted & (CEPH_CAP_FILE_RD|CEPH_CAP_FILE_WR))) | ||
2497 | ci->i_ceph_flags &= ~CEPH_I_CAP_DROPPED; | 2503 | ci->i_ceph_flags &= ~CEPH_I_CAP_DROPPED; |
2498 | } | 2504 | } |
2499 | 2505 | ||