Hide Forgot
Hello, I’m using glusterfs-2.0.4 and building a c-program with libglusterfsclient. I’ve created a directory, ‘test’ and wrote a file, ‘hello.txt’, to the directory on glusterfs mounted volume. Then I wanted to list all the files/sub-directories in the directory. My code was as followings, ====== struct dirent *dirp = NULL; glusterfs_dir_t dirfd = NULL; char *path = “/gfs_mount/test/”; dirfd = glusterfs_opendir(path); while( (dirp = glusterfs_readdir(dirfd) != NULL) ){ printf("## %s %d %d\n", dirp->d_name, dirp->d_type, dirp->d_reclen ); for( i = 0 ; i < 256; i++ ){ printf("%d ", dirp->d_name[i]); } printf("\n");} glusterfs_closedir(dirfd); ===== What I expected result was, ## Hello.txt 8 24 ## . 4 16 ## .. 4 16 But ## 0 74 0 0 0 0 0 0 0 0 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ## 0 24578 0 0 0 0 0 0 0 0 46 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ## | 135 48751 124 0 0 0 0 0 0 0 104 101 108 108 111 46 116 120 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 As you see, first 8 bytes has garbage data and d_type value is not correct. Here're my configuraitons. <client configuration> volume client01 type protocol/client option transport-type tcp option remote-host 10.30.3.15 option remote-port 6996 option username hwuser option password otepass option remote-subvolume brick01 end-volume volume client02 type protocol/client option transport-type tcp option remote-host 10.30.3.15 option remote-port 6996 option username hwuser option password otepass option remote-subvolume brick02 end-volume volume client03 type protocol/client option transport-type tcp option remote-host 10.30.3.22 option remote-port 6996 option username hwuser option password otepass option remote-subvolume brick01 end-volume volume client04 type protocol/client option transport-type tcp option remote-host 10.30.3.22 option remote-port 6996 option username hwuser option password otepass option remote-subvolume brick02 end-volume volume client05 type protocol/client option transport-type tcp option remote-host 10.30.3.21 option remote-port 6996 option username hwuser option password otepass option remote-subvolume brick01 end-volume volume client06 type protocol/client option transport-type tcp option remote-host 10.30.3.21 option remote-port 6996 option username hwuser option password otepass option remote-subvolume brick02 end-volume volume distribute type cluster/distribute subvolumes client01 client02 client03 client04 client05 client06 end-volume <one of server volumes and others are same> volume posix01 type storage/posix option directory /home/export end-volume volume posix02 type storage/posix option directory /home2/export end-volume volume locks01 type features/locks subvolumes posix01 end-volume volume locks02 type features/locks subvolumes posix02 end-volume volume brick01 type performance/io-threads option thread-count 8 subvolumes locks01 end-volume volume brick02 type performance/io-threads option thread-count 8 subvolumes locks02 end-volume volume server type protocol/server subvolumes brick01 brick02 option transport-type tcp option auth.login.brick01.allow hwuser option auth.login.brick02.allow hwuser option auth.login.hwuser.password otepass #option auth.addr.brick01.allow * #option auth.addr.brick02.allow * end-volume And my test program was #include <time.h> #include <unistd.h> #include <stdio.h> #include <string.h> #include <sys/uio.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #include <errno.h> #include <libglusterfsclient.h> int readdirs(const char* path){ int ret = 0; char file_name[1024]; struct dirent *dirp = NULL; glusterfs_dir_t dirfd = NULL; dirfd = glusterfs_opendir( path ); if( dirfd == NULL ) { printf("dirfd is null\n"); return -1; } while( (dirp = glusterfs_readdir(dirfd)) != NULL ) { printf("%s %s %d %d\n", dirp->d_name, &dirp->d_name[8], dirp->d_type, dirp->d_reclen ); } glusterfs_closedir( dirfd ); return ret; } int mount(){ int ret = 0; glusterfs_init_params_t params; char *mount_point = "/myvp"; memset (¶ms, 0, sizeof (params)); params.specfile = "/etc/glusterfs/glusterfs-client.vol"; params.volume_name = "myvp"; params.logfile = "./glusterfs.log"; params.loglevel = "DEBUG"; params.lookup_timeout = 600; params.stat_timeout = 600; ret = glusterfs_mount( mount_point, ¶ms ); return ret; } void handle_error( char* msg ) { char buf[1024]; char *p_msg = ""; int errno_ = errno ; if( msg ) p_msg = msg; snprintf( buf, sizeof(buf), "[Errno %d] %s %s" , errno_,strerror(errno_), p_msg); printf( "%s\n", buf ); } int main(){ int ret = 0; char *dir_path =( "/myvp/test" ); ret = mount(); if ( ret < 0 ) { handle_error(NULL); return ret; } ret = readdirs( dir_path ); if ( ret < 0 ) { handle_error( dir_path ); return ret; } return ret; }
The platform field above says "Windows". Is that correct or was the bug reported from a windows machine?
It was reported at the windows machine. The test code was run on debian box. Thanks
Thanks, I'll also need the glusterfs.log file. It might contain a few pointers to whats going on since you;re running in DEBUG mode.
Created attachment 52 [details] full output of `man playmidi` Attaching glusterfs.log but it doesn't look have much information
(In reply to comment #0) > Hello, > > I’m using glusterfs-2.0.4 and building a c-program with libglusterfsclient. > > I’ve created a directory, ‘test’ and wrote a file, ‘hello.txt’, to the > directory on glusterfs mounted volume. I am looking into this bug. In mean time, can you tell whether the "mounted volume" that you mention above used the same client and server volfiles? To isolate the bug on your system, another thing to try would be to remove all extra volumes and do a similar test but only with storage/posix volume in the volfile used while creating the directory and also while reading the directory through your program. It'll help me determine whether the bug is in libglusterfsclient or in a different component. Thanks > Then I wanted to list all the files/sub-directories in the directory. >
I've as yet not been able to reproduce this but I'll continue looking into it.
Sorry, I was stupid. I compiled glusterfs with -D_FILE_OFFSET_BITS=64 but I didn't at client program. After I specify the flag on my client program, it works fine as I expected.
I going to close this since we finally hit this bug too and have fixed it in recent commits. See bz 333. *** This bug has been marked as a duplicate of bug 333 ***