diff options
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/file.c | 7 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 24 | ||||
-rw-r--r-- | fs/btrfs/ordered-data.c | 21 | ||||
-rw-r--r-- | fs/btrfs/ordered-data.h | 2 | ||||
-rw-r--r-- | fs/btrfs/super.c | 1 |
5 files changed, 23 insertions, 32 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index d968900c6973..c4fa4664a456 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -978,6 +978,12 @@ out_nolock: | |||
978 | return num_written ? num_written : err; | 978 | return num_written ? num_written : err; |
979 | } | 979 | } |
980 | 980 | ||
981 | static int btrfs_release_file (struct inode * inode, struct file * filp) | ||
982 | { | ||
983 | btrfs_del_ordered_inode(inode); | ||
984 | return 0; | ||
985 | } | ||
986 | |||
981 | static int btrfs_sync_file(struct file *file, | 987 | static int btrfs_sync_file(struct file *file, |
982 | struct dentry *dentry, int datasync) | 988 | struct dentry *dentry, int datasync) |
983 | { | 989 | { |
@@ -1044,6 +1050,7 @@ struct file_operations btrfs_file_operations = { | |||
1044 | .write = btrfs_file_write, | 1050 | .write = btrfs_file_write, |
1045 | .mmap = btrfs_file_mmap, | 1051 | .mmap = btrfs_file_mmap, |
1046 | .open = generic_file_open, | 1052 | .open = generic_file_open, |
1053 | .release = btrfs_release_file, | ||
1047 | .fsync = btrfs_sync_file, | 1054 | .fsync = btrfs_sync_file, |
1048 | .unlocked_ioctl = btrfs_ioctl, | 1055 | .unlocked_ioctl = btrfs_ioctl, |
1049 | #ifdef CONFIG_COMPAT | 1056 | #ifdef CONFIG_COMPAT |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 40b4a8ec17fe..1569fb864515 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -857,15 +857,11 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) | |||
857 | nr = trans->blocks_used; | 857 | nr = trans->blocks_used; |
858 | 858 | ||
859 | if (inode->i_nlink == 0) { | 859 | if (inode->i_nlink == 0) { |
860 | int found; | ||
861 | /* if the inode isn't linked anywhere, | 860 | /* if the inode isn't linked anywhere, |
862 | * we don't need to worry about | 861 | * we don't need to worry about |
863 | * data=ordered | 862 | * data=ordered |
864 | */ | 863 | */ |
865 | found = btrfs_del_ordered_inode(inode); | 864 | btrfs_del_ordered_inode(inode); |
866 | if (found == 1) { | ||
867 | atomic_dec(&inode->i_count); | ||
868 | } | ||
869 | } | 865 | } |
870 | 866 | ||
871 | btrfs_end_transaction(trans, root); | 867 | btrfs_end_transaction(trans, root); |
@@ -1271,24 +1267,6 @@ fail: | |||
1271 | return err; | 1267 | return err; |
1272 | } | 1268 | } |
1273 | 1269 | ||
1274 | void btrfs_put_inode(struct inode *inode) | ||
1275 | { | ||
1276 | int ret; | ||
1277 | |||
1278 | if (!BTRFS_I(inode)->ordered_trans) { | ||
1279 | return; | ||
1280 | } | ||
1281 | |||
1282 | if (mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY) || | ||
1283 | mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK)) | ||
1284 | return; | ||
1285 | |||
1286 | ret = btrfs_del_ordered_inode(inode); | ||
1287 | if (ret == 1) { | ||
1288 | atomic_dec(&inode->i_count); | ||
1289 | } | ||
1290 | } | ||
1291 | |||
1292 | void btrfs_delete_inode(struct inode *inode) | 1270 | void btrfs_delete_inode(struct inode *inode) |
1293 | { | 1271 | { |
1294 | struct btrfs_trans_handle *trans; | 1272 | struct btrfs_trans_handle *trans; |
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 3814cb0246b4..8dd8180183ff 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c | |||
@@ -231,7 +231,7 @@ int btrfs_find_del_first_ordered_inode(struct btrfs_ordered_inode_tree *tree, | |||
231 | return 1; | 231 | return 1; |
232 | } | 232 | } |
233 | 233 | ||
234 | static int __btrfs_del_ordered_inode(struct btrfs_ordered_inode_tree *tree, | 234 | static void __btrfs_del_ordered_inode(struct btrfs_ordered_inode_tree *tree, |
235 | struct inode *inode, | 235 | struct inode *inode, |
236 | u64 root_objectid, u64 objectid) | 236 | u64 root_objectid, u64 objectid) |
237 | { | 237 | { |
@@ -243,31 +243,38 @@ static int __btrfs_del_ordered_inode(struct btrfs_ordered_inode_tree *tree, | |||
243 | node = __tree_search(&tree->tree, root_objectid, objectid, &prev); | 243 | node = __tree_search(&tree->tree, root_objectid, objectid, &prev); |
244 | if (!node) { | 244 | if (!node) { |
245 | write_unlock(&tree->lock); | 245 | write_unlock(&tree->lock); |
246 | return 0; | 246 | return; |
247 | } | 247 | } |
248 | rb_erase(node, &tree->tree); | 248 | rb_erase(node, &tree->tree); |
249 | BTRFS_I(inode)->ordered_trans = 0; | 249 | BTRFS_I(inode)->ordered_trans = 0; |
250 | write_unlock(&tree->lock); | 250 | write_unlock(&tree->lock); |
251 | atomic_dec(&inode->i_count); | ||
251 | entry = rb_entry(node, struct tree_entry, rb_node); | 252 | entry = rb_entry(node, struct tree_entry, rb_node); |
252 | kfree(entry); | 253 | kfree(entry); |
253 | return 1; | 254 | return; |
254 | } | 255 | } |
255 | 256 | ||
256 | int btrfs_del_ordered_inode(struct inode *inode) | 257 | void btrfs_del_ordered_inode(struct inode *inode) |
257 | { | 258 | { |
258 | struct btrfs_root *root = BTRFS_I(inode)->root; | 259 | struct btrfs_root *root = BTRFS_I(inode)->root; |
259 | u64 root_objectid = root->root_key.objectid; | 260 | u64 root_objectid = root->root_key.objectid; |
260 | int ret = 0; | 261 | |
262 | if (!BTRFS_I(inode)->ordered_trans) { | ||
263 | return; | ||
264 | } | ||
265 | |||
266 | if (mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY) || | ||
267 | mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK)) | ||
268 | return; | ||
261 | 269 | ||
262 | spin_lock(&root->fs_info->new_trans_lock); | 270 | spin_lock(&root->fs_info->new_trans_lock); |
263 | if (root->fs_info->running_transaction) { | 271 | if (root->fs_info->running_transaction) { |
264 | struct btrfs_ordered_inode_tree *tree; | 272 | struct btrfs_ordered_inode_tree *tree; |
265 | tree = &root->fs_info->running_transaction->ordered_inode_tree; | 273 | tree = &root->fs_info->running_transaction->ordered_inode_tree; |
266 | ret = __btrfs_del_ordered_inode(tree, inode, root_objectid, | 274 | __btrfs_del_ordered_inode(tree, inode, root_objectid, |
267 | inode->i_ino); | 275 | inode->i_ino); |
268 | } | 276 | } |
269 | spin_unlock(&root->fs_info->new_trans_lock); | 277 | spin_unlock(&root->fs_info->new_trans_lock); |
270 | return ret; | ||
271 | } | 278 | } |
272 | 279 | ||
273 | int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode) | 280 | int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode) |
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index 29047e0abaab..c515c4b39996 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h | |||
@@ -38,6 +38,6 @@ int btrfs_find_del_first_ordered_inode(struct btrfs_ordered_inode_tree *tree, | |||
38 | int btrfs_find_first_ordered_inode(struct btrfs_ordered_inode_tree *tree, | 38 | int btrfs_find_first_ordered_inode(struct btrfs_ordered_inode_tree *tree, |
39 | u64 *root_objectid, u64 *objectid, | 39 | u64 *root_objectid, u64 *objectid, |
40 | struct inode **inode); | 40 | struct inode **inode); |
41 | int btrfs_del_ordered_inode(struct inode *inode); | 41 | void btrfs_del_ordered_inode(struct inode *inode); |
42 | int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode); | 42 | int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode); |
43 | #endif | 43 | #endif |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 273a5b511f50..05029656e42e 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -487,7 +487,6 @@ static void btrfs_unlockfs(struct super_block *sb) | |||
487 | 487 | ||
488 | static struct super_operations btrfs_super_ops = { | 488 | static struct super_operations btrfs_super_ops = { |
489 | .delete_inode = btrfs_delete_inode, | 489 | .delete_inode = btrfs_delete_inode, |
490 | .put_inode = btrfs_put_inode, | ||
491 | .put_super = btrfs_put_super, | 490 | .put_super = btrfs_put_super, |
492 | .write_super = btrfs_write_super, | 491 | .write_super = btrfs_write_super, |
493 | .sync_fs = btrfs_sync_fs, | 492 | .sync_fs = btrfs_sync_fs, |