file.c (e02119d5a7b4396c5a872582fddc8bd6d305a70a) file.c (49eb7e46d47ea72a9bd2a5f8cedb04f5159cc277)
1/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

--- 1047 unchanged lines hidden (view full) ---

1056 if (BTRFS_I(inode)->last_trans <=
1057 root->fs_info->last_trans_committed) {
1058 BTRFS_I(inode)->last_trans = 0;
1059 mutex_unlock(&root->fs_info->trans_mutex);
1060 goto out;
1061 }
1062 mutex_unlock(&root->fs_info->trans_mutex);
1063
1/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

--- 1047 unchanged lines hidden (view full) ---

1056 if (BTRFS_I(inode)->last_trans <=
1057 root->fs_info->last_trans_committed) {
1058 BTRFS_I(inode)->last_trans = 0;
1059 mutex_unlock(&root->fs_info->trans_mutex);
1060 goto out;
1061 }
1062 mutex_unlock(&root->fs_info->trans_mutex);
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
1066 /*
1067 * ok we haven't committed the transaction yet, lets do a commit
1068 */
1069 if (file->private_data)
1070 btrfs_ioctl_trans_end(file);
1071
1072 trans = btrfs_start_transaction(root, 1);
1073 if (!trans) {
1074 ret = -ENOMEM;
1075 goto out;
1076 }
1077
1078 ret = btrfs_log_dentry_safe(trans, root, file->f_dentry);
1067
1068 /*
1069 * ok we haven't committed the transaction yet, lets do a commit
1070 */
1071 if (file->private_data)
1072 btrfs_ioctl_trans_end(file);
1073
1074 trans = btrfs_start_transaction(root, 1);
1075 if (!trans) {
1076 ret = -ENOMEM;
1077 goto out;
1078 }
1079
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) {
1082 ret = btrfs_commit_transaction(trans, root);
1083 } else {
1084 btrfs_sync_log(trans, root);
1085 ret = btrfs_end_transaction(trans, root);
1086 }
1097 if (ret > 0) {
1098 ret = btrfs_commit_transaction(trans, root);
1099 } else {
1100 btrfs_sync_log(trans, root);
1101 ret = btrfs_end_transaction(trans, root);
1102 }
1103 mutex_lock(&file->f_dentry->d_inode->i_mutex);
1087out:
1088 return ret > 0 ? EIO : ret;
1089}
1090
1091static struct vm_operations_struct btrfs_file_vm_ops = {
1092#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
1093 .nopage = filemap_nopage,
1094 .populate = filemap_populate,

--- 31 unchanged lines hidden ---
1104out:
1105 return ret > 0 ? EIO : ret;
1106}
1107
1108static struct vm_operations_struct btrfs_file_vm_ops = {
1109#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
1110 .nopage = filemap_nopage,
1111 .populate = filemap_populate,

--- 31 unchanged lines hidden ---