Bug 90021

Summary: client shows wrong(old) inode number, when client refer file directly.
Product: File System Reporter: Nakajima Akira (nakajima.akira)
Component: CIFSAssignee: fs_cifs (fs_cifs)
Status: RESOLVED CODE_FIX    
Severity: normal CC: jlayton, lsahlber, smfrench, szg00000
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.18.0 Subsystem:
Regression: No Bisected commit-id:
Attachments: patch__set uniquied to inode cache
patch__if different uniqueid, then return error

Description Nakajima Akira 2014-12-18 08:57:50 UTC
Created attachment 161151 [details]
patch__set uniquied to inode cache

//////////////////////////////////////////////////////////
Description of problem:
Old inode cache is used, when same filename and using ls -li <filename>.
This causes that client shows wrong(old) inode number.

When server is Windows, client has same problem.
//////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////
Version-Release number of selected component (if applicable):
CIFS client: kernel-3.18.0
samba server: samba-4.1.12-5.rc20
//////////////////////////////////////////////////////////

How reproducible:
Steps to Reproduce:

1. create file share service at samba server

server# setenforce 0
server# vi /etc/samba/smb.conf
[share]
path = /home/share
public = yes
writable = yes

server# smbpasswd -a XXX(username)
server# systemctl restart smb

2. mount cifs at CIFS client

client# mount -o user=XXX,serverino //server/share /mnt/share

3. create and list file at CIFS client

client# cd /mnt/share
client# touch a; ls -li
total 0
2400376 -rw-r--r--. 1 root root 0 Dec 18 09:45 a

4. remove and create files at samba server

server# rm -rf a; touch b a; ls -li
total 0
2400377 -rw-r--r--. 1 root root 0 Dec 18 09:45 a
2400376 -rw-r--r--. 1 root root 0 Dec 18 09:45 b

5. list file "directly" at CIFS client

client# ls -li a b
2400376 -rw-r--r--. 1 root root 0 Dec 18 09:45 a
2400376 -rw-r--r--. 1 root root 0 Dec 18 09:45 b

/////////////////////////////////////////
Client shows wrong(old) inode number.
2400377 is correct.
/////////////////////////////////////////

=====================================================
This is patch.
002-cifs-fix-set-uniqueid-to-inodecache_WhenDirectRefer.patch

But this patch is not applicable to when Server is Windows.

=====================================================

You look similar problem at https://bugzilla.kernel.org/show_bug.cgi?id=90011
  but there need different bug patches.
Patching both 001 and 002 is better.
Comment 1 Jeff Layton 2014-12-18 12:45:57 UTC
This looks wrong to me.

The inode number is derived solely from the uniqueid, so you can't go and change that in place without rehashing the inode. If a dentry all of a sudden shows that it has a different inode number, then that dentry should be invalidated and a new one instantiated with the new inode.

The right thing to do is to ensure that cifs_d_revalidate returns appropriately when the inode number changes.
Comment 2 Nakajima Akira 2014-12-19 04:13:53 UTC
Created attachment 161301 [details]
patch__if different uniqueid, then return error
Comment 3 Nakajima Akira 2014-12-19 04:16:00 UTC
Thanks for review.

I posted new patch (attachment 161301 [details]) which return error.
(then cifs_d_revalidate return error, and make new dentry and inode)

With this patch, next problem is little bit changed.
"Limited at the time of the same inode number"
https://bugzilla.kernel.org/show_bug.cgi?id=90031
Comment 4 Ronnie Sahlberg 2019-02-07 04:11:09 UTC
Can not be reproduced in current kernel so has been fixed sometime in the past.