]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
authorSteve French <sfrench@us.ibm.com>
Fri, 14 Mar 2008 19:29:18 +0000 (19:29 +0000)
committerSteve French <sfrench@us.ibm.com>
Fri, 14 Mar 2008 19:29:18 +0000 (19:29 +0000)
fs/cifs/cifs_dfs_ref.c
fs/cifs/cifsproto.h
fs/cifs/dns_resolve.c
fs/cifs/inode.c

index 7f8838253410572397725dffd3d92abba884c20c..a1a95b0271362cc2ef7feb34e3523781e833997f 100644 (file)
@@ -74,7 +74,7 @@ static char *cifs_get_share_name(const char *node_name)
        pSep = memchr(UNC+2, '\\', len-2);
        if (!pSep) {
                cERROR(1, ("%s: no server name end in node name: %s",
-                       __FUNCTION__, node_name));
+                       __func__, node_name));
                kfree(UNC);
                return NULL;
        }
@@ -84,7 +84,7 @@ static char *cifs_get_share_name(const char *node_name)
        pSep = memchr(UNC+(pSep-UNC), '\\', len-(pSep-UNC));
        if (!pSep) {
                cERROR(1, ("%s:2 cant find share name in node name: %s",
-                       __FUNCTION__, node_name));
+                       __func__, node_name));
                kfree(UNC);
                return NULL;
        }
@@ -127,7 +127,7 @@ static char *compose_mount_options(const char *sb_mountdata,
        rc = dns_resolve_server_name_to_ip(*devname, &srvIP);
        if (rc != 0) {
                cERROR(1, ("%s: Failed to resolve server part of %s to IP",
-                         __FUNCTION__, *devname));
+                         __func__, *devname));
                mountdata = ERR_PTR(rc);
                goto compose_mount_options_out;
        }
@@ -181,8 +181,8 @@ static char *compose_mount_options(const char *sb_mountdata,
                }
        }
 
-       /*cFYI(1,("%s: parent mountdata: %s", __FUNCTION__,sb_mountdata));*/
-       /*cFYI(1, ("%s: submount mountdata: %s", __FUNCTION__, mountdata ));*/
+       /*cFYI(1,("%s: parent mountdata: %s", __func__,sb_mountdata));*/
+       /*cFYI(1, ("%s: submount mountdata: %s", __func__, mountdata ));*/
 
 compose_mount_options_out:
        kfree(srvIP);
@@ -302,7 +302,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
        int rc = 0;
        struct vfsmount *mnt = ERR_PTR(-ENOENT);
 
-       cFYI(1, ("in %s", __FUNCTION__));
+       cFYI(1, ("in %s", __func__));
        BUG_ON(IS_ROOT(dentry));
 
        xid = GetXid();
@@ -336,7 +336,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
                        len = strlen(referrals[i].node_name);
                        if (len < 2) {
                                cERROR(1, ("%s: Net Address path too short: %s",
-                                       __FUNCTION__, referrals[i].node_name));
+                                       __func__, referrals[i].node_name));
                                rc = -EINVAL;
                                goto out_err;
                        }
@@ -344,7 +344,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
                                                nd->path.dentry,
                                                referrals[i].node_name);
                        cFYI(1, ("%s: cifs_dfs_do_refmount:%s , mnt:%p",
-                                        __FUNCTION__,
+                                        __func__,
                                        referrals[i].node_name, mnt));
 
                        /* complete mount procedure if we accured submount */
@@ -365,7 +365,7 @@ out:
        FreeXid(xid);
        free_dfs_info_array(referrals, num_referrals);
        kfree(full_path);
-       cFYI(1, ("leaving %s" , __FUNCTION__));
+       cFYI(1, ("leaving %s" , __func__));
        return ERR_PTR(rc);
 out_err:
        path_put(&nd->path);
index 0af63e6b426be4044e5d921c0b2ae53da517e5e5..a0414bda587c6d9da7b972701516c7be29c0d143 100644 (file)
@@ -39,8 +39,8 @@ extern int smb_send(struct socket *, struct smb_hdr *,
                        unsigned int /* length */ , struct sockaddr *);
 extern unsigned int _GetXid(void);
 extern void _FreeXid(unsigned int);
-#define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__FUNCTION__, xid,current->fsuid));
-#define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__FUNCTION__,curr_xid,(int)rc));}
+#define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__func__, xid,current->fsuid));
+#define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__func__,curr_xid,(int)rc));}
 extern char *build_path_from_dentry(struct dentry *);
 extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
 /* extern void renew_parental_timestamps(struct dentry *direntry);*/
index ef7f43824347f0b4960ae786fcc575eb5fbae4b7..7cc86c418182f261954dbcd18e8efd09b08df108 100644 (file)
@@ -77,14 +77,14 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
        /* search for server name delimiter */
        len = strlen(unc);
        if (len < 3) {
-               cFYI(1, ("%s: unc is too short: %s", __FUNCTION__, unc));
+               cFYI(1, ("%s: unc is too short: %s", __func__, unc));
                return -EINVAL;
        }
        len -= 2;
        name = memchr(unc+2, '\\', len);
        if (!name) {
                cFYI(1, ("%s: probably server name is whole unc: %s",
-                                       __FUNCTION__, unc));
+                                       __func__, unc));
        } else {
                len = (name - unc) - 2/* leading // */;
        }
@@ -104,7 +104,7 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
                if (*ip_addr) {
                        memcpy(*ip_addr, rkey->payload.data, len);
                        (*ip_addr)[len] = '\0';
-                       cFYI(1, ("%s: resolved: %s to %s", __FUNCTION__,
+                       cFYI(1, ("%s: resolved: %s to %s", __func__,
                                        rkey->description,
                                        *ip_addr
                                ));
@@ -114,7 +114,7 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
                }
                key_put(rkey);
        } else {
-               cERROR(1, ("%s: unable to resolve: %s", __FUNCTION__, name));
+               cERROR(1, ("%s: unable to resolve: %s", __func__, name));
        }
 
        kfree(name);
index 24eb4d392155b8d4482e7ff94f369c0a8c3a035d..e57e5c46ad48a2daea56c80bb911e5b8e1fc4098 100644 (file)
@@ -30,7 +30,7 @@
 #include "cifs_fs_sb.h"
 
 
-static void cifs_set_ops(struct inode *inode)
+static void cifs_set_ops(struct inode *inode, const bool is_dfs_referral)
 {
        struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
 
@@ -57,8 +57,16 @@ static void cifs_set_ops(struct inode *inode)
                        inode->i_data.a_ops = &cifs_addr_ops;
                break;
        case S_IFDIR:
-               inode->i_op = &cifs_dir_inode_ops;
-               inode->i_fop = &cifs_dir_ops;
+#ifdef CONFIG_CIFS_DFS_UPCALL
+               if (is_dfs_referral) {
+                       inode->i_op = &cifs_dfs_referral_inode_operations;
+               } else {
+#else /* NO DFS support, treat as a directory */
+               {
+#endif
+                       inode->i_op = &cifs_dir_inode_ops;
+                       inode->i_fop = &cifs_dir_ops;
+               }
                break;
        case S_IFLNK:
                inode->i_op = &cifs_symlink_inode_ops;
@@ -153,6 +161,30 @@ static void cifs_unix_info_to_inode(struct inode *inode,
        spin_unlock(&inode->i_lock);
 }
 
+static const unsigned char *cifs_get_search_path(struct cifsTconInfo *pTcon,
+                                       const char *search_path)
+{
+       int tree_len;
+       int path_len;
+       char *tmp_path;
+
+       if (!(pTcon->Flags & SMB_SHARE_IS_IN_DFS))
+               return search_path;
+
+       /* use full path name for working with DFS */
+       tree_len = strnlen(pTcon->treeName, MAX_TREE_SIZE + 1);
+       path_len = strnlen(search_path, MAX_PATHCONF);
+
+       tmp_path = kmalloc(tree_len+path_len+1, GFP_KERNEL);
+       if (tmp_path == NULL)
+               return search_path;
+
+       strncpy(tmp_path, pTcon->treeName, tree_len);
+       strncpy(tmp_path+tree_len, search_path, path_len);
+       tmp_path[tree_len+path_len] = 0;
+       return tmp_path;
+}
+
 int cifs_get_inode_info_unix(struct inode **pinode,
        const unsigned char *search_path, struct super_block *sb, int xid)
 {
@@ -161,41 +193,28 @@ int cifs_get_inode_info_unix(struct inode **pinode,
        struct cifsTconInfo *pTcon;
        struct inode *inode;
        struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
-       char *tmp_path;
+       const unsigned char *full_path;
+       bool is_dfs_referral = false;
 
        pTcon = cifs_sb->tcon;
        cFYI(1, ("Getting info on %s", search_path));
+
+       full_path = cifs_get_search_path(pTcon, search_path);
+
+try_again_CIFSSMBUnixQPathInfo:
        /* could have done a find first instead but this returns more info */
-       rc = CIFSSMBUnixQPathInfo(xid, pTcon, search_path, &findData,
+       rc = CIFSSMBUnixQPathInfo(xid, pTcon, full_path, &findData,
                                  cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
                                        CIFS_MOUNT_MAP_SPECIAL_CHR);
 /*     dump_mem("\nUnixQPathInfo return data", &findData,
                 sizeof(findData)); */
        if (rc) {
-               if (rc == -EREMOTE) {
-                       tmp_path =
-                           kmalloc(strnlen(pTcon->treeName,
-                                           MAX_TREE_SIZE + 1) +
-                                   strnlen(search_path, MAX_PATHCONF) + 1,
-                                   GFP_KERNEL);
-                       if (tmp_path == NULL)
-                               return -ENOMEM;
-
-                       /* have to skip first of the double backslash of
-                          UNC name */
-                       strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE);
-                       strncat(tmp_path, search_path, MAX_PATHCONF);
-                       rc = connect_to_dfs_path(xid, pTcon->ses,
-                                                /* treename + */ tmp_path,
-                                                cifs_sb->local_nls,
-                                                cifs_sb->mnt_cifs_flags &
-                                                   CIFS_MOUNT_MAP_SPECIAL_CHR);
-                       kfree(tmp_path);
-
-                       /* BB fix up inode etc. */
-               } else if (rc) {
-                       return rc;
+               if (rc == -EREMOTE && !is_dfs_referral) {
+                       is_dfs_referral = true;
+                       full_path = search_path;
+                       goto try_again_CIFSSMBUnixQPathInfo;
                }
+               goto cgiiu_exit;
        } else {
                struct cifsInodeInfo *cifsInfo;
                __u64 num_of_bytes = le64_to_cpu(findData.NumOfBytes);
@@ -204,8 +223,10 @@ int cifs_get_inode_info_unix(struct inode **pinode,
                /* get new inode */
                if (*pinode == NULL) {
                        *pinode = new_inode(sb);
-                       if (*pinode == NULL)
-                               return -ENOMEM;
+                       if (*pinode == NULL) {
+                               rc = -ENOMEM;
+                               goto cgiiu_exit;
+                       }
                        /* Is an i_ino of zero legal? */
                        /* Are there sanity checks we can use to ensure that
                           the server is really filling in that field? */
@@ -237,8 +258,11 @@ int cifs_get_inode_info_unix(struct inode **pinode,
                        (unsigned long) inode->i_size,
                        (unsigned long long)inode->i_blocks));
 
-               cifs_set_ops(inode);
+               cifs_set_ops(inode, is_dfs_referral);
        }
+cgiiu_exit:
+       if (full_path != search_path)
+               kfree(full_path);
        return rc;
 }
 
@@ -353,9 +377,10 @@ int cifs_get_inode_info(struct inode **pinode,
        struct cifsTconInfo *pTcon;
        struct inode *inode;
        struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
-       char *tmp_path;
+       const unsigned char *full_path = NULL;
        char *buf = NULL;
        int adjustTZ = FALSE;
+       bool is_dfs_referral = false;
 
        pTcon = cifs_sb->tcon;
        cFYI(1, ("Getting info on %s", search_path));
@@ -373,8 +398,12 @@ int cifs_get_inode_info(struct inode **pinode,
                if (buf == NULL)
                        return -ENOMEM;
                pfindData = (FILE_ALL_INFO *)buf;
+
+               full_path = cifs_get_search_path(pTcon, search_path);
+
+try_again_CIFSSMBQPathInfo:
                /* could do find first instead but this returns more info */
-               rc = CIFSSMBQPathInfo(xid, pTcon, search_path, pfindData,
+               rc = CIFSSMBQPathInfo(xid, pTcon, full_path, pfindData,
                              0 /* not legacy */,
                              cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
                                CIFS_MOUNT_MAP_SPECIAL_CHR);
@@ -382,7 +411,7 @@ int cifs_get_inode_info(struct inode **pinode,
                when server claims no NT SMB support and the above call
                failed at least once - set flag in tcon or mount */
                if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
-                       rc = SMBQueryInformation(xid, pTcon, search_path,
+                       rc = SMBQueryInformation(xid, pTcon, full_path,
                                        pfindData, cifs_sb->local_nls,
                                        cifs_sb->mnt_cifs_flags &
                                          CIFS_MOUNT_MAP_SPECIAL_CHR);
@@ -391,31 +420,12 @@ int cifs_get_inode_info(struct inode **pinode,
        }
        /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */
        if (rc) {
-               if (rc == -EREMOTE) {
-                       tmp_path =
-                           kmalloc(strnlen
-                                   (pTcon->treeName,
-                                    MAX_TREE_SIZE + 1) +
-                                   strnlen(search_path, MAX_PATHCONF) + 1,
-                                   GFP_KERNEL);
-                       if (tmp_path == NULL) {
-                               kfree(buf);
-                               return -ENOMEM;
-                       }
-
-                       strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE);
-                       strncat(tmp_path, search_path, MAX_PATHCONF);
-                       rc = connect_to_dfs_path(xid, pTcon->ses,
-                                                /* treename + */ tmp_path,
-                                                cifs_sb->local_nls,
-                                                cifs_sb->mnt_cifs_flags &
-                                                  CIFS_MOUNT_MAP_SPECIAL_CHR);
-                       kfree(tmp_path);
-                       /* BB fix up inode etc. */
-               } else if (rc) {
-                       kfree(buf);
-                       return rc;
+               if (rc == -EREMOTE && !is_dfs_referral) {
+                       is_dfs_referral = true;
+                       full_path = search_path;
+                       goto try_again_CIFSSMBQPathInfo;
                }
+               goto cgii_exit;
        } else {
                struct cifsInodeInfo *cifsInfo;
                __u32 attr = le32_to_cpu(pfindData->Attributes);
@@ -424,8 +434,8 @@ int cifs_get_inode_info(struct inode **pinode,
                if (*pinode == NULL) {
                        *pinode = new_inode(sb);
                        if (*pinode == NULL) {
-                               kfree(buf);
-                               return -ENOMEM;
+                               rc = -ENOMEM;
+                               goto cgii_exit;
                        }
                        /* Is an i_ino of zero legal? Can we use that to check
                           if the server supports returning inode numbers?  Are
@@ -573,8 +583,11 @@ int cifs_get_inode_info(struct inode **pinode,
                        atomic_set(&cifsInfo->inUse, 1);
                }
 
-               cifs_set_ops(inode);
+               cifs_set_ops(inode, is_dfs_referral);
        }
+cgii_exit:
+       if (full_path != search_path)
+               kfree(full_path);
        kfree(buf);
        return rc;
 }
@@ -804,7 +817,7 @@ static void posix_fill_in_inode(struct inode *tmp_inode,
        local_size  = tmp_inode->i_size;
 
        cifs_unix_info_to_inode(tmp_inode, pData, 1);
-       cifs_set_ops(tmp_inode);
+       cifs_set_ops(tmp_inode, false);
 
        if (!S_ISREG(tmp_inode->i_mode))
                return;
@@ -1407,11 +1420,10 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
        }
        cifsInode = CIFS_I(direntry->d_inode);
 
-       /* BB check if we need to refresh inode from server now ? BB */
-
-       if (attrs->ia_valid & ATTR_SIZE) {
+       if ((attrs->ia_valid & ATTR_MTIME) || (attrs->ia_valid & ATTR_SIZE)) {
                /*
-                  Flush data before changing file size on server. If the
+                  Flush data before changing file size or changing the last
+                  write time of the file on the server. If the
                   flush returns error, store it to report later and continue.
                   BB: This should be smarter. Why bother flushing pages that
                   will be truncated anyway? Also, should we error out here if
@@ -1422,7 +1434,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
                        CIFS_I(direntry->d_inode)->write_behind_rc = rc;
                        rc = 0;
                }
+       }
 
+       if (attrs->ia_valid & ATTR_SIZE) {
                /* To avoid spurious oplock breaks from server, in the case of
                   inodes that we already have open, avoid doing path based
                   setting of file size if we can do it by handle.