fixes for cephfs
cover fixes for cephfs
Hi,
These patchs are fixes for cephfs kernel client bugs when running 2 MDS with thrash_exports enabled.
These patches are also in:
git://github.com/ukernel/ceph-client.git master
Regards
Yan, Zheng
PATCH 1/6 ceph: Don't update i_max_size when handling non-auth cap
From: "Yan, Zheng" <[email protected]>
The cap from non-auth mds doesn't have a meaningful max_size value.
--- fs/ceph/caps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/caps.c +1 -1
@@ -2388,7 +2388,7 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant, &atime);/* max size increase? */ -if (max_size != ci->i_max_size) { +if (ci->i_auth_cap == cap && max_size != ci->i_max_size) {dout ("max_size %lld -> %llu\n" , ci->i_max_size, max_size); ci->i_max_size = max_size;if (max_size >= ci->i_wanted_max_size) {
Signature · 1 line
1.7.11.7
PATCH 2/6 ceph: Hold caps_list_lock when adjusting caps_{use,total}_count
In reply to Yan, ZhengFrom: "Yan, Zheng" <[email protected]>
--- fs/ceph/caps.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ceph/caps.c +2 -0
@@ -236,8 +236,10 @@ static struct ceph_cap *get_cap(struct ceph_mds_client *mdsc,if (!ctx) { cap =kmem_cache_alloc (ceph_cap_cachep,GFP_NOFS );if (cap) { +spin_lock (&mdsc->caps_list_lock); mdsc->caps_use_count++; mdsc->caps_total_count++; +spin_unlock (&mdsc->caps_list_lock); }return cap; }
Signature · 1 line
1.7.11.7
PATCH 3/6 ceph: Fix infinite loop in __wake_requests
In reply to Yan, ZhengFrom: "Yan, Zheng" <[email protected]>
__wake_requests() will enter infinite loop if we use it to wake requests in the session->s_waiting list. __wake_requests() deletes requests from the list and __do_request() adds requests back to the list.
--- fs/ceph/mds_client.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/ceph/mds_client.c +7 -2
@@ -1876,9 +1876,14 @@ finish:static void __wake_requests (struct ceph_mds_client *mdsc,struct list_head *head) { -struct ceph_mds_request *req, *nreq; +struct ceph_mds_request *req; +LIST_HEAD (tmp_list); + +list_splice_init (head, &tmp_list); -list_for_each_entry_safe (req, nreq, head, r_wait) { +while (!list_empty (&tmp_list)) { + req =list_entry (tmp_list.next, + struct ceph_mds_request, r_wait);list_del_init (&req->r_wait);__do_request (mdsc, req); }
Signature · 1 line
1.7.11.7
PATCH 4/6 ceph: Don't add dirty inode to dirty list if caps is in migration
In reply to Yan, ZhengFrom: "Yan, Zheng" <[email protected]>
Add dirty inode to cap_dirty_migrating list instead, this can avoid ceph_flush_dirty_caps() entering infinite loop.
--- fs/ceph/caps.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/ceph/caps.c +7 -3
@@ -1351,11 +1351,15 @@ int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)if (!ci->i_head_snapc) ci->i_head_snapc =ceph_get_snap_context ( ci->i_snap_realm->cached_context); -dout (" inode %p now dirty snapc %p\n" , &ci->vfs_inode, - ci->i_head_snapc); +dout (" inode %p now dirty snapc %p auth cap %p\n" , + &ci->vfs_inode, ci->i_head_snapc, ci->i_auth_cap);BUG_ON (!list_empty (&ci->i_dirty_item));spin_lock (&mdsc->cap_dirty_lock); -list_add (&ci->i_dirty_item, &mdsc->cap_dirty); +if (ci->i_auth_cap) +list_add (&ci->i_dirty_item, &mdsc->cap_dirty); +else +list_add (&ci->i_dirty_item, + &mdsc->cap_dirty_migrating);spin_unlock (&mdsc->cap_dirty_lock);if (ci->i_flushing_caps ==0 ) {ihold (inode);
Signature · 1 line
1.7.11.7
PATCH 5/6 ceph: Fix __ceph_do_pending_vmtruncate
In reply to Yan, ZhengFrom: "Yan, Zheng" <[email protected]>
we should set i_truncate_pending to 0 after page cache is truncated to i_truncate_size
--- fs/ceph/inode.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
fs/ceph/inode.c +9 -6
@@ -1466,7 +1466,7 @@ void __ceph_do_pending_vmtruncate(struct inode *inode) {struct ceph_inode_info *ci =ceph_inode (inode);u64 to; -int wrbuffer_refs, wake =0 ; +int wrbuffer_refs, finish =0 ; retry:spin_lock (&ci->i_ceph_lock);
@@ -1498,15 +1498,18 @@ retry:truncate_inode_pages (inode->i_mapping, to);spin_lock (&ci->i_ceph_lock); - ci->i_truncate_pending--; -if (ci->i_truncate_pending ==0 ) - wake =1 ; +if (to == ci->i_truncate_size) { + ci->i_truncate_pending =0 ; + finish =1 ; + }spin_unlock (&ci->i_ceph_lock); +if (!finish) + goto retry;if (wrbuffer_refs ==0 )ceph_check_caps (ci,CHECK_CAPS_AUTHONLY ,NULL ); -if (wake) -wake_up_all (&ci->i_cap_wq); + +wake_up_all (&ci->i_cap_wq); }
Signature · 1 line
1.7.11.7
PATCH 6/6 ceph: call handle_cap_grant() for cap import message
In reply to Yan, ZhengFrom: "Yan, Zheng" <[email protected]>
If client sends cap message that requests new max size during exporting caps, the exporting MDS will drop the message quietly. So the client may wait for the reply that updates the max size forever. call handle_cap_grant() for cap import message can avoid this issue.
--- fs/ceph/caps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ceph/caps.c +2 -2
@@ -2751,6 +2751,7 @@ static void handle_cap_import(struct ceph_mds_client *mdsc,/* make sure we re-request max_size, if necessary */ spin_lock (&ci->i_ceph_lock); + ci->i_wanted_max_size =0 ;/* reset */ ci->i_requested_max_size =0 ;spin_unlock (&ci->i_ceph_lock); }
@@ -2846,8 +2847,6 @@ void ceph_handle_caps(struct ceph_mds_session *session,case CEPH_CAP_OP_IMPORT :handle_cap_import (mdsc, inode, h, session, snaptrace, snaptrace_len); -ceph_check_caps (ceph_inode (inode),0 , session); - goto done_unlocked; }/* the rest require a cap */
@@ -2864,6 +2863,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,switch (op) {case CEPH_CAP_OP_REVOKE :case CEPH_CAP_OP_GRANT : +case CEPH_CAP_OP_IMPORT :handle_cap_grant (inode, h, session, cap, msg->middle); goto done_unlocked;
Signature · 1 line
1.7.11.7