diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-09-11 15:53:12 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:07 -0400 |
commit | 49eb7e46d47ea72a9bd2a5f8cedb04f5159cc277 (patch) | |
tree | c3d05588c3cf73453673206214fadedc07bd79d7 /fs/btrfs/file.c | |
parent | 98509cfc5a6857bddcfe4b19a9539726655ec9bd (diff) |
Btrfs: Dir fsync optimizations
Drop i_mutex during the commit
Don't bother doing the fsync at all unless the dir is marked as dirtied
and needing fsync in this transaction. For directories, this means
that someone has unlinked a file from the dir without fsyncing the
file.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 84ecf3ab8511..58b329ddb426 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -1061,7 +1061,9 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync) | |||
1061 | } | 1061 | } |
1062 | mutex_unlock(&root->fs_info->trans_mutex); | 1062 | mutex_unlock(&root->fs_info->trans_mutex); |
1063 | 1063 | ||
1064 | root->fs_info->tree_log_batch++; | ||
1064 | filemap_fdatawait(inode->i_mapping); | 1065 | filemap_fdatawait(inode->i_mapping); |
1066 | root->fs_info->tree_log_batch++; | ||
1065 | 1067 | ||
1066 | /* | 1068 | /* |
1067 | * ok we haven't committed the transaction yet, lets do a commit | 1069 | * ok we haven't committed the transaction yet, lets do a commit |
@@ -1076,14 +1078,29 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync) | |||
1076 | } | 1078 | } |
1077 | 1079 | ||
1078 | ret = btrfs_log_dentry_safe(trans, root, file->f_dentry); | 1080 | ret = btrfs_log_dentry_safe(trans, root, file->f_dentry); |
1079 | if (ret < 0) | 1081 | if (ret < 0) { |
1080 | goto out; | 1082 | goto out; |
1083 | } | ||
1084 | |||
1085 | /* we've logged all the items and now have a consistent | ||
1086 | * version of the file in the log. It is possible that | ||
1087 | * someone will come in and modify the file, but that's | ||
1088 | * fine because the log is consistent on disk, and we | ||
1089 | * have references to all of the file's extents | ||
1090 | * | ||
1091 | * It is possible that someone will come in and log the | ||
1092 | * file again, but that will end up using the synchronization | ||
1093 | * inside btrfs_sync_log to keep things safe. | ||
1094 | */ | ||
1095 | mutex_unlock(&file->f_dentry->d_inode->i_mutex); | ||
1096 | |||
1081 | if (ret > 0) { | 1097 | if (ret > 0) { |
1082 | ret = btrfs_commit_transaction(trans, root); | 1098 | ret = btrfs_commit_transaction(trans, root); |
1083 | } else { | 1099 | } else { |
1084 | btrfs_sync_log(trans, root); | 1100 | btrfs_sync_log(trans, root); |
1085 | ret = btrfs_end_transaction(trans, root); | 1101 | ret = btrfs_end_transaction(trans, root); |
1086 | } | 1102 | } |
1103 | mutex_lock(&file->f_dentry->d_inode->i_mutex); | ||
1087 | out: | 1104 | out: |
1088 | return ret > 0 ? EIO : ret; | 1105 | return ret > 0 ? EIO : ret; |
1089 | } | 1106 | } |