{
        struct inode *inode = file_inode(dst->fl_file);
        atomic_inc(&ceph_inode(inode)->i_filelock_ref);
+       dst->fl_u.ceph.inode = igrab(inode);
 }
 
+/*
+ * Do not use the 'fl->fl_file' in release function, which
+ * is possibly already released by another thread.
+ */
 static void ceph_fl_release_lock(struct file_lock *fl)
 {
-       struct inode *inode = file_inode(fl->fl_file);
-       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct inode *inode = fl->fl_u.ceph.inode;
+       struct ceph_inode_info *ci;
+
+       /*
+        * If inode is NULL it should be a request file_lock,
+        * nothing we can do.
+        */
+       if (!inode)
+               return;
+
+       ci = ceph_inode(inode);
        if (atomic_dec_and_test(&ci->i_filelock_ref)) {
                /* clear error when all locks are released */
                spin_lock(&ci->i_ceph_lock);
                ci->i_ceph_flags &= ~CEPH_I_ERROR_FILELOCK;
                spin_unlock(&ci->i_ceph_lock);
        }
+       fl->fl_u.ceph.inode = NULL;
+       iput(inode);
 }
 
 static const struct file_lock_operations ceph_fl_lock_ops = {