file-item.c (143bede527b054a271053f41bfaca2b57baa9408) | file-item.c (0678b61851b510ba68341dff59cd9b47e1712e91) |
---|---|
1/* 2 * Copyright (C) 2007 Oracle. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 270 unchanged lines hidden (view full) --- 279 struct list_head *list, int search_commit) 280{ 281 struct btrfs_key key; 282 struct btrfs_path *path; 283 struct extent_buffer *leaf; 284 struct btrfs_ordered_sum *sums; 285 struct btrfs_sector_sum *sector_sum; 286 struct btrfs_csum_item *item; | 1/* 2 * Copyright (C) 2007 Oracle. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 270 unchanged lines hidden (view full) --- 279 struct list_head *list, int search_commit) 280{ 281 struct btrfs_key key; 282 struct btrfs_path *path; 283 struct extent_buffer *leaf; 284 struct btrfs_ordered_sum *sums; 285 struct btrfs_sector_sum *sector_sum; 286 struct btrfs_csum_item *item; |
287 LIST_HEAD(tmplist); |
|
287 unsigned long offset; 288 int ret; 289 size_t size; 290 u64 csum_end; 291 u16 csum_size = btrfs_super_csum_size(root->fs_info->super_copy); 292 293 path = btrfs_alloc_path(); 294 if (!path) --- 58 unchanged lines hidden (view full) --- 353 csum_end = min(csum_end, end + 1); 354 item = btrfs_item_ptr(path->nodes[0], path->slots[0], 355 struct btrfs_csum_item); 356 while (start < csum_end) { 357 size = min_t(size_t, csum_end - start, 358 MAX_ORDERED_SUM_BYTES(root)); 359 sums = kzalloc(btrfs_ordered_sum_size(root, size), 360 GFP_NOFS); | 288 unsigned long offset; 289 int ret; 290 size_t size; 291 u64 csum_end; 292 u16 csum_size = btrfs_super_csum_size(root->fs_info->super_copy); 293 294 path = btrfs_alloc_path(); 295 if (!path) --- 58 unchanged lines hidden (view full) --- 354 csum_end = min(csum_end, end + 1); 355 item = btrfs_item_ptr(path->nodes[0], path->slots[0], 356 struct btrfs_csum_item); 357 while (start < csum_end) { 358 size = min_t(size_t, csum_end - start, 359 MAX_ORDERED_SUM_BYTES(root)); 360 sums = kzalloc(btrfs_ordered_sum_size(root, size), 361 GFP_NOFS); |
361 BUG_ON(!sums); | 362 if (!sums) { 363 ret = -ENOMEM; 364 goto fail; 365 } |
362 363 sector_sum = sums->sums; 364 sums->bytenr = start; 365 sums->len = size; 366 367 offset = (start - key.offset) >> 368 root->fs_info->sb->s_blocksize_bits; 369 offset *= csum_size; --- 5 unchanged lines hidden (view full) --- 375 offset, csum_size); 376 sector_sum->bytenr = start; 377 378 size -= root->sectorsize; 379 start += root->sectorsize; 380 offset += csum_size; 381 sector_sum++; 382 } | 366 367 sector_sum = sums->sums; 368 sums->bytenr = start; 369 sums->len = size; 370 371 offset = (start - key.offset) >> 372 root->fs_info->sb->s_blocksize_bits; 373 offset *= csum_size; --- 5 unchanged lines hidden (view full) --- 379 offset, csum_size); 380 sector_sum->bytenr = start; 381 382 size -= root->sectorsize; 383 start += root->sectorsize; 384 offset += csum_size; 385 sector_sum++; 386 } |
383 list_add_tail(&sums->list, list); | 387 list_add_tail(&sums->list, &tmplist); |
384 } 385 path->slots[0]++; 386 } 387 ret = 0; 388fail: | 388 } 389 path->slots[0]++; 390 } 391 ret = 0; 392fail: |
393 while (ret < 0 && !list_empty(&tmplist)) { 394 sums = list_entry(&tmplist, struct btrfs_ordered_sum, list); 395 list_del(&sums->list); 396 kfree(sums); 397 } 398 list_splice_tail(&tmplist, list); 399 |
|
389 btrfs_free_path(path); 390 return ret; 391} 392 393int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode, 394 struct bio *bio, u64 file_start, int contig) 395{ 396 struct btrfs_ordered_sum *sums; --- 449 unchanged lines hidden --- | 400 btrfs_free_path(path); 401 return ret; 402} 403 404int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode, 405 struct bio *bio, u64 file_start, int contig) 406{ 407 struct btrfs_ordered_sum *sums; --- 449 unchanged lines hidden --- |