info.c (da733563be5a9da26fe81d9f007262d00b846e22) info.c (6114eab535ab49239e0a6ce08eb9243664aef993)
1/*
2 * Copyright (c) 2006 Oracle. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:

--- 90 unchanged lines hidden (view full) ---

99/*
100 * Typically we hold an atomic kmap across multiple rds_info_copy() calls
101 * because the kmap is so expensive. This must be called before using blocking
102 * operations while holding the mapping and as the iterator is torn down.
103 */
104void rds_info_iter_unmap(struct rds_info_iterator *iter)
105{
106 if (iter->addr) {
1/*
2 * Copyright (c) 2006 Oracle. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:

--- 90 unchanged lines hidden (view full) ---

99/*
100 * Typically we hold an atomic kmap across multiple rds_info_copy() calls
101 * because the kmap is so expensive. This must be called before using blocking
102 * operations while holding the mapping and as the iterator is torn down.
103 */
104void rds_info_iter_unmap(struct rds_info_iterator *iter)
105{
106 if (iter->addr) {
107 kunmap_atomic(iter->addr, KM_USER0);
107 kunmap_atomic(iter->addr);
108 iter->addr = NULL;
109 }
110}
111
112/*
113 * get_user_pages() called flush_dcache_page() on the pages for us.
114 */
115void rds_info_copy(struct rds_info_iterator *iter, void *data,
116 unsigned long bytes)
117{
118 unsigned long this;
119
120 while (bytes) {
121 if (!iter->addr)
108 iter->addr = NULL;
109 }
110}
111
112/*
113 * get_user_pages() called flush_dcache_page() on the pages for us.
114 */
115void rds_info_copy(struct rds_info_iterator *iter, void *data,
116 unsigned long bytes)
117{
118 unsigned long this;
119
120 while (bytes) {
121 if (!iter->addr)
122 iter->addr = kmap_atomic(*iter->pages, KM_USER0);
122 iter->addr = kmap_atomic(*iter->pages);
123
124 this = min(bytes, PAGE_SIZE - iter->offset);
125
126 rdsdebug("page %p addr %p offset %lu this %lu data %p "
127 "bytes %lu\n", *iter->pages, iter->addr,
128 iter->offset, this, data, bytes);
129
130 memcpy(iter->addr + iter->offset, data, this);
131
132 data += this;
133 bytes -= this;
134 iter->offset += this;
135
136 if (iter->offset == PAGE_SIZE) {
123
124 this = min(bytes, PAGE_SIZE - iter->offset);
125
126 rdsdebug("page %p addr %p offset %lu this %lu data %p "
127 "bytes %lu\n", *iter->pages, iter->addr,
128 iter->offset, this, data, bytes);
129
130 memcpy(iter->addr + iter->offset, data, this);
131
132 data += this;
133 bytes -= this;
134 iter->offset += this;
135
136 if (iter->offset == PAGE_SIZE) {
137 kunmap_atomic(iter->addr, KM_USER0);
137 kunmap_atomic(iter->addr);
138 iter->addr = NULL;
139 iter->offset = 0;
140 iter->pages++;
141 }
142 }
143}
144EXPORT_SYMBOL_GPL(rds_info_copy);
145

--- 98 unchanged lines hidden ---
138 iter->addr = NULL;
139 iter->offset = 0;
140 iter->pages++;
141 }
142 }
143}
144EXPORT_SYMBOL_GPL(rds_info_copy);
145

--- 98 unchanged lines hidden ---