提交 84495f49 编写于 作者: A Alex Elder

libceph: some simple changes

Nothing too big here.
    - define the size of the buffer used for consuming ignored
      incoming data using a symbolic constant
    - simplify the condition determining whether to unmap the page
      in write_partial_msg_pages(): do it for crc but not if the
      page is the zero page
Signed-off-by: NAlex Elder <elder@dreamhost.com>
Signed-off-by: NSage Weil <sage@newdream.net>
上级 f42299e6
...@@ -38,6 +38,11 @@ static char tag_keepalive = CEPH_MSGR_TAG_KEEPALIVE; ...@@ -38,6 +38,11 @@ static char tag_keepalive = CEPH_MSGR_TAG_KEEPALIVE;
static struct lock_class_key socket_class; static struct lock_class_key socket_class;
#endif #endif
/*
* When skipping (ignoring) a block of input we read it into a "skip
* buffer," which is this many bytes in size.
*/
#define SKIP_BUF_SIZE 1024
static void queue_con(struct ceph_connection *con); static void queue_con(struct ceph_connection *con);
static void con_work(struct work_struct *); static void con_work(struct work_struct *);
...@@ -892,8 +897,7 @@ static int write_partial_msg_pages(struct ceph_connection *con) ...@@ -892,8 +897,7 @@ static int write_partial_msg_pages(struct ceph_connection *con)
MSG_DONTWAIT | MSG_NOSIGNAL | MSG_DONTWAIT | MSG_NOSIGNAL |
MSG_MORE); MSG_MORE);
if (do_crc && if (do_crc && kaddr != zero_page_address)
(msg->pages || msg->pagelist || msg->bio || in_trail))
kunmap(page); kunmap(page);
if (ret == -EAGAIN) if (ret == -EAGAIN)
...@@ -1982,8 +1986,9 @@ static int try_read(struct ceph_connection *con) ...@@ -1982,8 +1986,9 @@ static int try_read(struct ceph_connection *con)
* *
* FIXME: there must be a better way to do this! * FIXME: there must be a better way to do this!
*/ */
static char buf[1024]; static char buf[SKIP_BUF_SIZE];
int skip = min(1024, -con->in_base_pos); int skip = min((int) sizeof (buf), -con->in_base_pos);
dout("skipping %d / %d bytes\n", skip, -con->in_base_pos); dout("skipping %d / %d bytes\n", skip, -con->in_base_pos);
ret = ceph_tcp_recvmsg(con->sock, buf, skip); ret = ceph_tcp_recvmsg(con->sock, buf, skip);
if (ret <= 0) if (ret <= 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册