aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2010-03-16 16:42:00 -0400
committerSage Weil <sage@newdream.net>2010-03-23 10:46:54 -0400
commit15637c8b1251c38694c32214eba69b72a30e9d9b (patch)
treea410e4db868f75dbace870930b9b032b877a552d /fs/ceph
parentcdc2ce056a3620139056b60ad7f6d355ad13f445 (diff)
ceph: clean up handle_cap_grant, handle_caps wrt session mutex
Drop session mutex unconditionally in handle_cap_grant, and do the check_caps from the handle_cap_grant helper. This avoids using a magic return value. Also avoid using a flag variable in the IMPORT case and call check_caps at the appropriate point. Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/caps.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 782848632e81..d9e860ff9f3a 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2195,18 +2195,19 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
2195 * Handle a cap GRANT message from the MDS. (Note that a GRANT may 2195 * Handle a cap GRANT message from the MDS. (Note that a GRANT may
2196 * actually be a revocation if it specifies a smaller cap set.) 2196 * actually be a revocation if it specifies a smaller cap set.)
2197 * 2197 *
2198 * caller holds s_mutex. 2198 * caller holds s_mutex and i_lock, we drop both.
2199 *
2199 * return value: 2200 * return value:
2200 * 0 - ok 2201 * 0 - ok
2201 * 1 - check_caps on auth cap only (writeback) 2202 * 1 - check_caps on auth cap only (writeback)
2202 * 2 - check_caps (ack revoke) 2203 * 2 - check_caps (ack revoke)
2203 */ 2204 */
2204static int handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant, 2205static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2205 struct ceph_mds_session *session, 2206 struct ceph_mds_session *session,
2206 struct ceph_cap *cap, 2207 struct ceph_cap *cap,
2207 struct ceph_buffer *xattr_buf) 2208 struct ceph_buffer *xattr_buf)
2208 __releases(inode->i_lock) 2209 __releases(inode->i_lock)
2209 2210 __releases(session->s_mutex)
2210{ 2211{
2211 struct ceph_inode_info *ci = ceph_inode(inode); 2212 struct ceph_inode_info *ci = ceph_inode(inode);
2212 int mds = session->s_mds; 2213 int mds = session->s_mds;
@@ -2216,7 +2217,7 @@ static int handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2216 u64 size = le64_to_cpu(grant->size); 2217 u64 size = le64_to_cpu(grant->size);
2217 u64 max_size = le64_to_cpu(grant->max_size); 2218 u64 max_size = le64_to_cpu(grant->max_size);
2218 struct timespec mtime, atime, ctime; 2219 struct timespec mtime, atime, ctime;
2219 int reply = 0; 2220 int check_caps = 0;
2220 int wake = 0; 2221 int wake = 0;
2221 int writeback = 0; 2222 int writeback = 0;
2222 int revoked_rdcache = 0; 2223 int revoked_rdcache = 0;
@@ -2329,10 +2330,10 @@ static int handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2329 if ((used & ~newcaps) & CEPH_CAP_FILE_BUFFER) 2330 if ((used & ~newcaps) & CEPH_CAP_FILE_BUFFER)
2330 writeback = 1; /* will delay ack */ 2331 writeback = 1; /* will delay ack */
2331 else if (dirty & ~newcaps) 2332 else if (dirty & ~newcaps)
2332 reply = 1; /* initiate writeback in check_caps */ 2333 check_caps = 1; /* initiate writeback in check_caps */
2333 else if (((used & ~newcaps) & CEPH_CAP_FILE_CACHE) == 0 || 2334 else if (((used & ~newcaps) & CEPH_CAP_FILE_CACHE) == 0 ||
2334 revoked_rdcache) 2335 revoked_rdcache)
2335 reply = 2; /* send revoke ack in check_caps */ 2336 check_caps = 2; /* send revoke ack in check_caps */
2336 cap->issued = newcaps; 2337 cap->issued = newcaps;
2337 cap->implemented |= newcaps; 2338 cap->implemented |= newcaps;
2338 } else if (cap->issued == newcaps) { 2339 } else if (cap->issued == newcaps) {
@@ -2361,7 +2362,14 @@ static int handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2361 ceph_queue_invalidate(inode); 2362 ceph_queue_invalidate(inode);
2362 if (wake) 2363 if (wake)
2363 wake_up(&ci->i_cap_wq); 2364 wake_up(&ci->i_cap_wq);
2364 return reply; 2365
2366 if (check_caps == 1)
2367 ceph_check_caps(ci, CHECK_CAPS_NODELAY|CHECK_CAPS_AUTHONLY,
2368 session);
2369 else if (check_caps == 2)
2370 ceph_check_caps(ci, CHECK_CAPS_NODELAY, session);
2371 else
2372 mutex_unlock(&session->s_mutex);
2365} 2373}
2366 2374
2367/* 2375/*
@@ -2622,9 +2630,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
2622 u64 cap_id; 2630 u64 cap_id;
2623 u64 size, max_size; 2631 u64 size, max_size;
2624 u64 tid; 2632 u64 tid;
2625 int check_caps = 0;
2626 void *snaptrace; 2633 void *snaptrace;
2627 int r;
2628 2634
2629 dout("handle_caps from mds%d\n", mds); 2635 dout("handle_caps from mds%d\n", mds);
2630 2636
@@ -2669,8 +2675,9 @@ void ceph_handle_caps(struct ceph_mds_session *session,
2669 case CEPH_CAP_OP_IMPORT: 2675 case CEPH_CAP_OP_IMPORT:
2670 handle_cap_import(mdsc, inode, h, session, 2676 handle_cap_import(mdsc, inode, h, session,
2671 snaptrace, le32_to_cpu(h->snap_trace_len)); 2677 snaptrace, le32_to_cpu(h->snap_trace_len));
2672 check_caps = 1; /* we may have sent a RELEASE to the old auth */ 2678 ceph_check_caps(ceph_inode(inode), CHECK_CAPS_NODELAY,
2673 goto done; 2679 session);
2680 goto done_unlocked;
2674 } 2681 }
2675 2682
2676 /* the rest require a cap */ 2683 /* the rest require a cap */
@@ -2687,19 +2694,8 @@ void ceph_handle_caps(struct ceph_mds_session *session,
2687 switch (op) { 2694 switch (op) {
2688 case CEPH_CAP_OP_REVOKE: 2695 case CEPH_CAP_OP_REVOKE:
2689 case CEPH_CAP_OP_GRANT: 2696 case CEPH_CAP_OP_GRANT:
2690 r = handle_cap_grant(inode, h, session, cap, msg->middle); 2697 handle_cap_grant(inode, h, session, cap, msg->middle);
2691 if (r == 1) { 2698 goto done_unlocked;
2692 ceph_check_caps(ceph_inode(inode),
2693 CHECK_CAPS_NODELAY|CHECK_CAPS_AUTHONLY,
2694 session);
2695 session = NULL;
2696 } else if (r == 2) {
2697 ceph_check_caps(ceph_inode(inode),
2698 CHECK_CAPS_NODELAY,
2699 session);
2700 session = NULL;
2701 }
2702 break;
2703 2699
2704 case CEPH_CAP_OP_FLUSH_ACK: 2700 case CEPH_CAP_OP_FLUSH_ACK:
2705 handle_cap_flush_ack(inode, tid, h, session, cap); 2701 handle_cap_flush_ack(inode, tid, h, session, cap);
@@ -2716,11 +2712,8 @@ void ceph_handle_caps(struct ceph_mds_session *session,
2716 } 2712 }
2717 2713
2718done: 2714done:
2719 if (session) 2715 mutex_unlock(&session->s_mutex);
2720 mutex_unlock(&session->s_mutex); 2716done_unlocked:
2721
2722 if (check_caps)
2723 ceph_check_caps(ceph_inode(inode), CHECK_CAPS_NODELAY, NULL);
2724 if (inode) 2717 if (inode)
2725 iput(inode); 2718 iput(inode);
2726 return; 2719 return;