diff options
author | Sage Weil <sage@newdream.net> | 2009-12-22 13:45:45 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-12-23 11:17:20 -0500 |
commit | 350b1c32ea58d29e25d63fc25e92dd48f9339546 (patch) | |
tree | 4b9e8b06de8fd7e07c2292307e9a67c121f1e079 /fs/ceph/messenger.c | |
parent | ec302645f4a9bd9ec757c30d185557e1c0972c1a (diff) |
ceph: control access to page vector for incoming data
When we issue an OSD read, we specify a vector of pages that the data is to
be read into. The request may be sent multiple times, to multiple OSDs, if
the osdmap changes, which means we can get more than one reply.
Only read data into the page vector if the reply is coming from the
OSD we last sent the request to. Keep track of which connection is using
the vector by taking a reference. If another connection was already
using the vector before and a new reply comes in on the right connection,
revoke the pages from the other connection.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/messenger.c')
-rw-r--r-- | fs/ceph/messenger.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c index c03b4185c143..506b638a023b 100644 --- a/fs/ceph/messenger.c +++ b/fs/ceph/messenger.c | |||
@@ -1976,6 +1976,35 @@ void ceph_con_revoke(struct ceph_connection *con, struct ceph_msg *msg) | |||
1976 | } | 1976 | } |
1977 | 1977 | ||
1978 | /* | 1978 | /* |
1979 | * Revoke a page vector that we may be reading data into | ||
1980 | */ | ||
1981 | void ceph_con_revoke_pages(struct ceph_connection *con, struct page **pages) | ||
1982 | { | ||
1983 | mutex_lock(&con->mutex); | ||
1984 | if (con->in_msg && con->in_msg->pages == pages) { | ||
1985 | unsigned data_len = le32_to_cpu(con->in_hdr.data_len); | ||
1986 | |||
1987 | /* skip rest of message */ | ||
1988 | dout("con_revoke_pages %p msg %p pages %p revoked\n", con, | ||
1989 | con->in_msg, pages); | ||
1990 | if (con->in_msg_pos.data_pos < data_len) | ||
1991 | con->in_base_pos = con->in_msg_pos.data_pos - data_len; | ||
1992 | else | ||
1993 | con->in_base_pos = con->in_base_pos - | ||
1994 | sizeof(struct ceph_msg_header) - | ||
1995 | sizeof(struct ceph_msg_footer); | ||
1996 | con->in_msg->pages = NULL; | ||
1997 | ceph_msg_put(con->in_msg); | ||
1998 | con->in_msg = NULL; | ||
1999 | con->in_tag = CEPH_MSGR_TAG_READY; | ||
2000 | } else { | ||
2001 | dout("con_revoke_pages %p msg %p pages %p no-op\n", | ||
2002 | con, con->in_msg, pages); | ||
2003 | } | ||
2004 | mutex_unlock(&con->mutex); | ||
2005 | } | ||
2006 | |||
2007 | /* | ||
1979 | * Queue a keepalive byte to ensure the tcp connection is alive. | 2008 | * Queue a keepalive byte to ensure the tcp connection is alive. |
1980 | */ | 2009 | */ |
1981 | void ceph_con_keepalive(struct ceph_connection *con) | 2010 | void ceph_con_keepalive(struct ceph_connection *con) |