f2fs: trace f2fs_lookup
Subsystems (2)
PATCH 1/5 f2fs: trace f2fs_lookup
This patch adds trace for f2fs_lookup.
--- fs/f2fs/namei.c | 42 ++++++++++++++++++++++------------ include/trace/events/f2fs.h | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 15 deletions(-)
fs/f2fs/namei.c +27 -15
@@ -337,12 +337,14 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,struct inode *inode =NULL ;struct f2fs_dir_entry *de;struct page *page; -nid_t ino; +nid_t ino =-1 ;int err =0 ;unsigned int root_ino =F2FS_ROOT_INO (F2FS_I_SB (dir)); +trace_f2fs_lookup_start (dir, dentry, flags); +if (f2fs_encrypted_inode (dir)) { -int res =fscrypt_get_encryption_info (dir); + err =fscrypt_get_encryption_info (dir);/* * DCACHE_ENCRYPTED_WITH_KEY is set if the dentry is
@@ -352,18 +354,22 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,if (fscrypt_has_encryption_key (dir))fscrypt_set_encrypted_dentry (dentry);fscrypt_set_d_op (dentry); -if (res && res != -ENOKEY ) -return ERR_PTR (res); +if (err && err != -ENOKEY ) + goto out; } -if (dentry->d_name.len >F2FS_NAME_LEN ) -return ERR_PTR (-ENAMETOOLONG ); +if (dentry->d_name.len >F2FS_NAME_LEN ) { + err = -ENAMETOOLONG ; + goto out; + } de =f2fs_find_entry (dir, &dentry->d_name, &page);if (!de) { -if (IS_ERR (page)) -return (struct dentry *)page; -return d_splice_alias (inode, dentry); +if (IS_ERR (page)) { + err =PTR_ERR (page); + goto out; + } + goto out_splice; } ino =le32_to_cpu (de->ino);
@@ -371,19 +377,21 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,f2fs_put_page (page,0 ); inode =f2fs_iget (dir->i_sb, ino); -if (IS_ERR (inode)) -return ERR_CAST (inode); +if (IS_ERR (inode)) { + err =PTR_ERR (inode); + goto out; + }if ((dir->i_ino == root_ino) &&f2fs_has_inline_dots (dir)) { err =__recover_dot_dentries (dir, root_ino);if (err) - goto err_out; + goto out_iput; }if (f2fs_has_inline_dots (inode)) { err =__recover_dot_dentries (inode, dir->i_ino);if (err) - goto err_out; + goto out_iput; } if (f2fs_encrypted_inode(dir) && (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
@@ -392,12 +400,16 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,"Inconsistent encryption contexts: %lu/%lu" , dir->i_ino, inode->i_ino); err = -EPERM ; - goto err_out; + goto out_iput; } +out_splice: +trace_f2fs_lookup_end (dir, dentry, ino,0 );return d_splice_alias (inode, dentry); -err_out: +out_iput:iput (inode); +out: +trace_f2fs_lookup_end (dir, dentry, ino, err);return ERR_PTR (err); }
include/trace/events/f2fs.h +56 -0
62 lines not on this page · raw message
Signature · 1 line
2.13.1.388.g69e6b9b4f4a9
PATCH 2/5 f2fs: trace f2fs_readdir
This patch adds trace for f2fs_readdir.
--- fs/f2fs/dir.c | 14 +++++++++----- include/trace/events/f2fs.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-)
fs/f2fs/dir.c +9 -5
@@ -14,6 +14,7 @@#include "node.h" #include "acl.h" #include "xattr.h" +#include <trace/events/f2fs.h> static unsigned long dir_blocks (struct inode *inode) {
@@ -847,6 +848,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)struct f2fs_dentry_block *dentry_blk =NULL ;struct page *dentry_page =NULL ;struct file_ra_state *ra = &file->f_ra; +loff_t start_pos = ctx->pos;unsigned int n = ((unsigned long )ctx->pos /NR_DENTRY_IN_BLOCK );struct f2fs_dentry_ptr d;struct fscrypt_str fstr =FSTR_INIT (NULL ,0 );
@@ -855,16 +857,16 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)if (f2fs_encrypted_inode (inode)) { err =fscrypt_get_encryption_info (inode);if (err && err != -ENOKEY ) -return err; + goto out; err =fscrypt_fname_alloc_buffer (inode,F2FS_NAME_LEN , &fstr);if (err <0 ) -return err; + goto out; }if (f2fs_has_inline_dentry (inode)) { err =f2fs_read_inline_dir (file, ctx, &fstr); - goto out; + goto out_free; }/* readahead for multi pages of dir */
@@ -880,7 +882,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) err =0 ;continue ; }else { - goto out; + goto out_free; } }
@@ -900,8 +902,10 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)kunmap (dentry_page);f2fs_put_page (dentry_page,1 ); } -out: +out_free:fscrypt_fname_free_buffer (&fstr); +out: +trace_f2fs_readdir (inode, start_pos, ctx->pos, err);return err <0 ? err :0 ; }
include/trace/events/f2fs.h +29 -0
@@ -784,6 +784,35 @@ TRACE_EVENT(f2fs_lookup_end, __entry->err) ); +TRACE_EVENT (f2fs_readdir, + + TP_PROTO(struct inode *dir, loff_t start_pos, loff_t end_pos, int err), + +TP_ARGS (dir, start_pos, end_pos, err), + +TP_STRUCT__entry ( + __field(dev_t, dev) + __field(ino_t, ino) + __field(loff_t, start) + __field(loff_t, end) +__field (int, err) + ), + +TP_fast_assign ( + __entry->dev = dir->i_sb->s_dev; + __entry->ino = dir->i_ino; + __entry->start = start_pos; + __entry->end = end_pos; + __entry->err = err; + ), + +TP_printk ("dev = (%d,%d), ino = %lu, start_pos:%llu, end_pos:%llu, err:%d" , +show_dev_ino (__entry), + __entry->start, + __entry->end, + __entry->err) +); + TRACE_EVENT(f2fs_fallocate, TP_PROTO(struct inode *inode, int mode,
Signature · 6 lines
2.13.1.388.g69e6b9b4f4a9 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH 3/5 f2fs: allow readdir() to be interrupted
In reply to Chao YuThis patch follows ext4 to allow readdir() in large empty directory to be interrupted. Referenced commit of ext4: 1f60fbe72749 ("ext4: allow readdir()'s of large empty directories to be interrupted").
--- fs/f2fs/dir.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/f2fs/dir.c +9 -0
@@ -10,6 +10,7 @@*/ #include <linux/fs.h> #include <linux/f2fs_fs.h> +#include <linux/sched/signal.h> #include "f2fs.h" #include "node.h" #include "acl.h"
@@ -875,6 +876,14 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) min(npages - n, (pgoff_t)MAX_DIR_RA_PAGES));for (; n < npages; n++) { + +/* allow readdir() to be interrupted */ +if (fatal_signal_pending (current)) { + err = -ERESTARTSYS ; + goto out_free; + } +cond_resched (); + dentry_page =get_lock_data_page (inode, n, false);if (IS_ERR (dentry_page)) { err =PTR_ERR (dentry_page);
Signature · 6 lines
2.13.1.388.g69e6b9b4f4a9 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH 4/5 f2fs: relocate readahead codes in readdir()
In reply to Chao YuPreviously, for large directory, we just do readahead only once in readdir(), readdir()'s performance may drop when traversing latter blocks. In order to avoid this, relocate readahead codes to covering all traverse flow.
--- fs/f2fs/dir.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/dir.c +5 -5
@@ -870,11 +870,6 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) goto out_free; } -/* readahead for multi pages of dir */ -if (npages - n >1 && !ra_has_index (ra, n)) -page_cache_sync_readahead (inode->i_mapping, ra, file, n, -min (npages - n, (pgoff_t )MAX_DIR_RA_PAGES )); -for (; n < npages; n++) {/* allow readdir() to be interrupted */
@@ -884,6 +879,11 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) }cond_resched (); +/* readahead for multi pages of dir */ +if (npages - n >1 && !ra_has_index (ra, n)) +page_cache_sync_readahead (inode->i_mapping, ra, file, n, +min (npages - n, (pgoff_t )MAX_DIR_RA_PAGES )); + dentry_page =get_lock_data_page (inode, n, false);if (IS_ERR (dentry_page)) { err =PTR_ERR (dentry_page);
Signature · 1 line
2.13.1.388.g69e6b9b4f4a9
PATCH 5/5 f2fs: update ctx->pos correctly when hitting hole in directory
In reply to Chao YuThis patch fixes to update ctx->pos correctly when hitting hole in directory.
--- fs/f2fs/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/dir.c +1 -2
@@ -870,7 +870,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) goto out_free; } -for (; n < npages; n++) { +for (; n < npages; n++, ctx->pos = n *NR_DENTRY_IN_BLOCK ) {/* allow readdir() to be interrupted */ if (fatal_signal_pending (current)) {
@@ -907,7 +907,6 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)break ; } - ctx->pos = (n +1 ) *NR_DENTRY_IN_BLOCK ;kunmap (dentry_page);f2fs_put_page (dentry_page,1 ); }
Signature · 6 lines
2.13.1.388.g69e6b9b4f4a9 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot