No title delete lock Revision 353336633239 (Fri Mar 22 2019 at 17:14) - Diff Link to this snippet: https://friendpaste.com/45NhhVPko5txKuuzDPqhyK Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.cindex 3f180b857e20..eea7d68fdcf2 100644--- a/fs/btrfs/inode.c+++ b/fs/btrfs/inode.c@@ -2928,7 +2928,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) int compress_type = 0; int ret = 0; u64 logical_len = ordered_extent->len;- bool nolock;+ bool nolock = false; bool truncated = false; bool range_locked = false; bool clear_new_delalloc_bytes = false;@@ -2939,7 +2939,16 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) !test_bit(BTRFS_ORDERED_DIRECT, &ordered_extent->flags)) clear_new_delalloc_bytes = true; - nolock = btrfs_is_free_space_inode(BTRFS_I(inode));+ if (btrfs_is_free_space_inode(BTRFS_I(inode))) {+ nolock = true;+ } else if (btrfs_test_opt(fs_info, FLUSHONCOMMIT)) {+ spin_lock(&fs_info->trans_lock);+ if (fs_info->running_transaction &&+ (fs_info->running_transaction->state >=+ TRANS_STATE_COMMIT_START))+ nolock = true;+ spin_unlock(&fs_info->trans_lock);+ } if (test_bit(BTRFS_ORDERED_IOERR, &ordered_extent->flags)) { ret = -EIO;diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.cindex acdad6d658f5..42d756267e9a 100644--- a/fs/btrfs/transaction.c+++ b/fs/btrfs/transaction.c@@ -1888,17 +1888,8 @@ static void btrfs_cleanup_pending_block_groups(struct btrfs_trans_handle *trans) static inline int btrfs_start_delalloc_flush(struct btrfs_fs_info *fs_info) {- /*- * We use writeback_inodes_sb here because if we used- * btrfs_start_delalloc_roots we would deadlock with fs freeze.- * Currently are holding the fs freeze lock, if we do an async flush- * we'll do btrfs_join_transaction() and deadlock because we need to- * wait for the fs freeze lock. Using the direct flushing we benefit- * from already being in a transaction and our join_transaction doesn't- * have to re-take the fs freeze lock.- */ if (btrfs_test_opt(fs_info, FLUSHONCOMMIT))- writeback_inodes_sb(fs_info->sb, WB_REASON_SYNC);+ return btrfs_start_delalloc_roots(fs_info, -1); return 0; }