stat broken for CIFS filesystem

Bug #220658 reported by Michael Heča
8
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Fix Released
Medium
Jim Lieb

Bug Description

The reporter has the problem with a CIFS mount that [ -f file ] returns 0 even if the file does NOT exist. The attached starce shows:
stat64("./makefile", {st_mode=S_IFREG|0764, st_size=1386, ...}) = 0

This is clearly boken, since a subsequent open on the file fails...
-----
Original description follows:

Binary package hint: bash-completion

When pressing tab key after "make ", in directory where is file Makefile, message "grep: ./makefile: No such file or directory" is shown.

It's like bash do case insensitive compare in file /etc/bash_completion in next section:

                # make reads `GNUmakefile', then `makefile', then `Makefile'
                if [ -f ${makef_dir}/GNUmakefile ]; then
                        makef=${makef_dir}/GNUmakefile
                elif [ -f ${makef_dir}/makefile ]; then
                        makef=${makef_dir}/makefile
                elif [ -f ${makef_dir}/Makefile ]; then
                        makef=${makef_dir}/Makefile
                else
                        makef=${makef_dir}/*.mk # local convention
                fi

After update from 7.10 to 8.04 LTS. In version 7.10 is completion ok.

Tags: cft-2.6.27
Revision history for this message
Mika Fischer (zoop) wrote :

I cannot reproduce this on hardy...

What does the following print in the directory in question?
[ -f ./makefile ]; echo $?

Revision history for this message
Michael Heča (orgoj) wrote :

heca@pc-2:~/work/i2/samba/heca$ [ -f ./makefile ]; echo $?
0
heca@pc-2:~/work/i2/samba/heca$ [ -f ./Makefile ]; echo $?
0
heca@pc-2:~/work/i2/samba/heca$ ls -Al
celkem 2048
-rwxrw-r-- 1 contimex contimex 108 2006-08-02 14:55 index.html
drwxrwsr-x 9 contimex contimex 0 2008-01-31 15:50 lib
drwxrws--- 14 contimex contimex 0 2008-04-21 15:12 link
-rwxrw-r-- 1 contimex contimex 1386 2008-03-27 14:57 Makefile
drwxrwsr-x 6 contimex contimex 0 2008-04-22 16:56 .svn
drwxrwsr-x 8 contimex contimex 0 2008-03-28 18:55 tmp
drwxrwxr-x 4 contimex contimex 0 2008-03-28 18:55 tools
drwxrwxr-x 4 contimex contimex 0 2008-04-18 14:53 .unison
drwxrwsr-x 37 contimex contimex 0 2008-04-21 15:12 webs

It's mouted dir from Samba by CIFS.

Revision history for this message
Mika Fischer (zoop) wrote :

Well then this is the problem. It should print 1 if the file does not exist.

Can you do the following:
strace -o cifs-strace.txt bash -c '[ -f ./makefile ]'

And attach the resulting cifs-strace.txt to this bug? Maybe this tells us what's the problem. I suspect it's a bug in the CIFS filesystem driver.

Revision history for this message
Michael Heča (orgoj) wrote :
Revision history for this message
Michael Heča (orgoj) wrote :

I try completion on local filesystem and it's ok.

Revision history for this message
Mika Fischer (zoop) wrote :

orgoj, please attach the following things (see: https://wiki.ubuntu.com/KernelTeamBugPolicies):
 - uname -a > uname-a.log
 - cat /proc/version_signature > version.log
 - dmesg > dmesg.log
 - sudo lspci -vvnn > lspci-vvnn.log

And additionally please post the command you use to mount the remote filesystem, or the line in /etc/fstab if there is one.

I'll reassign this to the kernel team then.

description: updated
Changed in bash-completion:
assignee: nobody → ubuntu-kernel-team
Revision history for this message
Michael Heča (orgoj) wrote :
Revision history for this message
Michael Heča (orgoj) wrote :
Revision history for this message
Michael Heča (orgoj) wrote :
Revision history for this message
Michael Heča (orgoj) wrote :
Revision history for this message
Michael Heča (orgoj) wrote :
Revision history for this message
Leann Ogasawara (leannogasawara) wrote :

The Ubuntu Kernel Team is planning to move to the 2.6.27 kernel for the upcoming Intrepid Ibex 8.10 release. As a result, the kernel team would appreciate it if you could please test this newer 2.6.27 Ubuntu kernel. There are one of two ways you should be able to test:

1) If you are comfortable installing packages on your own, the linux-image-2.6.27-* package is currently available for you to install and test.

--or--

2) The upcoming Alpha5 for Intrepid Ibex 8.10 will contain this newer 2.6.27 Ubuntu kernel. Alpha5 is set to be released Thursday Sept 4. Please watch http://www.ubuntu.com/testing for Alpha5 to be announced. You should then be able to test via a LiveCD.

Please let us know immediately if this newer 2.6.27 kernel resolves the bug reported here or if the issue remains. More importantly, please open a new bug report for each new bug/regression introduced by the 2.6.27 kernel and tag the bug report with 'linux-2.6.27'. Also, please specifically note if the issue does or does not appear in the 2.6.26 kernel. Thanks again, we really appreicate your help and feedback.

Revision history for this message
Konstantin Baev (kipruss) wrote :

This painful problem, unfortunately, has not yet been solved. What are the prospects for its decision?

Example: (file "test" exist, file "tEsT" does not exist)

1. in local filesystem (correct behavior - case sensitive):

kipruss@kubuntu:~$ ls test
test
kipruss@kubuntu:~$ ls tEsT
ls: невозможно получить доступ к tEsT: No such file or directory
kipruss@kubuntu:~$ [ -f test ] || echo "not found"
kipruss@kubuntu:~$ [ -f tEsT ] || echo "not found"
not found

2. in directory, mounted by cifs (bug):

kipruss@kubuntu:~/heaven/stat$ ls test
test
kipruss@kubuntu:~/heaven/stat$ ls tEsT
tEsT
kipruss@kubuntu:~/heaven/stat$ [ -f test ] || echo "not found"
kipruss@kubuntu:~/heaven/stat$ [ -f tEsT ] || echo "not found"
kipruss@kubuntu:~/heaven/stat$ cat test
testtesttest
kipruss@kubuntu:~/heaven/stat$ cat tEsT
cat: tEsT: No such file or directory

Daniel T Chen (crimsun)
Changed in linux:
status: New → Confirmed
Revision history for this message
Konstantin Baev (kipruss) wrote :

My workaround (Kubuntu 8.10, kernel 2.6.27-9-generic):

I added to the begin of file "/usr/src/linux-source-2.6.27/fs/cifs/cifspdu.h" lines:

#ifndef CONFIG_CIFS_XATTR
#define CONFIG_CIFS_XATTR
#endif

#ifndef CONFIG_CIFS_POSIX
#define CONFIG_CIFS_POSIX
#endif

and recompiled driver "cifs.ko" separately, not recompiling kernel

so:

kipruss@kubuntu:~$ ls test
test
kipruss@kubuntu:~$ ls tEsT
ls: невозможно получить доступ к tEsT: No such file or directory

----

General solution:

In default kernel .config (CIFS part) we can found:

CONFIG_CIFS=m
# CONFIG_CIFS_DEBUG2 is not set
CONFIG_CIFS_DFS_UPCALL=y
CONFIG_CIFS_EXPERIMENTAL=y
# CONFIG_CIFS_STATS is not set
CONFIG_CIFS_UPCALL=y
CONFIG_CIFS_WEAK_PW_HASH=y
# CONFIG_CIFS_XATTR is not set

The problem will be solved if they change CIFS part of kernel .config file to

CONFIG_CIFS=m
# CONFIG_CIFS_DEBUG2 is not set
CONFIG_CIFS_DFS_UPCALL=y
CONFIG_CIFS_EXPERIMENTAL=y
# CONFIG_CIFS_STATS is not set
CONFIG_CIFS_UPCALL=y
CONFIG_CIFS_WEAK_PW_HASH=y
CONFIG_CIFS_XATTR=y
CONFIG_CIFS_POSIX=y

If this is not a bug, it is very strange feature of Ubuntu kernel config

P.S. In Ubuntu 8.04 - all the same

Changed in linux:
importance: Undecided → Medium
status: Confirmed → Triaged
Revision history for this message
Launchpad Janitor (janitor) wrote : Kernel team bugs

Per a decision made by the Ubuntu Kernel Team, bugs will longer be assigned to the ubuntu-kernel-team in Launchpad as part of the bug triage process. The ubuntu-kernel-team is being unassigned from this bug report. Refer to https://wiki.ubuntu.com/KernelTeamBugPolicies for more information. Thanks.

Revision history for this message
Andy Whitcroft (apw) wrote :

Having reviewed the two config options proposed for enabling it is not at all clear how either could possibly fix this problem, one enabling extended attributes and the other posix protection extensions. That in itself implies a bug elsewhere is being masked to my mind.

Revision history for this message
Konstantin Baev (kipruss) wrote :

Have you tried to rebuild the module cifs with these additions in cifspdu.h or rebuild the kernel or you think about this problem only in theory?

Revision history for this message
Jim Lieb (lieb) wrote :

The POSIX setting controls the wire protocol. Posix protocol makes filenames
case sensitive on the server side since that is where the name resolution takes place. The protocol setting is in fs/cifs/cifssmb.c:42 where the
protocol defs are enumerated.

The question here is what the default for CIFS should be because there are
compatibility implications for both. The default config from kernel.org is
to set POSIX and ATTR. What would break in Windows<->Linux interoperability if filenames became the UNIX/Linux default rather than the
Windows default?

My recommendation is to set them both because this is a client side setting.

Jim Lieb (lieb)
Changed in linux:
assignee: nobody → lieb
status: Triaged → In Progress
Revision history for this message
Tim Gardner (timg-tpi) wrote :
Changed in linux:
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package linux - 2.6.28-4.10

---------------
linux (2.6.28-4.10) jaunty; urgency=low

  [ Andy Whitcroft ]

  * update kernel bootloader recommends: to prefer grub
    - LP: #314004
  * SAUCE: don't use buggy _BCL/_BCM/_BQC for backlight control
    - LP: #311716
  * SAUCE: test-suspend -- add the suspend test scripts
    - LP: #316419

  [ Colin Watson ]

  * Enable udebs for armel

  [ Tim Gardner ]

  * SAUCE: Dell laptop digital mic does not work, PCI 1028:0271
    - LP: #309508
  * Enable CIFS_XATTR=y and CONFIG_CIFS_POSIX=y
    - LP: #220658

 -- Tim Gardner <email address hidden> Thu, 08 Jan 2009 10:38:22 -0700

Changed in linux:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.