extent_map.c (ae2f5411c4ce7180cca8418853db50c8e52d40db) | extent_map.c (0a2118dfd4c328e8823cdcfebf839dff73ac21e9) |
---|---|
1#include <linux/bitops.h> 2#include <linux/slab.h> 3#include <linux/bio.h> 4#include <linux/mm.h> 5#include <linux/gfp.h> 6#include <linux/pagemap.h> 7#include <linux/page-flags.h> 8#include <linux/module.h> 9#include <linux/spinlock.h> 10#include <linux/blkdev.h> 11#include <linux/swap.h> | 1#include <linux/bitops.h> 2#include <linux/slab.h> 3#include <linux/bio.h> 4#include <linux/mm.h> 5#include <linux/gfp.h> 6#include <linux/pagemap.h> 7#include <linux/page-flags.h> 8#include <linux/module.h> 9#include <linux/spinlock.h> 10#include <linux/blkdev.h> 11#include <linux/swap.h> |
12#include <linux/version.h> |
|
12#include "extent_map.h" 13 14/* temporary define until extent_map moves out of btrfs */ 15struct kmem_cache *btrfs_cache_create(const char *name, size_t size, 16 unsigned long extra_flags, 17 void (*ctor)(void *, struct kmem_cache *, 18 unsigned long)); 19 --- 1249 unchanged lines hidden (view full) --- 1269 * after a writepage IO is done, we need to: 1270 * clear the uptodate bits on error 1271 * clear the writeback bits in the extent tree for this IO 1272 * end_page_writeback if the page has no more pending IO 1273 * 1274 * Scheduling is not allowed, so the extent state tree is expected 1275 * to have one and only one object corresponding to this IO. 1276 */ | 13#include "extent_map.h" 14 15/* temporary define until extent_map moves out of btrfs */ 16struct kmem_cache *btrfs_cache_create(const char *name, size_t size, 17 unsigned long extra_flags, 18 void (*ctor)(void *, struct kmem_cache *, 19 unsigned long)); 20 --- 1249 unchanged lines hidden (view full) --- 1270 * after a writepage IO is done, we need to: 1271 * clear the uptodate bits on error 1272 * clear the writeback bits in the extent tree for this IO 1273 * end_page_writeback if the page has no more pending IO 1274 * 1275 * Scheduling is not allowed, so the extent state tree is expected 1276 * to have one and only one object corresponding to this IO. 1277 */ |
1278#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23) 1279static void end_bio_extent_writepage(struct bio *bio, int err) 1280#else |
|
1277static int end_bio_extent_writepage(struct bio *bio, 1278 unsigned int bytes_done, int err) | 1281static int end_bio_extent_writepage(struct bio *bio, 1282 unsigned int bytes_done, int err) |
1283#endif |
|
1279{ 1280 const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 1281 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 1282 struct extent_map_tree *tree = bio->bi_private; 1283 u64 start; 1284 u64 end; 1285 int whole_page; 1286 | 1284{ 1285 const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 1286 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 1287 struct extent_map_tree *tree = bio->bi_private; 1288 u64 start; 1289 u64 end; 1290 int whole_page; 1291 |
1292#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) |
|
1287 if (bio->bi_size) 1288 return 1; | 1293 if (bio->bi_size) 1294 return 1; |
1295#endif |
|
1289 1290 do { 1291 struct page *page = bvec->bv_page; 1292 start = (page->index << PAGE_CACHE_SHIFT) + bvec->bv_offset; 1293 end = start + bvec->bv_len - 1; 1294 1295 if (bvec->bv_offset == 0 && bvec->bv_len == PAGE_CACHE_SIZE) 1296 whole_page = 1; --- 14 unchanged lines hidden (view full) --- 1311 end_page_writeback(page); 1312 else 1313 check_page_writeback(tree, page); 1314 if (tree->ops && tree->ops->writepage_end_io_hook) 1315 tree->ops->writepage_end_io_hook(page, start, end); 1316 } while (bvec >= bio->bi_io_vec); 1317 1318 bio_put(bio); | 1296 1297 do { 1298 struct page *page = bvec->bv_page; 1299 start = (page->index << PAGE_CACHE_SHIFT) + bvec->bv_offset; 1300 end = start + bvec->bv_len - 1; 1301 1302 if (bvec->bv_offset == 0 && bvec->bv_len == PAGE_CACHE_SIZE) 1303 whole_page = 1; --- 14 unchanged lines hidden (view full) --- 1318 end_page_writeback(page); 1319 else 1320 check_page_writeback(tree, page); 1321 if (tree->ops && tree->ops->writepage_end_io_hook) 1322 tree->ops->writepage_end_io_hook(page, start, end); 1323 } while (bvec >= bio->bi_io_vec); 1324 1325 bio_put(bio); |
1326#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) |
|
1319 return 0; | 1327 return 0; |
1328#endif |
|
1320} 1321 1322/* 1323 * after a readpage IO is done, we need to: 1324 * clear the uptodate bits on error 1325 * set the uptodate bits if things worked 1326 * set the page up to date if all extents in the tree are uptodate 1327 * clear the lock bit in the extent tree 1328 * unlock the page if there are no other extents locked for it 1329 * 1330 * Scheduling is not allowed, so the extent state tree is expected 1331 * to have one and only one object corresponding to this IO. 1332 */ | 1329} 1330 1331/* 1332 * after a readpage IO is done, we need to: 1333 * clear the uptodate bits on error 1334 * set the uptodate bits if things worked 1335 * set the page up to date if all extents in the tree are uptodate 1336 * clear the lock bit in the extent tree 1337 * unlock the page if there are no other extents locked for it 1338 * 1339 * Scheduling is not allowed, so the extent state tree is expected 1340 * to have one and only one object corresponding to this IO. 1341 */ |
1342#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23) 1343static void end_bio_extent_readpage(struct bio *bio, int err) 1344#else |
|
1333static int end_bio_extent_readpage(struct bio *bio, 1334 unsigned int bytes_done, int err) | 1345static int end_bio_extent_readpage(struct bio *bio, 1346 unsigned int bytes_done, int err) |
1347#endif |
|
1335{ 1336 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 1337 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 1338 struct extent_map_tree *tree = bio->bi_private; 1339 u64 start; 1340 u64 end; 1341 int whole_page; 1342 int ret; 1343 | 1348{ 1349 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 1350 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 1351 struct extent_map_tree *tree = bio->bi_private; 1352 u64 start; 1353 u64 end; 1354 int whole_page; 1355 int ret; 1356 |
1357#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) |
|
1344 if (bio->bi_size) 1345 return 1; | 1358 if (bio->bi_size) 1359 return 1; |
1360#endif |
|
1346 1347 do { 1348 struct page *page = bvec->bv_page; 1349 start = (page->index << PAGE_CACHE_SHIFT) + bvec->bv_offset; 1350 end = start + bvec->bv_len - 1; 1351 1352 if (bvec->bv_offset == 0 && bvec->bv_len == PAGE_CACHE_SIZE) 1353 whole_page = 1; --- 23 unchanged lines hidden (view full) --- 1377 1378 if (whole_page) 1379 unlock_page(page); 1380 else 1381 check_page_locked(tree, page); 1382 } while (bvec >= bio->bi_io_vec); 1383 1384 bio_put(bio); | 1361 1362 do { 1363 struct page *page = bvec->bv_page; 1364 start = (page->index << PAGE_CACHE_SHIFT) + bvec->bv_offset; 1365 end = start + bvec->bv_len - 1; 1366 1367 if (bvec->bv_offset == 0 && bvec->bv_len == PAGE_CACHE_SIZE) 1368 whole_page = 1; --- 23 unchanged lines hidden (view full) --- 1392 1393 if (whole_page) 1394 unlock_page(page); 1395 else 1396 check_page_locked(tree, page); 1397 } while (bvec >= bio->bi_io_vec); 1398 1399 bio_put(bio); |
1400#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) |
|
1385 return 0; | 1401 return 0; |
1402#endif |
|
1386} 1387 1388/* 1389 * IO done from prepare_write is pretty simple, we just unlock 1390 * the structs in the extent tree when done, and set the uptodate bits 1391 * as appropriate. 1392 */ | 1403} 1404 1405/* 1406 * IO done from prepare_write is pretty simple, we just unlock 1407 * the structs in the extent tree when done, and set the uptodate bits 1408 * as appropriate. 1409 */ |
1410#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23) 1411static void end_bio_extent_preparewrite(struct bio *bio, int err) 1412#else |
|
1393static int end_bio_extent_preparewrite(struct bio *bio, 1394 unsigned int bytes_done, int err) | 1413static int end_bio_extent_preparewrite(struct bio *bio, 1414 unsigned int bytes_done, int err) |
1415#endif |
|
1395{ 1396 const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 1397 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 1398 struct extent_map_tree *tree = bio->bi_private; 1399 u64 start; 1400 u64 end; 1401 | 1416{ 1417 const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 1418 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 1419 struct extent_map_tree *tree = bio->bi_private; 1420 u64 start; 1421 u64 end; 1422 |
1423#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) |
|
1402 if (bio->bi_size) 1403 return 1; | 1424 if (bio->bi_size) 1425 return 1; |
1426#endif |
|
1404 1405 do { 1406 struct page *page = bvec->bv_page; 1407 start = (page->index << PAGE_CACHE_SHIFT) + bvec->bv_offset; 1408 end = start + bvec->bv_len - 1; 1409 1410 if (--bvec >= bio->bi_io_vec) 1411 prefetchw(&bvec->bv_page->flags); --- 5 unchanged lines hidden (view full) --- 1417 SetPageError(page); 1418 } 1419 1420 unlock_extent(tree, start, end, GFP_ATOMIC); 1421 1422 } while (bvec >= bio->bi_io_vec); 1423 1424 bio_put(bio); | 1427 1428 do { 1429 struct page *page = bvec->bv_page; 1430 start = (page->index << PAGE_CACHE_SHIFT) + bvec->bv_offset; 1431 end = start + bvec->bv_len - 1; 1432 1433 if (--bvec >= bio->bi_io_vec) 1434 prefetchw(&bvec->bv_page->flags); --- 5 unchanged lines hidden (view full) --- 1440 SetPageError(page); 1441 } 1442 1443 unlock_extent(tree, start, end, GFP_ATOMIC); 1444 1445 } while (bvec >= bio->bi_io_vec); 1446 1447 bio_put(bio); |
1448#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) |
|
1425 return 0; | 1449 return 0; |
1450#endif |
|
1426} 1427 1428static int submit_extent_page(int rw, struct extent_map_tree *tree, 1429 struct page *page, sector_t sector, 1430 size_t size, unsigned long offset, 1431 struct block_device *bdev, 1432 bio_end_io_t end_io_func) 1433{ --- 1289 unchanged lines hidden --- | 1451} 1452 1453static int submit_extent_page(int rw, struct extent_map_tree *tree, 1454 struct page *page, sector_t sector, 1455 size_t size, unsigned long offset, 1456 struct block_device *bdev, 1457 bio_end_io_t end_io_func) 1458{ --- 1289 unchanged lines hidden --- |