]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
cifs: clean up handling when server doesn't consistently support inode numbers
authorJeff Layton <jlayton@redhat.com>
Fri, 6 Nov 2009 19:18:29 +0000 (14:18 -0500)
committerSteve French <sfrench@us.ibm.com>
Fri, 6 Nov 2009 22:04:37 +0000 (22:04 +0000)
It's possible that a server will return a valid FileID when we query the
FILE_INTERNAL_INFO for the root inode, but then zeroed out inode numbers
when we do a FindFile with an infolevel of
SMB_FIND_FILE_ID_FULL_DIR_INFO.

In this situation turn off querying for server inode numbers, generate a
warning for the user and just generate an inode number using iunique.
Once we generate any inode number with iunique we can no longer use any
server inode numbers or we risk collisions, so ensure that we don't do
that in cifs_get_inode_info either.

Cc: Stable <stable@kernel.org>
Reported-by: Timothy Normand Miller <theosib@gmail.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/cifsproto.h
fs/cifs/inode.c
fs/cifs/misc.c
fs/cifs/readdir.c

index 6928c24d1d4265557d1dbb499707425acf0d0cca..5646727e33f543f70ec449b390d8955b66852dc9 100644 (file)
@@ -388,4 +388,5 @@ extern int CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon,
                const struct nls_table *nls_codepage, int remap_special_chars);
 extern int CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
                        const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
+extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
 #endif                 /* _CIFSPROTO_H */
index 5e2492535daa4ca626ec1e45e812ebd194fa7a2b..cababd8a52df32097f3219327ef491254ced34f0 100644 (file)
@@ -512,13 +512,10 @@ int cifs_get_inode_info(struct inode **pinode,
                                        cifs_sb->local_nls,
                                        cifs_sb->mnt_cifs_flags &
                                                CIFS_MOUNT_MAP_SPECIAL_CHR);
-                       if (rc1) {
+                       if (rc1 || !fattr.cf_uniqueid) {
                                cFYI(1, ("GetSrvInodeNum rc %d", rc1));
                                fattr.cf_uniqueid = iunique(sb, ROOT_I);
-                               /* disable serverino if call not supported */
-                               if (rc1 == -EINVAL)
-                                       cifs_sb->mnt_cifs_flags &=
-                                                       ~CIFS_MOUNT_SERVER_INUM;
+                               cifs_autodisable_serverino(cifs_sb);
                        }
                } else {
                        fattr.cf_uniqueid = iunique(sb, ROOT_I);
index 0241b25ac33ff0fbd48545f83a0f6e2cd3ca6e22..1e25efcb55c8cb43ac0a7c15a22c8aa3e9b935f4 100644 (file)
@@ -715,3 +715,17 @@ cifsConvertToUCS(__le16 *target, const char *source, int maxlen,
 ctoUCS_out:
        return i;
 }
+
+void
+cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)
+{
+       if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
+               cifs_sb->mnt_cifs_flags &= CIFS_MOUNT_SERVER_INUM;
+               cERROR(1, ("Autodisabling the use of server inode numbers on "
+                          "%s. This server doesn't seem to support them "
+                          "properly. Hardlinks will not be recognized on this "
+                          "mount. Consider mounting with the \"noserverino\" "
+                          "option to silence this message.",
+                          cifs_sb->tcon->treeName));
+       }
+}
index 1f098ca7163602bcdbb75aa4a69ed1f2bde4b8a2..f84062f9a9850a9fa4f38a5b4ec9f657c42ae474 100644 (file)
@@ -727,11 +727,12 @@ static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir,
                cifs_dir_info_to_fattr(&fattr, (FILE_DIRECTORY_INFO *)
                                        pfindEntry, cifs_sb);
 
-       /* FIXME: make _to_fattr functions fill this out */
-       if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_ID_FULL_DIR_INFO)
+       if (inum && (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
                fattr.cf_uniqueid = inum;
-       else
+       } else {
                fattr.cf_uniqueid = iunique(sb, ROOT_I);
+               cifs_autodisable_serverino(cifs_sb);
+       }
 
        ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid);
        tmp_dentry = cifs_readdir_lookup(file->f_dentry, &qstring, &fattr);