···657657 }658658 cFYI(1, ("Full path: %s inode = 0x%p", full_path, direntry->d_inode));659659660660+ /* Posix open is only called (at lookup time) for file create now.661661+ * For opens (rather than creates), because we do not know if it662662+ * is a file or directory yet, and current Samba no longer allows663663+ * us to do posix open on dirs, we could end up wasting an open call664664+ * on what turns out to be a dir. For file opens, we wait to call posix665665+ * open till cifs_open. It could be added here (lookup) in the future666666+ * but the performance tradeoff of the extra network request when EISDIR667667+ * or EACCES is returned would have to be weighed against the 50%668668+ * reduction in network traffic in the other paths.669669+ */660670 if (pTcon->unix_ext) {661671 if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY)) &&662662- (nd->flags & LOOKUP_OPEN) && !pTcon->broken_posix_open) {663663- if (!((nd->intent.open.flags & O_CREAT) &&664664- (nd->intent.open.flags & O_EXCL))) {665665- rc = cifs_posix_open(full_path, &newInode,672672+ (nd->flags & LOOKUP_OPEN) && !pTcon->broken_posix_open &&673673+ (nd->intent.open.flags & O_CREAT)) {674674+ rc = cifs_posix_open(full_path, &newInode,666675 parent_dir_inode->i_sb,667676 nd->intent.open.create_mode,668677 nd->intent.open.flags, &oplock,669678 &fileHandle, xid);670670- /*671671- * This code works around a bug in672672- * samba posix open in samba versions 3.3.1673673- * and earlier where create works674674- * but open fails with invalid parameter.675675- * If either of these error codes are676676- * returned, follow the normal lookup.677677- * Otherwise, the error during posix open678678- * is handled.679679- */680680- if ((rc != -EINVAL) && (rc != -EOPNOTSUPP))681681- posix_open = true;682682- else683683- pTcon->broken_posix_open = true;684684- }679679+ /*680680+ * The check below works around a bug in POSIX681681+ * open in samba versions 3.3.1 and earlier where682682+ * open could incorrectly fail with invalid parameter.683683+ * If either that or op not supported returned, follow684684+ * the normal lookup.685685+ */686686+ if ((rc == 0) || (rc == -ENOENT))687687+ posix_open = true;688688+ else if ((rc == -EINVAL) || (rc != -EOPNOTSUPP))689689+ pTcon->broken_posix_open = true;685690 }686691 if (!posix_open)687692 rc = cifs_get_inode_info_unix(&newInode, full_path,