Bug 761939 (GLUSTER-207)

Summary: [ glusterfs 2.0.6rc4 ] - "ls --color" takes time
Product: [Community] GlusterFS Reporter: Gururaj K <guru>
Component: posixAssignee: Vikas Gorur <vikas>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: low    
Version: 2.0.5CC: fharshav, gluster-bugs, vbellur
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Gururaj K 2009-08-12 08:08:31 UTC
* 4 server distribute-replicate
* IOT server side, WB client side

[root@client03 test]# touch a b c d
[root@client03 test]# mkdir x y z
[root@client03 test]# touch x/{1,2,3} y/{1,2,3,4} z/1
[root@client03 test]# ls -R
.:
a  b  c  d  x  y  z

./x:
1  2  3

./y:
1  2  3  4

./z:
1



* Using strace, we noticed differences between commands run on mountpoint and the backend:


[root@client03 test]# strace /bin/ls --color
..
lstat("b", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
lstat("c", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
lstat("x", {st_mode=S_IFDIR|0755, st_size=4118, ...}) = 0
lstat("y", {st_mode=S_IFDIR|0755, st_size=4126, ...}) = 0
lstat("z", {st_mode=S_IFDIR|0755, st_size=4102, ...}) = 0
getdents(3, /* 1 entries */, 131072)    = 24
lstat("d", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
getdents(3, /* 0 entries */, 131072)    = 0
munmap(0x2adae8b4d000, 135168)          = 0
close(3)                                = 0
..


[root@brick6 ~]# cd /jbod/pavan/exp26rc4/client03/test
[root@brick6 test]# strace /bin/ls --color
..
lstat("b", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
lstat("c", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
getdents(3, /* 0 entries */, 4096)      = 0
close(3)                                = 0
..


* We believe this is because we are not setting d_type from readdir. From the readdir manpage:

..
          struct dirent {
              ino_t          d_ino;       /* inode number */
              off_t          d_off;       /* offset to the next dirent */
              unsigned short d_reclen;    /* length of this record */
              unsigned char  d_type;      /* type of file */
              char           d_name[256]; /* filename */
          };

       According to POSIX, the dirent structure contains a field char d_name[] of unspecified size, with at most NAME_MAX characters preceding the terminating
       null byte.  POSIX.1-2001 also documents the field ino_t d_ino as an XSI extension.  Use of other fields will harm the portability of your programs.
..

Comment 1 Vikas Gorur 2009-09-08 08:38:59 UTC
Patch for review: http://patches.gluster.com/patch/1266/

Comment 2 Anand Avati 2009-09-09 09:41:25 UTC
PATCH: http://patches.gluster.com/patch/1266 in master (mount/fuse: Set d_type in readdir_cbk using the stat buf for the entry.)