ceph: don't release i_ceph_lock in handle_cap_trunc
authorJeff Layton <jlayton@kernel.org>
Wed, 18 Mar 2020 20:43:30 +0000 (16:43 -0400)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 1 Jun 2020 11:22:52 +0000 (13:22 +0200)
There's no reason to do this here. Just have the caller handle it.
Also, add a lockdep assertion.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/caps.c

index 056ad0d..34aa9f4 100644 (file)
@@ -3631,10 +3631,9 @@ static void handle_cap_flushsnap_ack(struct inode *inode, u64 flush_tid,
  *
  * caller hold s_mutex.
  */
-static void handle_cap_trunc(struct inode *inode,
+static bool handle_cap_trunc(struct inode *inode,
                             struct ceph_mds_caps *trunc,
                             struct ceph_mds_session *session)
-       __releases(ci->i_ceph_lock)
 {
        struct ceph_inode_info *ci = ceph_inode(inode);
        int mds = session->s_mds;
@@ -3645,7 +3644,9 @@ static void handle_cap_trunc(struct inode *inode,
        int implemented = 0;
        int dirty = __ceph_caps_dirty(ci);
        int issued = __ceph_caps_issued(ceph_inode(inode), &implemented);
-       int queue_trunc = 0;
+       bool queue_trunc = false;
+
+       lockdep_assert_held(&ci->i_ceph_lock);
 
        issued |= implemented | dirty;
 
@@ -3653,10 +3654,7 @@ static void handle_cap_trunc(struct inode *inode,
             inode, mds, seq, truncate_size, truncate_seq);
        queue_trunc = ceph_fill_file_size(inode, issued,
                                          truncate_seq, truncate_size, size);
-       spin_unlock(&ci->i_ceph_lock);
-
-       if (queue_trunc)
-               ceph_queue_vmtruncate(inode);
+       return queue_trunc;
 }
 
 /*
@@ -3905,6 +3903,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
        size_t snaptrace_len;
        void *p, *end;
        struct cap_extra_info extra_info = {};
+       bool queue_trunc;
 
        dout("handle_caps from mds%d\n", session->s_mds);
 
@@ -4088,7 +4087,10 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                break;
 
        case CEPH_CAP_OP_TRUNC:
-               handle_cap_trunc(inode, h, session);
+               queue_trunc = handle_cap_trunc(inode, h, session);
+               spin_unlock(&ci->i_ceph_lock);
+               if (queue_trunc)
+                       ceph_queue_vmtruncate(inode);
                break;
 
        default: