aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2012-06-12 10:20:45 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-31 01:45:52 -0400
commitb2b5ef5c8e89f19b68c174bf246f3ca212dbf0bc (patch)
tree05bc5ec6d01f45307eed33082f9f1c288c907999 /fs/btrfs/transaction.c
parent2c22b337b5bbb497c41b348b2357b7070ed5ba88 (diff)
btrfs: Convert to new freezing mechanism
We convert btrfs_file_aio_write() to use new freeze check. We also add proper freeze protection to btrfs_page_mkwrite(). We also add freeze protection to the transaction mechanism to avoid starting transactions on frozen filesystem. At minimum this is necessary to stop iput() of unlinked file to change frozen filesystem during truncation. Checks in cleaner_kthread() and transaction_kthread() can be safely removed since btrfs_freeze() will lock the mutexes and thus block the threads (and they shouldn't have anything to do anyway). CC: linux-btrfs@vger.kernel.org CC: Chris Mason <chris.mason@oracle.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index b72b068183ec..fa67ba51516e 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -329,6 +329,8 @@ again:
329 if (!h) 329 if (!h)
330 return ERR_PTR(-ENOMEM); 330 return ERR_PTR(-ENOMEM);
331 331
332 sb_start_intwrite(root->fs_info->sb);
333
332 if (may_wait_transaction(root, type)) 334 if (may_wait_transaction(root, type))
333 wait_current_trans(root); 335 wait_current_trans(root);
334 336
@@ -339,6 +341,7 @@ again:
339 } while (ret == -EBUSY); 341 } while (ret == -EBUSY);
340 342
341 if (ret < 0) { 343 if (ret < 0) {
344 sb_end_intwrite(root->fs_info->sb);
342 kmem_cache_free(btrfs_trans_handle_cachep, h); 345 kmem_cache_free(btrfs_trans_handle_cachep, h);
343 return ERR_PTR(ret); 346 return ERR_PTR(ret);
344 } 347 }
@@ -528,6 +531,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
528 count++; 531 count++;
529 } 532 }
530 533
534 sb_end_intwrite(root->fs_info->sb);
535
531 if (lock && !atomic_read(&root->fs_info->open_ioctl_trans) && 536 if (lock && !atomic_read(&root->fs_info->open_ioctl_trans) &&
532 should_end_transaction(trans, root)) { 537 should_end_transaction(trans, root)) {
533 trans->transaction->blocked = 1; 538 trans->transaction->blocked = 1;
@@ -1517,6 +1522,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
1517 put_transaction(cur_trans); 1522 put_transaction(cur_trans);
1518 put_transaction(cur_trans); 1523 put_transaction(cur_trans);
1519 1524
1525 sb_end_intwrite(root->fs_info->sb);
1526
1520 trace_btrfs_transaction_commit(root); 1527 trace_btrfs_transaction_commit(root);
1521 1528
1522 btrfs_scrub_continue(root); 1529 btrfs_scrub_continue(root);