diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-10-15 16:14:41 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:03:56 -0400 |
commit | ae5252bd51a252b7b8b02289337c36774835101c (patch) | |
tree | 0c2a62c2b0cdc59ecf44bbd1f49a8ca570917450 /fs/btrfs | |
parent | 6d36dcd48f1e4e7446d603a3df9638bd314a182d (diff) |
Btrfs: Go back to kmaps instead of page_address in extent_buffers
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/extent_map.c | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c index d2c733c68b4c..f150188f621c 100644 --- a/fs/btrfs/extent_map.c +++ b/fs/btrfs/extent_map.c | |||
@@ -1867,7 +1867,6 @@ sector_t extent_bmap(struct address_space *mapping, sector_t iblock, | |||
1867 | if (!em || IS_ERR(em)) | 1867 | if (!em || IS_ERR(em)) |
1868 | return 0; | 1868 | return 0; |
1869 | 1869 | ||
1870 | // XXX(hch): block 0 is valid in some cases, e.g. XFS RT device | ||
1871 | if (em->block_start == EXTENT_MAP_INLINE || | 1870 | if (em->block_start == EXTENT_MAP_INLINE || |
1872 | em->block_start == EXTENT_MAP_HOLE) | 1871 | em->block_start == EXTENT_MAP_HOLE) |
1873 | return 0; | 1872 | return 0; |
@@ -2199,10 +2198,9 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv, | |||
2199 | WARN_ON(!PageUptodate(page)); | 2198 | WARN_ON(!PageUptodate(page)); |
2200 | 2199 | ||
2201 | cur = min(len, (PAGE_CACHE_SIZE - offset)); | 2200 | cur = min(len, (PAGE_CACHE_SIZE - offset)); |
2202 | // kaddr = kmap_atomic(page, KM_USER0); | 2201 | kaddr = kmap_atomic(page, KM_USER0); |
2203 | kaddr = page_address(page); | ||
2204 | memcpy(dst, kaddr + offset, cur); | 2202 | memcpy(dst, kaddr + offset, cur); |
2205 | // kunmap_atomic(kaddr, KM_USER0); | 2203 | kunmap_atomic(kaddr, KM_USER0); |
2206 | 2204 | ||
2207 | dst += cur; | 2205 | dst += cur; |
2208 | len -= cur; | 2206 | len -= cur; |
@@ -2237,8 +2235,7 @@ int map_extent_buffer(struct extent_buffer *eb, unsigned long start, | |||
2237 | *map_start = (i << PAGE_CACHE_SHIFT) - start_offset; | 2235 | *map_start = (i << PAGE_CACHE_SHIFT) - start_offset; |
2238 | } | 2236 | } |
2239 | 2237 | ||
2240 | // kaddr = kmap_atomic(eb->pages[i], km); | 2238 | kaddr = kmap_atomic(extent_buffer_page(eb, i), km); |
2241 | kaddr = page_address(extent_buffer_page(eb, i)); | ||
2242 | *token = kaddr; | 2239 | *token = kaddr; |
2243 | *map = kaddr + offset; | 2240 | *map = kaddr + offset; |
2244 | *map_len = PAGE_CACHE_SIZE - offset; | 2241 | *map_len = PAGE_CACHE_SIZE - offset; |
@@ -2248,7 +2245,7 @@ EXPORT_SYMBOL(map_extent_buffer); | |||
2248 | 2245 | ||
2249 | void unmap_extent_buffer(struct extent_buffer *eb, char *token, int km) | 2246 | void unmap_extent_buffer(struct extent_buffer *eb, char *token, int km) |
2250 | { | 2247 | { |
2251 | // kunmap_atomic(token, km); | 2248 | kunmap_atomic(token, km); |
2252 | } | 2249 | } |
2253 | EXPORT_SYMBOL(unmap_extent_buffer); | 2250 | EXPORT_SYMBOL(unmap_extent_buffer); |
2254 | 2251 | ||
@@ -2278,10 +2275,9 @@ int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv, | |||
2278 | 2275 | ||
2279 | cur = min(len, (PAGE_CACHE_SIZE - offset)); | 2276 | cur = min(len, (PAGE_CACHE_SIZE - offset)); |
2280 | 2277 | ||
2281 | // kaddr = kmap_atomic(page, KM_USER0); | 2278 | kaddr = kmap_atomic(page, KM_USER0); |
2282 | kaddr = page_address(page); | ||
2283 | ret = memcmp(ptr, kaddr + offset, cur); | 2279 | ret = memcmp(ptr, kaddr + offset, cur); |
2284 | // kunmap_atomic(kaddr, KM_USER0); | 2280 | kunmap_atomic(kaddr, KM_USER0); |
2285 | if (ret) | 2281 | if (ret) |
2286 | break; | 2282 | break; |
2287 | 2283 | ||
@@ -2317,10 +2313,9 @@ void write_extent_buffer(struct extent_buffer *eb, const void *srcv, | |||
2317 | WARN_ON(!PageUptodate(page)); | 2313 | WARN_ON(!PageUptodate(page)); |
2318 | 2314 | ||
2319 | cur = min(len, PAGE_CACHE_SIZE - offset); | 2315 | cur = min(len, PAGE_CACHE_SIZE - offset); |
2320 | // kaddr = kmap_atomic(page, KM_USER0); | 2316 | kaddr = kmap_atomic(page, KM_USER0); |
2321 | kaddr = page_address(page); | ||
2322 | memcpy(kaddr + offset, src, cur); | 2317 | memcpy(kaddr + offset, src, cur); |
2323 | // kunmap_atomic(kaddr, KM_USER0); | 2318 | kunmap_atomic(kaddr, KM_USER0); |
2324 | 2319 | ||
2325 | src += cur; | 2320 | src += cur; |
2326 | len -= cur; | 2321 | len -= cur; |
@@ -2352,10 +2347,9 @@ void memset_extent_buffer(struct extent_buffer *eb, char c, | |||
2352 | WARN_ON(!PageUptodate(page)); | 2347 | WARN_ON(!PageUptodate(page)); |
2353 | 2348 | ||
2354 | cur = min(len, PAGE_CACHE_SIZE - offset); | 2349 | cur = min(len, PAGE_CACHE_SIZE - offset); |
2355 | // kaddr = kmap_atomic(page, KM_USER0); | 2350 | kaddr = kmap_atomic(page, KM_USER0); |
2356 | kaddr = page_address(page); | ||
2357 | memset(kaddr + offset, c, cur); | 2351 | memset(kaddr + offset, c, cur); |
2358 | // kunmap_atomic(kaddr, KM_USER0); | 2352 | kunmap_atomic(kaddr, KM_USER0); |
2359 | 2353 | ||
2360 | len -= cur; | 2354 | len -= cur; |
2361 | offset = 0; | 2355 | offset = 0; |
@@ -2388,10 +2382,9 @@ void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src, | |||
2388 | 2382 | ||
2389 | cur = min(len, (unsigned long)(PAGE_CACHE_SIZE - offset)); | 2383 | cur = min(len, (unsigned long)(PAGE_CACHE_SIZE - offset)); |
2390 | 2384 | ||
2391 | // kaddr = kmap_atomic(page, KM_USER1); | 2385 | kaddr = kmap_atomic(page, KM_USER1); |
2392 | kaddr = page_address(page); | ||
2393 | read_extent_buffer(src, kaddr + offset, src_offset, cur); | 2386 | read_extent_buffer(src, kaddr + offset, src_offset, cur); |
2394 | // kunmap_atomic(kaddr, KM_USER1); | 2387 | kunmap_atomic(kaddr, KM_USER1); |
2395 | 2388 | ||
2396 | src_offset += cur; | 2389 | src_offset += cur; |
2397 | len -= cur; | 2390 | len -= cur; |
@@ -2405,43 +2398,38 @@ static void move_pages(struct page *dst_page, struct page *src_page, | |||
2405 | unsigned long dst_off, unsigned long src_off, | 2398 | unsigned long dst_off, unsigned long src_off, |
2406 | unsigned long len) | 2399 | unsigned long len) |
2407 | { | 2400 | { |
2408 | // char *dst_kaddr = kmap_atomic(dst_page, KM_USER0); | 2401 | char *dst_kaddr = kmap_atomic(dst_page, KM_USER0); |
2409 | char *dst_kaddr = page_address(dst_page); | ||
2410 | if (dst_page == src_page) { | 2402 | if (dst_page == src_page) { |
2411 | memmove(dst_kaddr + dst_off, dst_kaddr + src_off, len); | 2403 | memmove(dst_kaddr + dst_off, dst_kaddr + src_off, len); |
2412 | } else { | 2404 | } else { |
2413 | // char *src_kaddr = kmap_atomic(src_page, KM_USER1); | 2405 | char *src_kaddr = kmap_atomic(src_page, KM_USER1); |
2414 | char *src_kaddr = page_address(src_page); | ||
2415 | char *p = dst_kaddr + dst_off + len; | 2406 | char *p = dst_kaddr + dst_off + len; |
2416 | char *s = src_kaddr + src_off + len; | 2407 | char *s = src_kaddr + src_off + len; |
2417 | 2408 | ||
2418 | while (len--) | 2409 | while (len--) |
2419 | *--p = *--s; | 2410 | *--p = *--s; |
2420 | 2411 | ||
2421 | // kunmap_atomic(src_kaddr, KM_USER1); | 2412 | kunmap_atomic(src_kaddr, KM_USER1); |
2422 | } | 2413 | } |
2423 | // kunmap_atomic(dst_kaddr, KM_USER0); | 2414 | kunmap_atomic(dst_kaddr, KM_USER0); |
2424 | } | 2415 | } |
2425 | 2416 | ||
2426 | static void copy_pages(struct page *dst_page, struct page *src_page, | 2417 | static void copy_pages(struct page *dst_page, struct page *src_page, |
2427 | unsigned long dst_off, unsigned long src_off, | 2418 | unsigned long dst_off, unsigned long src_off, |
2428 | unsigned long len) | 2419 | unsigned long len) |
2429 | { | 2420 | { |
2430 | //kmap_atomic(dst_page, KM_USER0); | 2421 | char *dst_kaddr = kmap_atomic(dst_page, KM_USER0); |
2431 | char *dst_kaddr = page_address(dst_page); | ||
2432 | char *src_kaddr; | 2422 | char *src_kaddr; |
2433 | 2423 | ||
2434 | if (dst_page != src_page) | 2424 | if (dst_page != src_page) |
2435 | src_kaddr = page_address(src_page); // kmap_atomic(src_page, KM_USER1); | 2425 | src_kaddr = kmap_atomic(src_page, KM_USER1); |
2436 | else | 2426 | else |
2437 | src_kaddr = dst_kaddr; | 2427 | src_kaddr = dst_kaddr; |
2438 | 2428 | ||
2439 | memcpy(dst_kaddr + dst_off, src_kaddr + src_off, len); | 2429 | memcpy(dst_kaddr + dst_off, src_kaddr + src_off, len); |
2440 | /* | ||
2441 | kunmap_atomic(dst_kaddr, KM_USER0); | 2430 | kunmap_atomic(dst_kaddr, KM_USER0); |
2442 | if (dst_page != src_page) | 2431 | if (dst_page != src_page) |
2443 | kunmap_atomic(src_kaddr, KM_USER1); | 2432 | kunmap_atomic(src_kaddr, KM_USER1); |
2444 | */ | ||
2445 | } | 2433 | } |
2446 | 2434 | ||
2447 | void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, | 2435 | void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, |
@@ -2537,7 +2525,7 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, | |||
2537 | 2525 | ||
2538 | cur = min(len, src_off_in_page + 1); | 2526 | cur = min(len, src_off_in_page + 1); |
2539 | cur = min(cur, dst_off_in_page + 1); | 2527 | cur = min(cur, dst_off_in_page + 1); |
2540 | // printk("move pages orig dst %lu src %lu len %lu, this %lu %lu %lu\n", dst_offset, src_offset, len, dst_off_in_page - cur + 1, src_off_in_page - cur + 1, cur); | 2528 | |
2541 | move_pages(extent_buffer_page(dst, dst_i), | 2529 | move_pages(extent_buffer_page(dst, dst_i), |
2542 | extent_buffer_page(dst, src_i), | 2530 | extent_buffer_page(dst, src_i), |
2543 | dst_off_in_page - cur + 1, | 2531 | dst_off_in_page - cur + 1, |