Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client:
ceph: keep reference to parent inode on ceph_dentry
ceph: queue cap_snaps once per realm
libceph: fix socket write error handling
libceph: fix socket read error handling

+46 -36
+4 -1
fs/ceph/dir.c
··· 60 } 61 di->dentry = dentry; 62 di->lease_session = NULL; 63 dentry->d_fsdata = di; 64 dentry->d_time = jiffies; 65 ceph_dentry_lru_add(dentry); ··· 1034 u64 snapid = CEPH_NOSNAP; 1035 1036 if (!IS_ROOT(dentry)) { 1037 - parent_inode = dentry->d_parent->d_inode; 1038 if (parent_inode) 1039 snapid = ceph_snap(parent_inode); 1040 } ··· 1059 kmem_cache_free(ceph_dentry_cachep, di); 1060 dentry->d_fsdata = NULL; 1061 } 1062 } 1063 1064 static int ceph_snapdir_d_revalidate(struct dentry *dentry,
··· 60 } 61 di->dentry = dentry; 62 di->lease_session = NULL; 63 + di->parent_inode = igrab(dentry->d_parent->d_inode); 64 dentry->d_fsdata = di; 65 dentry->d_time = jiffies; 66 ceph_dentry_lru_add(dentry); ··· 1033 u64 snapid = CEPH_NOSNAP; 1034 1035 if (!IS_ROOT(dentry)) { 1036 + parent_inode = di->parent_inode; 1037 if (parent_inode) 1038 snapid = ceph_snap(parent_inode); 1039 } ··· 1058 kmem_cache_free(ceph_dentry_cachep, di); 1059 dentry->d_fsdata = NULL; 1060 } 1061 + if (parent_inode) 1062 + iput(parent_inode); 1063 } 1064 1065 static int ceph_snapdir_d_revalidate(struct dentry *dentry,
+10 -4
fs/ceph/snap.c
··· 584 if (lastinode) 585 iput(lastinode); 586 587 - dout("queue_realm_cap_snaps %p %llx children\n", realm, realm->ino); 588 - list_for_each_entry(child, &realm->children, child_item) 589 - queue_realm_cap_snaps(child); 590 591 dout("queue_realm_cap_snaps %p %llx done\n", realm, realm->ino); 592 } 593 ··· 687 * queue cap snaps _after_ we've built the new snap contexts, 688 * so that i_head_snapc can be set appropriately. 689 */ 690 - list_for_each_entry(realm, &dirty_realms, dirty_item) { 691 queue_realm_cap_snaps(realm); 692 } 693
··· 584 if (lastinode) 585 iput(lastinode); 586 587 + list_for_each_entry(child, &realm->children, child_item) { 588 + dout("queue_realm_cap_snaps %p %llx queue child %p %llx\n", 589 + realm, realm->ino, child, child->ino); 590 + list_del_init(&child->dirty_item); 591 + list_add(&child->dirty_item, &realm->dirty_item); 592 + } 593 594 + list_del_init(&realm->dirty_item); 595 dout("queue_realm_cap_snaps %p %llx done\n", realm, realm->ino); 596 } 597 ··· 683 * queue cap snaps _after_ we've built the new snap contexts, 684 * so that i_head_snapc can be set appropriately. 685 */ 686 + while (!list_empty(&dirty_realms)) { 687 + realm = list_first_entry(&dirty_realms, struct ceph_snap_realm, 688 + dirty_item); 689 queue_realm_cap_snaps(realm); 690 } 691
+1
fs/ceph/super.h
··· 207 struct dentry *dentry; 208 u64 time; 209 u64 offset; 210 }; 211 212 struct ceph_inode_xattrs_info {
··· 207 struct dentry *dentry; 208 u64 time; 209 u64 offset; 210 + struct inode *parent_inode; 211 }; 212 213 struct ceph_inode_xattrs_info {
+31 -31
net/ceph/messenger.c
··· 252 { 253 struct kvec iov = {buf, len}; 254 struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL }; 255 256 - return kernel_recvmsg(sock, &msg, &iov, 1, len, msg.msg_flags); 257 } 258 259 /* ··· 268 size_t kvlen, size_t len, int more) 269 { 270 struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL }; 271 272 if (more) 273 msg.msg_flags |= MSG_MORE; 274 else 275 msg.msg_flags |= MSG_EOR; /* superfluous, but what the hell */ 276 277 - return kernel_sendmsg(sock, &msg, iov, kvlen, len); 278 } 279 280 ··· 855 (msg->pages || msg->pagelist || msg->bio || in_trail)) 856 kunmap(page); 857 858 if (ret <= 0) 859 goto out; 860 ··· 1747 if (con->out_skip) { 1748 ret = write_partial_skip(con); 1749 if (ret <= 0) 1750 - goto done; 1751 - if (ret < 0) { 1752 - dout("try_write write_partial_skip err %d\n", ret); 1753 - goto done; 1754 - } 1755 } 1756 if (con->out_kvec_left) { 1757 ret = write_partial_kvec(con); 1758 if (ret <= 0) 1759 - goto done; 1760 } 1761 1762 /* msg pages? */ ··· 1767 if (ret == 1) 1768 goto more_kvec; /* we need to send the footer, too! */ 1769 if (ret == 0) 1770 - goto done; 1771 if (ret < 0) { 1772 dout("try_write write_partial_msg_pages err %d\n", 1773 ret); 1774 - goto done; 1775 } 1776 } 1777 ··· 1795 /* Nothing to do! */ 1796 clear_bit(WRITE_PENDING, &con->state); 1797 dout("try_write nothing else to write.\n"); 1798 - done: 1799 ret = 0; 1800 out: 1801 - dout("try_write done on %p\n", con); 1802 return ret; 1803 } 1804 ··· 1826 dout("try_read connecting\n"); 1827 ret = read_partial_banner(con); 1828 if (ret <= 0) 1829 - goto done; 1830 - if (process_banner(con) < 0) { 1831 - ret = -1; 1832 goto out; 1833 - } 1834 } 1835 ret = read_partial_connect(con); 1836 if (ret <= 0) 1837 - goto done; 1838 - if (process_connect(con) < 0) { 1839 - ret = -1; 1840 goto out; 1841 - } 1842 goto more; 1843 } 1844 ··· 1851 dout("skipping %d / %d bytes\n", skip, -con->in_base_pos); 1852 ret = ceph_tcp_recvmsg(con->sock, buf, skip); 1853 if (ret <= 0) 1854 - goto done; 1855 con->in_base_pos += ret; 1856 if (con->in_base_pos) 1857 goto more; ··· 1862 */ 1863 ret = ceph_tcp_recvmsg(con->sock, &con->in_tag, 1); 1864 if (ret <= 0) 1865 - goto done; 1866 dout("try_read got tag %d\n", (int)con->in_tag); 1867 switch (con->in_tag) { 1868 case CEPH_MSGR_TAG_MSG: ··· 1873 break; 1874 case CEPH_MSGR_TAG_CLOSE: 1875 set_bit(CLOSED, &con->state); /* fixme */ 1876 - goto done; 1877 default: 1878 goto bad_tag; 1879 } ··· 1885 case -EBADMSG: 1886 con->error_msg = "bad crc"; 1887 ret = -EIO; 1888 - goto out; 1889 case -EIO: 1890 con->error_msg = "io error"; 1891 - goto out; 1892 - default: 1893 - goto done; 1894 } 1895 } 1896 if (con->in_tag == CEPH_MSGR_TAG_READY) 1897 goto more; ··· 1900 if (con->in_tag == CEPH_MSGR_TAG_ACK) { 1901 ret = read_partial_ack(con); 1902 if (ret <= 0) 1903 - goto done; 1904 process_ack(con); 1905 goto more; 1906 } 1907 1908 - done: 1909 - ret = 0; 1910 out: 1911 - dout("try_read done on %p\n", con); 1912 return ret; 1913 1914 bad_tag:
··· 252 { 253 struct kvec iov = {buf, len}; 254 struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL }; 255 + int r; 256 257 + r = kernel_recvmsg(sock, &msg, &iov, 1, len, msg.msg_flags); 258 + if (r == -EAGAIN) 259 + r = 0; 260 + return r; 261 } 262 263 /* ··· 264 size_t kvlen, size_t len, int more) 265 { 266 struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL }; 267 + int r; 268 269 if (more) 270 msg.msg_flags |= MSG_MORE; 271 else 272 msg.msg_flags |= MSG_EOR; /* superfluous, but what the hell */ 273 274 + r = kernel_sendmsg(sock, &msg, iov, kvlen, len); 275 + if (r == -EAGAIN) 276 + r = 0; 277 + return r; 278 } 279 280 ··· 847 (msg->pages || msg->pagelist || msg->bio || in_trail)) 848 kunmap(page); 849 850 + if (ret == -EAGAIN) 851 + ret = 0; 852 if (ret <= 0) 853 goto out; 854 ··· 1737 if (con->out_skip) { 1738 ret = write_partial_skip(con); 1739 if (ret <= 0) 1740 + goto out; 1741 } 1742 if (con->out_kvec_left) { 1743 ret = write_partial_kvec(con); 1744 if (ret <= 0) 1745 + goto out; 1746 } 1747 1748 /* msg pages? */ ··· 1761 if (ret == 1) 1762 goto more_kvec; /* we need to send the footer, too! */ 1763 if (ret == 0) 1764 + goto out; 1765 if (ret < 0) { 1766 dout("try_write write_partial_msg_pages err %d\n", 1767 ret); 1768 + goto out; 1769 } 1770 } 1771 ··· 1789 /* Nothing to do! */ 1790 clear_bit(WRITE_PENDING, &con->state); 1791 dout("try_write nothing else to write.\n"); 1792 ret = 0; 1793 out: 1794 + dout("try_write done on %p ret %d\n", con, ret); 1795 return ret; 1796 } 1797 ··· 1821 dout("try_read connecting\n"); 1822 ret = read_partial_banner(con); 1823 if (ret <= 0) 1824 goto out; 1825 + ret = process_banner(con); 1826 + if (ret < 0) 1827 + goto out; 1828 } 1829 ret = read_partial_connect(con); 1830 if (ret <= 0) 1831 goto out; 1832 + ret = process_connect(con); 1833 + if (ret < 0) 1834 + goto out; 1835 goto more; 1836 } 1837 ··· 1848 dout("skipping %d / %d bytes\n", skip, -con->in_base_pos); 1849 ret = ceph_tcp_recvmsg(con->sock, buf, skip); 1850 if (ret <= 0) 1851 + goto out; 1852 con->in_base_pos += ret; 1853 if (con->in_base_pos) 1854 goto more; ··· 1859 */ 1860 ret = ceph_tcp_recvmsg(con->sock, &con->in_tag, 1); 1861 if (ret <= 0) 1862 + goto out; 1863 dout("try_read got tag %d\n", (int)con->in_tag); 1864 switch (con->in_tag) { 1865 case CEPH_MSGR_TAG_MSG: ··· 1870 break; 1871 case CEPH_MSGR_TAG_CLOSE: 1872 set_bit(CLOSED, &con->state); /* fixme */ 1873 + goto out; 1874 default: 1875 goto bad_tag; 1876 } ··· 1882 case -EBADMSG: 1883 con->error_msg = "bad crc"; 1884 ret = -EIO; 1885 + break; 1886 case -EIO: 1887 con->error_msg = "io error"; 1888 + break; 1889 } 1890 + goto out; 1891 } 1892 if (con->in_tag == CEPH_MSGR_TAG_READY) 1893 goto more; ··· 1898 if (con->in_tag == CEPH_MSGR_TAG_ACK) { 1899 ret = read_partial_ack(con); 1900 if (ret <= 0) 1901 + goto out; 1902 process_ack(con); 1903 goto more; 1904 } 1905 1906 out: 1907 + dout("try_read done on %p ret %d\n", con, ret); 1908 return ret; 1909 1910 bad_tag: