diff options
Diffstat (limited to 'libglusterfs')
| -rw-r--r-- | libglusterfs/src/gf-dirent.c | 42 | ||||
| -rw-r--r-- | libglusterfs/src/gf-dirent.h | 3 | 
2 files changed, 45 insertions, 0 deletions
diff --git a/libglusterfs/src/gf-dirent.c b/libglusterfs/src/gf-dirent.c index 4c077e91871..e3c7bf6e0a9 100644 --- a/libglusterfs/src/gf-dirent.c +++ b/libglusterfs/src/gf-dirent.c @@ -20,6 +20,7 @@  #include <stdint.h>  #include "compat.h"  #include "xlator.h" +#include "syncop.h"  #define ONE 1ULL  #define PRESENT_D_OFF_BITS 63 @@ -262,3 +263,44 @@ gf_link_inodes_from_dirent (xlator_t *this, inode_t *parent,          return 0;  } + +int +gf_fill_iatt_for_dirent (gf_dirent_t *entry, inode_t *parent, xlator_t *subvol) +{ +        loc_t                   loc             = {0, }; +        int                     ret             = -1; +        char                   *path            = NULL; +        struct iatt             iatt            = {0,}; + +        loc.inode = inode_grep (parent->table, parent, entry->d_name); +        if (!loc.inode) { +                loc.inode = inode_new (parent->table); +                gf_uuid_copy (loc.inode->gfid, entry->d_stat.ia_gfid); +        } + +        gf_uuid_copy (loc.pargfid, parent->gfid); +        loc.name = entry->d_name; +        loc.parent = inode_ref (parent); +        ret = inode_path (loc.inode, entry->d_name, &path); +        loc.path = path; +        if (ret < 0) +                goto out; + +        ret = syncop_lookup (subvol, &loc, &iatt, NULL, NULL, NULL); +        if (ret) +                goto out; + +        entry->d_stat = iatt; +        entry->inode = inode_ref (loc.inode); +        /* We don't need to link inode here, because as part of readdirp_cbk +         * we will link all dirents. +         * +         * Since we did a proper lookup, we don't need to set need_lookup +         * flag. +         */ + +        ret = 0; +out: +        loc_wipe (&loc); +        return ret; +} diff --git a/libglusterfs/src/gf-dirent.h b/libglusterfs/src/gf-dirent.h index faeaf411941..faffabf1288 100644 --- a/libglusterfs/src/gf-dirent.h +++ b/libglusterfs/src/gf-dirent.h @@ -66,6 +66,9 @@ void gf_dirent_entry_free (gf_dirent_t *entry);  void gf_dirent_free (gf_dirent_t *entries);  int gf_link_inodes_from_dirent (xlator_t *this, inode_t *parent,                                  gf_dirent_t *entries); +int +gf_fill_iatt_for_dirent (gf_dirent_t *entry, inode_t *parent, +                         xlator_t *subvol);  void  gf_link_inode_from_dirent (xlator_t *this, inode_t *parent, gf_dirent_t *entry);  | 
