Bug 52791
Summary: | cf_nlink always 0 for directories on Windows 7/2008 Server mounts | ||
---|---|---|---|
Product: | File System | Reporter: | Dominik Schramm (dominik.schramm) |
Component: | CIFS | Assignee: | fs_cifs (fs_cifs) |
Status: | RESOLVED WILL_NOT_FIX | ||
Severity: | normal | CC: | admin, alan, bugs, fengxiaoli0714, ihryll, jlayton, ntlgnt1, sitsofe, soubok+kernel, staskorz |
Priority: | P1 | ||
Hardware: | All | ||
OS: | Linux | ||
Kernel Version: | 3.7.1 | Subsystem: | |
Regression: | No | Bisected commit-id: | |
Attachments: | attachment-24633-0.html |
Description
Dominik Schramm
2013-01-18 11:39:26 UTC
Me, too™ To be more precise: I can confirm the issue with 3.8.13 on the client and Windows Server 2003 R2 as well as samba on the server side, so this doesn't seem related to the Windows version really. Workaround works for me, however the real fix should likely rather care about this "somewhere else": (In reply to Dominik Schramm from comment #0) > In other words, the following piece of code in the current kernel does not > work, as the link count cf_nlink seems to be reset to 0 somewhere else: I can confirm this is a problem as well and needs to be resolved asap. I am running: kernel: 2.6.32-358.11.1.el6.x86_64 Samba: 3.6.9-151.el6.x86_64 When mounting CIFS share from EMC NAS and sharing via Samba, directories appear as regular files. I attempted the 'workaround' above by modifying inode.c in cifs.ko but the function set_nlink did not exist so wrote my own fix to force inode to 2 on directories: inode->i_rdev = fattr->cf_rdev; if (fattr->cf_cifsattrs & ATTR_DIRECTORY) inode->i_nlink = 2; else inode->i_nlink = fattr->cf_nlink; inode->i_uid = fattr->cf_uid; inode->i_gid = fattr->cf_gid; This code fixed it for me. I imagine lots of people are having this issue. This appears to be a samba bug. It should be testing with S_ISDIR(). Setting up i_nlink might be nice but you would have to set it correctly to account for all the subdirectories or it'll confuse other software much of which treats "0" as "undefined" and avoids optimisations. Also 2.6.32 is a completely obsolete kernel! Closing as will not fix, but if you do cook up a full patch that gets i_nlink right for the subdirectory count then go for it. Not a samba bug actually, since the server in this case is Windows or in the case of comment #2, an EMC NAS. The CIFS protocol doesn't state that the server must return a value of at least 2 for the NumberOfLinks value on a directory like we expect with POSIX-y servers, so it's quite common for them to return a NumberOfLinks value of 0 on a directory. We have some code in more modern kernels to make the client fake up an i_nlink value when this happens. If you're using RHEL6 above, then you're welcome to open a RH support case and ask us to backport those patches to RHEL6 kernel. The commit Jeff is refering to appears to be http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/fs/cifs?id=74d290da476f672ad756634d12aa707375d3564d . I can't see any part of it in the 3.2 stable kernel so I think there is a good case for backporting it... Opened backport request https://bugzilla.redhat.com/show_bug.cgi?id=1554342 Test on 4.17.0-rc1. The cf_nlink is correct for the direcotry of mounted point. But when I create the son directory in the father directory. The cf_nlink of the father directory doesn't be changed. -bash-4.2# stat cifs File: ‘cifs’ Size: 20090880 Blocks: 39240 IO Block: 16384 directory Device: 2eh/46d Inode: 281474976710691 Links: 2 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Context: system_u:object_r:cifs_t:s0 Access: 2018-05-07 03:07:52.364814200 -0400 Modify: 2018-05-07 03:07:52.364814200 -0400 Change: 2018-05-07 03:07:52.364814200 -0400 Birth: - -bash-4.2# stat cifs/sub-dir File: ‘cifs/sub-dir’ Size: 0 Blocks: 0 IO Block: 16384 directory Device: 2eh/46d Inode: 19421773393972992 Links: 2 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Context: system_u:object_r:cifs_t:s0 Access: 2018-05-07 03:07:52.364814200 -0400 Modify: 2018-05-07 03:07:52.364814200 -0400 Change: 2018-05-07 03:07:52.364814200 -0400 Birth: - -bash-4.2# stat cifs File: ‘cifs’ Size: 20090880 Blocks: 39240 IO Block: 16384 directory Device: 2eh/46d Inode: 281474976710691 Links: 2 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Context: system_u:object_r:cifs_t:s0 Access: 2018-05-07 03:07:52.364814200 -0400 Modify: 2018-05-07 03:07:52.364814200 -0400 Change: 2018-05-07 03:07:52.364814200 -0400 |