Skip to contentSkip to conversation

ocfs2: Remove open coded readdir()

PATCH New Mark Fasheh 2 participants 2 messages Sep 19, 2007 – Sep 20, 2007 OCFS2

lore
Share & tools
lore
#0 lore raw

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.

---
 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
index dbfa6f6..a75c340 100644
@@ -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
index 7bf9c0a..075d0e9 100644
@@ -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