diff options
author | Sage Weil <sage@newdream.net> | 2010-04-28 16:51:50 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-05-17 18:25:25 -0400 |
commit | 9dd4658db1be5ca92c2ed2fd7a100d973125d9c5 (patch) | |
tree | 0f9e2b9d0b6edd9c37a5f6528a1c7c60fb10a902 /fs/ceph | |
parent | 4f48280ee1d0654390cd50ad0c41ea93309e7c91 (diff) |
ceph: close messenger race
Simplify messenger locking, and close race between ceph_con_close() setting
the CLOSED bit and con_work() checking the bit, then taking the mutex.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/messenger.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c index 8cfca375c6a9..bb16edb1aef6 100644 --- a/fs/ceph/messenger.c +++ b/fs/ceph/messenger.c | |||
@@ -1546,7 +1546,6 @@ static int try_write(struct ceph_connection *con) | |||
1546 | dout("try_write start %p state %lu nref %d\n", con, con->state, | 1546 | dout("try_write start %p state %lu nref %d\n", con, con->state, |
1547 | atomic_read(&con->nref)); | 1547 | atomic_read(&con->nref)); |
1548 | 1548 | ||
1549 | mutex_lock(&con->mutex); | ||
1550 | more: | 1549 | more: |
1551 | dout("try_write out_kvec_bytes %d\n", con->out_kvec_bytes); | 1550 | dout("try_write out_kvec_bytes %d\n", con->out_kvec_bytes); |
1552 | 1551 | ||
@@ -1639,7 +1638,6 @@ do_next: | |||
1639 | done: | 1638 | done: |
1640 | ret = 0; | 1639 | ret = 0; |
1641 | out: | 1640 | out: |
1642 | mutex_unlock(&con->mutex); | ||
1643 | dout("try_write done on %p\n", con); | 1641 | dout("try_write done on %p\n", con); |
1644 | return ret; | 1642 | return ret; |
1645 | } | 1643 | } |
@@ -1651,7 +1649,6 @@ out: | |||
1651 | */ | 1649 | */ |
1652 | static int try_read(struct ceph_connection *con) | 1650 | static int try_read(struct ceph_connection *con) |
1653 | { | 1651 | { |
1654 | struct ceph_messenger *msgr; | ||
1655 | int ret = -1; | 1652 | int ret = -1; |
1656 | 1653 | ||
1657 | if (!con->sock) | 1654 | if (!con->sock) |
@@ -1661,9 +1658,6 @@ static int try_read(struct ceph_connection *con) | |||
1661 | return 0; | 1658 | return 0; |
1662 | 1659 | ||
1663 | dout("try_read start on %p\n", con); | 1660 | dout("try_read start on %p\n", con); |
1664 | msgr = con->msgr; | ||
1665 | |||
1666 | mutex_lock(&con->mutex); | ||
1667 | 1661 | ||
1668 | more: | 1662 | more: |
1669 | dout("try_read tag %d in_base_pos %d\n", (int)con->in_tag, | 1663 | dout("try_read tag %d in_base_pos %d\n", (int)con->in_tag, |
@@ -1758,7 +1752,6 @@ more: | |||
1758 | done: | 1752 | done: |
1759 | ret = 0; | 1753 | ret = 0; |
1760 | out: | 1754 | out: |
1761 | mutex_unlock(&con->mutex); | ||
1762 | dout("try_read done on %p\n", con); | 1755 | dout("try_read done on %p\n", con); |
1763 | return ret; | 1756 | return ret; |
1764 | 1757 | ||
@@ -1830,6 +1823,8 @@ more: | |||
1830 | dout("con_work %p start, clearing QUEUED\n", con); | 1823 | dout("con_work %p start, clearing QUEUED\n", con); |
1831 | clear_bit(QUEUED, &con->state); | 1824 | clear_bit(QUEUED, &con->state); |
1832 | 1825 | ||
1826 | mutex_lock(&con->mutex); | ||
1827 | |||
1833 | if (test_bit(CLOSED, &con->state)) { /* e.g. if we are replaced */ | 1828 | if (test_bit(CLOSED, &con->state)) { /* e.g. if we are replaced */ |
1834 | dout("con_work CLOSED\n"); | 1829 | dout("con_work CLOSED\n"); |
1835 | con_close_socket(con); | 1830 | con_close_socket(con); |
@@ -1844,11 +1839,16 @@ more: | |||
1844 | if (test_and_clear_bit(SOCK_CLOSED, &con->state) || | 1839 | if (test_and_clear_bit(SOCK_CLOSED, &con->state) || |
1845 | try_read(con) < 0 || | 1840 | try_read(con) < 0 || |
1846 | try_write(con) < 0) { | 1841 | try_write(con) < 0) { |
1842 | mutex_unlock(&con->mutex); | ||
1847 | backoff = 1; | 1843 | backoff = 1; |
1848 | ceph_fault(con); /* error/fault path */ | 1844 | ceph_fault(con); /* error/fault path */ |
1845 | goto done_unlocked; | ||
1849 | } | 1846 | } |
1850 | 1847 | ||
1851 | done: | 1848 | done: |
1849 | mutex_unlock(&con->mutex); | ||
1850 | |||
1851 | done_unlocked: | ||
1852 | clear_bit(BUSY, &con->state); | 1852 | clear_bit(BUSY, &con->state); |
1853 | dout("con->state=%lu\n", con->state); | 1853 | dout("con->state=%lu\n", con->state); |
1854 | if (test_bit(QUEUED, &con->state)) { | 1854 | if (test_bit(QUEUED, &con->state)) { |