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