Commit d81b8a40e2ece0a9ab57b1fe1798e291e75bf8fc

Authored by Pavel Shilovsky
Committed by Steve French
1 parent 0360d605a2

CIFS: Cleanup cifs open codepath

Rename CIFSSMBOpen to CIFS_open and make it take
cifs_open_parms structure as a parm.

Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: Steve French <smfrench@gmail.com>

Showing 8 changed files with 174 additions and 100 deletions Side-by-side Diff

... ... @@ -895,9 +895,10 @@
895 895 int oplock = 0;
896 896 unsigned int xid;
897 897 int rc, create_options = 0;
898   - __u16 fid;
899 898 struct cifs_tcon *tcon;
900 899 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
  900 + struct cifs_fid fid;
  901 + struct cifs_open_parms oparms;
901 902  
902 903 if (IS_ERR(tlink))
903 904 return ERR_CAST(tlink);
904 905  
... ... @@ -908,12 +909,19 @@
908 909 if (backup_cred(cifs_sb))
909 910 create_options |= CREATE_OPEN_BACKUP_INTENT;
910 911  
911   - rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL,
912   - create_options, &fid, &oplock, NULL, cifs_sb->local_nls,
913   - cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  912 + oparms.tcon = tcon;
  913 + oparms.cifs_sb = cifs_sb;
  914 + oparms.desired_access = READ_CONTROL;
  915 + oparms.create_options = create_options;
  916 + oparms.disposition = FILE_OPEN;
  917 + oparms.path = path;
  918 + oparms.fid = &fid;
  919 + oparms.reconnect = false;
  920 +
  921 + rc = CIFS_open(xid, &oparms, &oplock, NULL);
914 922 if (!rc) {
915   - rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
916   - CIFSSMBClose(xid, tcon, fid);
  923 + rc = CIFSSMBGetCIFSACL(xid, tcon, fid.netfid, &pntsd, pacllen);
  924 + CIFSSMBClose(xid, tcon, fid.netfid);
917 925 }
918 926  
919 927 cifs_put_tlink(tlink);
920 928  
... ... @@ -950,10 +958,11 @@
950 958 int oplock = 0;
951 959 unsigned int xid;
952 960 int rc, access_flags, create_options = 0;
953   - __u16 fid;
954 961 struct cifs_tcon *tcon;
955 962 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
956 963 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
  964 + struct cifs_fid fid;
  965 + struct cifs_open_parms oparms;
957 966  
958 967 if (IS_ERR(tlink))
959 968 return PTR_ERR(tlink);
960 969  
961 970  
... ... @@ -969,18 +978,25 @@
969 978 else
970 979 access_flags = WRITE_DAC;
971 980  
972   - rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, access_flags,
973   - create_options, &fid, &oplock, NULL, cifs_sb->local_nls,
974   - cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  981 + oparms.tcon = tcon;
  982 + oparms.cifs_sb = cifs_sb;
  983 + oparms.desired_access = access_flags;
  984 + oparms.create_options = create_options;
  985 + oparms.disposition = FILE_OPEN;
  986 + oparms.path = path;
  987 + oparms.fid = &fid;
  988 + oparms.reconnect = false;
  989 +
  990 + rc = CIFS_open(xid, &oparms, &oplock, NULL);
975 991 if (rc) {
976 992 cifs_dbg(VFS, "Unable to open file to set ACL\n");
977 993 goto out;
978 994 }
979 995  
980   - rc = CIFSSMBSetCIFSACL(xid, tcon, fid, pnntsd, acllen, aclflag);
  996 + rc = CIFSSMBSetCIFSACL(xid, tcon, fid.netfid, pnntsd, acllen, aclflag);
981 997 cifs_dbg(NOISY, "SetCIFSACL rc = %d\n", rc);
982 998  
983   - CIFSSMBClose(xid, tcon, fid);
  999 + CIFSSMBClose(xid, tcon, fid.netfid);
984 1000 out:
985 1001 free_xid(xid);
986 1002 cifs_put_tlink(tlink);
... ... @@ -362,11 +362,8 @@
362 362 const struct nls_table *nls_codepage);
363 363 extern int CIFSSMB_set_compression(const unsigned int xid,
364 364 struct cifs_tcon *tcon, __u16 fid);
365   -extern int CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon,
366   - const char *path, const int disposition,
367   - const int desired_access, const int create_options,
368   - __u16 *netfid, int *oplock, FILE_ALL_INFO *buf,
369   - const struct nls_table *nls, int remap);
  365 +extern int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms,
  366 + int *oplock, FILE_ALL_INFO *buf);
370 367 extern int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
371 368 const char *fileName, const int disposition,
372 369 const int access_flags, const int omode,
... ... @@ -1273,10 +1273,8 @@
1273 1273 }
1274 1274  
1275 1275 int
1276   -CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon,
1277   - const char *path, const int disposition, const int desired_access,
1278   - const int create_options, __u16 *netfid, int *oplock,
1279   - FILE_ALL_INFO *buf, const struct nls_table *nls, int remap)
  1276 +CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, int *oplock,
  1277 + FILE_ALL_INFO *buf)
1280 1278 {
1281 1279 int rc = -EACCES;
1282 1280 OPEN_REQ *req = NULL;
... ... @@ -1284,6 +1282,14 @@
1284 1282 int bytes_returned;
1285 1283 int name_len;
1286 1284 __u16 count;
  1285 + struct cifs_sb_info *cifs_sb = oparms->cifs_sb;
  1286 + struct cifs_tcon *tcon = oparms->tcon;
  1287 + int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
  1288 + const struct nls_table *nls = cifs_sb->local_nls;
  1289 + int create_options = oparms->create_options;
  1290 + int desired_access = oparms->desired_access;
  1291 + int disposition = oparms->disposition;
  1292 + const char *path = oparms->path;
1287 1293  
1288 1294 openRetry:
1289 1295 rc = smb_init(SMB_COM_NT_CREATE_ANDX, 24, tcon, (void **)&req,
... ... @@ -1367,7 +1373,7 @@
1367 1373 /* 1 byte no need to le_to_cpu */
1368 1374 *oplock = rsp->OplockLevel;
1369 1375 /* cifs fid stays in le */
1370   - *netfid = rsp->Fid;
  1376 + oparms->fid->netfid = rsp->Fid;
1371 1377  
1372 1378 /* Let caller know file was created so we can set the mode. */
1373 1379 /* Do we care about the CreateAction in any other cases? */
... ... @@ -570,7 +570,8 @@
570 570 char *full_path = NULL;
571 571 struct inode *newinode = NULL;
572 572 int oplock = 0;
573   - u16 netfid;
  573 + struct cifs_fid fid;
  574 + struct cifs_open_parms oparms;
574 575 FILE_ALL_INFO *buf = NULL;
575 576 unsigned int bytes_written;
576 577 struct win_dev *pdev;
... ... @@ -640,10 +641,16 @@
640 641 if (backup_cred(cifs_sb))
641 642 create_options |= CREATE_OPEN_BACKUP_INTENT;
642 643  
643   - rc = CIFSSMBOpen(xid, tcon, full_path, FILE_CREATE,
644   - GENERIC_WRITE, create_options,
645   - &netfid, &oplock, buf, cifs_sb->local_nls,
646   - cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  644 + oparms.tcon = tcon;
  645 + oparms.cifs_sb = cifs_sb;
  646 + oparms.desired_access = GENERIC_WRITE;
  647 + oparms.create_options = create_options;
  648 + oparms.disposition = FILE_CREATE;
  649 + oparms.path = full_path;
  650 + oparms.fid = &fid;
  651 + oparms.reconnect = false;
  652 +
  653 + rc = CIFS_open(xid, &oparms, &oplock, buf);
647 654 if (rc)
648 655 goto mknod_out;
649 656  
... ... @@ -653,7 +660,7 @@
653 660 */
654 661  
655 662 pdev = (struct win_dev *)buf;
656   - io_parms.netfid = netfid;
  663 + io_parms.netfid = fid.netfid;
657 664 io_parms.pid = current->tgid;
658 665 io_parms.tcon = tcon;
659 666 io_parms.offset = 0;
... ... @@ -671,7 +678,7 @@
671 678 rc = CIFSSMBWrite(xid, &io_parms, &bytes_written, (char *)pdev,
672 679 NULL, 0);
673 680 } /* else if (S_ISFIFO) */
674   - CIFSSMBClose(xid, tcon, netfid);
  681 + CIFSSMBClose(xid, tcon, fid.netfid);
675 682 d_drop(direntry);
676 683  
677 684 /* FIXME: add code here to set EAs */
... ... @@ -678,7 +678,7 @@
678 678  
679 679 /*
680 680 * Can not refresh inode by passing in file_info buf to be returned by
681   - * CIFSSMBOpen and then calling get_inode_info with returned buf since
  681 + * ops->open and then calling get_inode_info with returned buf since
682 682 * file might have write behind data that needs to be flushed and server
683 683 * version of file size can be stale. If we knew for sure that inode was
684 684 * not dirty locally we could do this.
... ... @@ -409,9 +409,10 @@
409 409 {
410 410 int rc;
411 411 int oplock = 0;
412   - __u16 netfid;
413 412 struct tcon_link *tlink;
414 413 struct cifs_tcon *tcon;
  414 + struct cifs_fid fid;
  415 + struct cifs_open_parms oparms;
415 416 struct cifs_io_parms io_parms;
416 417 char buf[24];
417 418 unsigned int bytes_read;
418 419  
... ... @@ -437,18 +438,23 @@
437 438 return PTR_ERR(tlink);
438 439 tcon = tlink_tcon(tlink);
439 440  
440   - rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, GENERIC_READ,
441   - CREATE_NOT_DIR, &netfid, &oplock, NULL,
442   - cifs_sb->local_nls,
443   - cifs_sb->mnt_cifs_flags &
444   - CIFS_MOUNT_MAP_SPECIAL_CHR);
  441 + oparms.tcon = tcon;
  442 + oparms.cifs_sb = cifs_sb;
  443 + oparms.desired_access = GENERIC_READ;
  444 + oparms.create_options = CREATE_NOT_DIR;
  445 + oparms.disposition = FILE_OPEN;
  446 + oparms.path = path;
  447 + oparms.fid = &fid;
  448 + oparms.reconnect = false;
  449 +
  450 + rc = CIFS_open(xid, &oparms, &oplock, NULL);
445 451 if (rc) {
446 452 cifs_put_tlink(tlink);
447 453 return rc;
448 454 }
449 455  
450 456 /* Read header */
451   - io_parms.netfid = netfid;
  457 + io_parms.netfid = fid.netfid;
452 458 io_parms.pid = current->tgid;
453 459 io_parms.tcon = tcon;
454 460 io_parms.offset = 0;
... ... @@ -494,7 +500,7 @@
494 500 fattr->cf_dtype = DT_REG;
495 501 rc = -EOPNOTSUPP; /* or some unknown SFU type */
496 502 }
497   - CIFSSMBClose(xid, tcon, netfid);
  503 + CIFSSMBClose(xid, tcon, fid.netfid);
498 504 cifs_put_tlink(tlink);
499 505 return rc;
500 506 }
... ... @@ -1035,7 +1041,8 @@
1035 1041 {
1036 1042 int oplock = 0;
1037 1043 int rc;
1038   - __u16 netfid;
  1044 + struct cifs_fid fid;
  1045 + struct cifs_open_parms oparms;
1039 1046 struct inode *inode = dentry->d_inode;
1040 1047 struct cifsInodeInfo *cifsInode = CIFS_I(inode);
1041 1048 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
... ... @@ -1058,10 +1065,16 @@
1058 1065 goto out;
1059 1066 }
1060 1067  
1061   - rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
1062   - DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR,
1063   - &netfid, &oplock, NULL, cifs_sb->local_nls,
1064   - cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  1068 + oparms.tcon = tcon;
  1069 + oparms.cifs_sb = cifs_sb;
  1070 + oparms.desired_access = DELETE | FILE_WRITE_ATTRIBUTES;
  1071 + oparms.create_options = CREATE_NOT_DIR;
  1072 + oparms.disposition = FILE_OPEN;
  1073 + oparms.path = full_path;
  1074 + oparms.fid = &fid;
  1075 + oparms.reconnect = false;
  1076 +
  1077 + rc = CIFS_open(xid, &oparms, &oplock, NULL);
1065 1078 if (rc != 0)
1066 1079 goto out;
1067 1080  
... ... @@ -1082,7 +1095,7 @@
1082 1095 goto out_close;
1083 1096 }
1084 1097 info_buf->Attributes = cpu_to_le32(dosattr);
1085   - rc = CIFSSMBSetFileInfo(xid, tcon, info_buf, netfid,
  1098 + rc = CIFSSMBSetFileInfo(xid, tcon, info_buf, fid.netfid,
1086 1099 current->tgid);
1087 1100 /* although we would like to mark the file hidden
1088 1101 if that fails we will still try to rename it */
... ... @@ -1093,7 +1106,8 @@
1093 1106 }
1094 1107  
1095 1108 /* rename the file */
1096   - rc = CIFSSMBRenameOpenFile(xid, tcon, netfid, NULL, cifs_sb->local_nls,
  1109 + rc = CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, NULL,
  1110 + cifs_sb->local_nls,
1097 1111 cifs_sb->mnt_cifs_flags &
1098 1112 CIFS_MOUNT_MAP_SPECIAL_CHR);
1099 1113 if (rc != 0) {
... ... @@ -1103,7 +1117,7 @@
1103 1117  
1104 1118 /* try to set DELETE_ON_CLOSE */
1105 1119 if (!cifsInode->delete_pending) {
1106   - rc = CIFSSMBSetFileDisposition(xid, tcon, true, netfid,
  1120 + rc = CIFSSMBSetFileDisposition(xid, tcon, true, fid.netfid,
1107 1121 current->tgid);
1108 1122 /*
1109 1123 * some samba versions return -ENOENT when we try to set the
... ... @@ -1123,7 +1137,7 @@
1123 1137 }
1124 1138  
1125 1139 out_close:
1126   - CIFSSMBClose(xid, tcon, netfid);
  1140 + CIFSSMBClose(xid, tcon, fid.netfid);
1127 1141 out:
1128 1142 kfree(info_buf);
1129 1143 cifs_put_tlink(tlink);
1130 1144  
... ... @@ -1135,13 +1149,13 @@
1135 1149 * them anyway.
1136 1150 */
1137 1151 undo_rename:
1138   - CIFSSMBRenameOpenFile(xid, tcon, netfid, dentry->d_name.name,
  1152 + CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, dentry->d_name.name,
1139 1153 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
1140 1154 CIFS_MOUNT_MAP_SPECIAL_CHR);
1141 1155 undo_setattr:
1142 1156 if (dosattr != origattr) {
1143 1157 info_buf->Attributes = cpu_to_le32(origattr);
1144   - if (!CIFSSMBSetFileInfo(xid, tcon, info_buf, netfid,
  1158 + if (!CIFSSMBSetFileInfo(xid, tcon, info_buf, fid.netfid,
1145 1159 current->tgid))
1146 1160 cifsInode->cifsAttrs = origattr;
1147 1161 }
... ... @@ -1552,7 +1566,8 @@
1552 1566 struct tcon_link *tlink;
1553 1567 struct cifs_tcon *tcon;
1554 1568 struct TCP_Server_Info *server;
1555   - __u16 srcfid;
  1569 + struct cifs_fid fid;
  1570 + struct cifs_open_parms oparms;
1556 1571 int oplock, rc;
1557 1572  
1558 1573 tlink = cifs_sb_tlink(cifs_sb);
1559 1574  
1560 1575  
1561 1576  
... ... @@ -1579,17 +1594,23 @@
1579 1594 if (to_dentry->d_parent != from_dentry->d_parent)
1580 1595 goto do_rename_exit;
1581 1596  
  1597 + oparms.tcon = tcon;
  1598 + oparms.cifs_sb = cifs_sb;
1582 1599 /* open the file to be renamed -- we need DELETE perms */
1583   - rc = CIFSSMBOpen(xid, tcon, from_path, FILE_OPEN, DELETE,
1584   - CREATE_NOT_DIR, &srcfid, &oplock, NULL,
1585   - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
1586   - CIFS_MOUNT_MAP_SPECIAL_CHR);
  1600 + oparms.desired_access = DELETE;
  1601 + oparms.create_options = CREATE_NOT_DIR;
  1602 + oparms.disposition = FILE_OPEN;
  1603 + oparms.path = from_path;
  1604 + oparms.fid = &fid;
  1605 + oparms.reconnect = false;
  1606 +
  1607 + rc = CIFS_open(xid, &oparms, &oplock, NULL);
1587 1608 if (rc == 0) {
1588   - rc = CIFSSMBRenameOpenFile(xid, tcon, srcfid,
  1609 + rc = CIFSSMBRenameOpenFile(xid, tcon, fid.netfid,
1589 1610 (const char *) to_dentry->d_name.name,
1590 1611 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
1591 1612 CIFS_MOUNT_MAP_SPECIAL_CHR);
1592   - CIFSSMBClose(xid, tcon, srcfid);
  1613 + CIFSSMBClose(xid, tcon, fid.netfid);
1593 1614 }
1594 1615 do_rename_exit:
1595 1616 cifs_put_tlink(tlink);
... ... @@ -320,16 +320,22 @@
320 320 {
321 321 int rc;
322 322 int oplock = 0;
323   - __u16 netfid = 0;
  323 + struct cifs_fid fid;
  324 + struct cifs_open_parms oparms;
324 325 struct cifs_io_parms io_parms;
325 326 int buf_type = CIFS_NO_BUFFER;
326 327 FILE_ALL_INFO file_info;
327 328  
328   - rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, GENERIC_READ,
329   - CREATE_NOT_DIR, &netfid, &oplock, &file_info,
330   - cifs_sb->local_nls,
331   - cifs_sb->mnt_cifs_flags &
332   - CIFS_MOUNT_MAP_SPECIAL_CHR);
  329 + oparms.tcon = tcon;
  330 + oparms.cifs_sb = cifs_sb;
  331 + oparms.desired_access = GENERIC_READ;
  332 + oparms.create_options = CREATE_NOT_DIR;
  333 + oparms.disposition = FILE_OPEN;
  334 + oparms.path = path;
  335 + oparms.fid = &fid;
  336 + oparms.reconnect = false;
  337 +
  338 + rc = CIFS_open(xid, &oparms, &oplock, &file_info);
333 339 if (rc)
334 340 return rc;
335 341  
... ... @@ -337,7 +343,7 @@
337 343 /* it's not a symlink */
338 344 goto out;
339 345  
340   - io_parms.netfid = netfid;
  346 + io_parms.netfid = fid.netfid;
341 347 io_parms.pid = current->tgid;
342 348 io_parms.tcon = tcon;
343 349 io_parms.offset = 0;
... ... @@ -345,7 +351,7 @@
345 351  
346 352 rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type);
347 353 out:
348   - CIFSSMBClose(xid, tcon, netfid);
  354 + CIFSSMBClose(xid, tcon, fid.netfid);
349 355 return rc;
350 356 }
351 357  
352 358  
353 359  
354 360  
... ... @@ -356,29 +362,35 @@
356 362 {
357 363 int rc;
358 364 int oplock = 0;
359   - __u16 netfid = 0;
  365 + struct cifs_fid fid;
  366 + struct cifs_open_parms oparms;
360 367 struct cifs_io_parms io_parms;
361 368 int create_options = CREATE_NOT_DIR;
362 369  
363 370 if (backup_cred(cifs_sb))
364 371 create_options |= CREATE_OPEN_BACKUP_INTENT;
365 372  
366   - rc = CIFSSMBOpen(xid, tcon, path, FILE_CREATE, GENERIC_WRITE,
367   - create_options, &netfid, &oplock, NULL,
368   - cifs_sb->local_nls,
369   - cifs_sb->mnt_cifs_flags &
370   - CIFS_MOUNT_MAP_SPECIAL_CHR);
  373 + oparms.tcon = tcon;
  374 + oparms.cifs_sb = cifs_sb;
  375 + oparms.desired_access = GENERIC_WRITE;
  376 + oparms.create_options = create_options;
  377 + oparms.disposition = FILE_OPEN;
  378 + oparms.path = path;
  379 + oparms.fid = &fid;
  380 + oparms.reconnect = false;
  381 +
  382 + rc = CIFS_open(xid, &oparms, &oplock, NULL);
371 383 if (rc)
372 384 return rc;
373 385  
374   - io_parms.netfid = netfid;
  386 + io_parms.netfid = fid.netfid;
375 387 io_parms.pid = current->tgid;
376 388 io_parms.tcon = tcon;
377 389 io_parms.offset = 0;
378 390 io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
379 391  
380 392 rc = CIFSSMBWrite(xid, &io_parms, pbytes_written, pbuf, NULL, 0);
381   - CIFSSMBClose(xid, tcon, netfid);
  393 + CIFSSMBClose(xid, tcon, fid.netfid);
382 394 return rc;
383 395 }
384 396  
... ... @@ -560,17 +560,24 @@
560 560 if (!rc && (le32_to_cpu(data->Attributes) & ATTR_REPARSE)) {
561 561 int tmprc;
562 562 int oplock = 0;
563   - __u16 netfid;
  563 + struct cifs_fid fid;
  564 + struct cifs_open_parms oparms;
564 565  
  566 + oparms.tcon = tcon;
  567 + oparms.cifs_sb = cifs_sb;
  568 + oparms.desired_access = FILE_READ_ATTRIBUTES;
  569 + oparms.create_options = 0;
  570 + oparms.disposition = FILE_OPEN;
  571 + oparms.path = full_path;
  572 + oparms.fid = &fid;
  573 + oparms.reconnect = false;
  574 +
565 575 /* Need to check if this is a symbolic link or not */
566   - tmprc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
567   - FILE_READ_ATTRIBUTES, 0, &netfid, &oplock,
568   - NULL, cifs_sb->local_nls,
569   - cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  576 + tmprc = CIFS_open(xid, &oparms, &oplock, NULL);
570 577 if (tmprc == -EOPNOTSUPP)
571 578 *symlink = true;
572 579 else
573   - CIFSSMBClose(xid, tcon, netfid);
  580 + CIFSSMBClose(xid, tcon, fid.netfid);
574 581 }
575 582  
576 583 return rc;
... ... @@ -705,12 +712,7 @@
705 712 oparms->cifs_sb->local_nls,
706 713 oparms->cifs_sb->mnt_cifs_flags
707 714 & CIFS_MOUNT_MAP_SPECIAL_CHR);
708   - return CIFSSMBOpen(xid, oparms->tcon, oparms->path,
709   - oparms->disposition, oparms->desired_access,
710   - oparms->create_options, &oparms->fid->netfid, oplock,
711   - buf, oparms->cifs_sb->local_nls,
712   - oparms->cifs_sb->mnt_cifs_flags &
713   - CIFS_MOUNT_MAP_SPECIAL_CHR);
  715 + return CIFS_open(xid, oparms, oplock, buf);
714 716 }
715 717  
716 718 static void
717 719  
... ... @@ -761,8 +763,9 @@
761 763 {
762 764 int oplock = 0;
763 765 int rc;
764   - __u16 netfid;
765 766 __u32 netpid;
  767 + struct cifs_fid fid;
  768 + struct cifs_open_parms oparms;
766 769 struct cifsFileInfo *open_file;
767 770 struct cifsInodeInfo *cinode = CIFS_I(inode);
768 771 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
... ... @@ -772,7 +775,7 @@
772 775 /* if the file is already open for write, just use that fileid */
773 776 open_file = find_writable_file(cinode, true);
774 777 if (open_file) {
775   - netfid = open_file->fid.netfid;
  778 + fid.netfid = open_file->fid.netfid;
776 779 netpid = open_file->pid;
777 780 tcon = tlink_tcon(open_file->tlink);
778 781 goto set_via_filehandle;
779 782  
... ... @@ -796,12 +799,17 @@
796 799 goto out;
797 800 }
798 801  
799   - cifs_dbg(FYI, "calling SetFileInfo since SetPathInfo for times not supported by this server\n");
800   - rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
801   - SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR,
802   - &netfid, &oplock, NULL, cifs_sb->local_nls,
803   - cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  802 + oparms.tcon = tcon;
  803 + oparms.cifs_sb = cifs_sb;
  804 + oparms.desired_access = SYNCHRONIZE | FILE_WRITE_ATTRIBUTES;
  805 + oparms.create_options = CREATE_NOT_DIR;
  806 + oparms.disposition = FILE_OPEN;
  807 + oparms.path = full_path;
  808 + oparms.fid = &fid;
  809 + oparms.reconnect = false;
804 810  
  811 + cifs_dbg(FYI, "calling SetFileInfo since SetPathInfo for times not supported by this server\n");
  812 + rc = CIFS_open(xid, &oparms, &oplock, NULL);
805 813 if (rc != 0) {
806 814 if (rc == -EIO)
807 815 rc = -EINVAL;
808 816  
... ... @@ -811,12 +819,12 @@
811 819 netpid = current->tgid;
812 820  
813 821 set_via_filehandle:
814   - rc = CIFSSMBSetFileInfo(xid, tcon, buf, netfid, netpid);
  822 + rc = CIFSSMBSetFileInfo(xid, tcon, buf, fid.netfid, netpid);
815 823 if (!rc)
816 824 cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
817 825  
818 826 if (open_file == NULL)
819   - CIFSSMBClose(xid, tcon, netfid);
  827 + CIFSSMBClose(xid, tcon, fid.netfid);
820 828 else
821 829 cifsFileInfo_put(open_file);
822 830 out:
... ... @@ -941,7 +949,8 @@
941 949 {
942 950 int rc;
943 951 int oplock = 0;
944   - __u16 netfid;
  952 + struct cifs_fid fid;
  953 + struct cifs_open_parms oparms;
945 954  
946 955 cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
947 956  
948 957  
949 958  
... ... @@ -957,21 +966,27 @@
957 966 goto out;
958 967 }
959 968  
960   - rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
961   - FILE_READ_ATTRIBUTES, OPEN_REPARSE_POINT, &netfid,
962   - &oplock, NULL, cifs_sb->local_nls,
963   - cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  969 + oparms.tcon = tcon;
  970 + oparms.cifs_sb = cifs_sb;
  971 + oparms.desired_access = FILE_READ_ATTRIBUTES;
  972 + oparms.create_options = OPEN_REPARSE_POINT;
  973 + oparms.disposition = FILE_OPEN;
  974 + oparms.path = full_path;
  975 + oparms.fid = &fid;
  976 + oparms.reconnect = false;
  977 +
  978 + rc = CIFS_open(xid, &oparms, &oplock, NULL);
964 979 if (rc)
965 980 goto out;
966 981  
967   - rc = CIFSSMBQuerySymLink(xid, tcon, netfid, target_path,
  982 + rc = CIFSSMBQuerySymLink(xid, tcon, fid.netfid, target_path,
968 983 cifs_sb->local_nls);
969 984 if (rc)
970 985 goto out_close;
971 986  
972 987 convert_delimiter(*target_path, '/');
973 988 out_close:
974   - CIFSSMBClose(xid, tcon, netfid);
  989 + CIFSSMBClose(xid, tcon, fid.netfid);
975 990 out:
976 991 if (!rc)
977 992 cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);