Whamcloud - gitweb
LU-3373 osd-ldiskfs: readdir replace by iterate 31/8231/11
authoryangsheng <yang.sheng@intel.com>
Thu, 27 Feb 2014 14:19:21 +0000 (22:19 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 25 Mar 2014 15:31:05 +0000 (15:31 +0000)
Use iterate instead of readdir callback in iop.

Signed-off-by: yang sheng <yang.sheng@intel.com>
Change-Id: Icb08292009c965ca693814e854ae2e77b3e7a4f0
Reviewed-on: http://review.whamcloud.com/8231
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Jenkins
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Peng Tao <bergwolf@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_scrub.c

index 75fc855..7461f9d 100644 (file)
@@ -4754,6 +4754,12 @@ static void osd_it_ea_put(const struct lu_env *env, struct dt_it *di)
 {
 }
 
+struct osd_filldir_cbs {
+#ifdef HAVE_DIR_CONTEXT
+       struct dir_context ctx;
+#endif
+       struct osd_it_ea  *it;
+};
 /**
  * It is called internally by ->readdir(). It fills the
  * iterator's in-memory data structure with required
@@ -4765,11 +4771,11 @@ static void osd_it_ea_put(const struct lu_env *env, struct dt_it *di)
  * \retval 0 on success
  * \retval 1 on buffer full
  */
-static int osd_ldiskfs_filldir(char *buf, const char *name, int namelen,
+static int osd_ldiskfs_filldir(void *buf, const char *name, int namelen,
                                loff_t offset, __u64 ino,
                                unsigned d_type)
 {
-        struct osd_it_ea        *it   = (struct osd_it_ea *)buf;
+       struct osd_it_ea        *it   = ((struct osd_filldir_cbs *)buf)->it;
        struct osd_object       *obj  = it->oie_obj;
         struct osd_it_ea_dirent *ent  = it->oie_dirent;
         struct lu_fid           *fid  = &ent->oied_fid;
@@ -4832,7 +4838,14 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env,
         struct osd_object  *obj   = it->oie_obj;
         struct inode       *inode = obj->oo_inode;
         struct htree_lock  *hlock = NULL;
-        int                 result = 0;
+       struct file        *filp  = &it->oie_file;
+       int                 rc = 0;
+       struct osd_filldir_cbs buf = {
+#ifdef HAVE_DIR_CONTEXT
+               .ctx.actor = osd_ldiskfs_filldir,
+#endif
+               .it = it
+       };
 
         ENTRY;
         it->oie_dirent = it->oie_buf;
@@ -4846,8 +4859,13 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env,
                down_read(&obj->oo_ext_idx_sem);
         }
 
-        result = inode->i_fop->readdir(&it->oie_file, it,
-                                       (filldir_t) osd_ldiskfs_filldir);
+#ifdef HAVE_DIR_CONTEXT
+       buf.ctx.pos = filp->f_pos;
+       rc = inode->i_fop->iterate(filp, &buf.ctx);
+       filp->f_pos = buf.ctx.pos;
+#else
+       rc = inode->i_fop->readdir(filp, &buf, osd_ldiskfs_filldir);
+#endif
 
         if (hlock != NULL)
                 ldiskfs_htree_unlock(hlock);
@@ -4863,7 +4881,7 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env,
                it->oie_it_dirent = 1;
        }
 
-       RETURN(result);
+       RETURN(rc);
 }
 
 /**
index 9228d00..7d6c011 100644 (file)
@@ -1443,6 +1443,10 @@ struct osd_ios_item {
 };
 
 struct osd_ios_filldir_buf {
+#ifdef HAVE_DIR_CONTEXT
+       /* please keep it as first member */
+       struct dir_context       ctx;
+#endif
        struct osd_thread_info  *oifb_info;
        struct osd_device       *oifb_dev;
        struct dentry           *oifb_dentry;
@@ -1738,7 +1742,13 @@ static int
 osd_ios_general_scan(struct osd_thread_info *info, struct osd_device *dev,
                     struct dentry *dentry, filldir_t filldir)
 {
-       struct osd_ios_filldir_buf    buf   = { info, dev, dentry };
+       struct osd_ios_filldir_buf    buf   = {
+#ifdef HAVE_DIR_CONTEXT
+                                               .ctx.actor = filldir,
+#endif
+                                               .oifb_info = info,
+                                               .oifb_dev = dev,
+                                               .oifb_dentry = dentry };
        struct file                  *filp  = &info->oti_it_ea.oie_file;
        struct inode                 *inode = dentry->d_inode;
        const struct file_operations *fops  = inode->i_fop;
@@ -1755,7 +1765,13 @@ osd_ios_general_scan(struct osd_thread_info *info, struct osd_device *dev,
        filp->private_data = NULL;
        set_file_inode(filp, inode);
 
+#ifdef HAVE_DIR_CONTEXT
+       buf.ctx.pos = filp->f_pos;
+       rc = fops->iterate(filp, &buf.ctx);
+       filp->f_pos = buf.ctx.pos;
+#else
        rc = fops->readdir(filp, &buf, filldir);
+#endif
        fops->release(inode, filp);
 
        RETURN(rc);