aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ceph/inode.c')
-rw-r--r--fs/ceph/inode.c70
1 files changed, 39 insertions, 31 deletions
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index f9e7399877d6..8ad50a30808e 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -341,7 +341,6 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
341 INIT_LIST_HEAD(&ci->i_cap_snaps); 341 INIT_LIST_HEAD(&ci->i_cap_snaps);
342 ci->i_head_snapc = NULL; 342 ci->i_head_snapc = NULL;
343 ci->i_snap_caps = 0; 343 ci->i_snap_caps = 0;
344 ci->i_cap_exporting_issued = 0;
345 344
346 for (i = 0; i < CEPH_FILE_MODE_NUM; i++) 345 for (i = 0; i < CEPH_FILE_MODE_NUM; i++)
347 ci->i_nr_by_mode[i] = 0; 346 ci->i_nr_by_mode[i] = 0;
@@ -407,7 +406,7 @@ void ceph_destroy_inode(struct inode *inode)
407 406
408 /* 407 /*
409 * we may still have a snap_realm reference if there are stray 408 * we may still have a snap_realm reference if there are stray
410 * caps in i_cap_exporting_issued or i_snap_caps. 409 * caps in i_snap_caps.
411 */ 410 */
412 if (ci->i_snap_realm) { 411 if (ci->i_snap_realm) {
413 struct ceph_mds_client *mdsc = 412 struct ceph_mds_client *mdsc =
@@ -582,6 +581,7 @@ static int fill_inode(struct inode *inode,
582 unsigned long ttl_from, int cap_fmode, 581 unsigned long ttl_from, int cap_fmode,
583 struct ceph_cap_reservation *caps_reservation) 582 struct ceph_cap_reservation *caps_reservation)
584{ 583{
584 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
585 struct ceph_mds_reply_inode *info = iinfo->in; 585 struct ceph_mds_reply_inode *info = iinfo->in;
586 struct ceph_inode_info *ci = ceph_inode(inode); 586 struct ceph_inode_info *ci = ceph_inode(inode);
587 int i; 587 int i;
@@ -591,7 +591,9 @@ static int fill_inode(struct inode *inode,
591 struct ceph_inode_frag *frag; 591 struct ceph_inode_frag *frag;
592 struct rb_node *rb_node; 592 struct rb_node *rb_node;
593 struct ceph_buffer *xattr_blob = NULL; 593 struct ceph_buffer *xattr_blob = NULL;
594 struct ceph_cap *new_cap = NULL;
594 int err = 0; 595 int err = 0;
596 bool wake = false;
595 bool queue_trunc = false; 597 bool queue_trunc = false;
596 bool new_version = false; 598 bool new_version = false;
597 599
@@ -599,6 +601,10 @@ static int fill_inode(struct inode *inode,
599 inode, ceph_vinop(inode), le64_to_cpu(info->version), 601 inode, ceph_vinop(inode), le64_to_cpu(info->version),
600 ci->i_version); 602 ci->i_version);
601 603
604 /* prealloc new cap struct */
605 if (info->cap.caps && ceph_snap(inode) == CEPH_NOSNAP)
606 new_cap = ceph_get_cap(mdsc, caps_reservation);
607
602 /* 608 /*
603 * prealloc xattr data, if it looks like we'll need it. only 609 * prealloc xattr data, if it looks like we'll need it. only
604 * if len > 4 (meaning there are actually xattrs; the first 4 610 * if len > 4 (meaning there are actually xattrs; the first 4
@@ -762,8 +768,37 @@ static int fill_inode(struct inode *inode,
762 dout(" marking %p complete (empty)\n", inode); 768 dout(" marking %p complete (empty)\n", inode);
763 __ceph_dir_set_complete(ci, atomic_read(&ci->i_release_count)); 769 __ceph_dir_set_complete(ci, atomic_read(&ci->i_release_count));
764 } 770 }
771
772 /* were we issued a capability? */
773 if (info->cap.caps) {
774 if (ceph_snap(inode) == CEPH_NOSNAP) {
775 ceph_add_cap(inode, session,
776 le64_to_cpu(info->cap.cap_id),
777 cap_fmode,
778 le32_to_cpu(info->cap.caps),
779 le32_to_cpu(info->cap.wanted),
780 le32_to_cpu(info->cap.seq),
781 le32_to_cpu(info->cap.mseq),
782 le64_to_cpu(info->cap.realm),
783 info->cap.flags, &new_cap);
784 wake = true;
785 } else {
786 dout(" %p got snap_caps %s\n", inode,
787 ceph_cap_string(le32_to_cpu(info->cap.caps)));
788 ci->i_snap_caps |= le32_to_cpu(info->cap.caps);
789 if (cap_fmode >= 0)
790 __ceph_get_fmode(ci, cap_fmode);
791 }
792 } else if (cap_fmode >= 0) {
793 pr_warning("mds issued no caps on %llx.%llx\n",
794 ceph_vinop(inode));
795 __ceph_get_fmode(ci, cap_fmode);
796 }
765 spin_unlock(&ci->i_ceph_lock); 797 spin_unlock(&ci->i_ceph_lock);
766 798
799 if (wake)
800 wake_up_all(&ci->i_cap_wq);
801
767 /* queue truncate if we saw i_size decrease */ 802 /* queue truncate if we saw i_size decrease */
768 if (queue_trunc) 803 if (queue_trunc)
769 ceph_queue_vmtruncate(inode); 804 ceph_queue_vmtruncate(inode);
@@ -806,41 +841,14 @@ static int fill_inode(struct inode *inode,
806 } 841 }
807 mutex_unlock(&ci->i_fragtree_mutex); 842 mutex_unlock(&ci->i_fragtree_mutex);
808 843
809 /* were we issued a capability? */
810 if (info->cap.caps) {
811 if (ceph_snap(inode) == CEPH_NOSNAP) {
812 ceph_add_cap(inode, session,
813 le64_to_cpu(info->cap.cap_id),
814 cap_fmode,
815 le32_to_cpu(info->cap.caps),
816 le32_to_cpu(info->cap.wanted),
817 le32_to_cpu(info->cap.seq),
818 le32_to_cpu(info->cap.mseq),
819 le64_to_cpu(info->cap.realm),
820 info->cap.flags,
821 caps_reservation);
822 } else {
823 spin_lock(&ci->i_ceph_lock);
824 dout(" %p got snap_caps %s\n", inode,
825 ceph_cap_string(le32_to_cpu(info->cap.caps)));
826 ci->i_snap_caps |= le32_to_cpu(info->cap.caps);
827 if (cap_fmode >= 0)
828 __ceph_get_fmode(ci, cap_fmode);
829 spin_unlock(&ci->i_ceph_lock);
830 }
831 } else if (cap_fmode >= 0) {
832 pr_warning("mds issued no caps on %llx.%llx\n",
833 ceph_vinop(inode));
834 __ceph_get_fmode(ci, cap_fmode);
835 }
836
837 /* update delegation info? */ 844 /* update delegation info? */
838 if (dirinfo) 845 if (dirinfo)
839 ceph_fill_dirfrag(inode, dirinfo); 846 ceph_fill_dirfrag(inode, dirinfo);
840 847
841 err = 0; 848 err = 0;
842
843out: 849out:
850 if (new_cap)
851 ceph_put_cap(mdsc, new_cap);
844 if (xattr_blob) 852 if (xattr_blob)
845 ceph_buffer_put(xattr_blob); 853 ceph_buffer_put(xattr_blob);
846 return err; 854 return err;