static void prepare_write_message_data(struct ceph_connection *con)
{
struct ceph_msg *msg = con->out_msg;
+ struct ceph_msg_pos *msg_pos = &con->out_msg_pos;
BUG_ON(!msg);
BUG_ON(!msg->hdr.data_len);
/* initialize page iterator */
- con->out_msg_pos.page = 0;
+ msg_pos->page = 0;
if (msg->pages)
- con->out_msg_pos.page_pos = msg->page_alignment;
+ msg_pos->page_pos = msg->page_alignment;
else
- con->out_msg_pos.page_pos = 0;
+ msg_pos->page_pos = 0;
#ifdef CONFIG_BLOCK
if (msg->bio)
init_bio_iter(msg->bio, &msg->bio_iter, &msg->bio_seg);
#endif
- con->out_msg_pos.data_pos = 0;
- con->out_msg_pos.did_page_crc = false;
+ msg_pos->data_pos = 0;
+ msg_pos->did_page_crc = false;
con->out_more = 1; /* data + footer will follow */
}
size_t len, size_t sent, bool in_trail)
{
struct ceph_msg *msg = con->out_msg;
+ struct ceph_msg_pos *msg_pos = &con->out_msg_pos;
BUG_ON(!msg);
BUG_ON(!sent);
- con->out_msg_pos.data_pos += sent;
- con->out_msg_pos.page_pos += sent;
+ msg_pos->data_pos += sent;
+ msg_pos->page_pos += sent;
if (sent < len)
return;
BUG_ON(sent != len);
- con->out_msg_pos.page_pos = 0;
- con->out_msg_pos.page++;
- con->out_msg_pos.did_page_crc = false;
+ msg_pos->page_pos = 0;
+ msg_pos->page++;
+ msg_pos->did_page_crc = false;
if (in_trail)
list_rotate_left(&msg->trail->head);
else if (msg->pagelist)
size_t received)
{
struct ceph_msg *msg = con->in_msg;
+ struct ceph_msg_pos *msg_pos = &con->in_msg_pos;
BUG_ON(!msg);
BUG_ON(!received);
- con->in_msg_pos.data_pos += received;
- con->in_msg_pos.page_pos += received;
+ msg_pos->data_pos += received;
+ msg_pos->page_pos += received;
if (received < len)
return;
BUG_ON(received != len);
- con->in_msg_pos.page_pos = 0;
- con->in_msg_pos.page++;
+ msg_pos->page_pos = 0;
+ msg_pos->page++;
#ifdef CONFIG_BLOCK
if (msg->bio)
iter_bio_next(&msg->bio_iter, &msg->bio_seg);
static int write_partial_msg_pages(struct ceph_connection *con)
{
struct ceph_msg *msg = con->out_msg;
+ struct ceph_msg_pos *msg_pos = &con->out_msg_pos;
unsigned int data_len = le32_to_cpu(msg->hdr.data_len);
size_t len;
bool do_datacrc = !con->msgr->nocrc;
const size_t trail_off = data_len - trail_len;
dout("write_partial_msg_pages %p msg %p page %d offset %d\n",
- con, msg, con->out_msg_pos.page, con->out_msg_pos.page_pos);
+ con, msg, msg_pos->page, msg_pos->page_pos);
/*
* Iterate through each page that contains data to be
* need to map the page. If we have no pages, they have
* been revoked, so use the zero page.
*/
- while (data_len > con->out_msg_pos.data_pos) {
+ while (data_len > msg_pos->data_pos) {
struct page *page = NULL;
int max_write = PAGE_SIZE;
int bio_offset = 0;
- in_trail = in_trail || con->out_msg_pos.data_pos >= trail_off;
+ in_trail = in_trail || msg_pos->data_pos >= trail_off;
if (!in_trail)
- total_max_write = trail_off - con->out_msg_pos.data_pos;
+ total_max_write = trail_off - msg_pos->data_pos;
if (in_trail) {
- total_max_write = data_len - con->out_msg_pos.data_pos;
+ total_max_write = data_len - msg_pos->data_pos;
page = list_first_entry(&msg->trail->head,
struct page, lru);
} else if (msg->pages) {
- page = msg->pages[con->out_msg_pos.page];
+ page = msg->pages[msg_pos->page];
} else if (msg->pagelist) {
page = list_first_entry(&msg->pagelist->head,
struct page, lru);
} else {
page = zero_page;
}
- len = min_t(int, max_write - con->out_msg_pos.page_pos,
+ len = min_t(int, max_write - msg_pos->page_pos,
total_max_write);
- if (do_datacrc && !con->out_msg_pos.did_page_crc) {
+ if (do_datacrc && !msg_pos->did_page_crc) {
void *base;
u32 crc = le32_to_cpu(msg->footer.data_crc);
char *kaddr;
kaddr = kmap(page);
BUG_ON(kaddr == NULL);
- base = kaddr + con->out_msg_pos.page_pos + bio_offset;
+ base = kaddr + msg_pos->page_pos + bio_offset;
crc = crc32c(crc, base, len);
kunmap(page);
msg->footer.data_crc = cpu_to_le32(crc);
- con->out_msg_pos.did_page_crc = true;
+ msg_pos->did_page_crc = true;
}
ret = ceph_tcp_sendpage(con->sock, page,
- con->out_msg_pos.page_pos + bio_offset,
+ msg_pos->page_pos + bio_offset,
len, true);
if (ret <= 0)
goto out;
struct page **pages,
unsigned int data_len, bool do_datacrc)
{
+ struct ceph_msg_pos *msg_pos = &con->in_msg_pos;
struct page *page;
void *p;
int ret;
int left;
- left = min((int)(data_len - con->in_msg_pos.data_pos),
- (int)(PAGE_SIZE - con->in_msg_pos.page_pos));
+ left = min((int)(data_len - msg_pos->data_pos),
+ (int)(PAGE_SIZE - msg_pos->page_pos));
/* (page) data */
BUG_ON(pages == NULL);
- page = pages[con->in_msg_pos.page];
+ page = pages[msg_pos->page];
p = kmap(page);
- ret = ceph_tcp_recvmsg(con->sock, p + con->in_msg_pos.page_pos, left);
+ ret = ceph_tcp_recvmsg(con->sock, p + msg_pos->page_pos, left);
if (ret > 0 && do_datacrc)
con->in_data_crc =
crc32c(con->in_data_crc,
- p + con->in_msg_pos.page_pos, ret);
+ p + msg_pos->page_pos, ret);
kunmap(page);
if (ret <= 0)
return ret;
unsigned int data_len, bool do_datacrc)
{
struct ceph_msg *msg = con->in_msg;
+ struct ceph_msg_pos *msg_pos = &con->in_msg_pos;
struct bio_vec *bv;
struct page *page;
void *p;
BUG_ON(!msg->bio_iter);
bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg);
- left = min((int)(data_len - con->in_msg_pos.data_pos),
- (int)(bv->bv_len - con->in_msg_pos.page_pos));
+ left = min((int)(data_len - msg_pos->data_pos),
+ (int)(bv->bv_len - msg_pos->page_pos));
page = bv->bv_page;
p = kmap(page) + bv->bv_offset;
- ret = ceph_tcp_recvmsg(con->sock, p + con->in_msg_pos.page_pos, left);
+ ret = ceph_tcp_recvmsg(con->sock, p + msg_pos->page_pos, left);
if (ret > 0 && do_datacrc)
con->in_data_crc =
crc32c(con->in_data_crc,
- p + con->in_msg_pos.page_pos, ret);
+ p + msg_pos->page_pos, ret);
kunmap(page);
if (ret <= 0)
return ret;
static int read_partial_message(struct ceph_connection *con)
{
struct ceph_msg *m = con->in_msg;
+ struct ceph_msg_pos *msg_pos = &con->in_msg_pos;
int size;
int end;
int ret;
if (m->middle)
m->middle->vec.iov_len = 0;
- con->in_msg_pos.page = 0;
+ msg_pos->page = 0;
if (m->pages)
- con->in_msg_pos.page_pos = m->page_alignment;
+ msg_pos->page_pos = m->page_alignment;
else
- con->in_msg_pos.page_pos = 0;
- con->in_msg_pos.data_pos = 0;
+ msg_pos->page_pos = 0;
+ msg_pos->data_pos = 0;
#ifdef CONFIG_BLOCK
if (m->bio)
}
/* (page) data */
- while (con->in_msg_pos.data_pos < data_len) {
+ while (msg_pos->data_pos < data_len) {
if (m->pages) {
ret = read_partial_message_pages(con, m->pages,
data_len, do_datacrc);