This check for a user transaction is a bogus: fsync() with an open user transaction is verboten. If the caller is the same process who started a user transaction, and this is a different file, we will deadlock. If it''s the same file, this check means we won''t deadlock, but the transaction will be prematurely closed out. Any user transaction ioctl users should be careful to avoid fsync() and close out the transaction explicitly. Signed-off-by: Sage Weil <sage@newdream.net> --- fs/btrfs/file.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index d146dde..2e6404f 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1097,12 +1097,6 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync) } mutex_unlock(&root->fs_info->trans_mutex); - /* - * ok we haven''t committed the transaction yet, lets do a commit - */ - if (file && file->private_data) - btrfs_ioctl_trans_end(file); - trans = btrfs_start_transaction(root, 1); if (!trans) { ret = -ENOMEM; -- 1.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Sage Weil
2010-Mar-15 17:26 UTC
[PATCH 2/2] Btrfs: warn when partial user transactions commit
Print a warning to the console when a btrfs ioctl transaction prematurely commits a possibly partial result. Signed-off-by: Sage Weil <sage@newdream.net> --- fs/btrfs/file.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 2e6404f..33975e7 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1046,8 +1046,11 @@ int btrfs_release_file(struct inode *inode, struct file *filp) if (inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT) filemap_flush(inode->i_mapping); } - if (filp->private_data) + if (filp->private_data) { + pr_warning("aborted btrfs user transaction, committing " + "partial result\n"); btrfs_ioctl_trans_end(filp); + } return 0; } -- 1.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html