aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file-item.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-08-15 15:34:18 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:06 -0400
commit53863232ef961778aa414b700ed88a48e8e871e6 (patch)
tree05a74ac264a5fb4f6b8824771f5820ca5907afe5 /fs/btrfs/file-item.c
parent4854ddd0ed0a687fc2d7c45a529c406232e31e7b (diff)
Btrfs: Lower contention on the csum mutex
This takes the csum mutex deeper in the call chain and releases it more often. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file-item.c')
-rw-r--r--fs/btrfs/file-item.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 51aba8cee7ce..9454e0a07c89 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -321,6 +321,7 @@ again:
321 file_key.offset = offset; 321 file_key.offset = offset;
322 btrfs_set_key_type(&file_key, BTRFS_CSUM_ITEM_KEY); 322 btrfs_set_key_type(&file_key, BTRFS_CSUM_ITEM_KEY);
323 323
324 mutex_lock(&BTRFS_I(inode)->csum_mutex);
324 item = btrfs_lookup_csum(trans, root, path, objectid, offset, 1); 325 item = btrfs_lookup_csum(trans, root, path, objectid, offset, 1);
325 if (!IS_ERR(item)) { 326 if (!IS_ERR(item)) {
326 leaf = path->nodes[0]; 327 leaf = path->nodes[0];
@@ -367,7 +368,7 @@ again:
367 ret = btrfs_search_slot(trans, root, &file_key, path, 368 ret = btrfs_search_slot(trans, root, &file_key, path,
368 BTRFS_CRC32_SIZE, 1); 369 BTRFS_CRC32_SIZE, 1);
369 if (ret < 0) 370 if (ret < 0)
370 goto fail; 371 goto fail_unlock;
371 if (ret == 0) { 372 if (ret == 0) {
372 BUG(); 373 BUG();
373 } 374 }
@@ -411,10 +412,10 @@ insert:
411 ret = btrfs_insert_empty_item(trans, root, path, &file_key, 412 ret = btrfs_insert_empty_item(trans, root, path, &file_key,
412 ins_size); 413 ins_size);
413 if (ret < 0) 414 if (ret < 0)
414 goto fail; 415 goto fail_unlock;
415 if (ret != 0) { 416 if (ret != 0) {
416 WARN_ON(1); 417 WARN_ON(1);
417 goto fail; 418 goto fail_unlock;
418 } 419 }
419csum: 420csum:
420 leaf = path->nodes[0]; 421 leaf = path->nodes[0];
@@ -427,6 +428,8 @@ found:
427 item_end = (struct btrfs_csum_item *)((unsigned char *)item_end + 428 item_end = (struct btrfs_csum_item *)((unsigned char *)item_end +
428 btrfs_item_size_nr(leaf, path->slots[0])); 429 btrfs_item_size_nr(leaf, path->slots[0]));
429 eb_token = NULL; 430 eb_token = NULL;
431 mutex_unlock(&BTRFS_I(inode)->csum_mutex);
432 cond_resched();
430next_sector: 433next_sector:
431 434
432 if (!eb_token || 435 if (!eb_token ||
@@ -467,13 +470,18 @@ next_sector:
467 eb_token = NULL; 470 eb_token = NULL;
468 } 471 }
469 btrfs_mark_buffer_dirty(path->nodes[0]); 472 btrfs_mark_buffer_dirty(path->nodes[0]);
473 cond_resched();
470 if (total_bytes < sums->len) { 474 if (total_bytes < sums->len) {
471 btrfs_release_path(root, path); 475 btrfs_release_path(root, path);
472 goto again; 476 goto again;
473 } 477 }
474fail: 478out:
475 btrfs_free_path(path); 479 btrfs_free_path(path);
476 return ret; 480 return ret;
481
482fail_unlock:
483 mutex_unlock(&BTRFS_I(inode)->csum_mutex);
484 goto out;
477} 485}
478 486
479int btrfs_csum_truncate(struct btrfs_trans_handle *trans, 487int btrfs_csum_truncate(struct btrfs_trans_handle *trans,