Merge tag '5.6-rc-smb3-plugfest-patches' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs fixes from Steve French:
"13 cifs/smb3 patches, most from testing at the SMB3 plugfest this week:

- Important fix for multichannel and for modefromsid mounts.

- Two reconnect fixes

- Addition of SMB3 change notify support

- Backup tools fix

- A few additional minor debug improvements (tracepoints and
additional logging found useful during testing this week)"

* tag '5.6-rc-smb3-plugfest-patches' of git://git.samba.org/sfrench/cifs-2.6:
smb3: Add defines for new information level, FileIdInformation
smb3: print warning once if posix context returned on open
smb3: add one more dynamic tracepoint missing from strict fsync path
cifs: fix mode bits from dir listing when mounted with modefromsid
cifs: fix channel signing
cifs: add SMB3 change notification support
cifs: make multichannel warning more visible
cifs: fix soft mounts hanging in the reconnect code
cifs: Add tracepoints for errors on flush or fsync
cifs: log warning message (once) if out of disk space
cifs: fail i/o on soft mounts if sessionsetup errors out
smb3: fix problem with null cifs super block with previous patch
SMB3: Backup intent flag missing from some more ops

+6
fs/cifs/cifs_ioctl.h
··· 65 65 __u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE]; 66 66 } __packed; 67 67 68 + struct smb3_notify { 69 + __u32 completion_filter; 70 + bool watch_tree; 71 + } __packed; 72 + 68 73 #define CIFS_IOCTL_MAGIC 0xCF 69 74 #define CIFS_IOC_COPYCHUNK_FILE _IOW(CIFS_IOCTL_MAGIC, 3, int) 70 75 #define CIFS_IOC_SET_INTEGRITY _IO(CIFS_IOCTL_MAGIC, 4) ··· 77 72 #define CIFS_ENUMERATE_SNAPSHOTS _IOR(CIFS_IOCTL_MAGIC, 6, struct smb_snapshot_array) 78 73 #define CIFS_QUERY_INFO _IOWR(CIFS_IOCTL_MAGIC, 7, struct smb_query_info) 79 74 #define CIFS_DUMP_KEY _IOWR(CIFS_IOCTL_MAGIC, 8, struct smb3_key_debug_info) 75 + #define CIFS_IOC_NOTIFY _IOW(CIFS_IOCTL_MAGIC, 9, struct smb3_notify)
+4 -10
fs/cifs/cifsacl.c
··· 1084 1084 struct cifs_ntsd *pntsd = NULL; 1085 1085 int oplock = 0; 1086 1086 unsigned int xid; 1087 - int rc, create_options = 0; 1087 + int rc; 1088 1088 struct cifs_tcon *tcon; 1089 1089 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); 1090 1090 struct cifs_fid fid; ··· 1096 1096 tcon = tlink_tcon(tlink); 1097 1097 xid = get_xid(); 1098 1098 1099 - if (backup_cred(cifs_sb)) 1100 - create_options |= CREATE_OPEN_BACKUP_INTENT; 1101 - 1102 1099 oparms.tcon = tcon; 1103 1100 oparms.cifs_sb = cifs_sb; 1104 1101 oparms.desired_access = READ_CONTROL; 1105 - oparms.create_options = create_options; 1102 + oparms.create_options = cifs_create_options(cifs_sb, 0); 1106 1103 oparms.disposition = FILE_OPEN; 1107 1104 oparms.path = path; 1108 1105 oparms.fid = &fid; ··· 1144 1147 { 1145 1148 int oplock = 0; 1146 1149 unsigned int xid; 1147 - int rc, access_flags, create_options = 0; 1150 + int rc, access_flags; 1148 1151 struct cifs_tcon *tcon; 1149 1152 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1150 1153 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); ··· 1157 1160 tcon = tlink_tcon(tlink); 1158 1161 xid = get_xid(); 1159 1162 1160 - if (backup_cred(cifs_sb)) 1161 - create_options |= CREATE_OPEN_BACKUP_INTENT; 1162 - 1163 1163 if (aclflag == CIFS_ACL_OWNER || aclflag == CIFS_ACL_GROUP) 1164 1164 access_flags = WRITE_OWNER; 1165 1165 else ··· 1165 1171 oparms.tcon = tcon; 1166 1172 oparms.cifs_sb = cifs_sb; 1167 1173 oparms.desired_access = access_flags; 1168 - oparms.create_options = create_options; 1174 + oparms.create_options = cifs_create_options(cifs_sb, 0); 1169 1175 oparms.disposition = FILE_OPEN; 1170 1176 oparms.path = path; 1171 1177 oparms.fid = &fid;
+1 -1
fs/cifs/cifsfs.c
··· 275 275 buf->f_ffree = 0; /* unlimited */ 276 276 277 277 if (server->ops->queryfs) 278 - rc = server->ops->queryfs(xid, tcon, buf); 278 + rc = server->ops->queryfs(xid, tcon, cifs_sb, buf); 279 279 280 280 free_xid(xid); 281 281 return 0;
+6 -2
fs/cifs/cifsglob.h
··· 298 298 const char *, struct dfs_info3_param **, 299 299 unsigned int *, const struct nls_table *, int); 300 300 /* informational QFS call */ 301 - void (*qfs_tcon)(const unsigned int, struct cifs_tcon *); 301 + void (*qfs_tcon)(const unsigned int, struct cifs_tcon *, 302 + struct cifs_sb_info *); 302 303 /* check if a path is accessible or not */ 303 304 int (*is_path_accessible)(const unsigned int, struct cifs_tcon *, 304 305 struct cifs_sb_info *, const char *); ··· 410 409 struct cifsInodeInfo *); 411 410 /* query remote filesystem */ 412 411 int (*queryfs)(const unsigned int, struct cifs_tcon *, 413 - struct kstatfs *); 412 + struct cifs_sb_info *, struct kstatfs *); 414 413 /* send mandatory brlock to the server */ 415 414 int (*mand_lock)(const unsigned int, struct cifsFileInfo *, __u64, 416 415 __u64, __u32, int, int, bool); ··· 431 430 struct cifsFileInfo *src_file); 432 431 int (*enum_snapshots)(const unsigned int xid, struct cifs_tcon *tcon, 433 432 struct cifsFileInfo *src_file, void __user *); 433 + int (*notify)(const unsigned int xid, struct file *pfile, 434 + void __user *pbuf); 434 435 int (*query_mf_symlink)(unsigned int, struct cifs_tcon *, 435 436 struct cifs_sb_info *, const unsigned char *, 436 437 char *, unsigned int *); ··· 493 490 /* ioctl passthrough for query_info */ 494 491 int (*ioctl_query_info)(const unsigned int xid, 495 492 struct cifs_tcon *tcon, 493 + struct cifs_sb_info *cifs_sb, 496 494 __le16 *path, int is_dir, 497 495 unsigned long p); 498 496 /* make unix special files (block, char, fifo, socket) */
+8
fs/cifs/cifsproto.h
··· 612 612 } 613 613 #endif 614 614 615 + static inline int cifs_create_options(struct cifs_sb_info *cifs_sb, int options) 616 + { 617 + if (cifs_sb && (backup_cred(cifs_sb))) 618 + return options | CREATE_OPEN_BACKUP_INTENT; 619 + else 620 + return options; 621 + } 622 + 615 623 #endif /* _CIFSPROTO_H */
+1 -1
fs/cifs/cifssmb.c
··· 260 260 if (server->tcpStatus != CifsNeedReconnect) 261 261 break; 262 262 263 - if (--retries) 263 + if (retries && --retries) 264 264 continue; 265 265 266 266 /*
+1 -1
fs/cifs/connect.c
··· 4365 4365 4366 4366 /* do not care if a following call succeed - informational */ 4367 4367 if (!tcon->pipe && server->ops->qfs_tcon) { 4368 - server->ops->qfs_tcon(*xid, tcon); 4368 + server->ops->qfs_tcon(*xid, tcon, cifs_sb); 4369 4369 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE) { 4370 4370 if (tcon->fsDevInfo.DeviceCharacteristics & 4371 4371 cpu_to_le32(FILE_READ_ONLY_DEVICE))
+1 -4
fs/cifs/dir.c
··· 355 355 if (!tcon->unix_ext && (mode & S_IWUGO) == 0) 356 356 create_options |= CREATE_OPTION_READONLY; 357 357 358 - if (backup_cred(cifs_sb)) 359 - create_options |= CREATE_OPEN_BACKUP_INTENT; 360 - 361 358 oparms.tcon = tcon; 362 359 oparms.cifs_sb = cifs_sb; 363 360 oparms.desired_access = desired_access; 364 - oparms.create_options = create_options; 361 + oparms.create_options = cifs_create_options(cifs_sb, create_options); 365 362 oparms.disposition = disposition; 366 363 oparms.path = full_path; 367 364 oparms.fid = fid;
+10 -11
fs/cifs/file.c
··· 222 222 if (!buf) 223 223 return -ENOMEM; 224 224 225 - if (backup_cred(cifs_sb)) 226 - create_options |= CREATE_OPEN_BACKUP_INTENT; 227 - 228 225 /* O_SYNC also has bit for O_DSYNC so following check picks up either */ 229 226 if (f_flags & O_SYNC) 230 227 create_options |= CREATE_WRITE_THROUGH; ··· 232 235 oparms.tcon = tcon; 233 236 oparms.cifs_sb = cifs_sb; 234 237 oparms.desired_access = desired_access; 235 - oparms.create_options = create_options; 238 + oparms.create_options = cifs_create_options(cifs_sb, create_options); 236 239 oparms.disposition = disposition; 237 240 oparms.path = full_path; 238 241 oparms.fid = fid; ··· 749 752 750 753 desired_access = cifs_convert_flags(cfile->f_flags); 751 754 752 - if (backup_cred(cifs_sb)) 753 - create_options |= CREATE_OPEN_BACKUP_INTENT; 754 - 755 755 /* O_SYNC also has bit for O_DSYNC so following check picks up either */ 756 756 if (cfile->f_flags & O_SYNC) 757 757 create_options |= CREATE_WRITE_THROUGH; ··· 762 768 oparms.tcon = tcon; 763 769 oparms.cifs_sb = cifs_sb; 764 770 oparms.desired_access = desired_access; 765 - oparms.create_options = create_options; 771 + oparms.create_options = cifs_create_options(cifs_sb, create_options); 766 772 oparms.disposition = disposition; 767 773 oparms.path = full_path; 768 774 oparms.fid = &cfile->fid; ··· 2593 2599 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2594 2600 2595 2601 rc = file_write_and_wait_range(file, start, end); 2596 - if (rc) 2602 + if (rc) { 2603 + trace_cifs_fsync_err(inode->i_ino, rc); 2597 2604 return rc; 2605 + } 2598 2606 2599 2607 xid = get_xid(); 2600 2608 ··· 2634 2638 struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file); 2635 2639 2636 2640 rc = file_write_and_wait_range(file, start, end); 2637 - if (rc) 2641 + if (rc) { 2642 + trace_cifs_fsync_err(file_inode(file)->i_ino, rc); 2638 2643 return rc; 2644 + } 2639 2645 2640 2646 xid = get_xid(); 2641 2647 ··· 2670 2672 rc = filemap_write_and_wait(inode->i_mapping); 2671 2673 2672 2674 cifs_dbg(FYI, "Flush inode %p file %p rc %d\n", inode, file, rc); 2673 - 2675 + if (rc) 2676 + trace_cifs_flush_err(inode->i_ino, rc); 2674 2677 return rc; 2675 2678 } 2676 2679
+3 -5
fs/cifs/inode.c
··· 475 475 oparms.tcon = tcon; 476 476 oparms.cifs_sb = cifs_sb; 477 477 oparms.desired_access = GENERIC_READ; 478 - oparms.create_options = CREATE_NOT_DIR; 479 - if (backup_cred(cifs_sb)) 480 - oparms.create_options |= CREATE_OPEN_BACKUP_INTENT; 478 + oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR); 481 479 oparms.disposition = FILE_OPEN; 482 480 oparms.path = path; 483 481 oparms.fid = &fid; ··· 1283 1285 oparms.tcon = tcon; 1284 1286 oparms.cifs_sb = cifs_sb; 1285 1287 oparms.desired_access = DELETE | FILE_WRITE_ATTRIBUTES; 1286 - oparms.create_options = CREATE_NOT_DIR; 1288 + oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR); 1287 1289 oparms.disposition = FILE_OPEN; 1288 1290 oparms.path = full_path; 1289 1291 oparms.fid = &fid; ··· 1821 1823 oparms.cifs_sb = cifs_sb; 1822 1824 /* open the file to be renamed -- we need DELETE perms */ 1823 1825 oparms.desired_access = DELETE; 1824 - oparms.create_options = CREATE_NOT_DIR; 1826 + oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR); 1825 1827 oparms.disposition = FILE_OPEN; 1826 1828 oparms.path = from_path; 1827 1829 oparms.fid = &fid;
+17 -1
fs/cifs/ioctl.c
··· 65 65 66 66 if (tcon->ses->server->ops->ioctl_query_info) 67 67 rc = tcon->ses->server->ops->ioctl_query_info( 68 - xid, tcon, utf16_path, 68 + xid, tcon, cifs_sb, utf16_path, 69 69 filep->private_data ? 0 : 1, p); 70 70 else 71 71 rc = -EOPNOTSUPP; ··· 169 169 unsigned int xid; 170 170 struct cifsFileInfo *pSMBFile = filep->private_data; 171 171 struct cifs_tcon *tcon; 172 + struct cifs_sb_info *cifs_sb; 172 173 __u64 ExtAttrBits = 0; 173 174 __u64 caps; 174 175 ··· 299 298 rc = -EFAULT; 300 299 else 301 300 rc = 0; 301 + break; 302 + case CIFS_IOC_NOTIFY: 303 + if (!S_ISDIR(inode->i_mode)) { 304 + /* Notify can only be done on directories */ 305 + rc = -EOPNOTSUPP; 306 + break; 307 + } 308 + cifs_sb = CIFS_SB(inode->i_sb); 309 + tcon = tlink_tcon(cifs_sb_tlink(cifs_sb)); 310 + if (tcon && tcon->ses->server->ops->notify) { 311 + rc = tcon->ses->server->ops->notify(xid, 312 + filep, (void __user *)arg); 313 + cifs_dbg(FYI, "ioctl notify rc %d\n", rc); 314 + } else 315 + rc = -EOPNOTSUPP; 302 316 break; 303 317 default: 304 318 cifs_dbg(FYI, "unsupported ioctl\n");
+4 -14
fs/cifs/link.c
··· 315 315 oparms.tcon = tcon; 316 316 oparms.cifs_sb = cifs_sb; 317 317 oparms.desired_access = GENERIC_READ; 318 - oparms.create_options = CREATE_NOT_DIR; 318 + oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR); 319 319 oparms.disposition = FILE_OPEN; 320 320 oparms.path = path; 321 321 oparms.fid = &fid; ··· 353 353 struct cifs_fid fid; 354 354 struct cifs_open_parms oparms; 355 355 struct cifs_io_parms io_parms; 356 - int create_options = CREATE_NOT_DIR; 357 - 358 - if (backup_cred(cifs_sb)) 359 - create_options |= CREATE_OPEN_BACKUP_INTENT; 360 356 361 357 oparms.tcon = tcon; 362 358 oparms.cifs_sb = cifs_sb; 363 359 oparms.desired_access = GENERIC_WRITE; 364 - oparms.create_options = create_options; 360 + oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR); 365 361 oparms.disposition = FILE_CREATE; 366 362 oparms.path = path; 367 363 oparms.fid = &fid; ··· 398 402 oparms.tcon = tcon; 399 403 oparms.cifs_sb = cifs_sb; 400 404 oparms.desired_access = GENERIC_READ; 401 - oparms.create_options = CREATE_NOT_DIR; 402 - if (backup_cred(cifs_sb)) 403 - oparms.create_options |= CREATE_OPEN_BACKUP_INTENT; 405 + oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR); 404 406 oparms.disposition = FILE_OPEN; 405 407 oparms.fid = &fid; 406 408 oparms.reconnect = false; ··· 451 457 struct cifs_fid fid; 452 458 struct cifs_open_parms oparms; 453 459 struct cifs_io_parms io_parms; 454 - int create_options = CREATE_NOT_DIR; 455 460 __le16 *utf16_path; 456 461 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE; 457 462 struct kvec iov[2]; 458 - 459 - if (backup_cred(cifs_sb)) 460 - create_options |= CREATE_OPEN_BACKUP_INTENT; 461 463 462 464 cifs_dbg(FYI, "%s: path: %s\n", __func__, path); 463 465 ··· 464 474 oparms.tcon = tcon; 465 475 oparms.cifs_sb = cifs_sb; 466 476 oparms.desired_access = GENERIC_WRITE; 467 - oparms.create_options = create_options; 477 + oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR); 468 478 oparms.disposition = FILE_CREATE; 469 479 oparms.fid = &fid; 470 480 oparms.reconnect = false;
+2 -1
fs/cifs/readdir.c
··· 196 196 * may look wrong since the inodes may not have timed out by the time 197 197 * "ls" does a stat() call on them. 198 198 */ 199 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) 199 + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) || 200 + (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)) 200 201 fattr->cf_flags |= CIFS_FATTR_NEED_REVAL; 201 202 202 203 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL &&
+1 -1
fs/cifs/sess.c
··· 101 101 iface_count = ses->iface_count; 102 102 if (iface_count <= 0) { 103 103 spin_unlock(&ses->iface_lock); 104 - cifs_dbg(FYI, "no iface list available to open channels\n"); 104 + cifs_dbg(VFS, "no iface list available to open channels\n"); 105 105 return 0; 106 106 } 107 107 ifaces = kmemdup(ses->iface_list, iface_count*sizeof(*ifaces),
+9 -10
fs/cifs/smb1ops.c
··· 504 504 } 505 505 506 506 static void 507 - cifs_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon) 507 + cifs_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon, 508 + struct cifs_sb_info *cifs_sb) 508 509 { 509 510 CIFSSMBQFSDeviceInfo(xid, tcon); 510 511 CIFSSMBQFSAttributeInfo(xid, tcon); ··· 566 565 oparms.tcon = tcon; 567 566 oparms.cifs_sb = cifs_sb; 568 567 oparms.desired_access = FILE_READ_ATTRIBUTES; 569 - oparms.create_options = 0; 568 + oparms.create_options = cifs_create_options(cifs_sb, 0); 570 569 oparms.disposition = FILE_OPEN; 571 570 oparms.path = full_path; 572 571 oparms.fid = &fid; ··· 794 793 oparms.tcon = tcon; 795 794 oparms.cifs_sb = cifs_sb; 796 795 oparms.desired_access = SYNCHRONIZE | FILE_WRITE_ATTRIBUTES; 797 - oparms.create_options = CREATE_NOT_DIR; 796 + oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR); 798 797 oparms.disposition = FILE_OPEN; 799 798 oparms.path = full_path; 800 799 oparms.fid = &fid; ··· 873 872 874 873 static int 875 874 cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon, 876 - struct kstatfs *buf) 875 + struct cifs_sb_info *cifs_sb, struct kstatfs *buf) 877 876 { 878 877 int rc = -EOPNOTSUPP; 879 878 ··· 971 970 oparms.tcon = tcon; 972 971 oparms.cifs_sb = cifs_sb; 973 972 oparms.desired_access = FILE_READ_ATTRIBUTES; 974 - oparms.create_options = OPEN_REPARSE_POINT; 973 + oparms.create_options = cifs_create_options(cifs_sb, 974 + OPEN_REPARSE_POINT); 975 975 oparms.disposition = FILE_OPEN; 976 976 oparms.path = full_path; 977 977 oparms.fid = &fid; ··· 1031 1029 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1032 1030 struct inode *newinode = NULL; 1033 1031 int rc = -EPERM; 1034 - int create_options = CREATE_NOT_DIR | CREATE_OPTION_SPECIAL; 1035 1032 FILE_ALL_INFO *buf = NULL; 1036 1033 struct cifs_io_parms io_parms; 1037 1034 __u32 oplock = 0; ··· 1091 1090 goto out; 1092 1091 } 1093 1092 1094 - if (backup_cred(cifs_sb)) 1095 - create_options |= CREATE_OPEN_BACKUP_INTENT; 1096 - 1097 1093 oparms.tcon = tcon; 1098 1094 oparms.cifs_sb = cifs_sb; 1099 1095 oparms.desired_access = GENERIC_WRITE; 1100 - oparms.create_options = create_options; 1096 + oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR | 1097 + CREATE_OPTION_SPECIAL); 1101 1098 oparms.disposition = FILE_CREATE; 1102 1099 oparms.path = full_path; 1103 1100 oparms.fid = &fid;
+2 -7
fs/cifs/smb2inode.c
··· 99 99 oparms.tcon = tcon; 100 100 oparms.desired_access = desired_access; 101 101 oparms.disposition = create_disposition; 102 - oparms.create_options = create_options; 103 - if (backup_cred(cifs_sb)) 104 - oparms.create_options |= CREATE_OPEN_BACKUP_INTENT; 102 + oparms.create_options = cifs_create_options(cifs_sb, create_options); 105 103 oparms.fid = &fid; 106 104 oparms.reconnect = false; 107 105 oparms.mode = mode; ··· 455 457 456 458 /* If it is a root and its handle is cached then use it */ 457 459 if (!strlen(full_path) && !no_cached_open) { 458 - rc = open_shroot(xid, tcon, &fid); 460 + rc = open_shroot(xid, tcon, cifs_sb, &fid); 459 461 if (rc) 460 462 goto out; 461 463 ··· 471 473 close_shroot(&tcon->crfid); 472 474 goto out; 473 475 } 474 - 475 - if (backup_cred(cifs_sb)) 476 - create_options |= CREATE_OPEN_BACKUP_INTENT; 477 476 478 477 cifs_get_readable_path(tcon, full_path, &cfile); 479 478 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
+90 -55
fs/cifs/smb2ops.c
··· 655 655 /* 656 656 * Open the directory at the root of a share 657 657 */ 658 - int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid) 658 + int open_shroot(unsigned int xid, struct cifs_tcon *tcon, 659 + struct cifs_sb_info *cifs_sb, struct cifs_fid *pfid) 659 660 { 660 661 struct cifs_ses *ses = tcon->ses; 661 662 struct TCP_Server_Info *server = ses->server; ··· 703 702 rqst[0].rq_nvec = SMB2_CREATE_IOV_SIZE; 704 703 705 704 oparms.tcon = tcon; 706 - oparms.create_options = 0; 705 + oparms.create_options = cifs_create_options(cifs_sb, 0); 707 706 oparms.desired_access = FILE_READ_ATTRIBUTES; 708 707 oparms.disposition = FILE_OPEN; 709 708 oparms.fid = pfid; ··· 819 818 } 820 819 821 820 static void 822 - smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon) 821 + smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon, 822 + struct cifs_sb_info *cifs_sb) 823 823 { 824 824 int rc; 825 825 __le16 srch_path = 0; /* Null - open root of share */ ··· 832 830 oparms.tcon = tcon; 833 831 oparms.desired_access = FILE_READ_ATTRIBUTES; 834 832 oparms.disposition = FILE_OPEN; 835 - oparms.create_options = 0; 833 + oparms.create_options = cifs_create_options(cifs_sb, 0); 836 834 oparms.fid = &fid; 837 835 oparms.reconnect = false; 838 836 ··· 840 838 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL, 841 839 NULL); 842 840 else 843 - rc = open_shroot(xid, tcon, &fid); 841 + rc = open_shroot(xid, tcon, cifs_sb, &fid); 844 842 845 843 if (rc) 846 844 return; ··· 862 860 } 863 861 864 862 static void 865 - smb2_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon) 863 + smb2_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon, 864 + struct cifs_sb_info *cifs_sb) 866 865 { 867 866 int rc; 868 867 __le16 srch_path = 0; /* Null - open root of share */ ··· 874 871 oparms.tcon = tcon; 875 872 oparms.desired_access = FILE_READ_ATTRIBUTES; 876 873 oparms.disposition = FILE_OPEN; 877 - oparms.create_options = 0; 874 + oparms.create_options = cifs_create_options(cifs_sb, 0); 878 875 oparms.fid = &fid; 879 876 oparms.reconnect = false; 880 877 ··· 909 906 oparms.tcon = tcon; 910 907 oparms.desired_access = FILE_READ_ATTRIBUTES; 911 908 oparms.disposition = FILE_OPEN; 912 - if (backup_cred(cifs_sb)) 913 - oparms.create_options = CREATE_OPEN_BACKUP_INTENT; 914 - else 915 - oparms.create_options = 0; 909 + oparms.create_options = cifs_create_options(cifs_sb, 0); 916 910 oparms.fid = &fid; 917 911 oparms.reconnect = false; 918 912 ··· 1151 1151 oparms.tcon = tcon; 1152 1152 oparms.desired_access = FILE_WRITE_EA; 1153 1153 oparms.disposition = FILE_OPEN; 1154 - if (backup_cred(cifs_sb)) 1155 - oparms.create_options = CREATE_OPEN_BACKUP_INTENT; 1156 - else 1157 - oparms.create_options = 0; 1154 + oparms.create_options = cifs_create_options(cifs_sb, 0); 1158 1155 oparms.fid = &fid; 1159 1156 oparms.reconnect = false; 1160 1157 ··· 1419 1422 static int 1420 1423 smb2_ioctl_query_info(const unsigned int xid, 1421 1424 struct cifs_tcon *tcon, 1425 + struct cifs_sb_info *cifs_sb, 1422 1426 __le16 *path, int is_dir, 1423 1427 unsigned long p) 1424 1428 { ··· 1445 1447 struct kvec close_iov[1]; 1446 1448 unsigned int size[2]; 1447 1449 void *data[2]; 1450 + int create_options = is_dir ? CREATE_NOT_FILE : CREATE_NOT_DIR; 1448 1451 1449 1452 memset(rqst, 0, sizeof(rqst)); 1450 1453 resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER; ··· 1476 1477 memset(&oparms, 0, sizeof(oparms)); 1477 1478 oparms.tcon = tcon; 1478 1479 oparms.disposition = FILE_OPEN; 1479 - if (is_dir) 1480 - oparms.create_options = CREATE_NOT_FILE; 1481 - else 1482 - oparms.create_options = CREATE_NOT_DIR; 1480 + oparms.create_options = cifs_create_options(cifs_sb, create_options); 1483 1481 oparms.fid = &fid; 1484 1482 oparms.reconnect = false; 1485 1483 ··· 2045 2049 return rc; 2046 2050 } 2047 2051 2052 + 2053 + 2054 + static int 2055 + smb3_notify(const unsigned int xid, struct file *pfile, 2056 + void __user *ioc_buf) 2057 + { 2058 + struct smb3_notify notify; 2059 + struct dentry *dentry = pfile->f_path.dentry; 2060 + struct inode *inode = file_inode(pfile); 2061 + struct cifs_sb_info *cifs_sb; 2062 + struct cifs_open_parms oparms; 2063 + struct cifs_fid fid; 2064 + struct cifs_tcon *tcon; 2065 + unsigned char *path = NULL; 2066 + __le16 *utf16_path = NULL; 2067 + u8 oplock = SMB2_OPLOCK_LEVEL_NONE; 2068 + int rc = 0; 2069 + 2070 + path = build_path_from_dentry(dentry); 2071 + if (path == NULL) 2072 + return -ENOMEM; 2073 + 2074 + cifs_sb = CIFS_SB(inode->i_sb); 2075 + 2076 + utf16_path = cifs_convert_path_to_utf16(path + 1, cifs_sb); 2077 + if (utf16_path == NULL) { 2078 + rc = -ENOMEM; 2079 + goto notify_exit; 2080 + } 2081 + 2082 + if (copy_from_user(&notify, ioc_buf, sizeof(struct smb3_notify))) { 2083 + rc = -EFAULT; 2084 + goto notify_exit; 2085 + } 2086 + 2087 + tcon = cifs_sb_master_tcon(cifs_sb); 2088 + oparms.tcon = tcon; 2089 + oparms.desired_access = FILE_READ_ATTRIBUTES; 2090 + oparms.disposition = FILE_OPEN; 2091 + oparms.create_options = cifs_create_options(cifs_sb, 0); 2092 + oparms.fid = &fid; 2093 + oparms.reconnect = false; 2094 + 2095 + rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL, NULL); 2096 + if (rc) 2097 + goto notify_exit; 2098 + 2099 + rc = SMB2_change_notify(xid, tcon, fid.persistent_fid, fid.volatile_fid, 2100 + notify.watch_tree, notify.completion_filter); 2101 + 2102 + SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); 2103 + 2104 + cifs_dbg(FYI, "change notify for path %s rc %d\n", path, rc); 2105 + 2106 + notify_exit: 2107 + kfree(path); 2108 + kfree(utf16_path); 2109 + return rc; 2110 + } 2111 + 2048 2112 static int 2049 2113 smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, 2050 2114 const char *path, struct cifs_sb_info *cifs_sb, ··· 2142 2086 oparms.tcon = tcon; 2143 2087 oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA; 2144 2088 oparms.disposition = FILE_OPEN; 2145 - if (backup_cred(cifs_sb)) 2146 - oparms.create_options = CREATE_OPEN_BACKUP_INTENT; 2147 - else 2148 - oparms.create_options = 0; 2089 + oparms.create_options = cifs_create_options(cifs_sb, 0); 2149 2090 oparms.fid = fid; 2150 2091 oparms.reconnect = false; 2151 2092 ··· 2396 2343 oparms.tcon = tcon; 2397 2344 oparms.desired_access = desired_access; 2398 2345 oparms.disposition = FILE_OPEN; 2399 - if (cifs_sb && backup_cred(cifs_sb)) 2400 - oparms.create_options = CREATE_OPEN_BACKUP_INTENT; 2401 - else 2402 - oparms.create_options = 0; 2346 + oparms.create_options = cifs_create_options(cifs_sb, 0); 2403 2347 oparms.fid = &fid; 2404 2348 oparms.reconnect = false; 2405 2349 ··· 2452 2402 2453 2403 static int 2454 2404 smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon, 2455 - struct kstatfs *buf) 2405 + struct cifs_sb_info *cifs_sb, struct kstatfs *buf) 2456 2406 { 2457 2407 struct smb2_query_info_rsp *rsp; 2458 2408 struct smb2_fs_full_size_info *info = NULL; ··· 2467 2417 FS_FULL_SIZE_INFORMATION, 2468 2418 SMB2_O_INFO_FILESYSTEM, 2469 2419 sizeof(struct smb2_fs_full_size_info), 2470 - &rsp_iov, &buftype, NULL); 2420 + &rsp_iov, &buftype, cifs_sb); 2471 2421 if (rc) 2472 2422 goto qfs_exit; 2473 2423 ··· 2489 2439 2490 2440 static int 2491 2441 smb311_queryfs(const unsigned int xid, struct cifs_tcon *tcon, 2492 - struct kstatfs *buf) 2442 + struct cifs_sb_info *cifs_sb, struct kstatfs *buf) 2493 2443 { 2494 2444 int rc; 2495 2445 __le16 srch_path = 0; /* Null - open root of share */ ··· 2498 2448 struct cifs_fid fid; 2499 2449 2500 2450 if (!tcon->posix_extensions) 2501 - return smb2_queryfs(xid, tcon, buf); 2451 + return smb2_queryfs(xid, tcon, cifs_sb, buf); 2502 2452 2503 2453 oparms.tcon = tcon; 2504 2454 oparms.desired_access = FILE_READ_ATTRIBUTES; 2505 2455 oparms.disposition = FILE_OPEN; 2506 - oparms.create_options = 0; 2456 + oparms.create_options = cifs_create_options(cifs_sb, 0); 2507 2457 oparms.fid = &fid; 2508 2458 oparms.reconnect = false; 2509 2459 ··· 2772 2722 struct smb2_create_rsp *create_rsp; 2773 2723 struct smb2_ioctl_rsp *ioctl_rsp; 2774 2724 struct reparse_data_buffer *reparse_buf; 2725 + int create_options = is_reparse_point ? OPEN_REPARSE_POINT : 0; 2775 2726 u32 plen; 2776 2727 2777 2728 cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path); ··· 2799 2748 oparms.tcon = tcon; 2800 2749 oparms.desired_access = FILE_READ_ATTRIBUTES; 2801 2750 oparms.disposition = FILE_OPEN; 2802 - 2803 - if (backup_cred(cifs_sb)) 2804 - oparms.create_options = CREATE_OPEN_BACKUP_INTENT; 2805 - else 2806 - oparms.create_options = 0; 2807 - if (is_reparse_point) 2808 - oparms.create_options = OPEN_REPARSE_POINT; 2809 - 2751 + oparms.create_options = cifs_create_options(cifs_sb, create_options); 2810 2752 oparms.fid = &fid; 2811 2753 oparms.reconnect = false; 2812 2754 ··· 2978 2934 tcon = tlink_tcon(tlink); 2979 2935 xid = get_xid(); 2980 2936 2981 - if (backup_cred(cifs_sb)) 2982 - oparms.create_options = CREATE_OPEN_BACKUP_INTENT; 2983 - else 2984 - oparms.create_options = 0; 2985 - 2986 2937 utf16_path = cifs_convert_path_to_utf16(path, cifs_sb); 2987 2938 if (!utf16_path) { 2988 2939 rc = -ENOMEM; ··· 2988 2949 oparms.tcon = tcon; 2989 2950 oparms.desired_access = READ_CONTROL; 2990 2951 oparms.disposition = FILE_OPEN; 2952 + oparms.create_options = cifs_create_options(cifs_sb, 0); 2991 2953 oparms.fid = &fid; 2992 2954 oparms.reconnect = false; 2993 2955 ··· 3030 2990 tcon = tlink_tcon(tlink); 3031 2991 xid = get_xid(); 3032 2992 3033 - if (backup_cred(cifs_sb)) 3034 - oparms.create_options = CREATE_OPEN_BACKUP_INTENT; 3035 - else 3036 - oparms.create_options = 0; 3037 - 3038 2993 if (aclflag == CIFS_ACL_OWNER || aclflag == CIFS_ACL_GROUP) 3039 2994 access_flags = WRITE_OWNER; 3040 2995 else ··· 3044 3009 3045 3010 oparms.tcon = tcon; 3046 3011 oparms.desired_access = access_flags; 3012 + oparms.create_options = cifs_create_options(cifs_sb, 0); 3047 3013 oparms.disposition = FILE_OPEN; 3048 3014 oparms.path = path; 3049 3015 oparms.fid = &fid; ··· 4527 4491 { 4528 4492 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 4529 4493 int rc = -EPERM; 4530 - int create_options = CREATE_NOT_DIR | CREATE_OPTION_SPECIAL; 4531 4494 FILE_ALL_INFO *buf = NULL; 4532 4495 struct cifs_io_parms io_parms; 4533 4496 __u32 oplock = 0; ··· 4562 4527 goto out; 4563 4528 } 4564 4529 4565 - if (backup_cred(cifs_sb)) 4566 - create_options |= CREATE_OPEN_BACKUP_INTENT; 4567 - 4568 4530 oparms.tcon = tcon; 4569 4531 oparms.cifs_sb = cifs_sb; 4570 4532 oparms.desired_access = GENERIC_WRITE; 4571 - oparms.create_options = create_options; 4533 + oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR | 4534 + CREATE_OPTION_SPECIAL); 4572 4535 oparms.disposition = FILE_CREATE; 4573 4536 oparms.path = full_path; 4574 4537 oparms.fid = &fid; ··· 4901 4868 .dir_needs_close = smb2_dir_needs_close, 4902 4869 .fallocate = smb3_fallocate, 4903 4870 .enum_snapshots = smb3_enum_snapshots, 4871 + .notify = smb3_notify, 4904 4872 .init_transform_rq = smb3_init_transform_rq, 4905 4873 .is_transform_hdr = smb3_is_transform_hdr, 4906 4874 .receive_transform = smb3_receive_transform, ··· 5012 4978 .dir_needs_close = smb2_dir_needs_close, 5013 4979 .fallocate = smb3_fallocate, 5014 4980 .enum_snapshots = smb3_enum_snapshots, 4981 + .notify = smb3_notify, 5015 4982 .init_transform_rq = smb3_init_transform_rq, 5016 4983 .is_transform_hdr = smb3_is_transform_hdr, 5017 4984 .receive_transform = smb3_receive_transform,
+34 -2
fs/cifs/smb2pdu.c
··· 350 350 } 351 351 352 352 rc = cifs_negotiate_protocol(0, tcon->ses); 353 - if (!rc && tcon->ses->need_reconnect) 353 + if (!rc && tcon->ses->need_reconnect) { 354 354 rc = cifs_setup_session(0, tcon->ses, nls_codepage); 355 - 355 + if ((rc == -EACCES) && !tcon->retry) { 356 + rc = -EHOSTDOWN; 357 + mutex_unlock(&tcon->ses->session_mutex); 358 + goto failed; 359 + } 360 + } 356 361 if (rc || !tcon->need_reconnect) { 357 362 mutex_unlock(&tcon->ses->session_mutex); 358 363 goto out; ··· 402 397 case SMB2_SET_INFO: 403 398 rc = -EAGAIN; 404 399 } 400 + failed: 405 401 unload_nls(nls_codepage); 406 402 return rc; 407 403 } ··· 1939 1933 buf->IndexNumber = pdisk_id->DiskFileId; 1940 1934 } 1941 1935 1936 + static void 1937 + parse_posix_ctxt(struct create_context *cc, struct smb_posix_info *pposix_inf) 1938 + { 1939 + /* struct smb_posix_info *ppinf = (struct smb_posix_info *)cc; */ 1940 + 1941 + /* TODO: Need to add parsing for the context and return */ 1942 + printk_once(KERN_WARNING 1943 + "SMB3 3.11 POSIX response context not completed yet\n"); 1944 + } 1945 + 1942 1946 void 1943 1947 smb2_parse_contexts(struct TCP_Server_Info *server, 1944 1948 struct smb2_create_rsp *rsp, ··· 1960 1944 unsigned int next; 1961 1945 unsigned int remaining; 1962 1946 char *name; 1947 + const char smb3_create_tag_posix[] = {0x93, 0xAD, 0x25, 0x50, 0x9C, 1948 + 0xB4, 0x11, 0xE7, 0xB4, 0x23, 0x83, 1949 + 0xDE, 0x96, 0x8B, 0xCD, 0x7C}; 1963 1950 1964 1951 *oplock = 0; 1965 1952 data_offset = (char *)rsp + le32_to_cpu(rsp->CreateContextsOffset); ··· 1982 1963 else if (buf && (le16_to_cpu(cc->NameLength) == 4) && 1983 1964 strncmp(name, SMB2_CREATE_QUERY_ON_DISK_ID, 4) == 0) 1984 1965 parse_query_id_ctxt(cc, buf); 1966 + else if ((le16_to_cpu(cc->NameLength) == 16)) { 1967 + if (memcmp(name, smb3_create_tag_posix, 16) == 0) 1968 + parse_posix_ctxt(cc, NULL); 1969 + } 1970 + /* else { 1971 + cifs_dbg(FYI, "Context not matched with len %d\n", 1972 + le16_to_cpu(cc->NameLength)); 1973 + cifs_dump_mem("Cctxt name: ", name, 4); 1974 + } */ 1985 1975 1986 1976 next = le32_to_cpu(cc->Next); 1987 1977 if (!next) ··· 3385 3357 3386 3358 req->PersistentFileId = persistent_fid; 3387 3359 req->VolatileFileId = volatile_fid; 3360 + /* See note 354 of MS-SMB2, 64K max */ 3388 3361 req->OutputBufferLength = 3389 3362 cpu_to_le32(SMB2_MAX_BUFFER_SIZE - MAX_SMB2_HDR_SIZE); 3390 3363 req->CompletionFilter = cpu_to_le32(completion_filter); ··· 4052 4023 wdata->cfile->fid.persistent_fid, 4053 4024 tcon->tid, tcon->ses->Suid, wdata->offset, 4054 4025 wdata->bytes, wdata->result); 4026 + if (wdata->result == -ENOSPC) 4027 + printk_once(KERN_WARNING "Out of space writing to %s\n", 4028 + tcon->treeName); 4055 4029 } else 4056 4030 trace_smb3_write_done(0 /* no xid */, 4057 4031 wdata->cfile->fid.persistent_fid,
+16
fs/cifs/smb2pdu.h
··· 1519 1519 #define FILE_NORMALIZED_NAME_INFORMATION 48 1520 1520 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50 1521 1521 #define FILE_STANDARD_LINK_INFORMATION 54 1522 + #define FILE_ID_INFORMATION 59 1522 1523 1523 1524 struct smb2_file_internal_info { 1524 1525 __le64 IndexNumber; ··· 1594 1593 __le32 Reserved; 1595 1594 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */ 1596 1595 1596 + /* See MS-FSCC 2.4.43 */ 1597 + struct smb2_file_id_information { 1598 + __le64 VolumeSerialNumber; 1599 + __u64 PersistentFileId; /* opaque endianness */ 1600 + __u64 VolatileFileId; /* opaque endianness */ 1601 + } __packed; /* level 59 */ 1602 + 1597 1603 extern char smb2_padding[7]; 1598 1604 1605 + /* equivalent of the contents of SMB3.1.1 POSIX open context response */ 1606 + struct smb_posix_info { 1607 + __le32 nlink; 1608 + __le32 reparse_tag; 1609 + __le32 mode; 1610 + kuid_t uid; 1611 + kuid_t gid; 1612 + }; 1599 1613 #endif /* _SMB2PDU_H */
+1 -1
fs/cifs/smb2proto.h
··· 68 68 struct mid_q_entry *mid); 69 69 70 70 extern int open_shroot(unsigned int xid, struct cifs_tcon *tcon, 71 - struct cifs_fid *pfid); 71 + struct cifs_sb_info *cifs_sb, struct cifs_fid *pfid); 72 72 extern void close_shroot(struct cached_fid *cfid); 73 73 extern void close_shroot_lease(struct cached_fid *cfid); 74 74 extern void close_shroot_lease_locked(struct cached_fid *cfid);
+3 -2
fs/cifs/smb2transport.c
··· 104 104 { 105 105 struct cifs_chan *chan; 106 106 struct cifs_ses *ses = NULL; 107 + struct TCP_Server_Info *it = NULL; 107 108 int i; 108 109 int rc = 0; 109 110 110 111 spin_lock(&cifs_tcp_ses_lock); 111 112 112 - list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { 113 - list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { 113 + list_for_each_entry(it, &cifs_tcp_ses_list, tcp_ses_list) { 114 + list_for_each_entry(ses, &it->smb_ses_list, smb_ses_list) { 114 115 if (ses->Suid == ses_id) 115 116 goto found; 116 117 }
+27
fs/cifs/trace.h
··· 547 547 548 548 DEFINE_SMB3_EXIT_ERR_EVENT(exit_err); 549 549 550 + 551 + DECLARE_EVENT_CLASS(smb3_sync_err_class, 552 + TP_PROTO(unsigned long ino, 553 + int rc), 554 + TP_ARGS(ino, rc), 555 + TP_STRUCT__entry( 556 + __field(unsigned long, ino) 557 + __field(int, rc) 558 + ), 559 + TP_fast_assign( 560 + __entry->ino = ino; 561 + __entry->rc = rc; 562 + ), 563 + TP_printk("\tino=%lu rc=%d", 564 + __entry->ino, __entry->rc) 565 + ) 566 + 567 + #define DEFINE_SMB3_SYNC_ERR_EVENT(name) \ 568 + DEFINE_EVENT(smb3_sync_err_class, cifs_##name, \ 569 + TP_PROTO(unsigned long ino, \ 570 + int rc), \ 571 + TP_ARGS(ino, rc)) 572 + 573 + DEFINE_SMB3_SYNC_ERR_EVENT(fsync_err); 574 + DEFINE_SMB3_SYNC_ERR_EVENT(flush_err); 575 + 576 + 550 577 DECLARE_EVENT_CLASS(smb3_enter_exit_class, 551 578 TP_PROTO(unsigned int xid, 552 579 const char *func_name),