[Gluster-devel] Using syncop_readdir inside Xlator

Poornima Gurusiddaiah pgurusid at redhat.com
Wed Mar 28 02:53:41 UTC 2018


On Tue, Mar 27, 2018, 8:48 PM David Spisla <spisla80 at gmail.com> wrote:

> Dear Gluster Devels,
>
> I want to read all the entries in a DIR inside of a xlator. For this
> purpose I use the syncop_readdir function which is also used in die
> self-heal functionality for example.
> Here is a piece of code from inside the worm_rename function:
>
>
>                fd_t                 *fd             = NULL;
>                gf_dirent_t           entries;
>
>                 fd = fd_anonymous (oldloc->inode);
>                 if (fd == NULL) {
>                         gf_log (this->name, GF_LOG_ERROR, "fd creation
> failed");
>                         ret = -ENOMEM;
>                         goto out;
>                 }
>                 INIT_LIST_HEAD (&entries.list);
>                 ret = syncop_readdir (this, fd, 131072, 0, &entries, NULL,
> NULL);
>                 if (ret) {
>

Readdir returns the number of entries read, hence ret will be > 0, if there
are dir entries read and it's a success case. The check should be ret < 0.
If it fails with ret < 0 case then I would suspect fd_anonymous, I m not
sure whether it works for readdir, need to check the code.

Regards,
Poornima

                        gf_log (this->name, GF_LOG_ERROR, "failed getting
> dir entries");
>                         ret = -ENOMEM;
>                         goto out;
>                }
>
> The problem is, that I always get the Error: "failed getting dir entries"
> . It seems to be that there is something wrong with the execution of that
> function. Any ideas?
>
> Regards
> David Spisla
> _______________________________________________
> Gluster-devel mailing list
> Gluster-devel at gluster.org
> http://lists.gluster.org/mailman/listinfo/gluster-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gluster.org/pipermail/gluster-devel/attachments/20180328/93de7172/attachment.html>


More information about the Gluster-devel mailing list