aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 14:34:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 14:34:40 -0400
commit2ac232f37fa0e8551856a575fe299c47b65b4d66 (patch)
tree58ff15ecdbc383415a82ea678e5191db16a479f3 /fs/ext3
parentfa8f53ace4af9470d8414427cb3dc3c0ffc4f182 (diff)
parent5cf49d763eb141d236e92be6d4a0dc94e31fa886 (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs-2.6: jbd: change the field "b_cow_tid" of struct journal_head from type unsigned to tid_t ext3.txt: update the links in the section "useful links" to the latest ones ext3: Fix data corruption in inodes with journalled data ext2: check xattr name_len before acquiring xattr_sem in ext2_xattr_get ext3: Fix compilation with -DDX_DEBUG quota: Remove unused declaration jbd: Use WRITE_SYNC in journal checkpoint. jbd: Fix oops in journal_remove_journal_head() ext3: Return -EINVAL when start is beyond the end of fs in ext3_trim_fs() ext3/ioctl.c: silence sparse warnings about different address spaces ext3/ext4 Documentation: remove bh/nobh since it has been deprecated ext3: Improve truncate error handling ext3: use proper little-endian bitops ext2: include fs.h into ext2_fs.h ext3: Fix oops in ext3_try_to_allocate_with_rsv() jbd: fix a bug of leaking jh->b_jcount jbd: remove dependency on __GFP_NOFAIL ext3: Convert ext3 to new truncate calling convention jbd: Add fixed tracepoints ext3: Add fixed tracepoints Resolve conflicts in fs/ext3/fsync.c due to fsync locking push-down and new fixed tracepoints.
Diffstat (limited to 'fs/ext3')
-rw-r--r--fs/ext3/balloc.c38
-rw-r--r--fs/ext3/file.c1
-rw-r--r--fs/ext3/fsync.c11
-rw-r--r--fs/ext3/ialloc.c4
-rw-r--r--fs/ext3/inode.c193
-rw-r--r--fs/ext3/ioctl.c4
-rw-r--r--fs/ext3/namei.c7
-rw-r--r--fs/ext3/super.c13
-rw-r--r--fs/ext3/xattr.c12
9 files changed, 201 insertions, 82 deletions
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index fe52297e31ad..6386d76f44a7 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -21,6 +21,7 @@
21#include <linux/quotaops.h> 21#include <linux/quotaops.h>
22#include <linux/buffer_head.h> 22#include <linux/buffer_head.h>
23#include <linux/blkdev.h> 23#include <linux/blkdev.h>
24#include <trace/events/ext3.h>
24 25
25/* 26/*
26 * balloc.c contains the blocks allocation and deallocation routines 27 * balloc.c contains the blocks allocation and deallocation routines
@@ -161,6 +162,7 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group)
161 desc = ext3_get_group_desc(sb, block_group, NULL); 162 desc = ext3_get_group_desc(sb, block_group, NULL);
162 if (!desc) 163 if (!desc)
163 return NULL; 164 return NULL;
165 trace_ext3_read_block_bitmap(sb, block_group);
164 bitmap_blk = le32_to_cpu(desc->bg_block_bitmap); 166 bitmap_blk = le32_to_cpu(desc->bg_block_bitmap);
165 bh = sb_getblk(sb, bitmap_blk); 167 bh = sb_getblk(sb, bitmap_blk);
166 if (unlikely(!bh)) { 168 if (unlikely(!bh)) {
@@ -351,6 +353,7 @@ void ext3_rsv_window_add(struct super_block *sb,
351 struct rb_node * parent = NULL; 353 struct rb_node * parent = NULL;
352 struct ext3_reserve_window_node *this; 354 struct ext3_reserve_window_node *this;
353 355
356 trace_ext3_rsv_window_add(sb, rsv);
354 while (*p) 357 while (*p)
355 { 358 {
356 parent = *p; 359 parent = *p;
@@ -476,8 +479,10 @@ void ext3_discard_reservation(struct inode *inode)
476 rsv = &block_i->rsv_window_node; 479 rsv = &block_i->rsv_window_node;
477 if (!rsv_is_empty(&rsv->rsv_window)) { 480 if (!rsv_is_empty(&rsv->rsv_window)) {
478 spin_lock(rsv_lock); 481 spin_lock(rsv_lock);
479 if (!rsv_is_empty(&rsv->rsv_window)) 482 if (!rsv_is_empty(&rsv->rsv_window)) {
483 trace_ext3_discard_reservation(inode, rsv);
480 rsv_window_remove(inode->i_sb, rsv); 484 rsv_window_remove(inode->i_sb, rsv);
485 }
481 spin_unlock(rsv_lock); 486 spin_unlock(rsv_lock);
482 } 487 }
483} 488}
@@ -683,14 +688,10 @@ error_return:
683void ext3_free_blocks(handle_t *handle, struct inode *inode, 688void ext3_free_blocks(handle_t *handle, struct inode *inode,
684 ext3_fsblk_t block, unsigned long count) 689 ext3_fsblk_t block, unsigned long count)
685{ 690{
686 struct super_block * sb; 691 struct super_block *sb = inode->i_sb;
687 unsigned long dquot_freed_blocks; 692 unsigned long dquot_freed_blocks;
688 693
689 sb = inode->i_sb; 694 trace_ext3_free_blocks(inode, block, count);
690 if (!sb) {
691 printk ("ext3_free_blocks: nonexistent device");
692 return;
693 }
694 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks); 695 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
695 if (dquot_freed_blocks) 696 if (dquot_freed_blocks)
696 dquot_free_block(inode, dquot_freed_blocks); 697 dquot_free_block(inode, dquot_freed_blocks);
@@ -1136,6 +1137,7 @@ static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv,
1136 else 1137 else
1137 start_block = grp_goal + group_first_block; 1138 start_block = grp_goal + group_first_block;
1138 1139
1140 trace_ext3_alloc_new_reservation(sb, start_block);
1139 size = my_rsv->rsv_goal_size; 1141 size = my_rsv->rsv_goal_size;
1140 1142
1141 if (!rsv_is_empty(&my_rsv->rsv_window)) { 1143 if (!rsv_is_empty(&my_rsv->rsv_window)) {
@@ -1230,8 +1232,11 @@ retry:
1230 * check if the first free block is within the 1232 * check if the first free block is within the
1231 * free space we just reserved 1233 * free space we just reserved
1232 */ 1234 */
1233 if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end) 1235 if (start_block >= my_rsv->rsv_start &&
1236 start_block <= my_rsv->rsv_end) {
1237 trace_ext3_reserved(sb, start_block, my_rsv);
1234 return 0; /* success */ 1238 return 0; /* success */
1239 }
1235 /* 1240 /*
1236 * if the first free bit we found is out of the reservable space 1241 * if the first free bit we found is out of the reservable space
1237 * continue search for next reservable space, 1242 * continue search for next reservable space,
@@ -1514,10 +1519,6 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
1514 1519
1515 *errp = -ENOSPC; 1520 *errp = -ENOSPC;
1516 sb = inode->i_sb; 1521 sb = inode->i_sb;
1517 if (!sb) {
1518 printk("ext3_new_block: nonexistent device");
1519 return 0;
1520 }
1521 1522
1522 /* 1523 /*
1523 * Check quota for allocation of this block. 1524 * Check quota for allocation of this block.
@@ -1528,8 +1529,10 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
1528 return 0; 1529 return 0;
1529 } 1530 }
1530 1531
1532 trace_ext3_request_blocks(inode, goal, num);
1533
1531 sbi = EXT3_SB(sb); 1534 sbi = EXT3_SB(sb);
1532 es = EXT3_SB(sb)->s_es; 1535 es = sbi->s_es;
1533 ext3_debug("goal=%lu.\n", goal); 1536 ext3_debug("goal=%lu.\n", goal);
1534 /* 1537 /*
1535 * Allocate a block from reservation only when 1538 * Allocate a block from reservation only when
@@ -1742,6 +1745,10 @@ allocated:
1742 brelse(bitmap_bh); 1745 brelse(bitmap_bh);
1743 dquot_free_block(inode, *count-num); 1746 dquot_free_block(inode, *count-num);
1744 *count = num; 1747 *count = num;
1748
1749 trace_ext3_allocate_blocks(inode, goal, num,
1750 (unsigned long long)ret_block);
1751
1745 return ret_block; 1752 return ret_block;
1746 1753
1747io_error: 1754io_error:
@@ -1996,6 +2003,7 @@ ext3_grpblk_t ext3_trim_all_free(struct super_block *sb, unsigned int group,
1996 if ((next - start) < minblocks) 2003 if ((next - start) < minblocks)
1997 goto free_extent; 2004 goto free_extent;
1998 2005
2006 trace_ext3_discard_blocks(sb, discard_block, next - start);
1999 /* Send the TRIM command down to the device */ 2007 /* Send the TRIM command down to the device */
2000 err = sb_issue_discard(sb, discard_block, next - start, 2008 err = sb_issue_discard(sb, discard_block, next - start,
2001 GFP_NOFS, 0); 2009 GFP_NOFS, 0);
@@ -2100,7 +2108,7 @@ int ext3_trim_fs(struct super_block *sb, struct fstrim_range *range)
2100 if (unlikely(minlen > EXT3_BLOCKS_PER_GROUP(sb))) 2108 if (unlikely(minlen > EXT3_BLOCKS_PER_GROUP(sb)))
2101 return -EINVAL; 2109 return -EINVAL;
2102 if (start >= max_blks) 2110 if (start >= max_blks)
2103 goto out; 2111 return -EINVAL;
2104 if (start + len > max_blks) 2112 if (start + len > max_blks)
2105 len = max_blks - start; 2113 len = max_blks - start;
2106 2114
@@ -2148,8 +2156,6 @@ int ext3_trim_fs(struct super_block *sb, struct fstrim_range *range)
2148 2156
2149 if (ret >= 0) 2157 if (ret >= 0)
2150 ret = 0; 2158 ret = 0;
2151
2152out:
2153 range->len = trimmed * sb->s_blocksize; 2159 range->len = trimmed * sb->s_blocksize;
2154 2160
2155 return ret; 2161 return ret;
diff --git a/fs/ext3/file.c b/fs/ext3/file.c
index 2be5b99097f1..724df69847dc 100644
--- a/fs/ext3/file.c
+++ b/fs/ext3/file.c
@@ -71,7 +71,6 @@ const struct file_operations ext3_file_operations = {
71}; 71};
72 72
73const struct inode_operations ext3_file_inode_operations = { 73const struct inode_operations ext3_file_inode_operations = {
74 .truncate = ext3_truncate,
75 .setattr = ext3_setattr, 74 .setattr = ext3_setattr,
76#ifdef CONFIG_EXT3_FS_XATTR 75#ifdef CONFIG_EXT3_FS_XATTR
77 .setxattr = generic_setxattr, 76 .setxattr = generic_setxattr,
diff --git a/fs/ext3/fsync.c b/fs/ext3/fsync.c
index 0bcf63adb80a..d494c554c6e6 100644
--- a/fs/ext3/fsync.c
+++ b/fs/ext3/fsync.c
@@ -30,6 +30,7 @@
30#include <linux/jbd.h> 30#include <linux/jbd.h>
31#include <linux/ext3_fs.h> 31#include <linux/ext3_fs.h>
32#include <linux/ext3_jbd.h> 32#include <linux/ext3_jbd.h>
33#include <trace/events/ext3.h>
33 34
34/* 35/*
35 * akpm: A new design for ext3_sync_file(). 36 * akpm: A new design for ext3_sync_file().
@@ -51,12 +52,14 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
51 int ret, needs_barrier = 0; 52 int ret, needs_barrier = 0;
52 tid_t commit_tid; 53 tid_t commit_tid;
53 54
55 trace_ext3_sync_file_enter(file, datasync);
56
54 if (inode->i_sb->s_flags & MS_RDONLY) 57 if (inode->i_sb->s_flags & MS_RDONLY)
55 return 0; 58 return 0;
56 59
57 ret = filemap_write_and_wait_range(inode->i_mapping, start, end); 60 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
58 if (ret) 61 if (ret)
59 return ret; 62 goto out;
60 63
61 /* 64 /*
62 * Taking the mutex here just to keep consistent with how fsync was 65 * Taking the mutex here just to keep consistent with how fsync was
@@ -83,7 +86,8 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
83 */ 86 */
84 if (ext3_should_journal_data(inode)) { 87 if (ext3_should_journal_data(inode)) {
85 mutex_unlock(&inode->i_mutex); 88 mutex_unlock(&inode->i_mutex);
86 return ext3_force_commit(inode->i_sb); 89 ret = ext3_force_commit(inode->i_sb);
90 goto out;
87 } 91 }
88 92
89 if (datasync) 93 if (datasync)
@@ -104,6 +108,9 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
104 */ 108 */
105 if (needs_barrier) 109 if (needs_barrier)
106 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); 110 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
111
107 mutex_unlock(&inode->i_mutex); 112 mutex_unlock(&inode->i_mutex);
113out:
114 trace_ext3_sync_file_exit(inode, ret);
108 return ret; 115 return ret;
109} 116}
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index bfc2dc43681d..bf09cbf938cc 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -23,6 +23,7 @@
23#include <linux/buffer_head.h> 23#include <linux/buffer_head.h>
24#include <linux/random.h> 24#include <linux/random.h>
25#include <linux/bitops.h> 25#include <linux/bitops.h>
26#include <trace/events/ext3.h>
26 27
27#include <asm/byteorder.h> 28#include <asm/byteorder.h>
28 29
@@ -118,6 +119,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
118 119
119 ino = inode->i_ino; 120 ino = inode->i_ino;
120 ext3_debug ("freeing inode %lu\n", ino); 121 ext3_debug ("freeing inode %lu\n", ino);
122 trace_ext3_free_inode(inode);
121 123
122 is_directory = S_ISDIR(inode->i_mode); 124 is_directory = S_ISDIR(inode->i_mode);
123 125
@@ -426,6 +428,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir,
426 return ERR_PTR(-EPERM); 428 return ERR_PTR(-EPERM);
427 429
428 sb = dir->i_sb; 430 sb = dir->i_sb;
431 trace_ext3_request_inode(dir, mode);
429 inode = new_inode(sb); 432 inode = new_inode(sb);
430 if (!inode) 433 if (!inode)
431 return ERR_PTR(-ENOMEM); 434 return ERR_PTR(-ENOMEM);
@@ -601,6 +604,7 @@ got:
601 } 604 }
602 605
603 ext3_debug("allocating inode %lu\n", inode->i_ino); 606 ext3_debug("allocating inode %lu\n", inode->i_ino);
607 trace_ext3_allocate_inode(inode, dir, mode);
604 goto really_out; 608 goto really_out;
605fail: 609fail:
606 ext3_std_error(sb, err); 610 ext3_std_error(sb, err);
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 2978a2a17a59..04da6acde85d 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -38,10 +38,12 @@
38#include <linux/bio.h> 38#include <linux/bio.h>
39#include <linux/fiemap.h> 39#include <linux/fiemap.h>
40#include <linux/namei.h> 40#include <linux/namei.h>
41#include <trace/events/ext3.h>
41#include "xattr.h" 42#include "xattr.h"
42#include "acl.h" 43#include "acl.h"
43 44
44static int ext3_writepage_trans_blocks(struct inode *inode); 45static int ext3_writepage_trans_blocks(struct inode *inode);
46static int ext3_block_truncate_page(struct inode *inode, loff_t from);
45 47
46/* 48/*
47 * Test whether an inode is a fast symlink. 49 * Test whether an inode is a fast symlink.
@@ -70,6 +72,7 @@ int ext3_forget(handle_t *handle, int is_metadata, struct inode *inode,
70 72
71 might_sleep(); 73 might_sleep();
72 74
75 trace_ext3_forget(inode, is_metadata, blocknr);
73 BUFFER_TRACE(bh, "enter"); 76 BUFFER_TRACE(bh, "enter");
74 77
75 jbd_debug(4, "forgetting bh %p: is_metadata = %d, mode %o, " 78 jbd_debug(4, "forgetting bh %p: is_metadata = %d, mode %o, "
@@ -194,20 +197,47 @@ static int truncate_restart_transaction(handle_t *handle, struct inode *inode)
194 */ 197 */
195void ext3_evict_inode (struct inode *inode) 198void ext3_evict_inode (struct inode *inode)
196{ 199{
200 struct ext3_inode_info *ei = EXT3_I(inode);
197 struct ext3_block_alloc_info *rsv; 201 struct ext3_block_alloc_info *rsv;
198 handle_t *handle; 202 handle_t *handle;
199 int want_delete = 0; 203 int want_delete = 0;
200 204
205 trace_ext3_evict_inode(inode);
201 if (!inode->i_nlink && !is_bad_inode(inode)) { 206 if (!inode->i_nlink && !is_bad_inode(inode)) {
202 dquot_initialize(inode); 207 dquot_initialize(inode);
203 want_delete = 1; 208 want_delete = 1;
204 } 209 }
205 210
211 /*
212 * When journalling data dirty buffers are tracked only in the journal.
213 * So although mm thinks everything is clean and ready for reaping the
214 * inode might still have some pages to write in the running
215 * transaction or waiting to be checkpointed. Thus calling
216 * journal_invalidatepage() (via truncate_inode_pages()) to discard
217 * these buffers can cause data loss. Also even if we did not discard
218 * these buffers, we would have no way to find them after the inode
219 * is reaped and thus user could see stale data if he tries to read
220 * them before the transaction is checkpointed. So be careful and
221 * force everything to disk here... We use ei->i_datasync_tid to
222 * store the newest transaction containing inode's data.
223 *
224 * Note that directories do not have this problem because they don't
225 * use page cache.
226 */
227 if (inode->i_nlink && ext3_should_journal_data(inode) &&
228 (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode))) {
229 tid_t commit_tid = atomic_read(&ei->i_datasync_tid);
230 journal_t *journal = EXT3_SB(inode->i_sb)->s_journal;
231
232 log_start_commit(journal, commit_tid);
233 log_wait_commit(journal, commit_tid);
234 filemap_write_and_wait(&inode->i_data);
235 }
206 truncate_inode_pages(&inode->i_data, 0); 236 truncate_inode_pages(&inode->i_data, 0);
207 237
208 ext3_discard_reservation(inode); 238 ext3_discard_reservation(inode);
209 rsv = EXT3_I(inode)->i_block_alloc_info; 239 rsv = ei->i_block_alloc_info;
210 EXT3_I(inode)->i_block_alloc_info = NULL; 240 ei->i_block_alloc_info = NULL;
211 if (unlikely(rsv)) 241 if (unlikely(rsv))
212 kfree(rsv); 242 kfree(rsv);
213 243
@@ -231,15 +261,13 @@ void ext3_evict_inode (struct inode *inode)
231 if (inode->i_blocks) 261 if (inode->i_blocks)
232 ext3_truncate(inode); 262 ext3_truncate(inode);
233 /* 263 /*
234 * Kill off the orphan record which ext3_truncate created. 264 * Kill off the orphan record created when the inode lost the last
235 * AKPM: I think this can be inside the above `if'. 265 * link. Note that ext3_orphan_del() has to be able to cope with the
236 * Note that ext3_orphan_del() has to be able to cope with the 266 * deletion of a non-existent orphan - ext3_truncate() could
237 * deletion of a non-existent orphan - this is because we don't 267 * have removed the record.
238 * know if ext3_truncate() actually created an orphan record.
239 * (Well, we could do this if we need to, but heck - it works)
240 */ 268 */
241 ext3_orphan_del(handle, inode); 269 ext3_orphan_del(handle, inode);
242 EXT3_I(inode)->i_dtime = get_seconds(); 270 ei->i_dtime = get_seconds();
243 271
244 /* 272 /*
245 * One subtle ordering requirement: if anything has gone wrong 273 * One subtle ordering requirement: if anything has gone wrong
@@ -842,6 +870,7 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
842 ext3_fsblk_t first_block = 0; 870 ext3_fsblk_t first_block = 0;
843 871
844 872
873 trace_ext3_get_blocks_enter(inode, iblock, maxblocks, create);
845 J_ASSERT(handle != NULL || create == 0); 874 J_ASSERT(handle != NULL || create == 0);
846 depth = ext3_block_to_path(inode,iblock,offsets,&blocks_to_boundary); 875 depth = ext3_block_to_path(inode,iblock,offsets,&blocks_to_boundary);
847 876
@@ -886,6 +915,9 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
886 if (!create || err == -EIO) 915 if (!create || err == -EIO)
887 goto cleanup; 916 goto cleanup;
888 917
918 /*
919 * Block out ext3_truncate while we alter the tree
920 */
889 mutex_lock(&ei->truncate_mutex); 921 mutex_lock(&ei->truncate_mutex);
890 922
891 /* 923 /*
@@ -934,9 +966,6 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
934 */ 966 */
935 count = ext3_blks_to_allocate(partial, indirect_blks, 967 count = ext3_blks_to_allocate(partial, indirect_blks,
936 maxblocks, blocks_to_boundary); 968 maxblocks, blocks_to_boundary);
937 /*
938 * Block out ext3_truncate while we alter the tree
939 */
940 err = ext3_alloc_branch(handle, inode, indirect_blks, &count, goal, 969 err = ext3_alloc_branch(handle, inode, indirect_blks, &count, goal,
941 offsets + (partial - chain), partial); 970 offsets + (partial - chain), partial);
942 971
@@ -970,6 +999,9 @@ cleanup:
970 } 999 }
971 BUFFER_TRACE(bh_result, "returned"); 1000 BUFFER_TRACE(bh_result, "returned");
972out: 1001out:
1002 trace_ext3_get_blocks_exit(inode, iblock,
1003 depth ? le32_to_cpu(chain[depth-1].key) : 0,
1004 count, err);
973 return err; 1005 return err;
974} 1006}
975 1007
@@ -1202,6 +1234,16 @@ static void ext3_truncate_failed_write(struct inode *inode)
1202 ext3_truncate(inode); 1234 ext3_truncate(inode);
1203} 1235}
1204 1236
1237/*
1238 * Truncate blocks that were not used by direct IO write. We have to zero out
1239 * the last file block as well because direct IO might have written to it.
1240 */
1241static void ext3_truncate_failed_direct_write(struct inode *inode)
1242{
1243 ext3_block_truncate_page(inode, inode->i_size);
1244 ext3_truncate(inode);
1245}
1246
1205static int ext3_write_begin(struct file *file, struct address_space *mapping, 1247static int ext3_write_begin(struct file *file, struct address_space *mapping,
1206 loff_t pos, unsigned len, unsigned flags, 1248 loff_t pos, unsigned len, unsigned flags,
1207 struct page **pagep, void **fsdata) 1249 struct page **pagep, void **fsdata)
@@ -1217,6 +1259,8 @@ static int ext3_write_begin(struct file *file, struct address_space *mapping,
1217 * we allocate blocks but write fails for some reason */ 1259 * we allocate blocks but write fails for some reason */
1218 int needed_blocks = ext3_writepage_trans_blocks(inode) + 1; 1260 int needed_blocks = ext3_writepage_trans_blocks(inode) + 1;
1219 1261
1262 trace_ext3_write_begin(inode, pos, len, flags);
1263
1220 index = pos >> PAGE_CACHE_SHIFT; 1264 index = pos >> PAGE_CACHE_SHIFT;
1221 from = pos & (PAGE_CACHE_SIZE - 1); 1265 from = pos & (PAGE_CACHE_SIZE - 1);
1222 to = from + len; 1266 to = from + len;
@@ -1332,6 +1376,7 @@ static int ext3_ordered_write_end(struct file *file,
1332 unsigned from, to; 1376 unsigned from, to;
1333 int ret = 0, ret2; 1377 int ret = 0, ret2;
1334 1378
1379 trace_ext3_ordered_write_end(inode, pos, len, copied);
1335 copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); 1380 copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
1336 1381
1337 from = pos & (PAGE_CACHE_SIZE - 1); 1382 from = pos & (PAGE_CACHE_SIZE - 1);
@@ -1367,6 +1412,7 @@ static int ext3_writeback_write_end(struct file *file,
1367 struct inode *inode = file->f_mapping->host; 1412 struct inode *inode = file->f_mapping->host;
1368 int ret; 1413 int ret;
1369 1414
1415 trace_ext3_writeback_write_end(inode, pos, len, copied);
1370 copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); 1416 copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
1371 update_file_sizes(inode, pos, copied); 1417 update_file_sizes(inode, pos, copied);
1372 /* 1418 /*
@@ -1391,10 +1437,12 @@ static int ext3_journalled_write_end(struct file *file,
1391{ 1437{
1392 handle_t *handle = ext3_journal_current_handle(); 1438 handle_t *handle = ext3_journal_current_handle();
1393 struct inode *inode = mapping->host; 1439 struct inode *inode = mapping->host;
1440 struct ext3_inode_info *ei = EXT3_I(inode);
1394 int ret = 0, ret2; 1441 int ret = 0, ret2;
1395 int partial = 0; 1442 int partial = 0;
1396 unsigned from, to; 1443 unsigned from, to;
1397 1444
1445 trace_ext3_journalled_write_end(inode, pos, len, copied);
1398 from = pos & (PAGE_CACHE_SIZE - 1); 1446 from = pos & (PAGE_CACHE_SIZE - 1);
1399 to = from + len; 1447 to = from + len;
1400 1448
@@ -1419,8 +1467,9 @@ static int ext3_journalled_write_end(struct file *file,
1419 if (pos + len > inode->i_size && ext3_can_truncate(inode)) 1467 if (pos + len > inode->i_size && ext3_can_truncate(inode))
1420 ext3_orphan_add(handle, inode); 1468 ext3_orphan_add(handle, inode);
1421 ext3_set_inode_state(inode, EXT3_STATE_JDATA); 1469 ext3_set_inode_state(inode, EXT3_STATE_JDATA);
1422 if (inode->i_size > EXT3_I(inode)->i_disksize) { 1470 atomic_set(&ei->i_datasync_tid, handle->h_transaction->t_tid);
1423 EXT3_I(inode)->i_disksize = inode->i_size; 1471 if (inode->i_size > ei->i_disksize) {
1472 ei->i_disksize = inode->i_size;
1424 ret2 = ext3_mark_inode_dirty(handle, inode); 1473 ret2 = ext3_mark_inode_dirty(handle, inode);
1425 if (!ret) 1474 if (!ret)
1426 ret = ret2; 1475 ret = ret2;
@@ -1577,6 +1626,7 @@ static int ext3_ordered_writepage(struct page *page,
1577 if (ext3_journal_current_handle()) 1626 if (ext3_journal_current_handle())
1578 goto out_fail; 1627 goto out_fail;
1579 1628
1629 trace_ext3_ordered_writepage(page);
1580 if (!page_has_buffers(page)) { 1630 if (!page_has_buffers(page)) {
1581 create_empty_buffers(page, inode->i_sb->s_blocksize, 1631 create_empty_buffers(page, inode->i_sb->s_blocksize,
1582 (1 << BH_Dirty)|(1 << BH_Uptodate)); 1632 (1 << BH_Dirty)|(1 << BH_Uptodate));
@@ -1647,6 +1697,7 @@ static int ext3_writeback_writepage(struct page *page,
1647 if (ext3_journal_current_handle()) 1697 if (ext3_journal_current_handle())
1648 goto out_fail; 1698 goto out_fail;
1649 1699
1700 trace_ext3_writeback_writepage(page);
1650 if (page_has_buffers(page)) { 1701 if (page_has_buffers(page)) {
1651 if (!walk_page_buffers(NULL, page_buffers(page), 0, 1702 if (!walk_page_buffers(NULL, page_buffers(page), 0,
1652 PAGE_CACHE_SIZE, NULL, buffer_unmapped)) { 1703 PAGE_CACHE_SIZE, NULL, buffer_unmapped)) {
@@ -1689,6 +1740,7 @@ static int ext3_journalled_writepage(struct page *page,
1689 if (ext3_journal_current_handle()) 1740 if (ext3_journal_current_handle())
1690 goto no_write; 1741 goto no_write;
1691 1742
1743 trace_ext3_journalled_writepage(page);
1692 handle = ext3_journal_start(inode, ext3_writepage_trans_blocks(inode)); 1744 handle = ext3_journal_start(inode, ext3_writepage_trans_blocks(inode));
1693 if (IS_ERR(handle)) { 1745 if (IS_ERR(handle)) {
1694 ret = PTR_ERR(handle); 1746 ret = PTR_ERR(handle);
@@ -1715,6 +1767,8 @@ static int ext3_journalled_writepage(struct page *page,
1715 if (ret == 0) 1767 if (ret == 0)
1716 ret = err; 1768 ret = err;
1717 ext3_set_inode_state(inode, EXT3_STATE_JDATA); 1769 ext3_set_inode_state(inode, EXT3_STATE_JDATA);
1770 atomic_set(&EXT3_I(inode)->i_datasync_tid,
1771 handle->h_transaction->t_tid);
1718 unlock_page(page); 1772 unlock_page(page);
1719 } else { 1773 } else {
1720 /* 1774 /*
@@ -1739,6 +1793,7 @@ out_unlock:
1739 1793
1740static int ext3_readpage(struct file *file, struct page *page) 1794static int ext3_readpage(struct file *file, struct page *page)
1741{ 1795{
1796 trace_ext3_readpage(page);
1742 return mpage_readpage(page, ext3_get_block); 1797 return mpage_readpage(page, ext3_get_block);
1743} 1798}
1744 1799
@@ -1753,6 +1808,8 @@ static void ext3_invalidatepage(struct page *page, unsigned long offset)
1753{ 1808{
1754 journal_t *journal = EXT3_JOURNAL(page->mapping->host); 1809 journal_t *journal = EXT3_JOURNAL(page->mapping->host);
1755 1810
1811 trace_ext3_invalidatepage(page, offset);
1812
1756 /* 1813 /*
1757 * If it's a full truncate we just forget about the pending dirtying 1814 * If it's a full truncate we just forget about the pending dirtying
1758 */ 1815 */
@@ -1766,6 +1823,7 @@ static int ext3_releasepage(struct page *page, gfp_t wait)
1766{ 1823{
1767 journal_t *journal = EXT3_JOURNAL(page->mapping->host); 1824 journal_t *journal = EXT3_JOURNAL(page->mapping->host);
1768 1825
1826 trace_ext3_releasepage(page);
1769 WARN_ON(PageChecked(page)); 1827 WARN_ON(PageChecked(page));
1770 if (!page_has_buffers(page)) 1828 if (!page_has_buffers(page))
1771 return 0; 1829 return 0;
@@ -1794,6 +1852,8 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
1794 size_t count = iov_length(iov, nr_segs); 1852 size_t count = iov_length(iov, nr_segs);
1795 int retries = 0; 1853 int retries = 0;
1796 1854
1855 trace_ext3_direct_IO_enter(inode, offset, iov_length(iov, nr_segs), rw);
1856
1797 if (rw == WRITE) { 1857 if (rw == WRITE) {
1798 loff_t final_size = offset + count; 1858 loff_t final_size = offset + count;
1799 1859
@@ -1827,7 +1887,7 @@ retry:
1827 loff_t end = offset + iov_length(iov, nr_segs); 1887 loff_t end = offset + iov_length(iov, nr_segs);
1828 1888
1829 if (end > isize) 1889 if (end > isize)
1830 vmtruncate(inode, isize); 1890 ext3_truncate_failed_direct_write(inode);
1831 } 1891 }
1832 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) 1892 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
1833 goto retry; 1893 goto retry;
@@ -1841,7 +1901,7 @@ retry:
1841 /* This is really bad luck. We've written the data 1901 /* This is really bad luck. We've written the data
1842 * but cannot extend i_size. Truncate allocated blocks 1902 * but cannot extend i_size. Truncate allocated blocks
1843 * and pretend the write failed... */ 1903 * and pretend the write failed... */
1844 ext3_truncate(inode); 1904 ext3_truncate_failed_direct_write(inode);
1845 ret = PTR_ERR(handle); 1905 ret = PTR_ERR(handle);
1846 goto out; 1906 goto out;
1847 } 1907 }
@@ -1867,6 +1927,8 @@ retry:
1867 ret = err; 1927 ret = err;
1868 } 1928 }
1869out: 1929out:
1930 trace_ext3_direct_IO_exit(inode, offset,
1931 iov_length(iov, nr_segs), rw, ret);
1870 return ret; 1932 return ret;
1871} 1933}
1872 1934
@@ -1949,17 +2011,24 @@ void ext3_set_aops(struct inode *inode)
1949 * This required during truncate. We need to physically zero the tail end 2011 * This required during truncate. We need to physically zero the tail end
1950 * of that block so it doesn't yield old data if the file is later grown. 2012 * of that block so it doesn't yield old data if the file is later grown.
1951 */ 2013 */
1952static int ext3_block_truncate_page(handle_t *handle, struct page *page, 2014static int ext3_block_truncate_page(struct inode *inode, loff_t from)
1953 struct address_space *mapping, loff_t from)
1954{ 2015{
1955 ext3_fsblk_t index = from >> PAGE_CACHE_SHIFT; 2016 ext3_fsblk_t index = from >> PAGE_CACHE_SHIFT;
1956 unsigned offset = from & (PAGE_CACHE_SIZE-1); 2017 unsigned offset = from & (PAGE_CACHE_SIZE - 1);
1957 unsigned blocksize, iblock, length, pos; 2018 unsigned blocksize, iblock, length, pos;
1958 struct inode *inode = mapping->host; 2019 struct page *page;
2020 handle_t *handle = NULL;
1959 struct buffer_head *bh; 2021 struct buffer_head *bh;
1960 int err = 0; 2022 int err = 0;
1961 2023
2024 /* Truncated on block boundary - nothing to do */
1962 blocksize = inode->i_sb->s_blocksize; 2025 blocksize = inode->i_sb->s_blocksize;
2026 if ((from & (blocksize - 1)) == 0)
2027 return 0;
2028
2029 page = grab_cache_page(inode->i_mapping, index);
2030 if (!page)
2031 return -ENOMEM;
1963 length = blocksize - (offset & (blocksize - 1)); 2032 length = blocksize - (offset & (blocksize - 1));
1964 iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits); 2033 iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
1965 2034
@@ -2004,11 +2073,23 @@ static int ext3_block_truncate_page(handle_t *handle, struct page *page,
2004 goto unlock; 2073 goto unlock;
2005 } 2074 }
2006 2075
2076 /* data=writeback mode doesn't need transaction to zero-out data */
2077 if (!ext3_should_writeback_data(inode)) {
2078 /* We journal at most one block */
2079 handle = ext3_journal_start(inode, 1);
2080 if (IS_ERR(handle)) {
2081 clear_highpage(page);
2082 flush_dcache_page(page);
2083 err = PTR_ERR(handle);
2084 goto unlock;
2085 }
2086 }
2087
2007 if (ext3_should_journal_data(inode)) { 2088 if (ext3_should_journal_data(inode)) {
2008 BUFFER_TRACE(bh, "get write access"); 2089 BUFFER_TRACE(bh, "get write access");
2009 err = ext3_journal_get_write_access(handle, bh); 2090 err = ext3_journal_get_write_access(handle, bh);
2010 if (err) 2091 if (err)
2011 goto unlock; 2092 goto stop;
2012 } 2093 }
2013 2094
2014 zero_user(page, offset, length); 2095 zero_user(page, offset, length);
@@ -2022,6 +2103,9 @@ static int ext3_block_truncate_page(handle_t *handle, struct page *page,
2022 err = ext3_journal_dirty_data(handle, bh); 2103 err = ext3_journal_dirty_data(handle, bh);
2023 mark_buffer_dirty(bh); 2104 mark_buffer_dirty(bh);
2024 } 2105 }
2106stop:
2107 if (handle)
2108 ext3_journal_stop(handle);
2025 2109
2026unlock: 2110unlock:
2027 unlock_page(page); 2111 unlock_page(page);
@@ -2390,8 +2474,6 @@ static void ext3_free_branches(handle_t *handle, struct inode *inode,
2390 2474
2391int ext3_can_truncate(struct inode *inode) 2475int ext3_can_truncate(struct inode *inode)
2392{ 2476{
2393 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2394 return 0;
2395 if (S_ISREG(inode->i_mode)) 2477 if (S_ISREG(inode->i_mode))
2396 return 1; 2478 return 1;
2397 if (S_ISDIR(inode->i_mode)) 2479 if (S_ISDIR(inode->i_mode))
@@ -2435,7 +2517,6 @@ void ext3_truncate(struct inode *inode)
2435 struct ext3_inode_info *ei = EXT3_I(inode); 2517 struct ext3_inode_info *ei = EXT3_I(inode);
2436 __le32 *i_data = ei->i_data; 2518 __le32 *i_data = ei->i_data;
2437 int addr_per_block = EXT3_ADDR_PER_BLOCK(inode->i_sb); 2519 int addr_per_block = EXT3_ADDR_PER_BLOCK(inode->i_sb);
2438 struct address_space *mapping = inode->i_mapping;
2439 int offsets[4]; 2520 int offsets[4];
2440 Indirect chain[4]; 2521 Indirect chain[4];
2441 Indirect *partial; 2522 Indirect *partial;
@@ -2443,7 +2524,8 @@ void ext3_truncate(struct inode *inode)
2443 int n; 2524 int n;
2444 long last_block; 2525 long last_block;
2445 unsigned blocksize = inode->i_sb->s_blocksize; 2526 unsigned blocksize = inode->i_sb->s_blocksize;
2446 struct page *page; 2527
2528 trace_ext3_truncate_enter(inode);
2447 2529
2448 if (!ext3_can_truncate(inode)) 2530 if (!ext3_can_truncate(inode))
2449 goto out_notrans; 2531 goto out_notrans;
@@ -2451,37 +2533,12 @@ void ext3_truncate(struct inode *inode)
2451 if (inode->i_size == 0 && ext3_should_writeback_data(inode)) 2533 if (inode->i_size == 0 && ext3_should_writeback_data(inode))
2452 ext3_set_inode_state(inode, EXT3_STATE_FLUSH_ON_CLOSE); 2534 ext3_set_inode_state(inode, EXT3_STATE_FLUSH_ON_CLOSE);
2453 2535
2454 /*
2455 * We have to lock the EOF page here, because lock_page() nests
2456 * outside journal_start().
2457 */
2458 if ((inode->i_size & (blocksize - 1)) == 0) {
2459 /* Block boundary? Nothing to do */
2460 page = NULL;
2461 } else {
2462 page = grab_cache_page(mapping,
2463 inode->i_size >> PAGE_CACHE_SHIFT);
2464 if (!page)
2465 goto out_notrans;
2466 }
2467
2468 handle = start_transaction(inode); 2536 handle = start_transaction(inode);
2469 if (IS_ERR(handle)) { 2537 if (IS_ERR(handle))
2470 if (page) {
2471 clear_highpage(page);
2472 flush_dcache_page(page);
2473 unlock_page(page);
2474 page_cache_release(page);
2475 }
2476 goto out_notrans; 2538 goto out_notrans;
2477 }
2478 2539
2479 last_block = (inode->i_size + blocksize-1) 2540 last_block = (inode->i_size + blocksize-1)
2480 >> EXT3_BLOCK_SIZE_BITS(inode->i_sb); 2541 >> EXT3_BLOCK_SIZE_BITS(inode->i_sb);
2481
2482 if (page)
2483 ext3_block_truncate_page(handle, page, mapping, inode->i_size);
2484
2485 n = ext3_block_to_path(inode, last_block, offsets, NULL); 2542 n = ext3_block_to_path(inode, last_block, offsets, NULL);
2486 if (n == 0) 2543 if (n == 0)
2487 goto out_stop; /* error */ 2544 goto out_stop; /* error */
@@ -2596,6 +2653,7 @@ out_stop:
2596 ext3_orphan_del(handle, inode); 2653 ext3_orphan_del(handle, inode);
2597 2654
2598 ext3_journal_stop(handle); 2655 ext3_journal_stop(handle);
2656 trace_ext3_truncate_exit(inode);
2599 return; 2657 return;
2600out_notrans: 2658out_notrans:
2601 /* 2659 /*
@@ -2604,6 +2662,7 @@ out_notrans:
2604 */ 2662 */
2605 if (inode->i_nlink) 2663 if (inode->i_nlink)
2606 ext3_orphan_del(NULL, inode); 2664 ext3_orphan_del(NULL, inode);
2665 trace_ext3_truncate_exit(inode);
2607} 2666}
2608 2667
2609static ext3_fsblk_t ext3_get_inode_block(struct super_block *sb, 2668static ext3_fsblk_t ext3_get_inode_block(struct super_block *sb,
@@ -2745,6 +2804,7 @@ make_io:
2745 * has in-inode xattrs, or we don't have this inode in memory. 2804 * has in-inode xattrs, or we don't have this inode in memory.
2746 * Read the block from disk. 2805 * Read the block from disk.
2747 */ 2806 */
2807 trace_ext3_load_inode(inode);
2748 get_bh(bh); 2808 get_bh(bh);
2749 bh->b_end_io = end_buffer_read_sync; 2809 bh->b_end_io = end_buffer_read_sync;
2750 submit_bh(READ_META, bh); 2810 submit_bh(READ_META, bh);
@@ -3229,18 +3289,36 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
3229 } 3289 }
3230 3290
3231 error = ext3_orphan_add(handle, inode); 3291 error = ext3_orphan_add(handle, inode);
3292 if (error) {
3293 ext3_journal_stop(handle);
3294 goto err_out;
3295 }
3232 EXT3_I(inode)->i_disksize = attr->ia_size; 3296 EXT3_I(inode)->i_disksize = attr->ia_size;
3233 rc = ext3_mark_inode_dirty(handle, inode); 3297 error = ext3_mark_inode_dirty(handle, inode);
3234 if (!error)
3235 error = rc;
3236 ext3_journal_stop(handle); 3298 ext3_journal_stop(handle);
3299 if (error) {
3300 /* Some hard fs error must have happened. Bail out. */
3301 ext3_orphan_del(NULL, inode);
3302 goto err_out;
3303 }
3304 rc = ext3_block_truncate_page(inode, attr->ia_size);
3305 if (rc) {
3306 /* Cleanup orphan list and exit */
3307 handle = ext3_journal_start(inode, 3);
3308 if (IS_ERR(handle)) {
3309 ext3_orphan_del(NULL, inode);
3310 goto err_out;
3311 }
3312 ext3_orphan_del(handle, inode);
3313 ext3_journal_stop(handle);
3314 goto err_out;
3315 }
3237 } 3316 }
3238 3317
3239 if ((attr->ia_valid & ATTR_SIZE) && 3318 if ((attr->ia_valid & ATTR_SIZE) &&
3240 attr->ia_size != i_size_read(inode)) { 3319 attr->ia_size != i_size_read(inode)) {
3241 rc = vmtruncate(inode, attr->ia_size); 3320 truncate_setsize(inode, attr->ia_size);
3242 if (rc) 3321 ext3_truncate(inode);
3243 goto err_out;
3244 } 3322 }
3245 3323
3246 setattr_copy(inode, attr); 3324 setattr_copy(inode, attr);
@@ -3374,6 +3452,7 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode)
3374 int err; 3452 int err;
3375 3453
3376 might_sleep(); 3454 might_sleep();
3455 trace_ext3_mark_inode_dirty(inode, _RET_IP_);
3377 err = ext3_reserve_inode_write(handle, inode, &iloc); 3456 err = ext3_reserve_inode_write(handle, inode, &iloc);
3378 if (!err) 3457 if (!err)
3379 err = ext3_mark_iloc_dirty(handle, inode, &iloc); 3458 err = ext3_mark_iloc_dirty(handle, inode, &iloc);
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
index f4090bd2f345..c7f43944f160 100644
--- a/fs/ext3/ioctl.c
+++ b/fs/ext3/ioctl.c
@@ -285,7 +285,7 @@ group_add_out:
285 if (!capable(CAP_SYS_ADMIN)) 285 if (!capable(CAP_SYS_ADMIN))
286 return -EPERM; 286 return -EPERM;
287 287
288 if (copy_from_user(&range, (struct fstrim_range *)arg, 288 if (copy_from_user(&range, (struct fstrim_range __user *)arg,
289 sizeof(range))) 289 sizeof(range)))
290 return -EFAULT; 290 return -EFAULT;
291 291
@@ -293,7 +293,7 @@ group_add_out:
293 if (ret < 0) 293 if (ret < 0)
294 return ret; 294 return ret;
295 295
296 if (copy_to_user((struct fstrim_range *)arg, &range, 296 if (copy_to_user((struct fstrim_range __user *)arg, &range,
297 sizeof(range))) 297 sizeof(range)))
298 return -EFAULT; 298 return -EFAULT;
299 299
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 3b57230a17bb..6e18a0b7750d 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -36,6 +36,7 @@
36#include <linux/quotaops.h> 36#include <linux/quotaops.h>
37#include <linux/buffer_head.h> 37#include <linux/buffer_head.h>
38#include <linux/bio.h> 38#include <linux/bio.h>
39#include <trace/events/ext3.h>
39 40
40#include "namei.h" 41#include "namei.h"
41#include "xattr.h" 42#include "xattr.h"
@@ -287,7 +288,7 @@ static struct stats dx_show_leaf(struct dx_hash_info *hinfo, struct ext3_dir_ent
287 while (len--) printk("%c", *name++); 288 while (len--) printk("%c", *name++);
288 ext3fs_dirhash(de->name, de->name_len, &h); 289 ext3fs_dirhash(de->name, de->name_len, &h);
289 printk(":%x.%u ", h.hash, 290 printk(":%x.%u ", h.hash,
290 ((char *) de - base)); 291 (unsigned) ((char *) de - base));
291 } 292 }
292 space += EXT3_DIR_REC_LEN(de->name_len); 293 space += EXT3_DIR_REC_LEN(de->name_len);
293 names++; 294 names++;
@@ -1013,7 +1014,7 @@ static struct buffer_head * ext3_dx_find_entry(struct inode *dir,
1013 1014
1014 *err = -ENOENT; 1015 *err = -ENOENT;
1015errout: 1016errout:
1016 dxtrace(printk("%s not found\n", name)); 1017 dxtrace(printk("%s not found\n", entry->name));
1017 dx_release (frames); 1018 dx_release (frames);
1018 return NULL; 1019 return NULL;
1019} 1020}
@@ -2140,6 +2141,7 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry)
2140 struct ext3_dir_entry_2 * de; 2141 struct ext3_dir_entry_2 * de;
2141 handle_t *handle; 2142 handle_t *handle;
2142 2143
2144 trace_ext3_unlink_enter(dir, dentry);
2143 /* Initialize quotas before so that eventual writes go 2145 /* Initialize quotas before so that eventual writes go
2144 * in separate transaction */ 2146 * in separate transaction */
2145 dquot_initialize(dir); 2147 dquot_initialize(dir);
@@ -2185,6 +2187,7 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry)
2185end_unlink: 2187end_unlink:
2186 ext3_journal_stop(handle); 2188 ext3_journal_stop(handle);
2187 brelse (bh); 2189 brelse (bh);
2190 trace_ext3_unlink_exit(dentry, retval);
2188 return retval; 2191 return retval;
2189} 2192}
2190 2193
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index b57ea2f91269..7beb69ae0015 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -44,6 +44,9 @@
44#include "acl.h" 44#include "acl.h"
45#include "namei.h" 45#include "namei.h"
46 46
47#define CREATE_TRACE_POINTS
48#include <trace/events/ext3.h>
49
47#ifdef CONFIG_EXT3_DEFAULTS_TO_ORDERED 50#ifdef CONFIG_EXT3_DEFAULTS_TO_ORDERED
48 #define EXT3_MOUNT_DEFAULT_DATA_MODE EXT3_MOUNT_ORDERED_DATA 51 #define EXT3_MOUNT_DEFAULT_DATA_MODE EXT3_MOUNT_ORDERED_DATA
49#else 52#else
@@ -497,6 +500,14 @@ static struct inode *ext3_alloc_inode(struct super_block *sb)
497 return &ei->vfs_inode; 500 return &ei->vfs_inode;
498} 501}
499 502
503static int ext3_drop_inode(struct inode *inode)
504{
505 int drop = generic_drop_inode(inode);
506
507 trace_ext3_drop_inode(inode, drop);
508 return drop;
509}
510
500static void ext3_i_callback(struct rcu_head *head) 511static void ext3_i_callback(struct rcu_head *head)
501{ 512{
502 struct inode *inode = container_of(head, struct inode, i_rcu); 513 struct inode *inode = container_of(head, struct inode, i_rcu);
@@ -788,6 +799,7 @@ static const struct super_operations ext3_sops = {
788 .destroy_inode = ext3_destroy_inode, 799 .destroy_inode = ext3_destroy_inode,
789 .write_inode = ext3_write_inode, 800 .write_inode = ext3_write_inode,
790 .dirty_inode = ext3_dirty_inode, 801 .dirty_inode = ext3_dirty_inode,
802 .drop_inode = ext3_drop_inode,
791 .evict_inode = ext3_evict_inode, 803 .evict_inode = ext3_evict_inode,
792 .put_super = ext3_put_super, 804 .put_super = ext3_put_super,
793 .sync_fs = ext3_sync_fs, 805 .sync_fs = ext3_sync_fs,
@@ -2509,6 +2521,7 @@ static int ext3_sync_fs(struct super_block *sb, int wait)
2509{ 2521{
2510 tid_t target; 2522 tid_t target;
2511 2523
2524 trace_ext3_sync_fs(sb, wait);
2512 if (journal_start_commit(EXT3_SB(sb)->s_journal, &target)) { 2525 if (journal_start_commit(EXT3_SB(sb)->s_journal, &target)) {
2513 if (wait) 2526 if (wait)
2514 log_wait_commit(EXT3_SB(sb)->s_journal, target); 2527 log_wait_commit(EXT3_SB(sb)->s_journal, target);
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index 32e6cc23bd9a..d565759d82ee 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -803,8 +803,16 @@ inserted:
803 /* We need to allocate a new block */ 803 /* We need to allocate a new block */
804 ext3_fsblk_t goal = ext3_group_first_block_no(sb, 804 ext3_fsblk_t goal = ext3_group_first_block_no(sb,
805 EXT3_I(inode)->i_block_group); 805 EXT3_I(inode)->i_block_group);
806 ext3_fsblk_t block = ext3_new_block(handle, inode, 806 ext3_fsblk_t block;
807 goal, &error); 807
808 /*
809 * Protect us agaist concurrent allocations to the
810 * same inode from ext3_..._writepage(). Reservation
811 * code does not expect racing allocations.
812 */
813 mutex_lock(&EXT3_I(inode)->truncate_mutex);
814 block = ext3_new_block(handle, inode, goal, &error);
815 mutex_unlock(&EXT3_I(inode)->truncate_mutex);
808 if (error) 816 if (error)
809 goto cleanup; 817 goto cleanup;
810 ea_idebug(inode, "creating block %d", block); 818 ea_idebug(inode, "creating block %d", block);