Skip to content

Commit

Permalink
ext3: Add fixed tracepoints
Browse files Browse the repository at this point in the history
This commit adds fixed tracepoints to the ext3 code. It is based on ext4
tracepoints, however due to the differences of both file systems, there
are some tracepoints missing (those for delaloc and for multi-block
allocator) and there are some ext3 specific as well (for reservation
windows).

Here is a list:

ext3_free_inode
ext3_request_inode
ext3_allocate_inode
ext3_evict_inode
ext3_drop_inode
ext3_mark_inode_dirty
ext3_write_begin
ext3_ordered_write_end
ext3_writeback_write_end
ext3_journalled_write_end
ext3_ordered_writepage
ext3_writeback_writepage
ext3_journalled_writepage
ext3_readpage
ext3_releasepage
ext3_invalidatepage
ext3_discard_blocks
ext3_request_blocks
ext3_allocate_blocks
ext3_free_blocks
ext3_sync_file_enter
ext3_sync_file_exit
ext3_sync_fs
ext3_rsv_window_add
ext3_discard_reservation
ext3_alloc_new_reservation
ext3_reserved
ext3_forget
ext3_read_block_bitmap
ext3_direct_IO_enter
ext3_direct_IO_exit
ext3_unlink_enter
ext3_unlink_exit
ext3_truncate_enter
ext3_truncate_exit
ext3_get_blocks_enter
ext3_get_blocks_exit
ext3_load_inode

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
  • Loading branch information
Lukas Czerner authored and Jan Kara committed Jun 25, 2011
1 parent 5220cc9 commit 785c4bc
Show file tree
Hide file tree
Showing 7 changed files with 946 additions and 16 deletions.
34 changes: 21 additions & 13 deletions fs/ext3/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/quotaops.h>
#include <linux/buffer_head.h>
#include <linux/blkdev.h>
#include <trace/events/ext3.h>

/*
* balloc.c contains the blocks allocation and deallocation routines
Expand Down Expand Up @@ -161,6 +162,7 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group)
desc = ext3_get_group_desc(sb, block_group, NULL);
if (!desc)
return NULL;
trace_ext3_read_block_bitmap(sb, block_group);
bitmap_blk = le32_to_cpu(desc->bg_block_bitmap);
bh = sb_getblk(sb, bitmap_blk);
if (unlikely(!bh)) {
Expand Down Expand Up @@ -351,6 +353,7 @@ void ext3_rsv_window_add(struct super_block *sb,
struct rb_node * parent = NULL;
struct ext3_reserve_window_node *this;

trace_ext3_rsv_window_add(sb, rsv);
while (*p)
{
parent = *p;
Expand Down Expand Up @@ -476,8 +479,10 @@ void ext3_discard_reservation(struct inode *inode)
rsv = &block_i->rsv_window_node;
if (!rsv_is_empty(&rsv->rsv_window)) {
spin_lock(rsv_lock);
if (!rsv_is_empty(&rsv->rsv_window))
if (!rsv_is_empty(&rsv->rsv_window)) {
trace_ext3_discard_reservation(inode, rsv);
rsv_window_remove(inode->i_sb, rsv);
}
spin_unlock(rsv_lock);
}
}
Expand Down Expand Up @@ -683,14 +688,10 @@ void ext3_free_blocks_sb(handle_t *handle, struct super_block *sb,
void ext3_free_blocks(handle_t *handle, struct inode *inode,
ext3_fsblk_t block, unsigned long count)
{
struct super_block * sb;
struct super_block *sb = inode->i_sb;
unsigned long dquot_freed_blocks;

sb = inode->i_sb;
if (!sb) {
printk ("ext3_free_blocks: nonexistent device");
return;
}
trace_ext3_free_blocks(inode, block, count);
ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
if (dquot_freed_blocks)
dquot_free_block(inode, dquot_freed_blocks);
Expand Down Expand Up @@ -1136,6 +1137,7 @@ static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv,
else
start_block = grp_goal + group_first_block;

trace_ext3_alloc_new_reservation(sb, start_block);
size = my_rsv->rsv_goal_size;

if (!rsv_is_empty(&my_rsv->rsv_window)) {
Expand Down Expand Up @@ -1230,8 +1232,11 @@ static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv,
* check if the first free block is within the
* free space we just reserved
*/
if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end)
if (start_block >= my_rsv->rsv_start &&
start_block <= my_rsv->rsv_end) {
trace_ext3_reserved(sb, start_block, my_rsv);
return 0; /* success */
}
/*
* if the first free bit we found is out of the reservable space
* continue search for next reservable space,
Expand Down Expand Up @@ -1514,10 +1519,6 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,

*errp = -ENOSPC;
sb = inode->i_sb;
if (!sb) {
printk("ext3_new_block: nonexistent device");
return 0;
}

/*
* Check quota for allocation of this block.
Expand All @@ -1528,8 +1529,10 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
return 0;
}

trace_ext3_request_blocks(inode, goal, num);

sbi = EXT3_SB(sb);
es = EXT3_SB(sb)->s_es;
es = sbi->s_es;
ext3_debug("goal=%lu.\n", goal);
/*
* Allocate a block from reservation only when
Expand Down Expand Up @@ -1742,6 +1745,10 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
brelse(bitmap_bh);
dquot_free_block(inode, *count-num);
*count = num;

trace_ext3_allocate_blocks(inode, goal, num,
(unsigned long long)ret_block);

return ret_block;

io_error:
Expand Down Expand Up @@ -1996,6 +2003,7 @@ ext3_grpblk_t ext3_trim_all_free(struct super_block *sb, unsigned int group,
if ((next - start) < minblocks)
goto free_extent;

trace_ext3_discard_blocks(sb, discard_block, next - start);
/* Send the TRIM command down to the device */
err = sb_issue_discard(sb, discard_block, next - start,
GFP_NOFS, 0);
Expand Down
15 changes: 12 additions & 3 deletions fs/ext3/fsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/jbd.h>
#include <linux/ext3_fs.h>
#include <linux/ext3_jbd.h>
#include <trace/events/ext3.h>

/*
* akpm: A new design for ext3_sync_file().
Expand All @@ -51,10 +52,13 @@ int ext3_sync_file(struct file *file, int datasync)
int ret, needs_barrier = 0;
tid_t commit_tid;

J_ASSERT(ext3_journal_current_handle() == NULL);

trace_ext3_sync_file_enter(file, datasync);

if (inode->i_sb->s_flags & MS_RDONLY)
return 0;

J_ASSERT(ext3_journal_current_handle() == NULL);

/*
* data=writeback,ordered:
Expand All @@ -70,8 +74,10 @@ int ext3_sync_file(struct file *file, int datasync)
* (they were dirtied by commit). But that's OK - the blocks are
* safe in-journal, which is all fsync() needs to ensure.
*/
if (ext3_should_journal_data(inode))
return ext3_force_commit(inode->i_sb);
if (ext3_should_journal_data(inode)) {
ret = ext3_force_commit(inode->i_sb);
goto out;
}

if (datasync)
commit_tid = atomic_read(&ei->i_datasync_tid);
Expand All @@ -91,5 +97,8 @@ int ext3_sync_file(struct file *file, int datasync)
*/
if (needs_barrier)
blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);

out:
trace_ext3_sync_file_exit(inode, ret);
return ret;
}
4 changes: 4 additions & 0 deletions fs/ext3/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/buffer_head.h>
#include <linux/random.h>
#include <linux/bitops.h>
#include <trace/events/ext3.h>

#include <asm/byteorder.h>

Expand Down Expand Up @@ -118,6 +119,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)

ino = inode->i_ino;
ext3_debug ("freeing inode %lu\n", ino);
trace_ext3_free_inode(inode);

is_directory = S_ISDIR(inode->i_mode);

Expand Down Expand Up @@ -426,6 +428,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir,
return ERR_PTR(-EPERM);

sb = dir->i_sb;
trace_ext3_request_inode(dir, mode);
inode = new_inode(sb);
if (!inode)
return ERR_PTR(-ENOMEM);
Expand Down Expand Up @@ -601,6 +604,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir,
}

ext3_debug("allocating inode %lu\n", inode->i_ino);
trace_ext3_allocate_inode(inode, dir, mode);
goto really_out;
fail:
ext3_std_error(sb, err);
Expand Down
29 changes: 29 additions & 0 deletions fs/ext3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <linux/bio.h>
#include <linux/fiemap.h>
#include <linux/namei.h>
#include <trace/events/ext3.h>
#include "xattr.h"
#include "acl.h"

Expand Down Expand Up @@ -70,6 +71,7 @@ int ext3_forget(handle_t *handle, int is_metadata, struct inode *inode,

might_sleep();

trace_ext3_forget(inode, is_metadata, blocknr);
BUFFER_TRACE(bh, "enter");

jbd_debug(4, "forgetting bh %p: is_metadata = %d, mode %o, "
Expand Down Expand Up @@ -198,6 +200,7 @@ void ext3_evict_inode (struct inode *inode)
handle_t *handle;
int want_delete = 0;

trace_ext3_evict_inode(inode);
if (!inode->i_nlink && !is_bad_inode(inode)) {
dquot_initialize(inode);
want_delete = 1;
Expand Down Expand Up @@ -842,6 +845,7 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
ext3_fsblk_t first_block = 0;


trace_ext3_get_blocks_enter(inode, iblock, maxblocks, create);
J_ASSERT(handle != NULL || create == 0);
depth = ext3_block_to_path(inode,iblock,offsets,&blocks_to_boundary);

Expand Down Expand Up @@ -970,6 +974,9 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
}
BUFFER_TRACE(bh_result, "returned");
out:
trace_ext3_get_blocks_exit(inode, iblock,
depth ? le32_to_cpu(chain[depth-1].key) : 0,
count, err);
return err;
}

Expand Down Expand Up @@ -1217,6 +1224,8 @@ static int ext3_write_begin(struct file *file, struct address_space *mapping,
* we allocate blocks but write fails for some reason */
int needed_blocks = ext3_writepage_trans_blocks(inode) + 1;

trace_ext3_write_begin(inode, pos, len, flags);

index = pos >> PAGE_CACHE_SHIFT;
from = pos & (PAGE_CACHE_SIZE - 1);
to = from + len;
Expand Down Expand Up @@ -1332,6 +1341,7 @@ static int ext3_ordered_write_end(struct file *file,
unsigned from, to;
int ret = 0, ret2;

trace_ext3_ordered_write_end(inode, pos, len, copied);
copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);

from = pos & (PAGE_CACHE_SIZE - 1);
Expand Down Expand Up @@ -1367,6 +1377,7 @@ static int ext3_writeback_write_end(struct file *file,
struct inode *inode = file->f_mapping->host;
int ret;

trace_ext3_writeback_write_end(inode, pos, len, copied);
copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
update_file_sizes(inode, pos, copied);
/*
Expand Down Expand Up @@ -1395,6 +1406,7 @@ static int ext3_journalled_write_end(struct file *file,
int partial = 0;
unsigned from, to;

trace_ext3_journalled_write_end(inode, pos, len, copied);
from = pos & (PAGE_CACHE_SIZE - 1);
to = from + len;

Expand Down Expand Up @@ -1577,6 +1589,7 @@ static int ext3_ordered_writepage(struct page *page,
if (ext3_journal_current_handle())
goto out_fail;

trace_ext3_ordered_writepage(page);
if (!page_has_buffers(page)) {
create_empty_buffers(page, inode->i_sb->s_blocksize,
(1 << BH_Dirty)|(1 << BH_Uptodate));
Expand Down Expand Up @@ -1647,6 +1660,7 @@ static int ext3_writeback_writepage(struct page *page,
if (ext3_journal_current_handle())
goto out_fail;

trace_ext3_writeback_writepage(page);
if (page_has_buffers(page)) {
if (!walk_page_buffers(NULL, page_buffers(page), 0,
PAGE_CACHE_SIZE, NULL, buffer_unmapped)) {
Expand Down Expand Up @@ -1689,6 +1703,7 @@ static int ext3_journalled_writepage(struct page *page,
if (ext3_journal_current_handle())
goto no_write;

trace_ext3_journalled_writepage(page);
handle = ext3_journal_start(inode, ext3_writepage_trans_blocks(inode));
if (IS_ERR(handle)) {
ret = PTR_ERR(handle);
Expand Down Expand Up @@ -1739,6 +1754,7 @@ static int ext3_journalled_writepage(struct page *page,

static int ext3_readpage(struct file *file, struct page *page)
{
trace_ext3_readpage(page);
return mpage_readpage(page, ext3_get_block);
}

Expand All @@ -1753,6 +1769,8 @@ static void ext3_invalidatepage(struct page *page, unsigned long offset)
{
journal_t *journal = EXT3_JOURNAL(page->mapping->host);

trace_ext3_invalidatepage(page, offset);

/*
* If it's a full truncate we just forget about the pending dirtying
*/
Expand All @@ -1766,6 +1784,7 @@ static int ext3_releasepage(struct page *page, gfp_t wait)
{
journal_t *journal = EXT3_JOURNAL(page->mapping->host);

trace_ext3_releasepage(page);
WARN_ON(PageChecked(page));
if (!page_has_buffers(page))
return 0;
Expand Down Expand Up @@ -1794,6 +1813,8 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
size_t count = iov_length(iov, nr_segs);
int retries = 0;

trace_ext3_direct_IO_enter(inode, offset, iov_length(iov, nr_segs), rw);

if (rw == WRITE) {
loff_t final_size = offset + count;

Expand Down Expand Up @@ -1868,6 +1889,8 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
ret = err;
}
out:
trace_ext3_direct_IO_exit(inode, offset,
iov_length(iov, nr_segs), rw, ret);
return ret;
}

Expand Down Expand Up @@ -2446,6 +2469,8 @@ void ext3_truncate(struct inode *inode)
unsigned blocksize = inode->i_sb->s_blocksize;
struct page *page;

trace_ext3_truncate_enter(inode);

if (!ext3_can_truncate(inode))
goto out_notrans;

Expand Down Expand Up @@ -2597,6 +2622,7 @@ void ext3_truncate(struct inode *inode)
ext3_orphan_del(handle, inode);

ext3_journal_stop(handle);
trace_ext3_truncate_exit(inode);
return;
out_notrans:
/*
Expand All @@ -2605,6 +2631,7 @@ void ext3_truncate(struct inode *inode)
*/
if (inode->i_nlink)
ext3_orphan_del(NULL, inode);
trace_ext3_truncate_exit(inode);
}

static ext3_fsblk_t ext3_get_inode_block(struct super_block *sb,
Expand Down Expand Up @@ -2746,6 +2773,7 @@ static int __ext3_get_inode_loc(struct inode *inode,
* has in-inode xattrs, or we don't have this inode in memory.
* Read the block from disk.
*/
trace_ext3_load_inode(inode);
get_bh(bh);
bh->b_end_io = end_buffer_read_sync;
submit_bh(READ_META, bh);
Expand Down Expand Up @@ -3372,6 +3400,7 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode)
int err;

might_sleep();
trace_ext3_mark_inode_dirty(inode, _RET_IP_);
err = ext3_reserve_inode_write(handle, inode, &iloc);
if (!err)
err = ext3_mark_iloc_dirty(handle, inode, &iloc);
Expand Down
3 changes: 3 additions & 0 deletions fs/ext3/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <linux/quotaops.h>
#include <linux/buffer_head.h>
#include <linux/bio.h>
#include <trace/events/ext3.h>

#include "namei.h"
#include "xattr.h"
Expand Down Expand Up @@ -2144,6 +2145,7 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry)
struct ext3_dir_entry_2 * de;
handle_t *handle;

trace_ext3_unlink_enter(dir, dentry);
/* Initialize quotas before so that eventual writes go
* in separate transaction */
dquot_initialize(dir);
Expand Down Expand Up @@ -2189,6 +2191,7 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry)
end_unlink:
ext3_journal_stop(handle);
brelse (bh);
trace_ext3_unlink_exit(dentry, retval);
return retval;
}

Expand Down
Loading

0 comments on commit 785c4bc

Please sign in to comment.