ocfs2: Remove open coded readdir()
PATCH 6/15 ocfs2: Remove open coded readdir()
ocfs2_queue_orphans() has an open coded readdir loop which can easily just use a directory accessor function.
Signed-off-by Mark Fasheh <[email protected]>
--- fs/ocfs2/dir.c | 28 +++++++++++-- fs/ocfs2/dir.h | 7 +-- fs/ocfs2/journal.c | 118 +++++++++++++++++++-------------------------------- 3 files changed, 70 insertions(+), 83 deletions(-)
fs/ocfs2/dir.c +24 -4
@@ -81,10 +81,10 @@ static int ocfs2_do_extend_dir(struct super_block *sb,struct ocfs2_alloc_context *meta_ac, struct buffer_head **new_bh); -int ocfs2_check_dir_entry (struct inode * dir, -struct ocfs2_dir_entry * de, -struct buffer_head * bh, -unsigned long offset) +static int ocfs2_check_dir_entry (struct inode * dir, +struct ocfs2_dir_entry * de, +struct buffer_head * bh, +unsigned long offset) {const char *error_msg =NULL ;const int rlen =le16_to_cpu (de->rec_len);
@@ -532,6 +532,26 @@ out: }/* +* This is intended to be called from inside other kernel functions, +* so we fake some arguments. +*/ +int ocfs2_dir_foreach (struct inode *inode,loff_t *f_pos,void *priv, +filldir_t filldir) +{ +int ret =0 ; +unsigned long version = inode->i_version; + +while (*f_pos <i_size_read (inode)) { + ret =ocfs2_dir_foreach_blk (inode, &version, f_pos, priv, + filldir); +if (ret) +break ; + } + +return 0 ; +} + +/* * ocfs2_readdir() * */
fs/ocfs2/dir.h +2 -5
@@ -62,6 +62,8 @@ int ocfs2_find_files_on_disk(const char *name,struct buffer_head **dirent_bh, struct ocfs2_dir_entry **dirent);int ocfs2_readdir (struct file *filp,void *dirent,filldir_t filldir); +int ocfs2_dir_foreach (struct inode *inode,loff_t *f_pos,void *priv, +filldir_t filldir); int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, struct inode *dir, struct buffer_head *parent_fe_bh,
@@ -76,9 +78,4 @@ int ocfs2_fill_new_dir(struct ocfs2_super *osb,struct buffer_head *fe_bh, struct ocfs2_alloc_context *data_ac); -int ocfs2_check_dir_entry (struct inode *dir, -struct ocfs2_dir_entry *de, -struct buffer_head *bh, -unsigned long offset); -#endif /* OCFS2_DIR_H */
fs/ocfs2/journal.c +44 -74
138 lines not on this page · raw message
Signature · 1 line
1.5.0.6
PATCH 6/15 ocfs2: Remove open coded readdir()
Quoted 4 lines · Mark Fasheh
ocfs2_queue_orphans()has an open coded readdir loop which can easily just use a directory accessor function.Signed-off-by Mark Fasheh <[email protected]>
Nice cleanup.
Signed-off-by Joel Becker <[email protected]>
Signature · 7 lines
"Drake! We're LEAVING!" Joel Becker Principal Software Developer Oracle E-mail: [email protected] Phone: (650) 506-8127