diff options
author | Zhi Zhang <zhang.david2011@gmail.com> | 2018-01-24 08:24:33 -0500 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2018-02-26 10:19:16 -0500 |
commit | 6ef0bc6ddee1f62310877a1d53b1ea1d0d8e51a2 (patch) | |
tree | a4657907e7179ff8d0ffe81c26cae5911790bc41 /fs/ceph/caps.c | |
parent | 4a3928c6f8a53fa1aed28ccba227742486e8ddcb (diff) |
ceph: flush dirty caps of unlinked inode ASAP
Client should release unlinked inode from its cache ASAP. But client
can't release inode with dirty caps.
Link: http://tracker.ceph.com/issues/22886
Signed-off-by: Zhi Zhang <zhang.david2011@gmail.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r-- | fs/ceph/caps.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 6582c4507e6c..0e5bd3e3344e 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -3965,6 +3965,32 @@ void ceph_put_fmode(struct ceph_inode_info *ci, int fmode) | |||
3965 | } | 3965 | } |
3966 | 3966 | ||
3967 | /* | 3967 | /* |
3968 | * For a soon-to-be unlinked file, drop the AUTH_RDCACHE caps. If it | ||
3969 | * looks like the link count will hit 0, drop any other caps (other | ||
3970 | * than PIN) we don't specifically want (due to the file still being | ||
3971 | * open). | ||
3972 | */ | ||
3973 | int ceph_drop_caps_for_unlink(struct inode *inode) | ||
3974 | { | ||
3975 | struct ceph_inode_info *ci = ceph_inode(inode); | ||
3976 | int drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; | ||
3977 | |||
3978 | spin_lock(&ci->i_ceph_lock); | ||
3979 | if (inode->i_nlink == 1) { | ||
3980 | drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN); | ||
3981 | |||
3982 | ci->i_ceph_flags |= CEPH_I_NODELAY; | ||
3983 | if (__ceph_caps_dirty(ci)) { | ||
3984 | struct ceph_mds_client *mdsc = | ||
3985 | ceph_inode_to_client(inode)->mdsc; | ||
3986 | __cap_delay_requeue_front(mdsc, ci); | ||
3987 | } | ||
3988 | } | ||
3989 | spin_unlock(&ci->i_ceph_lock); | ||
3990 | return drop; | ||
3991 | } | ||
3992 | |||
3993 | /* | ||
3968 | * Helpers for embedding cap and dentry lease releases into mds | 3994 | * Helpers for embedding cap and dentry lease releases into mds |
3969 | * requests. | 3995 | * requests. |
3970 | * | 3996 | * |