Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6:
[CIFS] Fix endian error comparing authusers when cifsacl enabled
[CIFS] Rename three structures to avoid camel case
Fix extended security auth failure
CIFS: Add rwpidforward mount option
CIFS: Migrate to shared superblock model
[CIFS] Migrate from prefixpath logic
CIFS: Fix memory leak in cifs_do_mount
[CIFS] When mandatory encryption on share, fail mount
CIFS: Use pid saved from cifsFileInfo in writepages and set_file_size
cifs: add cifs_async_writev
cifs: clean up wsize negotiation and allow for larger wsize
cifs: convert cifs_writepages to use async writes
CIFS: Fix undefined behavior when mount fails
cifs: don't call mid_q_entry->callback under the Global_MidLock (try #5)
CIFS: Simplify mount code for further shared sb capability
CIFS: Simplify connection structure search calls
cifs: remove unused SMB2 config and mount options
cifs: add ignore_pend flag to cifs_call_async
cifs: make cifs_send_async take a kvec array
cifs: consolidate SendReceive response checks

+1572 -1045
-20
fs/cifs/Kconfig
··· 153 153 Allows to fetch CIFS/NTFS ACL from the server. The DACL blob 154 154 is handed over to the application/caller. 155 155 156 - config CIFS_SMB2 157 - bool "SMB2 network file system support (EXPERIMENTAL)" 158 - depends on EXPERIMENTAL && INET && BROKEN 159 - select NLS 160 - select KEYS 161 - select FSCACHE 162 - select DNS_RESOLVER 163 - 164 - help 165 - This enables experimental support for the SMB2 (Server Message Block 166 - version 2) protocol. The SMB2 protocol is the successor to the 167 - popular CIFS and SMB network file sharing protocols. SMB2 is the 168 - native file sharing mechanism for recent versions of Windows 169 - operating systems (since Vista). SMB2 enablement will eventually 170 - allow users better performance, security and features, than would be 171 - possible with cifs. Note that smb2 mount options also are simpler 172 - (compared to cifs) due to protocol improvements. 173 - 174 - Unless you are a developer or tester, say N. 175 - 176 156 config CIFS_NFSD_EXPORT 177 157 bool "Allow nfsd to export CIFS file system (EXPERIMENTAL)" 178 158 depends on CIFS && EXPERIMENTAL
+3
fs/cifs/README
··· 457 457 otherwise - read from the server. All written data are stored 458 458 in the cache, but if the client doesn't have Exclusive Oplock, 459 459 it writes the data to the server. 460 + rwpidforward Forward pid of a process who opened a file to any read or write 461 + operation on that file. This prevent applications like WINE 462 + from failing on read and write if we use mandatory brlock style. 460 463 acl Allow setfacl and getfacl to manage posix ACLs if server 461 464 supports them. (default) 462 465 noacl Do not allow setfacl and getfacl calls on this mount
+3 -3
fs/cifs/cache.c
··· 146 146 static uint16_t cifs_super_get_key(const void *cookie_netfs_data, void *buffer, 147 147 uint16_t maxbuf) 148 148 { 149 - const struct cifsTconInfo *tcon = cookie_netfs_data; 149 + const struct cifs_tcon *tcon = cookie_netfs_data; 150 150 char *sharename; 151 151 uint16_t len; 152 152 ··· 173 173 uint16_t maxbuf) 174 174 { 175 175 struct cifs_fscache_super_auxdata auxdata; 176 - const struct cifsTconInfo *tcon = cookie_netfs_data; 176 + const struct cifs_tcon *tcon = cookie_netfs_data; 177 177 178 178 memset(&auxdata, 0, sizeof(auxdata)); 179 179 auxdata.resource_id = tcon->resource_id; ··· 192 192 uint16_t datalen) 193 193 { 194 194 struct cifs_fscache_super_auxdata auxdata; 195 - const struct cifsTconInfo *tcon = cookie_netfs_data; 195 + const struct cifs_tcon *tcon = cookie_netfs_data; 196 196 197 197 if (datalen != sizeof(auxdata)) 198 198 return FSCACHE_CHECKAUX_OBSOLETE;
+13 -13
fs/cifs/cifs_debug.c
··· 110 110 struct list_head *tmp1, *tmp2, *tmp3; 111 111 struct mid_q_entry *mid_entry; 112 112 struct TCP_Server_Info *server; 113 - struct cifsSesInfo *ses; 114 - struct cifsTconInfo *tcon; 113 + struct cifs_ses *ses; 114 + struct cifs_tcon *tcon; 115 115 int i, j; 116 116 __u32 dev_type; 117 117 ··· 152 152 tcp_ses_list); 153 153 i++; 154 154 list_for_each(tmp2, &server->smb_ses_list) { 155 - ses = list_entry(tmp2, struct cifsSesInfo, 155 + ses = list_entry(tmp2, struct cifs_ses, 156 156 smb_ses_list); 157 157 if ((ses->serverDomain == NULL) || 158 158 (ses->serverOS == NULL) || ··· 171 171 seq_printf(m, "TCP status: %d\n\tLocal Users To " 172 172 "Server: %d SecMode: 0x%x Req On Wire: %d", 173 173 server->tcpStatus, server->srv_count, 174 - server->secMode, 174 + server->sec_mode, 175 175 atomic_read(&server->inFlight)); 176 176 177 177 #ifdef CONFIG_CIFS_STATS2 ··· 183 183 seq_puts(m, "\n\tShares:"); 184 184 j = 0; 185 185 list_for_each(tmp3, &ses->tcon_list) { 186 - tcon = list_entry(tmp3, struct cifsTconInfo, 186 + tcon = list_entry(tmp3, struct cifs_tcon, 187 187 tcon_list); 188 188 ++j; 189 189 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); ··· 256 256 int rc; 257 257 struct list_head *tmp1, *tmp2, *tmp3; 258 258 struct TCP_Server_Info *server; 259 - struct cifsSesInfo *ses; 260 - struct cifsTconInfo *tcon; 259 + struct cifs_ses *ses; 260 + struct cifs_tcon *tcon; 261 261 262 262 rc = get_user(c, buffer); 263 263 if (rc) ··· 273 273 server = list_entry(tmp1, struct TCP_Server_Info, 274 274 tcp_ses_list); 275 275 list_for_each(tmp2, &server->smb_ses_list) { 276 - ses = list_entry(tmp2, struct cifsSesInfo, 276 + ses = list_entry(tmp2, struct cifs_ses, 277 277 smb_ses_list); 278 278 list_for_each(tmp3, &ses->tcon_list) { 279 279 tcon = list_entry(tmp3, 280 - struct cifsTconInfo, 280 + struct cifs_tcon, 281 281 tcon_list); 282 282 atomic_set(&tcon->num_smbs_sent, 0); 283 283 atomic_set(&tcon->num_writes, 0); ··· 312 312 int i; 313 313 struct list_head *tmp1, *tmp2, *tmp3; 314 314 struct TCP_Server_Info *server; 315 - struct cifsSesInfo *ses; 316 - struct cifsTconInfo *tcon; 315 + struct cifs_ses *ses; 316 + struct cifs_tcon *tcon; 317 317 318 318 seq_printf(m, 319 319 "Resources in use\nCIFS Session: %d\n", ··· 346 346 server = list_entry(tmp1, struct TCP_Server_Info, 347 347 tcp_ses_list); 348 348 list_for_each(tmp2, &server->smb_ses_list) { 349 - ses = list_entry(tmp2, struct cifsSesInfo, 349 + ses = list_entry(tmp2, struct cifs_ses, 350 350 smb_ses_list); 351 351 list_for_each(tmp3, &ses->tcon_list) { 352 352 tcon = list_entry(tmp3, 353 - struct cifsTconInfo, 353 + struct cifs_tcon, 354 354 tcon_list); 355 355 i++; 356 356 seq_printf(m, "\n%d) %s", i, tcon->treeName);
+1 -1
fs/cifs/cifs_dfs_ref.c
··· 272 272 struct dfs_info3_param *referrals = NULL; 273 273 unsigned int num_referrals = 0; 274 274 struct cifs_sb_info *cifs_sb; 275 - struct cifsSesInfo *ses; 275 + struct cifs_ses *ses; 276 276 char *full_path; 277 277 int xid, i; 278 278 int rc;
+1 -2
fs/cifs/cifs_fs_sb.h
··· 41 41 #define CIFS_MOUNT_MF_SYMLINKS 0x10000 /* Minshall+French Symlinks enabled */ 42 42 #define CIFS_MOUNT_MULTIUSER 0x20000 /* multiuser mount */ 43 43 #define CIFS_MOUNT_STRICT_IO 0x40000 /* strict cache mode */ 44 + #define CIFS_MOUNT_RWPIDFORWARD 0x80000 /* use pid forwarding for rw */ 44 45 45 46 struct cifs_sb_info { 46 47 struct rb_root tlink_tree; ··· 57 56 mode_t mnt_file_mode; 58 57 mode_t mnt_dir_mode; 59 58 unsigned int mnt_cifs_flags; 60 - int prepathlen; 61 - char *prepath; /* relative path under the share to mount to */ 62 59 char *mountdata; /* options received at mount time or via DFS refs */ 63 60 struct backing_dev_info bdi; 64 61 struct delayed_work prune_tlinks;
+1 -1
fs/cifs/cifs_spnego.c
··· 95 95 96 96 /* get a key struct with a SPNEGO security blob, suitable for session setup */ 97 97 struct key * 98 - cifs_get_spnego_key(struct cifsSesInfo *sesInfo) 98 + cifs_get_spnego_key(struct cifs_ses *sesInfo) 99 99 { 100 100 struct TCP_Server_Info *server = sesInfo->server; 101 101 struct sockaddr_in *sa = (struct sockaddr_in *) &server->dstaddr;
+1 -1
fs/cifs/cifs_spnego.h
··· 41 41 42 42 #ifdef __KERNEL__ 43 43 extern struct key_type cifs_spnego_key_type; 44 - extern struct key *cifs_get_spnego_key(struct cifsSesInfo *sesInfo); 44 + extern struct key *cifs_get_spnego_key(struct cifs_ses *sesInfo); 45 45 #endif /* KERNEL */ 46 46 47 47 #endif /* _CIFS_SPNEGO_H */
+5 -4
fs/cifs/cifsacl.c
··· 38 38 1, 1, {0, 0, 0, 0, 0, 1}, {0} }; 39 39 /* security id for Authenticated Users system group */ 40 40 static const struct cifs_sid sid_authusers = { 41 - 1, 1, {0, 0, 0, 0, 0, 5}, {11} }; 41 + 1, 1, {0, 0, 0, 0, 0, 5}, {cpu_to_le32(11)} }; 42 42 /* group users */ 43 43 static const struct cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {} }; 44 44 ··· 458 458 if (num_subauth) { 459 459 for (i = 0; i < num_subauth; ++i) { 460 460 if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) { 461 - if (ctsid->sub_auth[i] > cwsid->sub_auth[i]) 461 + if (le32_to_cpu(ctsid->sub_auth[i]) > 462 + le32_to_cpu(cwsid->sub_auth[i])) 462 463 return 1; 463 464 else 464 465 return -1; ··· 946 945 int oplock = 0; 947 946 int xid, rc; 948 947 __u16 fid; 949 - struct cifsTconInfo *tcon; 948 + struct cifs_tcon *tcon; 950 949 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); 951 950 952 951 if (IS_ERR(tlink)) ··· 1014 1013 int oplock = 0; 1015 1014 int xid, rc; 1016 1015 __u16 fid; 1017 - struct cifsTconInfo *tcon; 1016 + struct cifs_tcon *tcon; 1018 1017 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); 1019 1018 1020 1019 if (IS_ERR(tlink))
+7 -7
fs/cifs/cifsencrypt.c
··· 229 229 } 230 230 231 231 /* first calculate 24 bytes ntlm response and then 16 byte session key */ 232 - int setup_ntlm_response(struct cifsSesInfo *ses) 232 + int setup_ntlm_response(struct cifs_ses *ses) 233 233 { 234 234 int rc = 0; 235 235 unsigned int temp_len = CIFS_SESS_KEY_SIZE + CIFS_AUTH_RESP_SIZE; ··· 312 312 * Allocate domain name which gets freed when session struct is deallocated. 313 313 */ 314 314 static int 315 - build_avpair_blob(struct cifsSesInfo *ses, const struct nls_table *nls_cp) 315 + build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp) 316 316 { 317 317 unsigned int dlen; 318 318 unsigned int wlen; ··· 400 400 * about target string i.e. for some, just user name might suffice. 401 401 */ 402 402 static int 403 - find_domain_name(struct cifsSesInfo *ses, const struct nls_table *nls_cp) 403 + find_domain_name(struct cifs_ses *ses, const struct nls_table *nls_cp) 404 404 { 405 405 unsigned int attrsize; 406 406 unsigned int type; ··· 445 445 return 0; 446 446 } 447 447 448 - static int calc_ntlmv2_hash(struct cifsSesInfo *ses, char *ntlmv2_hash, 448 + static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, 449 449 const struct nls_table *nls_cp) 450 450 { 451 451 int rc = 0; ··· 527 527 } 528 528 529 529 static int 530 - CalcNTLMv2_response(const struct cifsSesInfo *ses, char *ntlmv2_hash) 530 + CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash) 531 531 { 532 532 int rc; 533 533 unsigned int offset = CIFS_SESS_KEY_SIZE + 8; ··· 563 563 564 564 565 565 int 566 - setup_ntlmv2_rsp(struct cifsSesInfo *ses, const struct nls_table *nls_cp) 566 + setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp) 567 567 { 568 568 int rc; 569 569 int baselen; ··· 649 649 } 650 650 651 651 int 652 - calc_seckey(struct cifsSesInfo *ses) 652 + calc_seckey(struct cifs_ses *ses) 653 653 { 654 654 int rc; 655 655 struct crypto_blkcipher *tfm_arc4;
+185 -48
fs/cifs/cifsfs.c
··· 104 104 } 105 105 106 106 static int 107 - cifs_read_super(struct super_block *sb, void *data, 107 + cifs_read_super(struct super_block *sb, struct smb_vol *volume_info, 108 108 const char *devname, int silent) 109 109 { 110 110 struct inode *inode; 111 111 struct cifs_sb_info *cifs_sb; 112 112 int rc = 0; 113 113 114 - /* BB should we make this contingent on mount parm? */ 115 - sb->s_flags |= MS_NODIRATIME | MS_NOATIME; 116 - sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL); 117 114 cifs_sb = CIFS_SB(sb); 118 - if (cifs_sb == NULL) 119 - return -ENOMEM; 120 115 121 116 spin_lock_init(&cifs_sb->tlink_tree_lock); 122 117 cifs_sb->tlink_tree = RB_ROOT; 123 118 124 119 rc = bdi_setup_and_register(&cifs_sb->bdi, "cifs", BDI_CAP_MAP_COPY); 125 - if (rc) { 126 - kfree(cifs_sb); 120 + if (rc) 127 121 return rc; 128 - } 122 + 129 123 cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages; 130 124 131 - /* 132 - * Copy mount params to sb for use in submounts. Better to do 133 - * the copy here and deal with the error before cleanup gets 134 - * complicated post-mount. 135 - */ 136 - if (data) { 137 - cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); 138 - if (cifs_sb->mountdata == NULL) { 139 - bdi_destroy(&cifs_sb->bdi); 140 - kfree(sb->s_fs_info); 141 - sb->s_fs_info = NULL; 142 - return -ENOMEM; 143 - } 144 - } 145 - 146 - rc = cifs_mount(sb, cifs_sb, devname); 125 + rc = cifs_mount(sb, cifs_sb, volume_info, devname); 147 126 148 127 if (rc) { 149 128 if (!silent) ··· 173 194 cifs_umount(sb, cifs_sb); 174 195 175 196 out_mount_failed: 176 - if (cifs_sb) { 177 - if (cifs_sb->mountdata) { 178 - kfree(cifs_sb->mountdata); 179 - cifs_sb->mountdata = NULL; 180 - } 181 - unload_nls(cifs_sb->local_nls); 182 - bdi_destroy(&cifs_sb->bdi); 183 - kfree(cifs_sb); 184 - } 197 + bdi_destroy(&cifs_sb->bdi); 185 198 return rc; 186 199 } 187 200 ··· 208 237 { 209 238 struct super_block *sb = dentry->d_sb; 210 239 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 211 - struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb); 240 + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 212 241 int rc = -EOPNOTSUPP; 213 242 int xid; 214 243 ··· 361 390 cifs_show_options(struct seq_file *s, struct vfsmount *m) 362 391 { 363 392 struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb); 364 - struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb); 393 + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 365 394 struct sockaddr *srcaddr; 366 395 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; 367 396 ··· 415 444 seq_printf(s, ",nocase"); 416 445 if (tcon->retry) 417 446 seq_printf(s, ",hard"); 418 - if (cifs_sb->prepath) 419 - seq_printf(s, ",prepath=%s", cifs_sb->prepath); 447 + if (tcon->unix_ext) 448 + seq_printf(s, ",unix"); 449 + else 450 + seq_printf(s, ",nounix"); 420 451 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 421 452 seq_printf(s, ",posixpaths"); 422 453 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) 423 454 seq_printf(s, ",setuids"); 424 455 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) 425 456 seq_printf(s, ",serverino"); 457 + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 458 + seq_printf(s, ",rwpidforward"); 459 + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) 460 + seq_printf(s, ",forcemand"); 426 461 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) 427 462 seq_printf(s, ",directio"); 428 463 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) ··· 461 484 static void cifs_umount_begin(struct super_block *sb) 462 485 { 463 486 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 464 - struct cifsTconInfo *tcon; 487 + struct cifs_tcon *tcon; 465 488 466 489 if (cifs_sb == NULL) 467 490 return; ··· 536 559 #endif 537 560 }; 538 561 562 + /* 563 + * Get root dentry from superblock according to prefix path mount option. 564 + * Return dentry with refcount + 1 on success and NULL otherwise. 565 + */ 566 + static struct dentry * 567 + cifs_get_root(struct smb_vol *vol, struct super_block *sb) 568 + { 569 + int xid, rc; 570 + struct inode *inode; 571 + struct qstr name; 572 + struct dentry *dparent = NULL, *dchild = NULL, *alias; 573 + struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 574 + unsigned int i, full_len, len; 575 + char *full_path = NULL, *pstart; 576 + char sep; 577 + 578 + full_path = cifs_build_path_to_root(vol, cifs_sb, 579 + cifs_sb_master_tcon(cifs_sb)); 580 + if (full_path == NULL) 581 + return NULL; 582 + 583 + cFYI(1, "Get root dentry for %s", full_path); 584 + 585 + xid = GetXid(); 586 + sep = CIFS_DIR_SEP(cifs_sb); 587 + dparent = dget(sb->s_root); 588 + full_len = strlen(full_path); 589 + full_path[full_len] = sep; 590 + pstart = full_path + 1; 591 + 592 + for (i = 1, len = 0; i <= full_len; i++) { 593 + if (full_path[i] != sep || !len) { 594 + len++; 595 + continue; 596 + } 597 + 598 + full_path[i] = 0; 599 + cFYI(1, "get dentry for %s", pstart); 600 + 601 + name.name = pstart; 602 + name.len = len; 603 + name.hash = full_name_hash(pstart, len); 604 + dchild = d_lookup(dparent, &name); 605 + if (dchild == NULL) { 606 + cFYI(1, "not exists"); 607 + dchild = d_alloc(dparent, &name); 608 + if (dchild == NULL) { 609 + dput(dparent); 610 + dparent = NULL; 611 + goto out; 612 + } 613 + } 614 + 615 + cFYI(1, "get inode"); 616 + if (dchild->d_inode == NULL) { 617 + cFYI(1, "not exists"); 618 + inode = NULL; 619 + if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext) 620 + rc = cifs_get_inode_info_unix(&inode, full_path, 621 + sb, xid); 622 + else 623 + rc = cifs_get_inode_info(&inode, full_path, 624 + NULL, sb, xid, NULL); 625 + if (rc) { 626 + dput(dchild); 627 + dput(dparent); 628 + dparent = NULL; 629 + goto out; 630 + } 631 + alias = d_materialise_unique(dchild, inode); 632 + if (alias != NULL) { 633 + dput(dchild); 634 + if (IS_ERR(alias)) { 635 + dput(dparent); 636 + dparent = NULL; 637 + goto out; 638 + } 639 + dchild = alias; 640 + } 641 + } 642 + cFYI(1, "parent %p, child %p", dparent, dchild); 643 + 644 + dput(dparent); 645 + dparent = dchild; 646 + len = 0; 647 + pstart = full_path + i + 1; 648 + full_path[i] = sep; 649 + } 650 + out: 651 + _FreeXid(xid); 652 + kfree(full_path); 653 + return dparent; 654 + } 655 + 539 656 static struct dentry * 540 657 cifs_do_mount(struct file_system_type *fs_type, 541 - int flags, const char *dev_name, void *data) 658 + int flags, const char *dev_name, void *data) 542 659 { 543 660 int rc; 544 661 struct super_block *sb; 545 - 546 - sb = sget(fs_type, NULL, set_anon_super, NULL); 662 + struct cifs_sb_info *cifs_sb; 663 + struct smb_vol *volume_info; 664 + struct cifs_mnt_data mnt_data; 665 + struct dentry *root; 547 666 548 667 cFYI(1, "Devname: %s flags: %d ", dev_name, flags); 549 668 550 - if (IS_ERR(sb)) 551 - return ERR_CAST(sb); 669 + rc = cifs_setup_volume_info(&volume_info, (char *)data, dev_name); 670 + if (rc) 671 + return ERR_PTR(rc); 672 + 673 + cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL); 674 + if (cifs_sb == NULL) { 675 + root = ERR_PTR(-ENOMEM); 676 + goto out; 677 + } 678 + 679 + cifs_setup_cifs_sb(volume_info, cifs_sb); 680 + 681 + mnt_data.vol = volume_info; 682 + mnt_data.cifs_sb = cifs_sb; 683 + mnt_data.flags = flags; 684 + 685 + sb = sget(fs_type, cifs_match_super, set_anon_super, &mnt_data); 686 + if (IS_ERR(sb)) { 687 + root = ERR_CAST(sb); 688 + goto out_cifs_sb; 689 + } 690 + 691 + if (sb->s_fs_info) { 692 + cFYI(1, "Use existing superblock"); 693 + goto out_shared; 694 + } 695 + 696 + /* 697 + * Copy mount params for use in submounts. Better to do 698 + * the copy here and deal with the error before cleanup gets 699 + * complicated post-mount. 700 + */ 701 + cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); 702 + if (cifs_sb->mountdata == NULL) { 703 + root = ERR_PTR(-ENOMEM); 704 + goto out_super; 705 + } 552 706 553 707 sb->s_flags = flags; 708 + /* BB should we make this contingent on mount parm? */ 709 + sb->s_flags |= MS_NODIRATIME | MS_NOATIME; 710 + sb->s_fs_info = cifs_sb; 554 711 555 - rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0); 712 + rc = cifs_read_super(sb, volume_info, dev_name, 713 + flags & MS_SILENT ? 1 : 0); 556 714 if (rc) { 557 - deactivate_locked_super(sb); 558 - return ERR_PTR(rc); 715 + root = ERR_PTR(rc); 716 + goto out_super; 559 717 } 718 + 560 719 sb->s_flags |= MS_ACTIVE; 561 - return dget(sb->s_root); 720 + 721 + root = cifs_get_root(volume_info, sb); 722 + if (root == NULL) 723 + goto out_super; 724 + 725 + cFYI(1, "dentry root is: %p", root); 726 + goto out; 727 + 728 + out_shared: 729 + root = cifs_get_root(volume_info, sb); 730 + if (root) 731 + cFYI(1, "dentry root is: %p", root); 732 + goto out; 733 + 734 + out_super: 735 + kfree(cifs_sb->mountdata); 736 + deactivate_locked_super(sb); 737 + 738 + out_cifs_sb: 739 + unload_nls(cifs_sb->local_nls); 740 + kfree(cifs_sb); 741 + 742 + out: 743 + cifs_cleanup_volume_info(&volume_info); 744 + return root; 562 745 } 563 746 564 747 static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
+116 -13
fs/cifs/cifsglob.h
··· 155 155 ***************************************************************** 156 156 */ 157 157 158 + struct smb_vol { 159 + char *username; 160 + char *password; 161 + char *domainname; 162 + char *UNC; 163 + char *UNCip; 164 + char *iocharset; /* local code page for mapping to and from Unicode */ 165 + char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */ 166 + char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */ 167 + uid_t cred_uid; 168 + uid_t linux_uid; 169 + gid_t linux_gid; 170 + mode_t file_mode; 171 + mode_t dir_mode; 172 + unsigned secFlg; 173 + bool retry:1; 174 + bool intr:1; 175 + bool setuids:1; 176 + bool override_uid:1; 177 + bool override_gid:1; 178 + bool dynperm:1; 179 + bool noperm:1; 180 + bool no_psx_acl:1; /* set if posix acl support should be disabled */ 181 + bool cifs_acl:1; 182 + bool no_xattr:1; /* set if xattr (EA) support should be disabled*/ 183 + bool server_ino:1; /* use inode numbers from server ie UniqueId */ 184 + bool direct_io:1; 185 + bool strict_io:1; /* strict cache behavior */ 186 + bool remap:1; /* set to remap seven reserved chars in filenames */ 187 + bool posix_paths:1; /* unset to not ask for posix pathnames. */ 188 + bool no_linux_ext:1; 189 + bool sfu_emul:1; 190 + bool nullauth:1; /* attempt to authenticate with null user */ 191 + bool nocase:1; /* request case insensitive filenames */ 192 + bool nobrl:1; /* disable sending byte range locks to srv */ 193 + bool mand_lock:1; /* send mandatory not posix byte range lock reqs */ 194 + bool seal:1; /* request transport encryption on share */ 195 + bool nodfs:1; /* Do not request DFS, even if available */ 196 + bool local_lease:1; /* check leases only on local system, not remote */ 197 + bool noblocksnd:1; 198 + bool noautotune:1; 199 + bool nostrictsync:1; /* do not force expensive SMBflush on every sync */ 200 + bool fsc:1; /* enable fscache */ 201 + bool mfsymlinks:1; /* use Minshall+French Symlinks */ 202 + bool multiuser:1; 203 + bool rwpidforward:1; /* pid forward for read/write operations */ 204 + unsigned int rsize; 205 + unsigned int wsize; 206 + bool sockopt_tcp_nodelay:1; 207 + unsigned short int port; 208 + unsigned long actimeo; /* attribute cache timeout (jiffies) */ 209 + char *prepath; 210 + struct sockaddr_storage srcaddr; /* allow binding to a local IP */ 211 + struct nls_table *local_nls; 212 + }; 213 + 214 + #define CIFS_MOUNT_MASK (CIFS_MOUNT_NO_PERM | CIFS_MOUNT_SET_UID | \ 215 + CIFS_MOUNT_SERVER_INUM | CIFS_MOUNT_DIRECT_IO | \ 216 + CIFS_MOUNT_NO_XATTR | CIFS_MOUNT_MAP_SPECIAL_CHR | \ 217 + CIFS_MOUNT_UNX_EMUL | CIFS_MOUNT_NO_BRL | \ 218 + CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_OVERR_UID | \ 219 + CIFS_MOUNT_OVERR_GID | CIFS_MOUNT_DYNPERM | \ 220 + CIFS_MOUNT_NOPOSIXBRL | CIFS_MOUNT_NOSSYNC | \ 221 + CIFS_MOUNT_FSCACHE | CIFS_MOUNT_MF_SYMLINKS | \ 222 + CIFS_MOUNT_MULTIUSER | CIFS_MOUNT_STRICT_IO) 223 + 224 + #define CIFS_MS_MASK (MS_RDONLY | MS_MANDLOCK | MS_NOEXEC | MS_NOSUID | \ 225 + MS_NODEV | MS_SYNCHRONOUS) 226 + 227 + struct cifs_mnt_data { 228 + struct cifs_sb_info *cifs_sb; 229 + struct smb_vol *vol; 230 + int flags; 231 + }; 232 + 158 233 struct TCP_Server_Info { 159 234 struct list_head tcp_ses_list; 160 235 struct list_head smb_ses_list; ··· 254 179 struct mutex srv_mutex; 255 180 struct task_struct *tsk; 256 181 char server_GUID[16]; 257 - char secMode; 182 + char sec_mode; 258 183 bool session_estab; /* mark when very first sess is established */ 259 184 u16 dialect; /* dialect index that server chose */ 260 185 enum securityEnum secType; ··· 329 254 /* 330 255 * Session structure. One of these for each uid session with a particular host 331 256 */ 332 - struct cifsSesInfo { 257 + struct cifs_ses { 333 258 struct list_head smb_ses_list; 334 259 struct list_head tcon_list; 335 260 struct mutex session_mutex; ··· 369 294 * there is one of these for each connection to a resource on a particular 370 295 * session 371 296 */ 372 - struct cifsTconInfo { 297 + struct cifs_tcon { 373 298 struct list_head tcon_list; 374 299 int tc_count; 375 300 struct list_head openFileList; 376 - struct cifsSesInfo *ses; /* pointer to session associated with */ 301 + struct cifs_ses *ses; /* pointer to session associated with */ 377 302 char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */ 378 303 char *nativeFileSystem; 379 304 char *password; /* for share-level security */ ··· 455 380 #define TCON_LINK_IN_TREE 2 456 381 unsigned long tl_time; 457 382 atomic_t tl_count; 458 - struct cifsTconInfo *tl_tcon; 383 + struct cifs_tcon *tl_tcon; 459 384 }; 460 385 461 386 extern struct tcon_link *cifs_sb_tlink(struct cifs_sb_info *cifs_sb); 462 387 463 - static inline struct cifsTconInfo * 388 + static inline struct cifs_tcon * 464 389 tlink_tcon(struct tcon_link *tlink) 465 390 { 466 391 return tlink->tl_tcon; ··· 477 402 } 478 403 479 404 /* This function is always expected to succeed */ 480 - extern struct cifsTconInfo *cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb); 405 + extern struct cifs_tcon *cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb); 481 406 482 407 /* 483 408 * This info hangs off the cifsFileInfo structure, pointed to by llist. ··· 528 453 struct mutex fh_mutex; /* prevents reopen race after dead ses*/ 529 454 struct cifs_search_info srch_inf; 530 455 struct work_struct oplock_break; /* work for oplock breaks */ 456 + }; 457 + 458 + struct cifs_io_parms { 459 + __u16 netfid; 460 + __u32 pid; 461 + __u64 offset; 462 + unsigned int length; 463 + struct cifs_tcon *tcon; 531 464 }; 532 465 533 466 /* ··· 592 509 return '\\'; 593 510 } 594 511 512 + static inline void 513 + convert_delimiter(char *path, char delim) 514 + { 515 + int i; 516 + char old_delim; 517 + 518 + if (path == NULL) 519 + return; 520 + 521 + if (delim == '/') 522 + old_delim = '\\'; 523 + else 524 + old_delim = '/'; 525 + 526 + for (i = 0; path[i] != '\0'; i++) { 527 + if (path[i] == old_delim) 528 + path[i] = delim; 529 + } 530 + } 531 + 595 532 #ifdef CONFIG_CIFS_STATS 596 533 #define cifs_stats_inc atomic_inc 597 534 598 - static inline void cifs_stats_bytes_written(struct cifsTconInfo *tcon, 535 + static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon, 599 536 unsigned int bytes) 600 537 { 601 538 if (bytes) { ··· 625 522 } 626 523 } 627 524 628 - static inline void cifs_stats_bytes_read(struct cifsTconInfo *tcon, 525 + static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon, 629 526 unsigned int bytes) 630 527 { 631 528 spin_lock(&tcon->stat_lock); ··· 646 543 * This is the prototype for the mid callback function. When creating one, 647 544 * take special care to avoid deadlocks. Things to bear in mind: 648 545 * 649 - * - it will be called by cifsd 650 - * - the GlobalMid_Lock will be held 651 - * - the mid will be removed from the pending_mid_q list 546 + * - it will be called by cifsd, with no locks held 547 + * - the mid will be removed from any lists 652 548 */ 653 549 typedef void (mid_callback_t)(struct mid_q_entry *mid); 654 550 ··· 675 573 struct oplock_q_entry { 676 574 struct list_head qhead; 677 575 struct inode *pinode; 678 - struct cifsTconInfo *tcon; 576 + struct cifs_tcon *tcon; 679 577 __u16 netfid; 680 578 }; 681 579 ··· 758 656 #define MID_RESPONSE_RECEIVED 4 759 657 #define MID_RETRY_NEEDED 8 /* session closed while this request out */ 760 658 #define MID_RESPONSE_MALFORMED 0x10 659 + #define MID_SHUTDOWN 0x20 761 660 762 661 /* Types of response buffer returned from SendReceive2 */ 763 662 #define CIFS_NO_BUFFER 0 /* Response buffer not returned */
+116 -93
fs/cifs/cifsproto.h
··· 57 57 extern void exit_cifs_idmap(void); 58 58 extern void cifs_destroy_idmaptrees(void); 59 59 extern char *build_path_from_dentry(struct dentry *); 60 - extern char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb, 61 - struct cifsTconInfo *tcon); 60 + extern char *cifs_build_path_to_root(struct smb_vol *vol, 61 + struct cifs_sb_info *cifs_sb, 62 + struct cifs_tcon *tcon); 62 63 extern char *build_wildcard_path_from_dentry(struct dentry *direntry); 63 64 extern char *cifs_compose_mount_options(const char *sb_mountdata, 64 65 const char *fullpath, const struct dfs_info3_param *ref, ··· 68 67 extern struct mid_q_entry *AllocMidQEntry(const struct smb_hdr *smb_buffer, 69 68 struct TCP_Server_Info *server); 70 69 extern void DeleteMidQEntry(struct mid_q_entry *midEntry); 71 - extern int cifs_call_async(struct TCP_Server_Info *server, 72 - struct smb_hdr *in_buf, mid_callback_t *callback, 73 - void *cbdata); 74 - extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *, 70 + extern int cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, 71 + unsigned int nvec, mid_callback_t *callback, 72 + void *cbdata, bool ignore_pend); 73 + extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *, 75 74 struct smb_hdr * /* input */ , 76 75 struct smb_hdr * /* out */ , 77 76 int * /* bytes returned */ , const int long_op); 78 - extern int SendReceiveNoRsp(const unsigned int xid, struct cifsSesInfo *ses, 77 + extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses, 79 78 struct smb_hdr *in_buf, int flags); 80 - extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *, 79 + extern int cifs_check_receive(struct mid_q_entry *mid, 80 + struct TCP_Server_Info *server, bool log_error); 81 + extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *, 81 82 struct kvec *, int /* nvec to send */, 82 83 int * /* type of buf returned */ , const int flags); 83 84 extern int SendReceiveBlockingLock(const unsigned int xid, 84 - struct cifsTconInfo *ptcon, 85 + struct cifs_tcon *ptcon, 85 86 struct smb_hdr *in_buf , 86 87 struct smb_hdr *out_buf, 87 88 int *bytes_returned); ··· 102 99 extern int cifs_set_port(struct sockaddr *addr, const unsigned short int port); 103 100 extern int cifs_fill_sockaddr(struct sockaddr *dst, const char *src, int len, 104 101 const unsigned short int port); 105 - extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr); 102 + extern int map_smb_to_linux_error(struct smb_hdr *smb, bool logErr); 106 103 extern void header_assemble(struct smb_hdr *, char /* command */ , 107 - const struct cifsTconInfo *, int /* length of 104 + const struct cifs_tcon *, int /* length of 108 105 fixed section (word count) in two byte units */); 109 106 extern int small_smb_init_no_tc(const int smb_cmd, const int wct, 110 - struct cifsSesInfo *ses, 107 + struct cifs_ses *ses, 111 108 void **request_buf); 112 - extern int CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, 109 + extern int CIFS_SessSetup(unsigned int xid, struct cifs_ses *ses, 113 110 const struct nls_table *nls_cp); 114 111 extern __u16 GetNextMid(struct TCP_Server_Info *server); 115 112 extern struct timespec cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601); ··· 151 148 extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *, 152 149 const char *); 153 150 151 + extern void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, 152 + struct cifs_sb_info *cifs_sb); 153 + extern int cifs_match_super(struct super_block *, void *); 154 + extern void cifs_cleanup_volume_info(struct smb_vol **pvolume_info); 155 + extern int cifs_setup_volume_info(struct smb_vol **pvolume_info, 156 + char *mount_data, const char *devname); 154 157 extern int cifs_mount(struct super_block *, struct cifs_sb_info *, 155 - const char *); 158 + struct smb_vol *, const char *); 156 159 extern int cifs_umount(struct super_block *, struct cifs_sb_info *); 157 160 extern void cifs_dfs_release_automount_timer(void); 158 161 void cifs_proc_init(void); 159 162 void cifs_proc_clean(void); 160 163 161 164 extern int cifs_negotiate_protocol(unsigned int xid, 162 - struct cifsSesInfo *ses); 163 - extern int cifs_setup_session(unsigned int xid, struct cifsSesInfo *ses, 165 + struct cifs_ses *ses); 166 + extern int cifs_setup_session(unsigned int xid, struct cifs_ses *ses, 164 167 struct nls_table *nls_info); 165 - extern int CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses); 168 + extern int CIFSSMBNegotiate(unsigned int xid, struct cifs_ses *ses); 166 169 167 - extern int CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, 168 - const char *tree, struct cifsTconInfo *tcon, 170 + extern int CIFSTCon(unsigned int xid, struct cifs_ses *ses, 171 + const char *tree, struct cifs_tcon *tcon, 169 172 const struct nls_table *); 170 173 171 - extern int CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, 174 + extern int CIFSFindFirst(const int xid, struct cifs_tcon *tcon, 172 175 const char *searchName, const struct nls_table *nls_codepage, 173 176 __u16 *searchHandle, struct cifs_search_info *psrch_inf, 174 177 int map, const char dirsep); 175 178 176 - extern int CIFSFindNext(const int xid, struct cifsTconInfo *tcon, 179 + extern int CIFSFindNext(const int xid, struct cifs_tcon *tcon, 177 180 __u16 searchHandle, struct cifs_search_info *psrch_inf); 178 181 179 - extern int CIFSFindClose(const int, struct cifsTconInfo *tcon, 182 + extern int CIFSFindClose(const int, struct cifs_tcon *tcon, 180 183 const __u16 search_handle); 181 184 182 - extern int CIFSSMBQFileInfo(const int xid, struct cifsTconInfo *tcon, 185 + extern int CIFSSMBQFileInfo(const int xid, struct cifs_tcon *tcon, 183 186 u16 netfid, FILE_ALL_INFO *pFindData); 184 - extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, 187 + extern int CIFSSMBQPathInfo(const int xid, struct cifs_tcon *tcon, 185 188 const unsigned char *searchName, 186 189 FILE_ALL_INFO *findData, 187 190 int legacy /* whether to use old info level */, 188 191 const struct nls_table *nls_codepage, int remap); 189 - extern int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon, 192 + extern int SMBQueryInformation(const int xid, struct cifs_tcon *tcon, 190 193 const unsigned char *searchName, 191 194 FILE_ALL_INFO *findData, 192 195 const struct nls_table *nls_codepage, int remap); 193 196 194 - extern int CIFSSMBUnixQFileInfo(const int xid, struct cifsTconInfo *tcon, 197 + extern int CIFSSMBUnixQFileInfo(const int xid, struct cifs_tcon *tcon, 195 198 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData); 196 199 extern int CIFSSMBUnixQPathInfo(const int xid, 197 - struct cifsTconInfo *tcon, 200 + struct cifs_tcon *tcon, 198 201 const unsigned char *searchName, 199 202 FILE_UNIX_BASIC_INFO *pFindData, 200 203 const struct nls_table *nls_codepage, int remap); 201 204 202 - extern int CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, 205 + extern int CIFSGetDFSRefer(const int xid, struct cifs_ses *ses, 203 206 const unsigned char *searchName, 204 207 struct dfs_info3_param **target_nodes, 205 208 unsigned int *number_of_nodes_in_array, 206 209 const struct nls_table *nls_codepage, int remap); 207 210 208 - extern int get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, 211 + extern int get_dfs_path(int xid, struct cifs_ses *pSesInfo, 209 212 const char *old_path, 210 213 const struct nls_table *nls_codepage, 211 214 unsigned int *pnum_referrals, 212 215 struct dfs_info3_param **preferrals, 213 216 int remap); 214 - extern void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon, 217 + extern void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon, 215 218 struct super_block *sb, struct smb_vol *vol); 216 - extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, 219 + extern int CIFSSMBQFSInfo(const int xid, struct cifs_tcon *tcon, 217 220 struct kstatfs *FSData); 218 - extern int SMBOldQFSInfo(const int xid, struct cifsTconInfo *tcon, 221 + extern int SMBOldQFSInfo(const int xid, struct cifs_tcon *tcon, 219 222 struct kstatfs *FSData); 220 - extern int CIFSSMBSetFSUnixInfo(const int xid, struct cifsTconInfo *tcon, 223 + extern int CIFSSMBSetFSUnixInfo(const int xid, struct cifs_tcon *tcon, 221 224 __u64 cap); 222 225 223 226 extern int CIFSSMBQFSAttributeInfo(const int xid, 224 - struct cifsTconInfo *tcon); 225 - extern int CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon); 226 - extern int CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon); 227 - extern int CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon, 227 + struct cifs_tcon *tcon); 228 + extern int CIFSSMBQFSDeviceInfo(const int xid, struct cifs_tcon *tcon); 229 + extern int CIFSSMBQFSUnixInfo(const int xid, struct cifs_tcon *tcon); 230 + extern int CIFSSMBQFSPosixInfo(const int xid, struct cifs_tcon *tcon, 228 231 struct kstatfs *FSData); 229 232 230 - extern int CIFSSMBSetPathInfo(const int xid, struct cifsTconInfo *tcon, 233 + extern int CIFSSMBSetPathInfo(const int xid, struct cifs_tcon *tcon, 231 234 const char *fileName, const FILE_BASIC_INFO *data, 232 235 const struct nls_table *nls_codepage, 233 236 int remap_special_chars); 234 - extern int CIFSSMBSetFileInfo(const int xid, struct cifsTconInfo *tcon, 237 + extern int CIFSSMBSetFileInfo(const int xid, struct cifs_tcon *tcon, 235 238 const FILE_BASIC_INFO *data, __u16 fid, 236 239 __u32 pid_of_opener); 237 - extern int CIFSSMBSetFileDisposition(const int xid, struct cifsTconInfo *tcon, 240 + extern int CIFSSMBSetFileDisposition(const int xid, struct cifs_tcon *tcon, 238 241 bool delete_file, __u16 fid, __u32 pid_of_opener); 239 242 #if 0 240 - extern int CIFSSMBSetAttrLegacy(int xid, struct cifsTconInfo *tcon, 243 + extern int CIFSSMBSetAttrLegacy(int xid, struct cifs_tcon *tcon, 241 244 char *fileName, __u16 dos_attributes, 242 245 const struct nls_table *nls_codepage); 243 246 #endif /* possibly unneeded function */ 244 - extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, 247 + extern int CIFSSMBSetEOF(const int xid, struct cifs_tcon *tcon, 245 248 const char *fileName, __u64 size, 246 249 bool setAllocationSizeFlag, 247 250 const struct nls_table *nls_codepage, 248 251 int remap_special_chars); 249 - extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, 252 + extern int CIFSSMBSetFileSize(const int xid, struct cifs_tcon *tcon, 250 253 __u64 size, __u16 fileHandle, __u32 opener_pid, 251 254 bool AllocSizeFlag); 252 255 ··· 266 257 dev_t device; 267 258 }; 268 259 269 - extern int CIFSSMBUnixSetFileInfo(const int xid, struct cifsTconInfo *tcon, 260 + extern int CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon, 270 261 const struct cifs_unix_set_info_args *args, 271 262 u16 fid, u32 pid_of_opener); 272 263 273 - extern int CIFSSMBUnixSetPathInfo(const int xid, struct cifsTconInfo *pTcon, 264 + extern int CIFSSMBUnixSetPathInfo(const int xid, struct cifs_tcon *pTcon, 274 265 char *fileName, 275 266 const struct cifs_unix_set_info_args *args, 276 267 const struct nls_table *nls_codepage, 277 268 int remap_special_chars); 278 269 279 - extern int CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, 270 + extern int CIFSSMBMkDir(const int xid, struct cifs_tcon *tcon, 280 271 const char *newName, 281 272 const struct nls_table *nls_codepage, 282 273 int remap_special_chars); 283 - extern int CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, 274 + extern int CIFSSMBRmDir(const int xid, struct cifs_tcon *tcon, 284 275 const char *name, const struct nls_table *nls_codepage, 285 276 int remap_special_chars); 286 - extern int CIFSPOSIXDelFile(const int xid, struct cifsTconInfo *tcon, 277 + extern int CIFSPOSIXDelFile(const int xid, struct cifs_tcon *tcon, 287 278 const char *name, __u16 type, 288 279 const struct nls_table *nls_codepage, 289 280 int remap_special_chars); 290 - extern int CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, 281 + extern int CIFSSMBDelFile(const int xid, struct cifs_tcon *tcon, 291 282 const char *name, 292 283 const struct nls_table *nls_codepage, 293 284 int remap_special_chars); 294 - extern int CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, 285 + extern int CIFSSMBRename(const int xid, struct cifs_tcon *tcon, 295 286 const char *fromName, const char *toName, 296 287 const struct nls_table *nls_codepage, 297 288 int remap_special_chars); 298 - extern int CIFSSMBRenameOpenFile(const int xid, struct cifsTconInfo *pTcon, 289 + extern int CIFSSMBRenameOpenFile(const int xid, struct cifs_tcon *pTcon, 299 290 int netfid, const char *target_name, 300 291 const struct nls_table *nls_codepage, 301 292 int remap_special_chars); 302 293 extern int CIFSCreateHardLink(const int xid, 303 - struct cifsTconInfo *tcon, 294 + struct cifs_tcon *tcon, 304 295 const char *fromName, const char *toName, 305 296 const struct nls_table *nls_codepage, 306 297 int remap_special_chars); 307 298 extern int CIFSUnixCreateHardLink(const int xid, 308 - struct cifsTconInfo *tcon, 299 + struct cifs_tcon *tcon, 309 300 const char *fromName, const char *toName, 310 301 const struct nls_table *nls_codepage, 311 302 int remap_special_chars); 312 303 extern int CIFSUnixCreateSymLink(const int xid, 313 - struct cifsTconInfo *tcon, 304 + struct cifs_tcon *tcon, 314 305 const char *fromName, const char *toName, 315 306 const struct nls_table *nls_codepage); 316 307 extern int CIFSSMBUnixQuerySymLink(const int xid, 317 - struct cifsTconInfo *tcon, 308 + struct cifs_tcon *tcon, 318 309 const unsigned char *searchName, char **syminfo, 319 310 const struct nls_table *nls_codepage); 320 311 #ifdef CONFIG_CIFS_SYMLINK_EXPERIMENTAL 321 312 extern int CIFSSMBQueryReparseLinkInfo(const int xid, 322 - struct cifsTconInfo *tcon, 313 + struct cifs_tcon *tcon, 323 314 const unsigned char *searchName, 324 315 char *symlinkinfo, const int buflen, __u16 fid, 325 316 const struct nls_table *nls_codepage); 326 317 #endif /* temporarily unused until cifs_symlink fixed */ 327 - extern int CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon, 318 + extern int CIFSSMBOpen(const int xid, struct cifs_tcon *tcon, 328 319 const char *fileName, const int disposition, 329 320 const int access_flags, const int omode, 330 321 __u16 *netfid, int *pOplock, FILE_ALL_INFO *, 331 322 const struct nls_table *nls_codepage, int remap); 332 - extern int SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, 323 + extern int SMBLegacyOpen(const int xid, struct cifs_tcon *tcon, 333 324 const char *fileName, const int disposition, 334 325 const int access_flags, const int omode, 335 326 __u16 *netfid, int *pOplock, FILE_ALL_INFO *, 336 327 const struct nls_table *nls_codepage, int remap); 337 - extern int CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, 328 + extern int CIFSPOSIXCreate(const int xid, struct cifs_tcon *tcon, 338 329 u32 posix_flags, __u64 mode, __u16 *netfid, 339 330 FILE_UNIX_BASIC_INFO *pRetData, 340 331 __u32 *pOplock, const char *name, 341 332 const struct nls_table *nls_codepage, int remap); 342 - extern int CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, 333 + extern int CIFSSMBClose(const int xid, struct cifs_tcon *tcon, 343 334 const int smb_file_id); 344 335 345 - extern int CIFSSMBFlush(const int xid, struct cifsTconInfo *tcon, 336 + extern int CIFSSMBFlush(const int xid, struct cifs_tcon *tcon, 346 337 const int smb_file_id); 347 338 348 - extern int CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, 349 - const int netfid, unsigned int count, 350 - const __u64 lseek, unsigned int *nbytes, char **buf, 339 + extern int CIFSSMBRead(const int xid, struct cifs_io_parms *io_parms, 340 + unsigned int *nbytes, char **buf, 351 341 int *return_buf_type); 352 - extern int CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, 353 - const int netfid, const unsigned int count, 354 - const __u64 lseek, unsigned int *nbytes, 355 - const char *buf, const char __user *ubuf, 342 + extern int CIFSSMBWrite(const int xid, struct cifs_io_parms *io_parms, 343 + unsigned int *nbytes, const char *buf, 344 + const char __user *ubuf, const int long_op); 345 + extern int CIFSSMBWrite2(const int xid, struct cifs_io_parms *io_parms, 346 + unsigned int *nbytes, struct kvec *iov, const int nvec, 356 347 const int long_op); 357 - extern int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, 358 - const int netfid, const unsigned int count, 359 - const __u64 offset, unsigned int *nbytes, 360 - struct kvec *iov, const int nvec, const int long_op); 361 - extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, 348 + extern int CIFSGetSrvInodeNumber(const int xid, struct cifs_tcon *tcon, 362 349 const unsigned char *searchName, __u64 *inode_number, 363 350 const struct nls_table *nls_codepage, 364 351 int remap_special_chars); 365 352 366 - extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, 353 + extern int CIFSSMBLock(const int xid, struct cifs_tcon *tcon, 367 354 const __u16 netfid, const __u64 len, 368 355 const __u64 offset, const __u32 numUnlock, 369 356 const __u32 numLock, const __u8 lockType, 370 357 const bool waitFlag, const __u8 oplock_level); 371 - extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, 358 + extern int CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, 372 359 const __u16 smb_file_id, const int get_flag, 373 360 const __u64 len, struct file_lock *, 374 361 const __u16 lock_type, const bool waitFlag); 375 - extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon); 362 + extern int CIFSSMBTDis(const int xid, struct cifs_tcon *tcon); 376 363 extern int CIFSSMBEcho(struct TCP_Server_Info *server); 377 - extern int CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses); 364 + extern int CIFSSMBLogoff(const int xid, struct cifs_ses *ses); 378 365 379 - extern struct cifsSesInfo *sesInfoAlloc(void); 380 - extern void sesInfoFree(struct cifsSesInfo *); 381 - extern struct cifsTconInfo *tconInfoAlloc(void); 382 - extern void tconInfoFree(struct cifsTconInfo *); 366 + extern struct cifs_ses *sesInfoAlloc(void); 367 + extern void sesInfoFree(struct cifs_ses *); 368 + extern struct cifs_tcon *tconInfoAlloc(void); 369 + extern void tconInfoFree(struct cifs_tcon *); 383 370 384 371 extern int cifs_sign_smb(struct smb_hdr *, struct TCP_Server_Info *, __u32 *); 385 372 extern int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *, ··· 384 379 struct TCP_Server_Info *server, 385 380 __u32 expected_sequence_number); 386 381 extern int SMBNTencrypt(unsigned char *, unsigned char *, unsigned char *); 387 - extern int setup_ntlm_response(struct cifsSesInfo *); 388 - extern int setup_ntlmv2_rsp(struct cifsSesInfo *, const struct nls_table *); 382 + extern int setup_ntlm_response(struct cifs_ses *); 383 + extern int setup_ntlmv2_rsp(struct cifs_ses *, const struct nls_table *); 389 384 extern int cifs_crypto_shash_allocate(struct TCP_Server_Info *); 390 385 extern void cifs_crypto_shash_release(struct TCP_Server_Info *); 391 - extern int calc_seckey(struct cifsSesInfo *); 386 + extern int calc_seckey(struct cifs_ses *); 392 387 393 388 #ifdef CONFIG_CIFS_WEAK_PW_HASH 394 389 extern int calc_lanman_hash(const char *password, const char *cryptkey, 395 390 bool encrypt, char *lnm_session_key); 396 391 #endif /* CIFS_WEAK_PW_HASH */ 397 392 #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */ 398 - extern int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon, 393 + extern int CIFSSMBNotify(const int xid, struct cifs_tcon *tcon, 399 394 const int notify_subdirs, const __u16 netfid, 400 395 __u32 filter, struct file *file, int multishot, 401 396 const struct nls_table *nls_codepage); 402 397 #endif /* was needed for dnotify, and will be needed for inotify when VFS fix */ 403 398 extern int CIFSSMBCopy(int xid, 404 - struct cifsTconInfo *source_tcon, 399 + struct cifs_tcon *source_tcon, 405 400 const char *fromName, 406 401 const __u16 target_tid, 407 402 const char *toName, const int flags, 408 403 const struct nls_table *nls_codepage, 409 404 int remap_special_chars); 410 - extern ssize_t CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, 405 + extern ssize_t CIFSSMBQAllEAs(const int xid, struct cifs_tcon *tcon, 411 406 const unsigned char *searchName, 412 407 const unsigned char *ea_name, char *EAData, 413 408 size_t bufsize, const struct nls_table *nls_codepage, 414 409 int remap_special_chars); 415 - extern int CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, 410 + extern int CIFSSMBSetEA(const int xid, struct cifs_tcon *tcon, 416 411 const char *fileName, const char *ea_name, 417 412 const void *ea_value, const __u16 ea_value_len, 418 413 const struct nls_table *nls_codepage, int remap_special_chars); 419 - extern int CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, 414 + extern int CIFSSMBGetCIFSACL(const int xid, struct cifs_tcon *tcon, 420 415 __u16 fid, struct cifs_ntsd **acl_inf, __u32 *buflen); 421 - extern int CIFSSMBSetCIFSACL(const int, struct cifsTconInfo *, __u16, 416 + extern int CIFSSMBSetCIFSACL(const int, struct cifs_tcon *, __u16, 422 417 struct cifs_ntsd *, __u32); 423 - extern int CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon, 418 + extern int CIFSSMBGetPosixACL(const int xid, struct cifs_tcon *tcon, 424 419 const unsigned char *searchName, 425 420 char *acl_inf, const int buflen, const int acl_type, 426 421 const struct nls_table *nls_codepage, int remap_special_chars); 427 - extern int CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon, 422 + extern int CIFSSMBSetPosixACL(const int xid, struct cifs_tcon *tcon, 428 423 const unsigned char *fileName, 429 424 const char *local_acl, const int buflen, const int acl_type, 430 425 const struct nls_table *nls_codepage, int remap_special_chars); 431 - extern int CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon, 426 + extern int CIFSGetExtAttr(const int xid, struct cifs_tcon *tcon, 432 427 const int netfid, __u64 *pExtAttrBits, __u64 *pMask); 433 428 extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb); 434 429 extern bool CIFSCouldBeMFSymlink(const struct cifs_fattr *fattr); ··· 439 434 extern int E_md4hash(const unsigned char *passwd, unsigned char *p16); 440 435 extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8, 441 436 unsigned char *p24); 437 + 438 + /* asynchronous write support */ 439 + struct cifs_writedata { 440 + struct kref refcount; 441 + enum writeback_sync_modes sync_mode; 442 + struct work_struct work; 443 + struct cifsFileInfo *cfile; 444 + __u64 offset; 445 + unsigned int bytes; 446 + int result; 447 + unsigned int nr_pages; 448 + struct page *pages[1]; 449 + }; 450 + 451 + int cifs_async_writev(struct cifs_writedata *wdata); 452 + struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages); 453 + void cifs_writedata_release(struct kref *refcount); 454 + 442 455 #endif /* _CIFSPROTO_H */
+361 -102
fs/cifs/cifssmb.c
··· 32 32 #include <linux/vfs.h> 33 33 #include <linux/slab.h> 34 34 #include <linux/posix_acl_xattr.h> 35 + #include <linux/pagemap.h> 35 36 #include <asm/uaccess.h> 36 37 #include "cifspdu.h" 37 38 #include "cifsglob.h" ··· 85 84 86 85 /* Mark as invalid, all open files on tree connections since they 87 86 were closed when session to server was lost */ 88 - static void mark_open_files_invalid(struct cifsTconInfo *pTcon) 87 + static void mark_open_files_invalid(struct cifs_tcon *pTcon) 89 88 { 90 89 struct cifsFileInfo *open_file = NULL; 91 90 struct list_head *tmp; ··· 105 104 106 105 /* reconnect the socket, tcon, and smb session if needed */ 107 106 static int 108 - cifs_reconnect_tcon(struct cifsTconInfo *tcon, int smb_command) 107 + cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command) 109 108 { 110 109 int rc = 0; 111 - struct cifsSesInfo *ses; 110 + struct cifs_ses *ses; 112 111 struct TCP_Server_Info *server; 113 112 struct nls_table *nls_codepage; 114 113 ··· 227 226 SMB information in the SMB header. If the return code is zero, this 228 227 function must have filled in request_buf pointer */ 229 228 static int 230 - small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, 229 + small_smb_init(int smb_command, int wct, struct cifs_tcon *tcon, 231 230 void **request_buf) 232 231 { 233 232 int rc; ··· 253 252 254 253 int 255 254 small_smb_init_no_tc(const int smb_command, const int wct, 256 - struct cifsSesInfo *ses, void **request_buf) 255 + struct cifs_ses *ses, void **request_buf) 257 256 { 258 257 int rc; 259 258 struct smb_hdr *buffer; ··· 279 278 280 279 /* If the return code is zero, this function must fill in request_buf pointer */ 281 280 static int 282 - __smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, 281 + __smb_init(int smb_command, int wct, struct cifs_tcon *tcon, 283 282 void **request_buf, void **response_buf) 284 283 { 285 284 *request_buf = cifs_buf_get(); ··· 305 304 306 305 /* If the return code is zero, this function must fill in request_buf pointer */ 307 306 static int 308 - smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, 307 + smb_init(int smb_command, int wct, struct cifs_tcon *tcon, 309 308 void **request_buf, void **response_buf) 310 309 { 311 310 int rc; ··· 318 317 } 319 318 320 319 static int 321 - smb_init_no_reconnect(int smb_command, int wct, struct cifsTconInfo *tcon, 320 + smb_init_no_reconnect(int smb_command, int wct, struct cifs_tcon *tcon, 322 321 void **request_buf, void **response_buf) 323 322 { 324 323 if (tcon->ses->need_reconnect || tcon->need_reconnect) ··· 367 366 } 368 367 369 368 int 370 - CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) 369 + CIFSSMBNegotiate(unsigned int xid, struct cifs_ses *ses) 371 370 { 372 371 NEGOTIATE_REQ *pSMB; 373 372 NEGOTIATE_RSP *pSMBr; ··· 451 450 rc = -EOPNOTSUPP; 452 451 goto neg_err_exit; 453 452 } 454 - server->secMode = (__u8)le16_to_cpu(rsp->SecurityMode); 453 + server->sec_mode = (__u8)le16_to_cpu(rsp->SecurityMode); 455 454 server->maxReq = le16_to_cpu(rsp->MaxMpxCount); 456 455 server->maxBuf = min((__u32)le16_to_cpu(rsp->MaxBufSize), 457 456 (__u32)CIFSMaxBufSize + MAX_CIFS_HDR_SIZE); ··· 505 504 cpu_to_le16(CIFS_CRYPTO_KEY_SIZE)) { 506 505 memcpy(ses->server->cryptkey, rsp->EncryptionKey, 507 506 CIFS_CRYPTO_KEY_SIZE); 508 - } else if (server->secMode & SECMODE_PW_ENCRYPT) { 507 + } else if (server->sec_mode & SECMODE_PW_ENCRYPT) { 509 508 rc = -EIO; /* need cryptkey unless plain text */ 510 509 goto neg_err_exit; 511 510 } ··· 527 526 goto neg_err_exit; 528 527 } 529 528 /* else wct == 17 NTLM */ 530 - server->secMode = pSMBr->SecurityMode; 531 - if ((server->secMode & SECMODE_USER) == 0) 529 + server->sec_mode = pSMBr->SecurityMode; 530 + if ((server->sec_mode & SECMODE_USER) == 0) 532 531 cFYI(1, "share mode security"); 533 532 534 - if ((server->secMode & SECMODE_PW_ENCRYPT) == 0) 533 + if ((server->sec_mode & SECMODE_PW_ENCRYPT) == 0) 535 534 #ifdef CONFIG_CIFS_WEAK_PW_HASH 536 535 if ((secFlags & CIFSSEC_MAY_PLNTXT) == 0) 537 536 #endif /* CIFS_WEAK_PW_HASH */ ··· 571 570 if (pSMBr->EncryptionKeyLength == CIFS_CRYPTO_KEY_SIZE) { 572 571 memcpy(ses->server->cryptkey, pSMBr->u.EncryptionKey, 573 572 CIFS_CRYPTO_KEY_SIZE); 574 - } else if ((pSMBr->hdr.Flags2 & SMBFLG2_EXT_SEC) 575 - && (pSMBr->EncryptionKeyLength == 0)) { 573 + } else if ((pSMBr->hdr.Flags2 & SMBFLG2_EXT_SEC || 574 + server->capabilities & CAP_EXTENDED_SECURITY) && 575 + (pSMBr->EncryptionKeyLength == 0)) { 576 576 /* decode security blob */ 577 - } else if (server->secMode & SECMODE_PW_ENCRYPT) { 578 - rc = -EIO; /* no crypt key only if plain text pwd */ 579 - goto neg_err_exit; 580 - } 581 - 582 - /* BB might be helpful to save off the domain of server here */ 583 - 584 - if ((pSMBr->hdr.Flags2 & SMBFLG2_EXT_SEC) && 585 - (server->capabilities & CAP_EXTENDED_SECURITY)) { 586 577 count = get_bcc(&pSMBr->hdr); 587 578 if (count < 16) { 588 579 rc = -EIO; ··· 617 624 } else 618 625 rc = -EOPNOTSUPP; 619 626 } 627 + } else if (server->sec_mode & SECMODE_PW_ENCRYPT) { 628 + rc = -EIO; /* no crypt key only if plain text pwd */ 629 + goto neg_err_exit; 620 630 } else 621 631 server->capabilities &= ~CAP_EXTENDED_SECURITY; 622 632 ··· 630 634 /* MUST_SIGN already includes the MAY_SIGN FLAG 631 635 so if this is zero it means that signing is disabled */ 632 636 cFYI(1, "Signing disabled"); 633 - if (server->secMode & SECMODE_SIGN_REQUIRED) { 637 + if (server->sec_mode & SECMODE_SIGN_REQUIRED) { 634 638 cERROR(1, "Server requires " 635 639 "packet signing to be enabled in " 636 640 "/proc/fs/cifs/SecurityFlags."); 637 641 rc = -EOPNOTSUPP; 638 642 } 639 - server->secMode &= 643 + server->sec_mode &= 640 644 ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED); 641 645 } else if ((secFlags & CIFSSEC_MUST_SIGN) == CIFSSEC_MUST_SIGN) { 642 646 /* signing required */ 643 647 cFYI(1, "Must sign - secFlags 0x%x", secFlags); 644 - if ((server->secMode & 648 + if ((server->sec_mode & 645 649 (SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED)) == 0) { 646 650 cERROR(1, "signing required but server lacks support"); 647 651 rc = -EOPNOTSUPP; 648 652 } else 649 - server->secMode |= SECMODE_SIGN_REQUIRED; 653 + server->sec_mode |= SECMODE_SIGN_REQUIRED; 650 654 } else { 651 655 /* signing optional ie CIFSSEC_MAY_SIGN */ 652 - if ((server->secMode & SECMODE_SIGN_REQUIRED) == 0) 653 - server->secMode &= 656 + if ((server->sec_mode & SECMODE_SIGN_REQUIRED) == 0) 657 + server->sec_mode &= 654 658 ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED); 655 659 } 656 660 ··· 662 666 } 663 667 664 668 int 665 - CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon) 669 + CIFSSMBTDis(const int xid, struct cifs_tcon *tcon) 666 670 { 667 671 struct smb_hdr *smb_buffer; 668 672 int rc = 0; ··· 721 725 { 722 726 ECHO_REQ *smb; 723 727 int rc = 0; 728 + struct kvec iov; 724 729 725 730 cFYI(1, "In echo request"); 726 731 ··· 736 739 put_bcc(1, &smb->hdr); 737 740 smb->Data[0] = 'a'; 738 741 inc_rfc1001_len(smb, 3); 742 + iov.iov_base = smb; 743 + iov.iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4; 739 744 740 - rc = cifs_call_async(server, (struct smb_hdr *)smb, 741 - cifs_echo_callback, server); 745 + rc = cifs_call_async(server, &iov, 1, cifs_echo_callback, server, true); 742 746 if (rc) 743 747 cFYI(1, "Echo request failed: %d", rc); 744 748 ··· 749 751 } 750 752 751 753 int 752 - CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses) 754 + CIFSSMBLogoff(const int xid, struct cifs_ses *ses) 753 755 { 754 756 LOGOFF_ANDX_REQ *pSMB; 755 757 int rc = 0; ··· 776 778 777 779 pSMB->hdr.Mid = GetNextMid(ses->server); 778 780 779 - if (ses->server->secMode & 781 + if (ses->server->sec_mode & 780 782 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 781 783 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 782 784 ··· 796 798 } 797 799 798 800 int 799 - CIFSPOSIXDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName, 801 + CIFSPOSIXDelFile(const int xid, struct cifs_tcon *tcon, const char *fileName, 800 802 __u16 type, const struct nls_table *nls_codepage, int remap) 801 803 { 802 804 TRANSACTION2_SPI_REQ *pSMB = NULL; ··· 871 873 } 872 874 873 875 int 874 - CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName, 876 + CIFSSMBDelFile(const int xid, struct cifs_tcon *tcon, const char *fileName, 875 877 const struct nls_table *nls_codepage, int remap) 876 878 { 877 879 DELETE_FILE_REQ *pSMB = NULL; ··· 916 918 } 917 919 918 920 int 919 - CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, const char *dirName, 921 + CIFSSMBRmDir(const int xid, struct cifs_tcon *tcon, const char *dirName, 920 922 const struct nls_table *nls_codepage, int remap) 921 923 { 922 924 DELETE_DIRECTORY_REQ *pSMB = NULL; ··· 959 961 } 960 962 961 963 int 962 - CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, 964 + CIFSSMBMkDir(const int xid, struct cifs_tcon *tcon, 963 965 const char *name, const struct nls_table *nls_codepage, int remap) 964 966 { 965 967 int rc = 0; ··· 1002 1004 } 1003 1005 1004 1006 int 1005 - CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags, 1007 + CIFSPOSIXCreate(const int xid, struct cifs_tcon *tcon, __u32 posix_flags, 1006 1008 __u64 mode, __u16 *netfid, FILE_UNIX_BASIC_INFO *pRetData, 1007 1009 __u32 *pOplock, const char *name, 1008 1010 const struct nls_table *nls_codepage, int remap) ··· 1168 1170 } 1169 1171 1170 1172 int 1171 - SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, 1173 + SMBLegacyOpen(const int xid, struct cifs_tcon *tcon, 1172 1174 const char *fileName, const int openDisposition, 1173 1175 const int access_flags, const int create_options, __u16 *netfid, 1174 1176 int *pOplock, FILE_ALL_INFO *pfile_info, ··· 1275 1277 } 1276 1278 1277 1279 int 1278 - CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon, 1280 + CIFSSMBOpen(const int xid, struct cifs_tcon *tcon, 1279 1281 const char *fileName, const int openDisposition, 1280 1282 const int access_flags, const int create_options, __u16 *netfid, 1281 1283 int *pOplock, FILE_ALL_INFO *pfile_info, ··· 1377 1379 } 1378 1380 1379 1381 int 1380 - CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid, 1381 - const unsigned int count, const __u64 lseek, unsigned int *nbytes, 1382 + CIFSSMBRead(const int xid, struct cifs_io_parms *io_parms, unsigned int *nbytes, 1382 1383 char **buf, int *pbuf_type) 1383 1384 { 1384 1385 int rc = -EACCES; ··· 1387 1390 int wct; 1388 1391 int resp_buf_type = 0; 1389 1392 struct kvec iov[1]; 1393 + __u32 pid = io_parms->pid; 1394 + __u16 netfid = io_parms->netfid; 1395 + __u64 offset = io_parms->offset; 1396 + struct cifs_tcon *tcon = io_parms->tcon; 1397 + unsigned int count = io_parms->length; 1390 1398 1391 1399 cFYI(1, "Reading %d bytes on fid %d", count, netfid); 1392 1400 if (tcon->ses->capabilities & CAP_LARGE_FILES) 1393 1401 wct = 12; 1394 1402 else { 1395 1403 wct = 10; /* old style read */ 1396 - if ((lseek >> 32) > 0) { 1404 + if ((offset >> 32) > 0) { 1397 1405 /* can not handle this big offset for old */ 1398 1406 return -EIO; 1399 1407 } ··· 1409 1407 if (rc) 1410 1408 return rc; 1411 1409 1410 + pSMB->hdr.Pid = cpu_to_le16((__u16)pid); 1411 + pSMB->hdr.PidHigh = cpu_to_le16((__u16)(pid >> 16)); 1412 + 1412 1413 /* tcon and ses pointer are checked in smb_init */ 1413 1414 if (tcon->ses->server == NULL) 1414 1415 return -ECONNABORTED; 1415 1416 1416 1417 pSMB->AndXCommand = 0xFF; /* none */ 1417 1418 pSMB->Fid = netfid; 1418 - pSMB->OffsetLow = cpu_to_le32(lseek & 0xFFFFFFFF); 1419 + pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF); 1419 1420 if (wct == 12) 1420 - pSMB->OffsetHigh = cpu_to_le32(lseek >> 32); 1421 + pSMB->OffsetHigh = cpu_to_le32(offset >> 32); 1421 1422 1422 1423 pSMB->Remaining = 0; 1423 1424 pSMB->MaxCount = cpu_to_le16(count & 0xFFFF); ··· 1489 1484 1490 1485 1491 1486 int 1492 - CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, 1493 - const int netfid, const unsigned int count, 1494 - const __u64 offset, unsigned int *nbytes, const char *buf, 1487 + CIFSSMBWrite(const int xid, struct cifs_io_parms *io_parms, 1488 + unsigned int *nbytes, const char *buf, 1495 1489 const char __user *ubuf, const int long_op) 1496 1490 { 1497 1491 int rc = -EACCES; ··· 1499 1495 int bytes_returned, wct; 1500 1496 __u32 bytes_sent; 1501 1497 __u16 byte_count; 1498 + __u32 pid = io_parms->pid; 1499 + __u16 netfid = io_parms->netfid; 1500 + __u64 offset = io_parms->offset; 1501 + struct cifs_tcon *tcon = io_parms->tcon; 1502 + unsigned int count = io_parms->length; 1502 1503 1503 1504 *nbytes = 0; 1504 1505 ··· 1525 1516 (void **) &pSMBr); 1526 1517 if (rc) 1527 1518 return rc; 1519 + 1520 + pSMB->hdr.Pid = cpu_to_le16((__u16)pid); 1521 + pSMB->hdr.PidHigh = cpu_to_le16((__u16)(pid >> 16)); 1522 + 1528 1523 /* tcon and ses pointer are checked in smb_init */ 1529 1524 if (tcon->ses->server == NULL) 1530 1525 return -ECONNABORTED; ··· 1615 1602 return rc; 1616 1603 } 1617 1604 1605 + void 1606 + cifs_writedata_release(struct kref *refcount) 1607 + { 1608 + struct cifs_writedata *wdata = container_of(refcount, 1609 + struct cifs_writedata, refcount); 1610 + 1611 + if (wdata->cfile) 1612 + cifsFileInfo_put(wdata->cfile); 1613 + 1614 + kfree(wdata); 1615 + } 1616 + 1617 + /* 1618 + * Write failed with a retryable error. Resend the write request. It's also 1619 + * possible that the page was redirtied so re-clean the page. 1620 + */ 1621 + static void 1622 + cifs_writev_requeue(struct cifs_writedata *wdata) 1623 + { 1624 + int i, rc; 1625 + struct inode *inode = wdata->cfile->dentry->d_inode; 1626 + 1627 + for (i = 0; i < wdata->nr_pages; i++) { 1628 + lock_page(wdata->pages[i]); 1629 + clear_page_dirty_for_io(wdata->pages[i]); 1630 + } 1631 + 1632 + do { 1633 + rc = cifs_async_writev(wdata); 1634 + } while (rc == -EAGAIN); 1635 + 1636 + for (i = 0; i < wdata->nr_pages; i++) { 1637 + if (rc != 0) 1638 + SetPageError(wdata->pages[i]); 1639 + unlock_page(wdata->pages[i]); 1640 + } 1641 + 1642 + mapping_set_error(inode->i_mapping, rc); 1643 + kref_put(&wdata->refcount, cifs_writedata_release); 1644 + } 1645 + 1646 + static void 1647 + cifs_writev_complete(struct work_struct *work) 1648 + { 1649 + struct cifs_writedata *wdata = container_of(work, 1650 + struct cifs_writedata, work); 1651 + struct inode *inode = wdata->cfile->dentry->d_inode; 1652 + int i = 0; 1653 + 1654 + if (wdata->result == 0) { 1655 + cifs_update_eof(CIFS_I(inode), wdata->offset, wdata->bytes); 1656 + cifs_stats_bytes_written(tlink_tcon(wdata->cfile->tlink), 1657 + wdata->bytes); 1658 + } else if (wdata->sync_mode == WB_SYNC_ALL && wdata->result == -EAGAIN) 1659 + return cifs_writev_requeue(wdata); 1660 + 1661 + for (i = 0; i < wdata->nr_pages; i++) { 1662 + struct page *page = wdata->pages[i]; 1663 + if (wdata->result == -EAGAIN) 1664 + __set_page_dirty_nobuffers(page); 1665 + else if (wdata->result < 0) 1666 + SetPageError(page); 1667 + end_page_writeback(page); 1668 + page_cache_release(page); 1669 + } 1670 + if (wdata->result != -EAGAIN) 1671 + mapping_set_error(inode->i_mapping, wdata->result); 1672 + kref_put(&wdata->refcount, cifs_writedata_release); 1673 + } 1674 + 1675 + struct cifs_writedata * 1676 + cifs_writedata_alloc(unsigned int nr_pages) 1677 + { 1678 + struct cifs_writedata *wdata; 1679 + 1680 + /* this would overflow */ 1681 + if (nr_pages == 0) { 1682 + cERROR(1, "%s: called with nr_pages == 0!", __func__); 1683 + return NULL; 1684 + } 1685 + 1686 + /* writedata + number of page pointers */ 1687 + wdata = kzalloc(sizeof(*wdata) + 1688 + sizeof(struct page *) * (nr_pages - 1), GFP_NOFS); 1689 + if (wdata != NULL) { 1690 + INIT_WORK(&wdata->work, cifs_writev_complete); 1691 + kref_init(&wdata->refcount); 1692 + } 1693 + return wdata; 1694 + } 1695 + 1696 + /* 1697 + * Check the midState and signature on received buffer (if any), and queue the 1698 + * workqueue completion task. 1699 + */ 1700 + static void 1701 + cifs_writev_callback(struct mid_q_entry *mid) 1702 + { 1703 + struct cifs_writedata *wdata = mid->callback_data; 1704 + struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); 1705 + unsigned int written; 1706 + WRITE_RSP *smb = (WRITE_RSP *)mid->resp_buf; 1707 + 1708 + switch (mid->midState) { 1709 + case MID_RESPONSE_RECEIVED: 1710 + wdata->result = cifs_check_receive(mid, tcon->ses->server, 0); 1711 + if (wdata->result != 0) 1712 + break; 1713 + 1714 + written = le16_to_cpu(smb->CountHigh); 1715 + written <<= 16; 1716 + written += le16_to_cpu(smb->Count); 1717 + /* 1718 + * Mask off high 16 bits when bytes written as returned 1719 + * by the server is greater than bytes requested by the 1720 + * client. OS/2 servers are known to set incorrect 1721 + * CountHigh values. 1722 + */ 1723 + if (written > wdata->bytes) 1724 + written &= 0xFFFF; 1725 + 1726 + if (written < wdata->bytes) 1727 + wdata->result = -ENOSPC; 1728 + else 1729 + wdata->bytes = written; 1730 + break; 1731 + case MID_REQUEST_SUBMITTED: 1732 + case MID_RETRY_NEEDED: 1733 + wdata->result = -EAGAIN; 1734 + break; 1735 + default: 1736 + wdata->result = -EIO; 1737 + break; 1738 + } 1739 + 1740 + queue_work(system_nrt_wq, &wdata->work); 1741 + DeleteMidQEntry(mid); 1742 + atomic_dec(&tcon->ses->server->inFlight); 1743 + wake_up(&tcon->ses->server->request_q); 1744 + } 1745 + 1746 + /* cifs_async_writev - send an async write, and set up mid to handle result */ 1618 1747 int 1619 - CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, 1620 - const int netfid, const unsigned int count, 1621 - const __u64 offset, unsigned int *nbytes, struct kvec *iov, 1622 - int n_vec, const int long_op) 1748 + cifs_async_writev(struct cifs_writedata *wdata) 1749 + { 1750 + int i, rc = -EACCES; 1751 + WRITE_REQ *smb = NULL; 1752 + int wct; 1753 + struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); 1754 + struct inode *inode = wdata->cfile->dentry->d_inode; 1755 + struct kvec *iov = NULL; 1756 + 1757 + if (tcon->ses->capabilities & CAP_LARGE_FILES) { 1758 + wct = 14; 1759 + } else { 1760 + wct = 12; 1761 + if (wdata->offset >> 32 > 0) { 1762 + /* can not handle big offset for old srv */ 1763 + return -EIO; 1764 + } 1765 + } 1766 + 1767 + rc = small_smb_init(SMB_COM_WRITE_ANDX, wct, tcon, (void **)&smb); 1768 + if (rc) 1769 + goto async_writev_out; 1770 + 1771 + /* 1 iov per page + 1 for header */ 1772 + iov = kzalloc((wdata->nr_pages + 1) * sizeof(*iov), GFP_NOFS); 1773 + if (iov == NULL) { 1774 + rc = -ENOMEM; 1775 + goto async_writev_out; 1776 + } 1777 + 1778 + smb->hdr.Pid = cpu_to_le16((__u16)wdata->cfile->pid); 1779 + smb->hdr.PidHigh = cpu_to_le16((__u16)(wdata->cfile->pid >> 16)); 1780 + 1781 + smb->AndXCommand = 0xFF; /* none */ 1782 + smb->Fid = wdata->cfile->netfid; 1783 + smb->OffsetLow = cpu_to_le32(wdata->offset & 0xFFFFFFFF); 1784 + if (wct == 14) 1785 + smb->OffsetHigh = cpu_to_le32(wdata->offset >> 32); 1786 + smb->Reserved = 0xFFFFFFFF; 1787 + smb->WriteMode = 0; 1788 + smb->Remaining = 0; 1789 + 1790 + smb->DataOffset = 1791 + cpu_to_le16(offsetof(struct smb_com_write_req, Data) - 4); 1792 + 1793 + /* 4 for RFC1001 length + 1 for BCC */ 1794 + iov[0].iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4 + 1; 1795 + iov[0].iov_base = smb; 1796 + 1797 + /* marshal up the pages into iov array */ 1798 + wdata->bytes = 0; 1799 + for (i = 0; i < wdata->nr_pages; i++) { 1800 + iov[i + 1].iov_len = min(inode->i_size - 1801 + page_offset(wdata->pages[i]), 1802 + (loff_t)PAGE_CACHE_SIZE); 1803 + iov[i + 1].iov_base = kmap(wdata->pages[i]); 1804 + wdata->bytes += iov[i + 1].iov_len; 1805 + } 1806 + 1807 + cFYI(1, "async write at %llu %u bytes", wdata->offset, wdata->bytes); 1808 + 1809 + smb->DataLengthLow = cpu_to_le16(wdata->bytes & 0xFFFF); 1810 + smb->DataLengthHigh = cpu_to_le16(wdata->bytes >> 16); 1811 + 1812 + if (wct == 14) { 1813 + inc_rfc1001_len(&smb->hdr, wdata->bytes + 1); 1814 + put_bcc(wdata->bytes + 1, &smb->hdr); 1815 + } else { 1816 + /* wct == 12 */ 1817 + struct smb_com_writex_req *smbw = 1818 + (struct smb_com_writex_req *)smb; 1819 + inc_rfc1001_len(&smbw->hdr, wdata->bytes + 5); 1820 + put_bcc(wdata->bytes + 5, &smbw->hdr); 1821 + iov[0].iov_len += 4; /* pad bigger by four bytes */ 1822 + } 1823 + 1824 + kref_get(&wdata->refcount); 1825 + rc = cifs_call_async(tcon->ses->server, iov, wdata->nr_pages + 1, 1826 + cifs_writev_callback, wdata, false); 1827 + 1828 + if (rc == 0) 1829 + cifs_stats_inc(&tcon->num_writes); 1830 + else 1831 + kref_put(&wdata->refcount, cifs_writedata_release); 1832 + 1833 + /* send is done, unmap pages */ 1834 + for (i = 0; i < wdata->nr_pages; i++) 1835 + kunmap(wdata->pages[i]); 1836 + 1837 + async_writev_out: 1838 + cifs_small_buf_release(smb); 1839 + kfree(iov); 1840 + return rc; 1841 + } 1842 + 1843 + int 1844 + CIFSSMBWrite2(const int xid, struct cifs_io_parms *io_parms, 1845 + unsigned int *nbytes, struct kvec *iov, int n_vec, 1846 + const int long_op) 1623 1847 { 1624 1848 int rc = -EACCES; 1625 1849 WRITE_REQ *pSMB = NULL; 1626 1850 int wct; 1627 1851 int smb_hdr_len; 1628 1852 int resp_buf_type = 0; 1853 + __u32 pid = io_parms->pid; 1854 + __u16 netfid = io_parms->netfid; 1855 + __u64 offset = io_parms->offset; 1856 + struct cifs_tcon *tcon = io_parms->tcon; 1857 + unsigned int count = io_parms->length; 1629 1858 1630 1859 *nbytes = 0; 1631 1860 ··· 1885 1630 rc = small_smb_init(SMB_COM_WRITE_ANDX, wct, tcon, (void **) &pSMB); 1886 1631 if (rc) 1887 1632 return rc; 1633 + 1634 + pSMB->hdr.Pid = cpu_to_le16((__u16)pid); 1635 + pSMB->hdr.PidHigh = cpu_to_le16((__u16)(pid >> 16)); 1636 + 1888 1637 /* tcon and ses pointer are checked in smb_init */ 1889 1638 if (tcon->ses->server == NULL) 1890 1639 return -ECONNABORTED; ··· 1964 1705 1965 1706 1966 1707 int 1967 - CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, 1708 + CIFSSMBLock(const int xid, struct cifs_tcon *tcon, 1968 1709 const __u16 smb_file_id, const __u64 len, 1969 1710 const __u64 offset, const __u32 numUnlock, 1970 1711 const __u32 numLock, const __u8 lockType, ··· 2034 1775 } 2035 1776 2036 1777 int 2037 - CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, 1778 + CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, 2038 1779 const __u16 smb_file_id, const int get_flag, const __u64 len, 2039 1780 struct file_lock *pLockData, const __u16 lock_type, 2040 1781 const bool waitFlag) ··· 2172 1913 2173 1914 2174 1915 int 2175 - CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id) 1916 + CIFSSMBClose(const int xid, struct cifs_tcon *tcon, int smb_file_id) 2176 1917 { 2177 1918 int rc = 0; 2178 1919 CLOSE_REQ *pSMB = NULL; ··· 2205 1946 } 2206 1947 2207 1948 int 2208 - CIFSSMBFlush(const int xid, struct cifsTconInfo *tcon, int smb_file_id) 1949 + CIFSSMBFlush(const int xid, struct cifs_tcon *tcon, int smb_file_id) 2209 1950 { 2210 1951 int rc = 0; 2211 1952 FLUSH_REQ *pSMB = NULL; ··· 2226 1967 } 2227 1968 2228 1969 int 2229 - CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, 1970 + CIFSSMBRename(const int xid, struct cifs_tcon *tcon, 2230 1971 const char *fromName, const char *toName, 2231 1972 const struct nls_table *nls_codepage, int remap) 2232 1973 { ··· 2293 2034 return rc; 2294 2035 } 2295 2036 2296 - int CIFSSMBRenameOpenFile(const int xid, struct cifsTconInfo *pTcon, 2037 + int CIFSSMBRenameOpenFile(const int xid, struct cifs_tcon *pTcon, 2297 2038 int netfid, const char *target_name, 2298 2039 const struct nls_table *nls_codepage, int remap) 2299 2040 { ··· 2373 2114 } 2374 2115 2375 2116 int 2376 - CIFSSMBCopy(const int xid, struct cifsTconInfo *tcon, const char *fromName, 2117 + CIFSSMBCopy(const int xid, struct cifs_tcon *tcon, const char *fromName, 2377 2118 const __u16 target_tid, const char *toName, const int flags, 2378 2119 const struct nls_table *nls_codepage, int remap) 2379 2120 { ··· 2441 2182 } 2442 2183 2443 2184 int 2444 - CIFSUnixCreateSymLink(const int xid, struct cifsTconInfo *tcon, 2185 + CIFSUnixCreateSymLink(const int xid, struct cifs_tcon *tcon, 2445 2186 const char *fromName, const char *toName, 2446 2187 const struct nls_table *nls_codepage) 2447 2188 { ··· 2530 2271 } 2531 2272 2532 2273 int 2533 - CIFSUnixCreateHardLink(const int xid, struct cifsTconInfo *tcon, 2274 + CIFSUnixCreateHardLink(const int xid, struct cifs_tcon *tcon, 2534 2275 const char *fromName, const char *toName, 2535 2276 const struct nls_table *nls_codepage, int remap) 2536 2277 { ··· 2615 2356 } 2616 2357 2617 2358 int 2618 - CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon, 2359 + CIFSCreateHardLink(const int xid, struct cifs_tcon *tcon, 2619 2360 const char *fromName, const char *toName, 2620 2361 const struct nls_table *nls_codepage, int remap) 2621 2362 { ··· 2687 2428 } 2688 2429 2689 2430 int 2690 - CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon, 2431 + CIFSSMBUnixQuerySymLink(const int xid, struct cifs_tcon *tcon, 2691 2432 const unsigned char *searchName, char **symlinkinfo, 2692 2433 const struct nls_table *nls_codepage) 2693 2434 { ··· 2792 2533 * it is not compiled in by default until callers fixed up and more tested. 2793 2534 */ 2794 2535 int 2795 - CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon, 2536 + CIFSSMBQueryReparseLinkInfo(const int xid, struct cifs_tcon *tcon, 2796 2537 const unsigned char *searchName, 2797 2538 char *symlinkinfo, const int buflen, __u16 fid, 2798 2539 const struct nls_table *nls_codepage) ··· 3030 2771 } 3031 2772 3032 2773 int 3033 - CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon, 2774 + CIFSSMBGetPosixACL(const int xid, struct cifs_tcon *tcon, 3034 2775 const unsigned char *searchName, 3035 2776 char *acl_inf, const int buflen, const int acl_type, 3036 2777 const struct nls_table *nls_codepage, int remap) ··· 3118 2859 } 3119 2860 3120 2861 int 3121 - CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon, 2862 + CIFSSMBSetPosixACL(const int xid, struct cifs_tcon *tcon, 3122 2863 const unsigned char *fileName, 3123 2864 const char *local_acl, const int buflen, 3124 2865 const int acl_type, ··· 3198 2939 3199 2940 /* BB fix tabs in this function FIXME BB */ 3200 2941 int 3201 - CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon, 2942 + CIFSGetExtAttr(const int xid, struct cifs_tcon *tcon, 3202 2943 const int netfid, __u64 *pExtAttrBits, __u64 *pMask) 3203 2944 { 3204 2945 int rc = 0; ··· 3291 3032 */ 3292 3033 static int 3293 3034 smb_init_nttransact(const __u16 sub_command, const int setup_count, 3294 - const int parm_len, struct cifsTconInfo *tcon, 3035 + const int parm_len, struct cifs_tcon *tcon, 3295 3036 void **ret_buf) 3296 3037 { 3297 3038 int rc; ··· 3374 3115 3375 3116 /* Get Security Descriptor (by handle) from remote server for a file or dir */ 3376 3117 int 3377 - CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid, 3118 + CIFSSMBGetCIFSACL(const int xid, struct cifs_tcon *tcon, __u16 fid, 3378 3119 struct cifs_ntsd **acl_inf, __u32 *pbuflen) 3379 3120 { 3380 3121 int rc = 0; ··· 3466 3207 } 3467 3208 3468 3209 int 3469 - CIFSSMBSetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid, 3210 + CIFSSMBSetCIFSACL(const int xid, struct cifs_tcon *tcon, __u16 fid, 3470 3211 struct cifs_ntsd *pntsd, __u32 acllen) 3471 3212 { 3472 3213 __u16 byte_count, param_count, data_count, param_offset, data_offset; ··· 3532 3273 3533 3274 /* Legacy Query Path Information call for lookup to old servers such 3534 3275 as Win9x/WinME */ 3535 - int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon, 3276 + int SMBQueryInformation(const int xid, struct cifs_tcon *tcon, 3536 3277 const unsigned char *searchName, 3537 3278 FILE_ALL_INFO *pFinfo, 3538 3279 const struct nls_table *nls_codepage, int remap) ··· 3600 3341 } 3601 3342 3602 3343 int 3603 - CIFSSMBQFileInfo(const int xid, struct cifsTconInfo *tcon, 3344 + CIFSSMBQFileInfo(const int xid, struct cifs_tcon *tcon, 3604 3345 u16 netfid, FILE_ALL_INFO *pFindData) 3605 3346 { 3606 3347 struct smb_t2_qfi_req *pSMB = NULL; ··· 3667 3408 } 3668 3409 3669 3410 int 3670 - CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, 3411 + CIFSSMBQPathInfo(const int xid, struct cifs_tcon *tcon, 3671 3412 const unsigned char *searchName, 3672 3413 FILE_ALL_INFO *pFindData, 3673 3414 int legacy /* old style infolevel */, ··· 3768 3509 } 3769 3510 3770 3511 int 3771 - CIFSSMBUnixQFileInfo(const int xid, struct cifsTconInfo *tcon, 3512 + CIFSSMBUnixQFileInfo(const int xid, struct cifs_tcon *tcon, 3772 3513 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData) 3773 3514 { 3774 3515 struct smb_t2_qfi_req *pSMB = NULL; ··· 3837 3578 } 3838 3579 3839 3580 int 3840 - CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, 3581 + CIFSSMBUnixQPathInfo(const int xid, struct cifs_tcon *tcon, 3841 3582 const unsigned char *searchName, 3842 3583 FILE_UNIX_BASIC_INFO *pFindData, 3843 3584 const struct nls_table *nls_codepage, int remap) ··· 3923 3664 3924 3665 /* xid, tcon, searchName and codepage are input parms, rest are returned */ 3925 3666 int 3926 - CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, 3667 + CIFSFindFirst(const int xid, struct cifs_tcon *tcon, 3927 3668 const char *searchName, 3928 3669 const struct nls_table *nls_codepage, 3929 3670 __u16 *pnetfid, ··· 4071 3812 return rc; 4072 3813 } 4073 3814 4074 - int CIFSFindNext(const int xid, struct cifsTconInfo *tcon, 3815 + int CIFSFindNext(const int xid, struct cifs_tcon *tcon, 4075 3816 __u16 searchHandle, struct cifs_search_info *psrch_inf) 4076 3817 { 4077 3818 TRANSACTION2_FNEXT_REQ *pSMB = NULL; ··· 4209 3950 } 4210 3951 4211 3952 int 4212 - CIFSFindClose(const int xid, struct cifsTconInfo *tcon, 3953 + CIFSFindClose(const int xid, struct cifs_tcon *tcon, 4213 3954 const __u16 searchHandle) 4214 3955 { 4215 3956 int rc = 0; ··· 4241 3982 } 4242 3983 4243 3984 int 4244 - CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, 3985 + CIFSGetSrvInodeNumber(const int xid, struct cifs_tcon *tcon, 4245 3986 const unsigned char *searchName, 4246 3987 __u64 *inode_number, 4247 3988 const struct nls_table *nls_codepage, int remap) ··· 4443 4184 } 4444 4185 4445 4186 int 4446 - CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, 4187 + CIFSGetDFSRefer(const int xid, struct cifs_ses *ses, 4447 4188 const unsigned char *searchName, 4448 4189 struct dfs_info3_param **target_nodes, 4449 4190 unsigned int *num_of_nodes, ··· 4492 4233 } 4493 4234 4494 4235 if (ses->server) { 4495 - if (ses->server->secMode & 4236 + if (ses->server->sec_mode & 4496 4237 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 4497 4238 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 4498 4239 } ··· 4557 4298 4558 4299 /* Query File System Info such as free space to old servers such as Win 9x */ 4559 4300 int 4560 - SMBOldQFSInfo(const int xid, struct cifsTconInfo *tcon, struct kstatfs *FSData) 4301 + SMBOldQFSInfo(const int xid, struct cifs_tcon *tcon, struct kstatfs *FSData) 4561 4302 { 4562 4303 /* level 0x01 SMB_QUERY_FILE_SYSTEM_INFO */ 4563 4304 TRANSACTION2_QFSI_REQ *pSMB = NULL; ··· 4636 4377 } 4637 4378 4638 4379 int 4639 - CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, struct kstatfs *FSData) 4380 + CIFSSMBQFSInfo(const int xid, struct cifs_tcon *tcon, struct kstatfs *FSData) 4640 4381 { 4641 4382 /* level 0x103 SMB_QUERY_FILE_SYSTEM_INFO */ 4642 4383 TRANSACTION2_QFSI_REQ *pSMB = NULL; ··· 4715 4456 } 4716 4457 4717 4458 int 4718 - CIFSSMBQFSAttributeInfo(const int xid, struct cifsTconInfo *tcon) 4459 + CIFSSMBQFSAttributeInfo(const int xid, struct cifs_tcon *tcon) 4719 4460 { 4720 4461 /* level 0x105 SMB_QUERY_FILE_SYSTEM_INFO */ 4721 4462 TRANSACTION2_QFSI_REQ *pSMB = NULL; ··· 4785 4526 } 4786 4527 4787 4528 int 4788 - CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon) 4529 + CIFSSMBQFSDeviceInfo(const int xid, struct cifs_tcon *tcon) 4789 4530 { 4790 4531 /* level 0x104 SMB_QUERY_FILE_SYSTEM_INFO */ 4791 4532 TRANSACTION2_QFSI_REQ *pSMB = NULL; ··· 4856 4597 } 4857 4598 4858 4599 int 4859 - CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon) 4600 + CIFSSMBQFSUnixInfo(const int xid, struct cifs_tcon *tcon) 4860 4601 { 4861 4602 /* level 0x200 SMB_QUERY_CIFS_UNIX_INFO */ 4862 4603 TRANSACTION2_QFSI_REQ *pSMB = NULL; ··· 4926 4667 } 4927 4668 4928 4669 int 4929 - CIFSSMBSetFSUnixInfo(const int xid, struct cifsTconInfo *tcon, __u64 cap) 4670 + CIFSSMBSetFSUnixInfo(const int xid, struct cifs_tcon *tcon, __u64 cap) 4930 4671 { 4931 4672 /* level 0x200 SMB_SET_CIFS_UNIX_INFO */ 4932 4673 TRANSACTION2_SETFSI_REQ *pSMB = NULL; ··· 5000 4741 5001 4742 5002 4743 int 5003 - CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon, 4744 + CIFSSMBQFSPosixInfo(const int xid, struct cifs_tcon *tcon, 5004 4745 struct kstatfs *FSData) 5005 4746 { 5006 4747 /* level 0x201 SMB_QUERY_CIFS_POSIX_INFO */ ··· 5093 4834 in Samba which this routine can run into */ 5094 4835 5095 4836 int 5096 - CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName, 4837 + CIFSSMBSetEOF(const int xid, struct cifs_tcon *tcon, const char *fileName, 5097 4838 __u64 size, bool SetAllocation, 5098 4839 const struct nls_table *nls_codepage, int remap) 5099 4840 { ··· 5182 4923 } 5183 4924 5184 4925 int 5185 - CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size, 4926 + CIFSSMBSetFileSize(const int xid, struct cifs_tcon *tcon, __u64 size, 5186 4927 __u16 fid, __u32 pid_of_opener, bool SetAllocation) 5187 4928 { 5188 4929 struct smb_com_transaction2_sfi_req *pSMB = NULL; ··· 5264 5005 time and resort to the original setpathinfo level which takes the ancient 5265 5006 DOS time format with 2 second granularity */ 5266 5007 int 5267 - CIFSSMBSetFileInfo(const int xid, struct cifsTconInfo *tcon, 5008 + CIFSSMBSetFileInfo(const int xid, struct cifs_tcon *tcon, 5268 5009 const FILE_BASIC_INFO *data, __u16 fid, __u32 pid_of_opener) 5269 5010 { 5270 5011 struct smb_com_transaction2_sfi_req *pSMB = NULL; ··· 5326 5067 } 5327 5068 5328 5069 int 5329 - CIFSSMBSetFileDisposition(const int xid, struct cifsTconInfo *tcon, 5070 + CIFSSMBSetFileDisposition(const int xid, struct cifs_tcon *tcon, 5330 5071 bool delete_file, __u16 fid, __u32 pid_of_opener) 5331 5072 { 5332 5073 struct smb_com_transaction2_sfi_req *pSMB = NULL; ··· 5382 5123 } 5383 5124 5384 5125 int 5385 - CIFSSMBSetPathInfo(const int xid, struct cifsTconInfo *tcon, 5126 + CIFSSMBSetPathInfo(const int xid, struct cifs_tcon *tcon, 5386 5127 const char *fileName, const FILE_BASIC_INFO *data, 5387 5128 const struct nls_table *nls_codepage, int remap) 5388 5129 { ··· 5466 5207 handling it anyway and NT4 was what we thought it would be needed for 5467 5208 Do not delete it until we prove whether needed for Win9x though */ 5468 5209 int 5469 - CIFSSMBSetAttrLegacy(int xid, struct cifsTconInfo *tcon, char *fileName, 5210 + CIFSSMBSetAttrLegacy(int xid, struct cifs_tcon *tcon, char *fileName, 5470 5211 __u16 dos_attrs, const struct nls_table *nls_codepage) 5471 5212 { 5472 5213 SETATTR_REQ *pSMB = NULL; ··· 5554 5295 } 5555 5296 5556 5297 int 5557 - CIFSSMBUnixSetFileInfo(const int xid, struct cifsTconInfo *tcon, 5298 + CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon, 5558 5299 const struct cifs_unix_set_info_args *args, 5559 5300 u16 fid, u32 pid_of_opener) 5560 5301 { ··· 5617 5358 } 5618 5359 5619 5360 int 5620 - CIFSSMBUnixSetPathInfo(const int xid, struct cifsTconInfo *tcon, char *fileName, 5361 + CIFSSMBUnixSetPathInfo(const int xid, struct cifs_tcon *tcon, char *fileName, 5621 5362 const struct cifs_unix_set_info_args *args, 5622 5363 const struct nls_table *nls_codepage, int remap) 5623 5364 { ··· 5704 5445 * the data isn't copied to it, but the length is returned. 5705 5446 */ 5706 5447 ssize_t 5707 - CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, 5448 + CIFSSMBQAllEAs(const int xid, struct cifs_tcon *tcon, 5708 5449 const unsigned char *searchName, const unsigned char *ea_name, 5709 5450 char *EAData, size_t buf_size, 5710 5451 const struct nls_table *nls_codepage, int remap) ··· 5885 5626 } 5886 5627 5887 5628 int 5888 - CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName, 5629 + CIFSSMBSetEA(const int xid, struct cifs_tcon *tcon, const char *fileName, 5889 5630 const char *ea_name, const void *ea_value, 5890 5631 const __u16 ea_value_len, const struct nls_table *nls_codepage, 5891 5632 int remap) ··· 6012 5753 * incompatible for network fs clients, we could instead simply 6013 5754 * expose this config flag by adding a future cifs (and smb2) notify ioctl. 6014 5755 */ 6015 - int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon, 5756 + int CIFSSMBNotify(const int xid, struct cifs_tcon *tcon, 6016 5757 const int notify_subdirs, const __u16 netfid, 6017 5758 __u32 filter, struct file *pfile, int multishot, 6018 5759 const struct nls_table *nls_codepage)
+350 -277
fs/cifs/connect.c
··· 57 57 58 58 extern mempool_t *cifs_req_poolp; 59 59 60 - struct smb_vol { 61 - char *username; 62 - char *password; 63 - char *domainname; 64 - char *UNC; 65 - char *UNCip; 66 - char *iocharset; /* local code page for mapping to and from Unicode */ 67 - char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */ 68 - char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */ 69 - uid_t cred_uid; 70 - uid_t linux_uid; 71 - gid_t linux_gid; 72 - mode_t file_mode; 73 - mode_t dir_mode; 74 - unsigned secFlg; 75 - bool retry:1; 76 - bool intr:1; 77 - bool setuids:1; 78 - bool override_uid:1; 79 - bool override_gid:1; 80 - bool dynperm:1; 81 - bool noperm:1; 82 - bool no_psx_acl:1; /* set if posix acl support should be disabled */ 83 - bool cifs_acl:1; 84 - bool no_xattr:1; /* set if xattr (EA) support should be disabled*/ 85 - bool server_ino:1; /* use inode numbers from server ie UniqueId */ 86 - bool direct_io:1; 87 - bool strict_io:1; /* strict cache behavior */ 88 - bool remap:1; /* set to remap seven reserved chars in filenames */ 89 - bool posix_paths:1; /* unset to not ask for posix pathnames. */ 90 - bool no_linux_ext:1; 91 - bool sfu_emul:1; 92 - bool nullauth:1; /* attempt to authenticate with null user */ 93 - bool nocase:1; /* request case insensitive filenames */ 94 - bool nobrl:1; /* disable sending byte range locks to srv */ 95 - bool mand_lock:1; /* send mandatory not posix byte range lock reqs */ 96 - bool seal:1; /* request transport encryption on share */ 97 - bool nodfs:1; /* Do not request DFS, even if available */ 98 - bool local_lease:1; /* check leases only on local system, not remote */ 99 - bool noblocksnd:1; 100 - bool noautotune:1; 101 - bool nostrictsync:1; /* do not force expensive SMBflush on every sync */ 102 - bool fsc:1; /* enable fscache */ 103 - bool mfsymlinks:1; /* use Minshall+French Symlinks */ 104 - bool multiuser:1; 105 - bool use_smb2:1; /* force smb2 use on mount instead of cifs */ 106 - unsigned int rsize; 107 - unsigned int wsize; 108 - bool sockopt_tcp_nodelay:1; 109 - unsigned short int port; 110 - unsigned long actimeo; /* attribute cache timeout (jiffies) */ 111 - char *prepath; 112 - struct sockaddr_storage srcaddr; /* allow binding to a local IP */ 113 - struct nls_table *local_nls; 114 - }; 115 - 116 60 /* FIXME: should these be tunable? */ 117 61 #define TLINK_ERROR_EXPIRE (1 * HZ) 118 62 #define TLINK_IDLE_EXPIRE (600 * HZ) ··· 79 135 { 80 136 int rc = 0; 81 137 struct list_head *tmp, *tmp2; 82 - struct cifsSesInfo *ses; 83 - struct cifsTconInfo *tcon; 138 + struct cifs_ses *ses; 139 + struct cifs_tcon *tcon; 84 140 struct mid_q_entry *mid_entry; 141 + struct list_head retry_list; 85 142 86 143 spin_lock(&GlobalMid_Lock); 87 144 if (server->tcpStatus == CifsExiting) { ··· 102 157 cFYI(1, "%s: marking sessions and tcons for reconnect", __func__); 103 158 spin_lock(&cifs_tcp_ses_lock); 104 159 list_for_each(tmp, &server->smb_ses_list) { 105 - ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); 160 + ses = list_entry(tmp, struct cifs_ses, smb_ses_list); 106 161 ses->need_reconnect = true; 107 162 ses->ipc_tid = 0; 108 163 list_for_each(tmp2, &ses->tcon_list) { 109 - tcon = list_entry(tmp2, struct cifsTconInfo, tcon_list); 164 + tcon = list_entry(tmp2, struct cifs_tcon, tcon_list); 110 165 tcon->need_reconnect = true; 111 166 } 112 167 } ··· 134 189 mutex_unlock(&server->srv_mutex); 135 190 136 191 /* mark submitted MIDs for retry and issue callback */ 137 - cFYI(1, "%s: issuing mid callbacks", __func__); 192 + INIT_LIST_HEAD(&retry_list); 193 + cFYI(1, "%s: moving mids to private list", __func__); 138 194 spin_lock(&GlobalMid_Lock); 139 195 list_for_each_safe(tmp, tmp2, &server->pending_mid_q) { 140 196 mid_entry = list_entry(tmp, struct mid_q_entry, qhead); 141 197 if (mid_entry->midState == MID_REQUEST_SUBMITTED) 142 198 mid_entry->midState = MID_RETRY_NEEDED; 199 + list_move(&mid_entry->qhead, &retry_list); 200 + } 201 + spin_unlock(&GlobalMid_Lock); 202 + 203 + cFYI(1, "%s: issuing mid callbacks", __func__); 204 + list_for_each_safe(tmp, tmp2, &retry_list) { 205 + mid_entry = list_entry(tmp, struct mid_q_entry, qhead); 143 206 list_del_init(&mid_entry->qhead); 144 207 mid_entry->callback(mid_entry); 145 208 } 146 - spin_unlock(&GlobalMid_Lock); 147 209 148 210 while (server->tcpStatus == CifsNeedReconnect) { 149 211 try_to_freeze(); ··· 624 672 mid_entry->when_received = jiffies; 625 673 #endif 626 674 list_del_init(&mid_entry->qhead); 627 - mid_entry->callback(mid_entry); 628 675 break; 629 676 } 630 677 spin_unlock(&GlobalMid_Lock); 631 678 632 679 if (mid_entry != NULL) { 680 + mid_entry->callback(mid_entry); 633 681 /* Was previous buf put in mpx struct for multi-rsp? */ 634 682 if (!isMultiRsp) { 635 683 /* smb buffer will be freed by user thread */ ··· 693 741 cifs_small_buf_release(smallbuf); 694 742 695 743 if (!list_empty(&server->pending_mid_q)) { 744 + struct list_head dispose_list; 745 + 746 + INIT_LIST_HEAD(&dispose_list); 696 747 spin_lock(&GlobalMid_Lock); 697 748 list_for_each_safe(tmp, tmp2, &server->pending_mid_q) { 698 749 mid_entry = list_entry(tmp, struct mid_q_entry, qhead); 699 - cFYI(1, "Clearing Mid 0x%x - issuing callback", 700 - mid_entry->mid); 750 + cFYI(1, "Clearing mid 0x%x", mid_entry->mid); 751 + mid_entry->midState = MID_SHUTDOWN; 752 + list_move(&mid_entry->qhead, &dispose_list); 753 + } 754 + spin_unlock(&GlobalMid_Lock); 755 + 756 + /* now walk dispose list and issue callbacks */ 757 + list_for_each_safe(tmp, tmp2, &dispose_list) { 758 + mid_entry = list_entry(tmp, struct mid_q_entry, qhead); 759 + cFYI(1, "Callback mid 0x%x", mid_entry->mid); 701 760 list_del_init(&mid_entry->qhead); 702 761 mid_entry->callback(mid_entry); 703 762 } 704 - spin_unlock(&GlobalMid_Lock); 705 763 /* 1/8th of sec is more than enough time for them to exit */ 706 764 msleep(125); 707 765 } ··· 1024 1062 (strnicmp(value, "1", 1) == 0)) { 1025 1063 /* this is the default */ 1026 1064 continue; 1027 - } else if ((strnicmp(value, "smb2", 4) == 0) || 1028 - (strnicmp(value, "2", 1) == 0)) { 1029 - #ifdef CONFIG_CIFS_SMB2 1030 - vol->use_smb2 = true; 1031 - #else 1032 - cERROR(1, "smb2 support not enabled"); 1033 - #endif /* CONFIG_CIFS_SMB2 */ 1034 1065 } 1035 1066 } else if ((strnicmp(data, "unc", 3) == 0) 1036 1067 || (strnicmp(data, "target", 6) == 0) ··· 1359 1404 vol->server_ino = 1; 1360 1405 } else if (strnicmp(data, "noserverino", 9) == 0) { 1361 1406 vol->server_ino = 0; 1407 + } else if (strnicmp(data, "rwpidforward", 4) == 0) { 1408 + vol->rwpidforward = 1; 1362 1409 } else if (strnicmp(data, "cifsacl", 7) == 0) { 1363 1410 vol->cifs_acl = 1; 1364 1411 } else if (strnicmp(data, "nocifsacl", 9) == 0) { ··· 1597 1640 1598 1641 /* now check if signing mode is acceptable */ 1599 1642 if ((secFlags & CIFSSEC_MAY_SIGN) == 0 && 1600 - (server->secMode & SECMODE_SIGN_REQUIRED)) 1643 + (server->sec_mode & SECMODE_SIGN_REQUIRED)) 1601 1644 return false; 1602 1645 else if (((secFlags & CIFSSEC_MUST_SIGN) == CIFSSEC_MUST_SIGN) && 1603 - (server->secMode & 1646 + (server->sec_mode & 1604 1647 (SECMODE_SIGN_ENABLED|SECMODE_SIGN_REQUIRED)) == 0) 1605 1648 return false; 1606 1649 1607 1650 return true; 1651 + } 1652 + 1653 + static int match_server(struct TCP_Server_Info *server, struct sockaddr *addr, 1654 + struct smb_vol *vol) 1655 + { 1656 + if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) 1657 + return 0; 1658 + 1659 + if (!match_address(server, addr, 1660 + (struct sockaddr *)&vol->srcaddr)) 1661 + return 0; 1662 + 1663 + if (!match_port(server, addr)) 1664 + return 0; 1665 + 1666 + if (!match_security(server, vol)) 1667 + return 0; 1668 + 1669 + return 1; 1608 1670 } 1609 1671 1610 1672 static struct TCP_Server_Info * ··· 1633 1657 1634 1658 spin_lock(&cifs_tcp_ses_lock); 1635 1659 list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { 1636 - if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) 1637 - continue; 1638 - 1639 - if (!match_address(server, addr, 1640 - (struct sockaddr *)&vol->srcaddr)) 1641 - continue; 1642 - 1643 - if (!match_port(server, addr)) 1644 - continue; 1645 - 1646 - if (!match_security(server, vol)) 1660 + if (!match_server(server, addr, vol)) 1647 1661 continue; 1648 1662 1649 1663 ++server->srv_count; ··· 1827 1861 return ERR_PTR(rc); 1828 1862 } 1829 1863 1830 - static struct cifsSesInfo * 1864 + static int match_session(struct cifs_ses *ses, struct smb_vol *vol) 1865 + { 1866 + switch (ses->server->secType) { 1867 + case Kerberos: 1868 + if (vol->cred_uid != ses->cred_uid) 1869 + return 0; 1870 + break; 1871 + default: 1872 + /* anything else takes username/password */ 1873 + if (ses->user_name == NULL) 1874 + return 0; 1875 + if (strncmp(ses->user_name, vol->username, 1876 + MAX_USERNAME_SIZE)) 1877 + return 0; 1878 + if (strlen(vol->username) != 0 && 1879 + ses->password != NULL && 1880 + strncmp(ses->password, 1881 + vol->password ? vol->password : "", 1882 + MAX_PASSWORD_SIZE)) 1883 + return 0; 1884 + } 1885 + return 1; 1886 + } 1887 + 1888 + static struct cifs_ses * 1831 1889 cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb_vol *vol) 1832 1890 { 1833 - struct cifsSesInfo *ses; 1891 + struct cifs_ses *ses; 1834 1892 1835 1893 spin_lock(&cifs_tcp_ses_lock); 1836 1894 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { 1837 - switch (server->secType) { 1838 - case Kerberos: 1839 - if (vol->cred_uid != ses->cred_uid) 1840 - continue; 1841 - break; 1842 - default: 1843 - /* anything else takes username/password */ 1844 - if (ses->user_name == NULL) 1845 - continue; 1846 - if (strncmp(ses->user_name, vol->username, 1847 - MAX_USERNAME_SIZE)) 1848 - continue; 1849 - if (strlen(vol->username) != 0 && 1850 - ses->password != NULL && 1851 - strncmp(ses->password, 1852 - vol->password ? vol->password : "", 1853 - MAX_PASSWORD_SIZE)) 1854 - continue; 1855 - } 1895 + if (!match_session(ses, vol)) 1896 + continue; 1856 1897 ++ses->ses_count; 1857 1898 spin_unlock(&cifs_tcp_ses_lock); 1858 1899 return ses; ··· 1869 1896 } 1870 1897 1871 1898 static void 1872 - cifs_put_smb_ses(struct cifsSesInfo *ses) 1899 + cifs_put_smb_ses(struct cifs_ses *ses) 1873 1900 { 1874 1901 int xid; 1875 1902 struct TCP_Server_Info *server = ses->server; ··· 1895 1922 1896 1923 static bool warned_on_ntlm; /* globals init to false automatically */ 1897 1924 1898 - static struct cifsSesInfo * 1925 + static struct cifs_ses * 1899 1926 cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) 1900 1927 { 1901 1928 int rc = -ENOMEM, xid; 1902 - struct cifsSesInfo *ses; 1929 + struct cifs_ses *ses; 1903 1930 struct sockaddr_in *addr = (struct sockaddr_in *)&server->dstaddr; 1904 1931 struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&server->dstaddr; 1905 1932 ··· 2002 2029 return ERR_PTR(rc); 2003 2030 } 2004 2031 2005 - static struct cifsTconInfo * 2006 - cifs_find_tcon(struct cifsSesInfo *ses, const char *unc) 2032 + static int match_tcon(struct cifs_tcon *tcon, const char *unc) 2033 + { 2034 + if (tcon->tidStatus == CifsExiting) 2035 + return 0; 2036 + if (strncmp(tcon->treeName, unc, MAX_TREE_SIZE)) 2037 + return 0; 2038 + return 1; 2039 + } 2040 + 2041 + static struct cifs_tcon * 2042 + cifs_find_tcon(struct cifs_ses *ses, const char *unc) 2007 2043 { 2008 2044 struct list_head *tmp; 2009 - struct cifsTconInfo *tcon; 2045 + struct cifs_tcon *tcon; 2010 2046 2011 2047 spin_lock(&cifs_tcp_ses_lock); 2012 2048 list_for_each(tmp, &ses->tcon_list) { 2013 - tcon = list_entry(tmp, struct cifsTconInfo, tcon_list); 2014 - if (tcon->tidStatus == CifsExiting) 2049 + tcon = list_entry(tmp, struct cifs_tcon, tcon_list); 2050 + if (!match_tcon(tcon, unc)) 2015 2051 continue; 2016 - if (strncmp(tcon->treeName, unc, MAX_TREE_SIZE)) 2017 - continue; 2018 - 2019 2052 ++tcon->tc_count; 2020 2053 spin_unlock(&cifs_tcp_ses_lock); 2021 2054 return tcon; ··· 2031 2052 } 2032 2053 2033 2054 static void 2034 - cifs_put_tcon(struct cifsTconInfo *tcon) 2055 + cifs_put_tcon(struct cifs_tcon *tcon) 2035 2056 { 2036 2057 int xid; 2037 - struct cifsSesInfo *ses = tcon->ses; 2058 + struct cifs_ses *ses = tcon->ses; 2038 2059 2039 2060 cFYI(1, "%s: tc_count=%d\n", __func__, tcon->tc_count); 2040 2061 spin_lock(&cifs_tcp_ses_lock); ··· 2055 2076 cifs_put_smb_ses(ses); 2056 2077 } 2057 2078 2058 - static struct cifsTconInfo * 2059 - cifs_get_tcon(struct cifsSesInfo *ses, struct smb_vol *volume_info) 2079 + static struct cifs_tcon * 2080 + cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info) 2060 2081 { 2061 2082 int rc, xid; 2062 - struct cifsTconInfo *tcon; 2083 + struct cifs_tcon *tcon; 2063 2084 2064 2085 tcon = cifs_find_tcon(ses, volume_info->UNC); 2065 2086 if (tcon) { ··· 2148 2169 return; 2149 2170 } 2150 2171 2172 + static inline struct tcon_link * 2173 + cifs_sb_master_tlink(struct cifs_sb_info *cifs_sb); 2174 + 2175 + static int 2176 + compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data) 2177 + { 2178 + struct cifs_sb_info *old = CIFS_SB(sb); 2179 + struct cifs_sb_info *new = mnt_data->cifs_sb; 2180 + 2181 + if ((sb->s_flags & CIFS_MS_MASK) != (mnt_data->flags & CIFS_MS_MASK)) 2182 + return 0; 2183 + 2184 + if ((old->mnt_cifs_flags & CIFS_MOUNT_MASK) != 2185 + (new->mnt_cifs_flags & CIFS_MOUNT_MASK)) 2186 + return 0; 2187 + 2188 + if (old->rsize != new->rsize) 2189 + return 0; 2190 + 2191 + /* 2192 + * We want to share sb only if we don't specify wsize or specified wsize 2193 + * is greater or equal than existing one. 2194 + */ 2195 + if (new->wsize && new->wsize < old->wsize) 2196 + return 0; 2197 + 2198 + if (old->mnt_uid != new->mnt_uid || old->mnt_gid != new->mnt_gid) 2199 + return 0; 2200 + 2201 + if (old->mnt_file_mode != new->mnt_file_mode || 2202 + old->mnt_dir_mode != new->mnt_dir_mode) 2203 + return 0; 2204 + 2205 + if (strcmp(old->local_nls->charset, new->local_nls->charset)) 2206 + return 0; 2207 + 2208 + if (old->actimeo != new->actimeo) 2209 + return 0; 2210 + 2211 + return 1; 2212 + } 2213 + 2151 2214 int 2152 - get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, 2215 + cifs_match_super(struct super_block *sb, void *data) 2216 + { 2217 + struct cifs_mnt_data *mnt_data = (struct cifs_mnt_data *)data; 2218 + struct smb_vol *volume_info; 2219 + struct cifs_sb_info *cifs_sb; 2220 + struct TCP_Server_Info *tcp_srv; 2221 + struct cifs_ses *ses; 2222 + struct cifs_tcon *tcon; 2223 + struct tcon_link *tlink; 2224 + struct sockaddr_storage addr; 2225 + int rc = 0; 2226 + 2227 + memset(&addr, 0, sizeof(struct sockaddr_storage)); 2228 + 2229 + spin_lock(&cifs_tcp_ses_lock); 2230 + cifs_sb = CIFS_SB(sb); 2231 + tlink = cifs_get_tlink(cifs_sb_master_tlink(cifs_sb)); 2232 + if (IS_ERR(tlink)) { 2233 + spin_unlock(&cifs_tcp_ses_lock); 2234 + return rc; 2235 + } 2236 + tcon = tlink_tcon(tlink); 2237 + ses = tcon->ses; 2238 + tcp_srv = ses->server; 2239 + 2240 + volume_info = mnt_data->vol; 2241 + 2242 + if (!volume_info->UNCip || !volume_info->UNC) 2243 + goto out; 2244 + 2245 + rc = cifs_fill_sockaddr((struct sockaddr *)&addr, 2246 + volume_info->UNCip, 2247 + strlen(volume_info->UNCip), 2248 + volume_info->port); 2249 + if (!rc) 2250 + goto out; 2251 + 2252 + if (!match_server(tcp_srv, (struct sockaddr *)&addr, volume_info) || 2253 + !match_session(ses, volume_info) || 2254 + !match_tcon(tcon, volume_info->UNC)) { 2255 + rc = 0; 2256 + goto out; 2257 + } 2258 + 2259 + rc = compare_mount_options(sb, mnt_data); 2260 + out: 2261 + cifs_put_tlink(tlink); 2262 + spin_unlock(&cifs_tcp_ses_lock); 2263 + return rc; 2264 + } 2265 + 2266 + int 2267 + get_dfs_path(int xid, struct cifs_ses *pSesInfo, const char *old_path, 2153 2268 const struct nls_table *nls_codepage, unsigned int *pnum_referrals, 2154 2269 struct dfs_info3_param **preferrals, int remap) 2155 2270 { ··· 2542 2469 return generic_ip_connect(server); 2543 2470 } 2544 2471 2545 - void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon, 2472 + void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon, 2546 2473 struct super_block *sb, struct smb_vol *vol_info) 2547 2474 { 2548 2475 /* if we are reconnecting then should we check to see if ··· 2571 2498 2572 2499 if (!CIFSSMBQFSUnixInfo(xid, tcon)) { 2573 2500 __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); 2574 - 2501 + cFYI(1, "unix caps which server supports %lld", cap); 2575 2502 /* check for reconnect case in which we do not 2576 2503 want to change the mount behavior if we can avoid it */ 2577 2504 if (vol_info == NULL) { ··· 2588 2515 cERROR(1, "server disabled POSIX path support"); 2589 2516 } 2590 2517 } 2518 + 2519 + if (cap & CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP) 2520 + cERROR(1, "per-share encryption not supported yet"); 2591 2521 2592 2522 cap &= CIFS_UNIX_CAP_MASK; 2593 2523 if (vol_info && vol_info->no_psx_acl) ··· 2609 2533 CIFS_SB(sb)->mnt_cifs_flags |= 2610 2534 CIFS_MOUNT_POSIX_PATHS; 2611 2535 } 2612 - 2613 - /* We might be setting the path sep back to a different 2614 - form if we are reconnecting and the server switched its 2615 - posix path capability for this share */ 2616 - if (sb && (CIFS_SB(sb)->prepathlen > 0)) 2617 - CIFS_SB(sb)->prepath[0] = CIFS_DIR_SEP(CIFS_SB(sb)); 2618 2536 2619 2537 if (sb && (CIFS_SB(sb)->rsize > 127 * 1024)) { 2620 2538 if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { ··· 2634 2564 cFYI(1, "very large read cap"); 2635 2565 if (cap & CIFS_UNIX_LARGE_WRITE_CAP) 2636 2566 cFYI(1, "very large write cap"); 2567 + if (cap & CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP) 2568 + cFYI(1, "transport encryption cap"); 2569 + if (cap & CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP) 2570 + cFYI(1, "mandatory transport encryption cap"); 2637 2571 #endif /* CIFS_DEBUG2 */ 2638 2572 if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) { 2639 2573 if (vol_info == NULL) { ··· 2654 2580 } 2655 2581 } 2656 2582 2657 - static void 2658 - convert_delimiter(char *path, char delim) 2659 - { 2660 - int i; 2661 - char old_delim; 2662 - 2663 - if (path == NULL) 2664 - return; 2665 - 2666 - if (delim == '/') 2667 - old_delim = '\\'; 2668 - else 2669 - old_delim = '/'; 2670 - 2671 - for (i = 0; path[i] != '\0'; i++) { 2672 - if (path[i] == old_delim) 2673 - path[i] = delim; 2674 - } 2675 - } 2676 - 2677 - static void setup_cifs_sb(struct smb_vol *pvolume_info, 2678 - struct cifs_sb_info *cifs_sb) 2583 + void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, 2584 + struct cifs_sb_info *cifs_sb) 2679 2585 { 2680 2586 INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks); 2681 2587 ··· 2669 2615 else /* default */ 2670 2616 cifs_sb->rsize = CIFSMaxBufSize; 2671 2617 2672 - if (pvolume_info->wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) { 2673 - cERROR(1, "wsize %d too large, using 4096 instead", 2674 - pvolume_info->wsize); 2675 - cifs_sb->wsize = 4096; 2676 - } else if (pvolume_info->wsize) 2677 - cifs_sb->wsize = pvolume_info->wsize; 2678 - else 2679 - cifs_sb->wsize = min_t(const int, 2680 - PAGEVEC_SIZE * PAGE_CACHE_SIZE, 2681 - 127*1024); 2682 - /* old default of CIFSMaxBufSize was too small now 2683 - that SMB Write2 can send multiple pages in kvec. 2684 - RFC1001 does not describe what happens when frame 2685 - bigger than 128K is sent so use that as max in 2686 - conjunction with 52K kvec constraint on arch with 4K 2687 - page size */ 2688 - 2689 2618 if (cifs_sb->rsize < 2048) { 2690 2619 cifs_sb->rsize = 2048; 2691 2620 /* Windows ME may prefer this */ 2692 2621 cFYI(1, "readsize set to minimum: 2048"); 2693 2622 } 2694 - /* calculate prepath */ 2695 - cifs_sb->prepath = pvolume_info->prepath; 2696 - if (cifs_sb->prepath) { 2697 - cifs_sb->prepathlen = strlen(cifs_sb->prepath); 2698 - /* we can not convert the / to \ in the path 2699 - separators in the prefixpath yet because we do not 2700 - know (until reset_cifs_unix_caps is called later) 2701 - whether POSIX PATH CAP is available. We normalize 2702 - the / to \ after reset_cifs_unix_caps is called */ 2703 - pvolume_info->prepath = NULL; 2704 - } else 2705 - cifs_sb->prepathlen = 0; 2623 + 2624 + /* 2625 + * Temporarily set wsize for matching superblock. If we end up using 2626 + * new sb then cifs_negotiate_wsize will later negotiate it downward 2627 + * if needed. 2628 + */ 2629 + cifs_sb->wsize = pvolume_info->wsize; 2630 + 2706 2631 cifs_sb->mnt_uid = pvolume_info->linux_uid; 2707 2632 cifs_sb->mnt_gid = pvolume_info->linux_gid; 2708 2633 cifs_sb->mnt_file_mode = pvolume_info->file_mode; ··· 2690 2657 cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode); 2691 2658 2692 2659 cifs_sb->actimeo = pvolume_info->actimeo; 2660 + cifs_sb->local_nls = pvolume_info->local_nls; 2693 2661 2694 2662 if (pvolume_info->noperm) 2695 2663 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; ··· 2710 2676 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOSSYNC; 2711 2677 if (pvolume_info->mand_lock) 2712 2678 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOPOSIXBRL; 2679 + if (pvolume_info->rwpidforward) 2680 + cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RWPIDFORWARD; 2713 2681 if (pvolume_info->cifs_acl) 2714 2682 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; 2715 2683 if (pvolume_info->override_uid) ··· 2745 2709 "mount option supported"); 2746 2710 } 2747 2711 2712 + /* 2713 + * When the server supports very large writes via POSIX extensions, we can 2714 + * allow up to 2^24 - PAGE_CACHE_SIZE. 2715 + * 2716 + * Note that this might make for "interesting" allocation problems during 2717 + * writeback however (as we have to allocate an array of pointers for the 2718 + * pages). A 16M write means ~32kb page array with PAGE_CACHE_SIZE == 4096. 2719 + */ 2720 + #define CIFS_MAX_WSIZE ((1<<24) - PAGE_CACHE_SIZE) 2721 + 2722 + /* 2723 + * When the server doesn't allow large posix writes, default to a wsize of 2724 + * 128k - PAGE_CACHE_SIZE -- one page less than the largest frame size 2725 + * described in RFC1001. This allows space for the header without going over 2726 + * that by default. 2727 + */ 2728 + #define CIFS_MAX_RFC1001_WSIZE (128 * 1024 - PAGE_CACHE_SIZE) 2729 + 2730 + /* 2731 + * The default wsize is 1M. find_get_pages seems to return a maximum of 256 2732 + * pages in a single call. With PAGE_CACHE_SIZE == 4k, this means we can fill 2733 + * a single wsize request with a single call. 2734 + */ 2735 + #define CIFS_DEFAULT_WSIZE (1024 * 1024) 2736 + 2737 + static unsigned int 2738 + cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info) 2739 + { 2740 + __u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); 2741 + struct TCP_Server_Info *server = tcon->ses->server; 2742 + unsigned int wsize = pvolume_info->wsize ? pvolume_info->wsize : 2743 + CIFS_DEFAULT_WSIZE; 2744 + 2745 + /* can server support 24-bit write sizes? (via UNIX extensions) */ 2746 + if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP)) 2747 + wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1001_WSIZE); 2748 + 2749 + /* no CAP_LARGE_WRITE_X? Limit it to 16 bits */ 2750 + if (!(server->capabilities & CAP_LARGE_WRITE_X)) 2751 + wsize = min_t(unsigned int, wsize, USHRT_MAX); 2752 + 2753 + /* hard limit of CIFS_MAX_WSIZE */ 2754 + wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE); 2755 + 2756 + return wsize; 2757 + } 2758 + 2748 2759 static int 2749 - is_path_accessible(int xid, struct cifsTconInfo *tcon, 2760 + is_path_accessible(int xid, struct cifs_tcon *tcon, 2750 2761 struct cifs_sb_info *cifs_sb, const char *full_path) 2751 2762 { 2752 2763 int rc; ··· 2816 2733 return rc; 2817 2734 } 2818 2735 2819 - static void 2820 - cleanup_volume_info(struct smb_vol **pvolume_info) 2736 + void 2737 + cifs_cleanup_volume_info(struct smb_vol **pvolume_info) 2821 2738 { 2822 2739 struct smb_vol *volume_info; 2823 2740 ··· 2847 2764 char *full_path; 2848 2765 2849 2766 int unc_len = strnlen(volume_info->UNC, MAX_TREE_SIZE + 1); 2850 - full_path = kmalloc(unc_len + cifs_sb->prepathlen + 1, GFP_KERNEL); 2767 + full_path = kmalloc(unc_len + 1, GFP_KERNEL); 2851 2768 if (full_path == NULL) 2852 2769 return ERR_PTR(-ENOMEM); 2853 2770 2854 2771 strncpy(full_path, volume_info->UNC, unc_len); 2855 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) { 2856 - int i; 2857 - for (i = 0; i < unc_len; i++) { 2858 - if (full_path[i] == '\\') 2859 - full_path[i] = '/'; 2860 - } 2861 - } 2862 - 2863 - if (cifs_sb->prepathlen) 2864 - strncpy(full_path + unc_len, cifs_sb->prepath, 2865 - cifs_sb->prepathlen); 2866 - 2867 - full_path[unc_len + cifs_sb->prepathlen] = 0; /* add trailing null */ 2772 + full_path[unc_len] = 0; /* add trailing null */ 2773 + convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb)); 2868 2774 return full_path; 2869 2775 } 2870 2776 ··· 2868 2796 * determine whether there were referrals. 2869 2797 */ 2870 2798 static int 2871 - expand_dfs_referral(int xid, struct cifsSesInfo *pSesInfo, 2799 + expand_dfs_referral(int xid, struct cifs_ses *pSesInfo, 2872 2800 struct smb_vol *volume_info, struct cifs_sb_info *cifs_sb, 2873 2801 int check_prefix) 2874 2802 { ··· 2912 2840 } 2913 2841 #endif 2914 2842 2915 - int 2916 - cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, 2917 - const char *devname) 2843 + int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, 2844 + const char *devname) 2918 2845 { 2919 - int rc; 2920 - int xid; 2921 2846 struct smb_vol *volume_info; 2922 - struct cifsSesInfo *pSesInfo; 2923 - struct cifsTconInfo *tcon; 2924 - struct TCP_Server_Info *srvTcp; 2925 - char *full_path; 2926 - struct tcon_link *tlink; 2927 - #ifdef CONFIG_CIFS_DFS_UPCALL 2928 - int referral_walks_count = 0; 2929 - try_mount_again: 2930 - /* cleanup activities if we're chasing a referral */ 2931 - if (referral_walks_count) { 2932 - if (tcon) 2933 - cifs_put_tcon(tcon); 2934 - else if (pSesInfo) 2935 - cifs_put_smb_ses(pSesInfo); 2847 + int rc = 0; 2936 2848 2937 - cleanup_volume_info(&volume_info); 2938 - FreeXid(xid); 2939 - } 2940 - #endif 2941 - rc = 0; 2942 - tcon = NULL; 2943 - pSesInfo = NULL; 2944 - srvTcp = NULL; 2945 - full_path = NULL; 2946 - tlink = NULL; 2947 - 2948 - xid = GetXid(); 2849 + *pvolume_info = NULL; 2949 2850 2950 2851 volume_info = kzalloc(sizeof(struct smb_vol), GFP_KERNEL); 2951 2852 if (!volume_info) { ··· 2926 2881 goto out; 2927 2882 } 2928 2883 2929 - if (cifs_parse_mount_options(cifs_sb->mountdata, devname, 2884 + if (cifs_parse_mount_options(mount_data, devname, 2930 2885 volume_info)) { 2931 2886 rc = -EINVAL; 2932 2887 goto out; ··· 2959 2914 goto out; 2960 2915 } 2961 2916 } 2962 - cifs_sb->local_nls = volume_info->local_nls; 2917 + 2918 + *pvolume_info = volume_info; 2919 + return rc; 2920 + out: 2921 + cifs_cleanup_volume_info(&volume_info); 2922 + return rc; 2923 + } 2924 + 2925 + int 2926 + cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, 2927 + struct smb_vol *volume_info, const char *devname) 2928 + { 2929 + int rc = 0; 2930 + int xid; 2931 + struct cifs_ses *pSesInfo; 2932 + struct cifs_tcon *tcon; 2933 + struct TCP_Server_Info *srvTcp; 2934 + char *full_path; 2935 + struct tcon_link *tlink; 2936 + #ifdef CONFIG_CIFS_DFS_UPCALL 2937 + int referral_walks_count = 0; 2938 + try_mount_again: 2939 + /* cleanup activities if we're chasing a referral */ 2940 + if (referral_walks_count) { 2941 + if (tcon) 2942 + cifs_put_tcon(tcon); 2943 + else if (pSesInfo) 2944 + cifs_put_smb_ses(pSesInfo); 2945 + 2946 + cifs_cleanup_volume_info(&volume_info); 2947 + FreeXid(xid); 2948 + } 2949 + #endif 2950 + tcon = NULL; 2951 + pSesInfo = NULL; 2952 + srvTcp = NULL; 2953 + full_path = NULL; 2954 + tlink = NULL; 2955 + 2956 + xid = GetXid(); 2963 2957 2964 2958 /* get a reference to a tcp session */ 2965 2959 srvTcp = cifs_get_tcp_session(volume_info); ··· 3015 2931 goto mount_fail_check; 3016 2932 } 3017 2933 3018 - setup_cifs_sb(volume_info, cifs_sb); 3019 2934 if (pSesInfo->capabilities & CAP_LARGE_FILES) 3020 2935 sb->s_maxbytes = MAX_LFS_FILESIZE; 3021 2936 else ··· 3031 2948 goto remote_path_check; 3032 2949 } 3033 2950 2951 + /* tell server which Unix caps we support */ 2952 + if (tcon->ses->capabilities & CAP_UNIX) { 2953 + /* reset of caps checks mount to see if unix extensions 2954 + disabled for just this mount */ 2955 + reset_cifs_unix_caps(xid, tcon, sb, volume_info); 2956 + if ((tcon->ses->server->tcpStatus == CifsNeedReconnect) && 2957 + (le64_to_cpu(tcon->fsUnixInfo.Capability) & 2958 + CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP)) { 2959 + rc = -EACCES; 2960 + goto mount_fail_check; 2961 + } 2962 + } else 2963 + tcon->unix_ext = 0; /* server does not support them */ 2964 + 3034 2965 /* do not care if following two calls succeed - informational */ 3035 2966 if (!tcon->ipc) { 3036 2967 CIFSSMBQFSDeviceInfo(xid, tcon); 3037 2968 CIFSSMBQFSAttributeInfo(xid, tcon); 3038 2969 } 3039 2970 3040 - /* tell server which Unix caps we support */ 3041 - if (tcon->ses->capabilities & CAP_UNIX) 3042 - /* reset of caps checks mount to see if unix extensions 3043 - disabled for just this mount */ 3044 - reset_cifs_unix_caps(xid, tcon, sb, volume_info); 3045 - else 3046 - tcon->unix_ext = 0; /* server does not support them */ 3047 - 3048 - /* convert forward to back slashes in prepath here if needed */ 3049 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) == 0) 3050 - convert_delimiter(cifs_sb->prepath, CIFS_DIR_SEP(cifs_sb)); 3051 - 3052 2971 if ((tcon->unix_ext == 0) && (cifs_sb->rsize > (1024 * 127))) { 3053 2972 cifs_sb->rsize = 1024 * 127; 3054 2973 cFYI(DBG2, "no very large read support, rsize now 127K"); 3055 2974 } 3056 - if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X)) 3057 - cifs_sb->wsize = min(cifs_sb->wsize, 3058 - (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE)); 3059 2975 if (!(tcon->ses->capabilities & CAP_LARGE_READ_X)) 3060 2976 cifs_sb->rsize = min(cifs_sb->rsize, 3061 2977 (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE)); 2978 + 2979 + cifs_sb->wsize = cifs_negotiate_wsize(tcon, volume_info); 3062 2980 3063 2981 remote_path_check: 3064 2982 #ifdef CONFIG_CIFS_DFS_UPCALL ··· 3080 2996 } 3081 2997 #endif 3082 2998 3083 - /* check if a whole path (including prepath) is not remote */ 2999 + /* check if a whole path is not remote */ 3084 3000 if (!rc && tcon) { 3085 3001 /* build_path_to_root works only when we have a valid tcon */ 3086 - full_path = cifs_build_path_to_root(cifs_sb, tcon); 3002 + full_path = cifs_build_path_to_root(volume_info, cifs_sb, tcon); 3087 3003 if (full_path == NULL) { 3088 3004 rc = -ENOMEM; 3089 3005 goto mount_fail_check; ··· 3109 3025 rc = -ELOOP; 3110 3026 goto mount_fail_check; 3111 3027 } 3112 - /* convert forward to back slashes in prepath here if needed */ 3113 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) == 0) 3114 - convert_delimiter(cifs_sb->prepath, 3115 - CIFS_DIR_SEP(cifs_sb)); 3116 3028 3117 3029 rc = expand_dfs_referral(xid, pSesInfo, volume_info, cifs_sb, 3118 3030 true); ··· 3167 3087 password will be freed at unmount time) */ 3168 3088 out: 3169 3089 /* zero out password before freeing */ 3170 - cleanup_volume_info(&volume_info); 3171 3090 FreeXid(xid); 3172 3091 return rc; 3173 3092 } 3174 3093 3175 3094 int 3176 - CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, 3177 - const char *tree, struct cifsTconInfo *tcon, 3095 + CIFSTCon(unsigned int xid, struct cifs_ses *ses, 3096 + const char *tree, struct cifs_tcon *tcon, 3178 3097 const struct nls_table *nls_codepage) 3179 3098 { 3180 3099 struct smb_hdr *smb_buffer; ··· 3205 3126 pSMB->AndXCommand = 0xFF; 3206 3127 pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); 3207 3128 bcc_ptr = &pSMB->Password[0]; 3208 - if ((ses->server->secMode) & SECMODE_USER) { 3129 + if ((ses->server->sec_mode) & SECMODE_USER) { 3209 3130 pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ 3210 3131 *bcc_ptr = 0; /* password is null byte */ 3211 3132 bcc_ptr++; /* skip password */ ··· 3222 3143 if ((global_secflags & CIFSSEC_MAY_LANMAN) && 3223 3144 (ses->server->secType == LANMAN)) 3224 3145 calc_lanman_hash(tcon->password, ses->server->cryptkey, 3225 - ses->server->secMode & 3146 + ses->server->sec_mode & 3226 3147 SECMODE_PW_ENCRYPT ? true : false, 3227 3148 bcc_ptr); 3228 3149 else ··· 3238 3159 } 3239 3160 } 3240 3161 3241 - if (ses->server->secMode & 3162 + if (ses->server->sec_mode & 3242 3163 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 3243 3164 smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 3244 3165 ··· 3334 3255 struct rb_root *root = &cifs_sb->tlink_tree; 3335 3256 struct rb_node *node; 3336 3257 struct tcon_link *tlink; 3337 - char *tmp; 3338 3258 3339 3259 cancel_delayed_work_sync(&cifs_sb->prune_tlinks); 3340 3260 ··· 3350 3272 } 3351 3273 spin_unlock(&cifs_sb->tlink_tree_lock); 3352 3274 3353 - tmp = cifs_sb->prepath; 3354 - cifs_sb->prepathlen = 0; 3355 - cifs_sb->prepath = NULL; 3356 - kfree(tmp); 3357 - 3358 3275 return 0; 3359 3276 } 3360 3277 3361 - int cifs_negotiate_protocol(unsigned int xid, struct cifsSesInfo *ses) 3278 + int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses) 3362 3279 { 3363 3280 int rc = 0; 3364 3281 struct TCP_Server_Info *server = ses->server; ··· 3383 3310 } 3384 3311 3385 3312 3386 - int cifs_setup_session(unsigned int xid, struct cifsSesInfo *ses, 3313 + int cifs_setup_session(unsigned int xid, struct cifs_ses *ses, 3387 3314 struct nls_table *nls_info) 3388 3315 { 3389 3316 int rc = 0; ··· 3395 3322 ses->capabilities &= (~CAP_UNIX); 3396 3323 3397 3324 cFYI(1, "Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", 3398 - server->secMode, server->capabilities, server->timeAdj); 3325 + server->sec_mode, server->capabilities, server->timeAdj); 3399 3326 3400 3327 rc = CIFS_SessSetup(xid, ses, nls_info); 3401 3328 if (rc) { ··· 3427 3354 return rc; 3428 3355 } 3429 3356 3430 - static struct cifsTconInfo * 3357 + static struct cifs_tcon * 3431 3358 cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid) 3432 3359 { 3433 - struct cifsTconInfo *master_tcon = cifs_sb_master_tcon(cifs_sb); 3434 - struct cifsSesInfo *ses; 3435 - struct cifsTconInfo *tcon = NULL; 3360 + struct cifs_tcon *master_tcon = cifs_sb_master_tcon(cifs_sb); 3361 + struct cifs_ses *ses; 3362 + struct cifs_tcon *tcon = NULL; 3436 3363 struct smb_vol *vol_info; 3437 3364 char username[28]; /* big enough for "krb50x" + hex of ULONG_MAX 6+16 */ 3438 3365 /* We used to have this as MAX_USERNAME which is */ ··· 3465 3392 3466 3393 ses = cifs_get_smb_ses(master_tcon->ses->server, vol_info); 3467 3394 if (IS_ERR(ses)) { 3468 - tcon = (struct cifsTconInfo *)ses; 3395 + tcon = (struct cifs_tcon *)ses; 3469 3396 cifs_put_tcp_session(master_tcon->ses->server); 3470 3397 goto out; 3471 3398 } ··· 3490 3417 return cifs_sb->master_tlink; 3491 3418 } 3492 3419 3493 - struct cifsTconInfo * 3420 + struct cifs_tcon * 3494 3421 cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb) 3495 3422 { 3496 3423 return tlink_tcon(cifs_sb_master_tlink(cifs_sb));
+16 -17
fs/cifs/dir.c
··· 50 50 { 51 51 struct dentry *temp; 52 52 int namelen; 53 - int pplen; 54 53 int dfsplen; 55 54 char *full_path; 56 55 char dirsep; 57 56 struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); 58 - struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb); 57 + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 59 58 60 59 if (direntry == NULL) 61 60 return NULL; /* not much we can do if dentry is freed and ··· 62 63 when the server crashed */ 63 64 64 65 dirsep = CIFS_DIR_SEP(cifs_sb); 65 - pplen = cifs_sb->prepathlen; 66 66 if (tcon->Flags & SMB_SHARE_IS_IN_DFS) 67 67 dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1); 68 68 else 69 69 dfsplen = 0; 70 70 cifs_bp_rename_retry: 71 - namelen = pplen + dfsplen; 71 + namelen = dfsplen; 72 72 for (temp = direntry; !IS_ROOT(temp);) { 73 73 namelen += (1 + temp->d_name.len); 74 74 temp = temp->d_parent; ··· 98 100 return NULL; 99 101 } 100 102 } 101 - if (namelen != pplen + dfsplen) { 103 + if (namelen != dfsplen) { 102 104 cERROR(1, "did not end path lookup where expected namelen is %d", 103 105 namelen); 104 106 /* presumably this is only possible if racing with a rename ··· 124 126 } 125 127 } 126 128 } 127 - strncpy(full_path + dfsplen, CIFS_SB(direntry->d_sb)->prepath, pplen); 128 129 return full_path; 129 130 } 130 131 ··· 149 152 __u16 fileHandle; 150 153 struct cifs_sb_info *cifs_sb; 151 154 struct tcon_link *tlink; 152 - struct cifsTconInfo *tcon; 155 + struct cifs_tcon *tcon; 153 156 char *full_path = NULL; 154 157 FILE_ALL_INFO *buf = NULL; 155 158 struct inode *newinode = NULL; ··· 353 356 int xid; 354 357 struct cifs_sb_info *cifs_sb; 355 358 struct tcon_link *tlink; 356 - struct cifsTconInfo *pTcon; 359 + struct cifs_tcon *pTcon; 360 + struct cifs_io_parms io_parms; 357 361 char *full_path = NULL; 358 362 struct inode *newinode = NULL; 359 363 int oplock = 0; ··· 437 439 * timestamps in, but we can reuse it safely */ 438 440 439 441 pdev = (struct win_dev *)buf; 442 + io_parms.netfid = fileHandle; 443 + io_parms.pid = current->tgid; 444 + io_parms.tcon = pTcon; 445 + io_parms.offset = 0; 446 + io_parms.length = sizeof(struct win_dev); 440 447 if (S_ISCHR(mode)) { 441 448 memcpy(pdev->type, "IntxCHR", 8); 442 449 pdev->major = 443 450 cpu_to_le64(MAJOR(device_number)); 444 451 pdev->minor = 445 452 cpu_to_le64(MINOR(device_number)); 446 - rc = CIFSSMBWrite(xid, pTcon, 447 - fileHandle, 448 - sizeof(struct win_dev), 449 - 0, &bytes_written, (char *)pdev, 453 + rc = CIFSSMBWrite(xid, &io_parms, 454 + &bytes_written, (char *)pdev, 450 455 NULL, 0); 451 456 } else if (S_ISBLK(mode)) { 452 457 memcpy(pdev->type, "IntxBLK", 8); ··· 457 456 cpu_to_le64(MAJOR(device_number)); 458 457 pdev->minor = 459 458 cpu_to_le64(MINOR(device_number)); 460 - rc = CIFSSMBWrite(xid, pTcon, 461 - fileHandle, 462 - sizeof(struct win_dev), 463 - 0, &bytes_written, (char *)pdev, 459 + rc = CIFSSMBWrite(xid, &io_parms, 460 + &bytes_written, (char *)pdev, 464 461 NULL, 0); 465 462 } /* else if (S_ISFIFO) */ 466 463 CIFSSMBClose(xid, pTcon, fileHandle); ··· 485 486 bool posix_open = false; 486 487 struct cifs_sb_info *cifs_sb; 487 488 struct tcon_link *tlink; 488 - struct cifsTconInfo *pTcon; 489 + struct cifs_tcon *pTcon; 489 490 struct cifsFileInfo *cfile; 490 491 struct inode *newInode = NULL; 491 492 char *full_path = NULL;
+193 -183
fs/cifs/file.c
··· 114 114 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 115 115 struct cifs_fattr fattr; 116 116 struct tcon_link *tlink; 117 - struct cifsTconInfo *tcon; 117 + struct cifs_tcon *tcon; 118 118 119 119 cFYI(1, "posix open %s", full_path); 120 120 ··· 168 168 169 169 static int 170 170 cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb, 171 - struct cifsTconInfo *tcon, unsigned int f_flags, __u32 *poplock, 171 + struct cifs_tcon *tcon, unsigned int f_flags, __u32 *poplock, 172 172 __u16 *pnetfid, int xid) 173 173 { 174 174 int rc; ··· 285 285 void cifsFileInfo_put(struct cifsFileInfo *cifs_file) 286 286 { 287 287 struct inode *inode = cifs_file->dentry->d_inode; 288 - struct cifsTconInfo *tcon = tlink_tcon(cifs_file->tlink); 288 + struct cifs_tcon *tcon = tlink_tcon(cifs_file->tlink); 289 289 struct cifsInodeInfo *cifsi = CIFS_I(inode); 290 290 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 291 291 struct cifsLockInfo *li, *tmp; ··· 343 343 int xid; 344 344 __u32 oplock; 345 345 struct cifs_sb_info *cifs_sb; 346 - struct cifsTconInfo *tcon; 346 + struct cifs_tcon *tcon; 347 347 struct tcon_link *tlink; 348 348 struct cifsFileInfo *pCifsFile = NULL; 349 349 char *full_path = NULL; ··· 457 457 int xid; 458 458 __u32 oplock; 459 459 struct cifs_sb_info *cifs_sb; 460 - struct cifsTconInfo *tcon; 460 + struct cifs_tcon *tcon; 461 461 struct cifsInodeInfo *pCifsInode; 462 462 struct inode *inode; 463 463 char *full_path = NULL; ··· 596 596 xid = GetXid(); 597 597 598 598 if (pCFileStruct) { 599 - struct cifsTconInfo *pTcon = tlink_tcon(pCFileStruct->tlink); 599 + struct cifs_tcon *pTcon = tlink_tcon(pCFileStruct->tlink); 600 600 601 601 cFYI(1, "Freeing private data in close dir"); 602 602 spin_lock(&cifs_file_list_lock); ··· 653 653 __u64 length; 654 654 bool wait_flag = false; 655 655 struct cifs_sb_info *cifs_sb; 656 - struct cifsTconInfo *tcon; 656 + struct cifs_tcon *tcon; 657 657 __u16 netfid; 658 658 __u8 lockType = LOCKING_ANDX_LARGE_FILES; 659 659 bool posix_locking = 0; ··· 725 725 else 726 726 posix_lock_type = CIFS_WRLCK; 727 727 rc = CIFSSMBPosixLock(xid, tcon, netfid, 1 /* get */, 728 - length, pfLock, 729 - posix_lock_type, wait_flag); 728 + length, pfLock, posix_lock_type, 729 + wait_flag); 730 730 FreeXid(xid); 731 731 return rc; 732 732 } ··· 797 797 posix_lock_type = CIFS_UNLCK; 798 798 799 799 rc = CIFSSMBPosixLock(xid, tcon, netfid, 0 /* set */, 800 - length, pfLock, 801 - posix_lock_type, wait_flag); 800 + length, pfLock, posix_lock_type, 801 + wait_flag); 802 802 } else { 803 803 struct cifsFileInfo *fid = file->private_data; 804 804 ··· 857 857 cifsi->server_eof = end_of_write; 858 858 } 859 859 860 - static ssize_t cifs_write(struct cifsFileInfo *open_file, 860 + static ssize_t cifs_write(struct cifsFileInfo *open_file, __u32 pid, 861 861 const char *write_data, size_t write_size, 862 862 loff_t *poffset) 863 863 { ··· 865 865 unsigned int bytes_written = 0; 866 866 unsigned int total_written; 867 867 struct cifs_sb_info *cifs_sb; 868 - struct cifsTconInfo *pTcon; 868 + struct cifs_tcon *pTcon; 869 869 int xid; 870 870 struct dentry *dentry = open_file->dentry; 871 871 struct cifsInodeInfo *cifsi = CIFS_I(dentry->d_inode); 872 + struct cifs_io_parms io_parms; 872 873 873 874 cifs_sb = CIFS_SB(dentry->d_sb); 874 875 ··· 902 901 /* iov[0] is reserved for smb header */ 903 902 iov[1].iov_base = (char *)write_data + total_written; 904 903 iov[1].iov_len = len; 905 - rc = CIFSSMBWrite2(xid, pTcon, open_file->netfid, len, 906 - *poffset, &bytes_written, iov, 1, 0); 904 + io_parms.netfid = open_file->netfid; 905 + io_parms.pid = pid; 906 + io_parms.tcon = pTcon; 907 + io_parms.offset = *poffset; 908 + io_parms.length = len; 909 + rc = CIFSSMBWrite2(xid, &io_parms, &bytes_written, iov, 910 + 1, 0); 907 911 } 908 912 if (rc || (bytes_written == 0)) { 909 913 if (total_written) ··· 1077 1071 1078 1072 open_file = find_writable_file(CIFS_I(mapping->host), false); 1079 1073 if (open_file) { 1080 - bytes_written = cifs_write(open_file, write_data, 1081 - to - from, &offset); 1074 + bytes_written = cifs_write(open_file, open_file->pid, 1075 + write_data, to - from, &offset); 1082 1076 cifsFileInfo_put(open_file); 1083 1077 /* Does mm or vfs already set times? */ 1084 1078 inode->i_atime = inode->i_mtime = current_fs_time(inode->i_sb); ··· 1098 1092 static int cifs_writepages(struct address_space *mapping, 1099 1093 struct writeback_control *wbc) 1100 1094 { 1101 - unsigned int bytes_to_write; 1102 - unsigned int bytes_written; 1103 - struct cifs_sb_info *cifs_sb; 1104 - int done = 0; 1105 - pgoff_t end; 1106 - pgoff_t index; 1107 - int range_whole = 0; 1108 - struct kvec *iov; 1109 - int len; 1110 - int n_iov = 0; 1111 - pgoff_t next; 1112 - int nr_pages; 1113 - __u64 offset = 0; 1114 - struct cifsFileInfo *open_file; 1115 - struct cifsTconInfo *tcon; 1116 - struct cifsInodeInfo *cifsi = CIFS_I(mapping->host); 1095 + struct cifs_sb_info *cifs_sb = CIFS_SB(mapping->host->i_sb); 1096 + bool done = false, scanned = false, range_whole = false; 1097 + pgoff_t end, index; 1098 + struct cifs_writedata *wdata; 1117 1099 struct page *page; 1118 - struct pagevec pvec; 1119 1100 int rc = 0; 1120 - int scanned = 0; 1121 - int xid; 1122 - 1123 - cifs_sb = CIFS_SB(mapping->host->i_sb); 1124 1101 1125 1102 /* 1126 - * If wsize is smaller that the page cache size, default to writing 1103 + * If wsize is smaller than the page cache size, default to writing 1127 1104 * one page at a time via cifs_writepage 1128 1105 */ 1129 1106 if (cifs_sb->wsize < PAGE_CACHE_SIZE) 1130 1107 return generic_writepages(mapping, wbc); 1131 1108 1132 - iov = kmalloc(32 * sizeof(struct kvec), GFP_KERNEL); 1133 - if (iov == NULL) 1134 - return generic_writepages(mapping, wbc); 1135 - 1136 - /* 1137 - * if there's no open file, then this is likely to fail too, 1138 - * but it'll at least handle the return. Maybe it should be 1139 - * a BUG() instead? 1140 - */ 1141 - open_file = find_writable_file(CIFS_I(mapping->host), false); 1142 - if (!open_file) { 1143 - kfree(iov); 1144 - return generic_writepages(mapping, wbc); 1145 - } 1146 - 1147 - tcon = tlink_tcon(open_file->tlink); 1148 - cifsFileInfo_put(open_file); 1149 - 1150 - xid = GetXid(); 1151 - 1152 - pagevec_init(&pvec, 0); 1153 1109 if (wbc->range_cyclic) { 1154 1110 index = mapping->writeback_index; /* Start from prev offset */ 1155 1111 end = -1; ··· 1119 1151 index = wbc->range_start >> PAGE_CACHE_SHIFT; 1120 1152 end = wbc->range_end >> PAGE_CACHE_SHIFT; 1121 1153 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) 1122 - range_whole = 1; 1123 - scanned = 1; 1154 + range_whole = true; 1155 + scanned = true; 1124 1156 } 1125 1157 retry: 1126 - while (!done && (index <= end) && 1127 - (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, 1128 - PAGECACHE_TAG_DIRTY, 1129 - min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1))) { 1130 - int first; 1131 - unsigned int i; 1158 + while (!done && index <= end) { 1159 + unsigned int i, nr_pages, found_pages; 1160 + pgoff_t next = 0, tofind; 1161 + struct page **pages; 1132 1162 1133 - first = -1; 1134 - next = 0; 1135 - n_iov = 0; 1136 - bytes_to_write = 0; 1163 + tofind = min((cifs_sb->wsize / PAGE_CACHE_SIZE) - 1, 1164 + end - index) + 1; 1137 1165 1138 - for (i = 0; i < nr_pages; i++) { 1139 - page = pvec.pages[i]; 1166 + wdata = cifs_writedata_alloc((unsigned int)tofind); 1167 + if (!wdata) { 1168 + rc = -ENOMEM; 1169 + break; 1170 + } 1171 + 1172 + /* 1173 + * find_get_pages_tag seems to return a max of 256 on each 1174 + * iteration, so we must call it several times in order to 1175 + * fill the array or the wsize is effectively limited to 1176 + * 256 * PAGE_CACHE_SIZE. 1177 + */ 1178 + found_pages = 0; 1179 + pages = wdata->pages; 1180 + do { 1181 + nr_pages = find_get_pages_tag(mapping, &index, 1182 + PAGECACHE_TAG_DIRTY, 1183 + tofind, pages); 1184 + found_pages += nr_pages; 1185 + tofind -= nr_pages; 1186 + pages += nr_pages; 1187 + } while (nr_pages && tofind && index <= end); 1188 + 1189 + if (found_pages == 0) { 1190 + kref_put(&wdata->refcount, cifs_writedata_release); 1191 + break; 1192 + } 1193 + 1194 + nr_pages = 0; 1195 + for (i = 0; i < found_pages; i++) { 1196 + page = wdata->pages[i]; 1140 1197 /* 1141 1198 * At this point we hold neither mapping->tree_lock nor 1142 1199 * lock on the page itself: the page may be truncated or ··· 1170 1177 * mapping 1171 1178 */ 1172 1179 1173 - if (first < 0) 1180 + if (nr_pages == 0) 1174 1181 lock_page(page); 1175 1182 else if (!trylock_page(page)) 1176 1183 break; ··· 1181 1188 } 1182 1189 1183 1190 if (!wbc->range_cyclic && page->index > end) { 1184 - done = 1; 1191 + done = true; 1185 1192 unlock_page(page); 1186 1193 break; 1187 1194 } ··· 1208 1215 set_page_writeback(page); 1209 1216 1210 1217 if (page_offset(page) >= mapping->host->i_size) { 1211 - done = 1; 1218 + done = true; 1212 1219 unlock_page(page); 1213 1220 end_page_writeback(page); 1214 1221 break; 1215 1222 } 1216 1223 1217 - /* 1218 - * BB can we get rid of this? pages are held by pvec 1219 - */ 1220 - page_cache_get(page); 1221 - 1222 - len = min(mapping->host->i_size - page_offset(page), 1223 - (loff_t)PAGE_CACHE_SIZE); 1224 - 1225 - /* reserve iov[0] for the smb header */ 1226 - n_iov++; 1227 - iov[n_iov].iov_base = kmap(page); 1228 - iov[n_iov].iov_len = len; 1229 - bytes_to_write += len; 1230 - 1231 - if (first < 0) { 1232 - first = i; 1233 - offset = page_offset(page); 1234 - } 1224 + wdata->pages[i] = page; 1235 1225 next = page->index + 1; 1236 - if (bytes_to_write + PAGE_CACHE_SIZE > cifs_sb->wsize) 1237 - break; 1226 + ++nr_pages; 1238 1227 } 1239 - if (n_iov) { 1240 - retry_write: 1241 - open_file = find_writable_file(CIFS_I(mapping->host), 1242 - false); 1243 - if (!open_file) { 1228 + 1229 + /* reset index to refind any pages skipped */ 1230 + if (nr_pages == 0) 1231 + index = wdata->pages[0]->index + 1; 1232 + 1233 + /* put any pages we aren't going to use */ 1234 + for (i = nr_pages; i < found_pages; i++) { 1235 + page_cache_release(wdata->pages[i]); 1236 + wdata->pages[i] = NULL; 1237 + } 1238 + 1239 + /* nothing to write? */ 1240 + if (nr_pages == 0) { 1241 + kref_put(&wdata->refcount, cifs_writedata_release); 1242 + continue; 1243 + } 1244 + 1245 + wdata->sync_mode = wbc->sync_mode; 1246 + wdata->nr_pages = nr_pages; 1247 + wdata->offset = page_offset(wdata->pages[0]); 1248 + 1249 + do { 1250 + if (wdata->cfile != NULL) 1251 + cifsFileInfo_put(wdata->cfile); 1252 + wdata->cfile = find_writable_file(CIFS_I(mapping->host), 1253 + false); 1254 + if (!wdata->cfile) { 1244 1255 cERROR(1, "No writable handles for inode"); 1245 1256 rc = -EBADF; 1246 - } else { 1247 - rc = CIFSSMBWrite2(xid, tcon, open_file->netfid, 1248 - bytes_to_write, offset, 1249 - &bytes_written, iov, n_iov, 1250 - 0); 1251 - cifsFileInfo_put(open_file); 1257 + break; 1252 1258 } 1259 + rc = cifs_async_writev(wdata); 1260 + } while (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN); 1253 1261 1254 - cFYI(1, "Write2 rc=%d, wrote=%u", rc, bytes_written); 1262 + for (i = 0; i < nr_pages; ++i) 1263 + unlock_page(wdata->pages[i]); 1255 1264 1256 - /* 1257 - * For now, treat a short write as if nothing got 1258 - * written. A zero length write however indicates 1259 - * ENOSPC or EFBIG. We have no way to know which 1260 - * though, so call it ENOSPC for now. EFBIG would 1261 - * get translated to AS_EIO anyway. 1262 - * 1263 - * FIXME: make it take into account the data that did 1264 - * get written 1265 - */ 1266 - if (rc == 0) { 1267 - if (bytes_written == 0) 1268 - rc = -ENOSPC; 1269 - else if (bytes_written < bytes_to_write) 1270 - rc = -EAGAIN; 1271 - } 1272 - 1273 - /* retry on data-integrity flush */ 1274 - if (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN) 1275 - goto retry_write; 1276 - 1277 - /* fix the stats and EOF */ 1278 - if (bytes_written > 0) { 1279 - cifs_stats_bytes_written(tcon, bytes_written); 1280 - cifs_update_eof(cifsi, offset, bytes_written); 1281 - } 1282 - 1283 - for (i = 0; i < n_iov; i++) { 1284 - page = pvec.pages[first + i]; 1285 - /* on retryable write error, redirty page */ 1265 + /* send failure -- clean up the mess */ 1266 + if (rc != 0) { 1267 + for (i = 0; i < nr_pages; ++i) { 1286 1268 if (rc == -EAGAIN) 1287 - redirty_page_for_writepage(wbc, page); 1288 - else if (rc != 0) 1289 - SetPageError(page); 1290 - kunmap(page); 1291 - unlock_page(page); 1292 - end_page_writeback(page); 1293 - page_cache_release(page); 1269 + redirty_page_for_writepage(wbc, 1270 + wdata->pages[i]); 1271 + else 1272 + SetPageError(wdata->pages[i]); 1273 + end_page_writeback(wdata->pages[i]); 1274 + page_cache_release(wdata->pages[i]); 1294 1275 } 1295 - 1296 1276 if (rc != -EAGAIN) 1297 1277 mapping_set_error(mapping, rc); 1298 - else 1299 - rc = 0; 1278 + } 1279 + kref_put(&wdata->refcount, cifs_writedata_release); 1300 1280 1301 - if ((wbc->nr_to_write -= n_iov) <= 0) 1302 - done = 1; 1303 - index = next; 1304 - } else 1305 - /* Need to re-find the pages we skipped */ 1306 - index = pvec.pages[0]->index + 1; 1281 + wbc->nr_to_write -= nr_pages; 1282 + if (wbc->nr_to_write <= 0) 1283 + done = true; 1307 1284 1308 - pagevec_release(&pvec); 1285 + index = next; 1309 1286 } 1287 + 1310 1288 if (!scanned && !done) { 1311 1289 /* 1312 1290 * We hit the last page and there is more work to be done: wrap 1313 1291 * back to the start of the file 1314 1292 */ 1315 - scanned = 1; 1293 + scanned = true; 1316 1294 index = 0; 1317 1295 goto retry; 1318 1296 } 1297 + 1319 1298 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) 1320 1299 mapping->writeback_index = index; 1321 1300 1322 - FreeXid(xid); 1323 - kfree(iov); 1324 1301 return rc; 1325 1302 } 1326 1303 ··· 1346 1383 { 1347 1384 int rc; 1348 1385 struct inode *inode = mapping->host; 1386 + struct cifsFileInfo *cfile = file->private_data; 1387 + struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb); 1388 + __u32 pid; 1389 + 1390 + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 1391 + pid = cfile->pid; 1392 + else 1393 + pid = current->tgid; 1349 1394 1350 1395 cFYI(1, "write_end for page %p from pos %lld with %d bytes", 1351 1396 page, pos, copied); ··· 1377 1406 /* BB check if anything else missing out of ppw 1378 1407 such as updating last write time */ 1379 1408 page_data = kmap(page); 1380 - rc = cifs_write(file->private_data, page_data + offset, 1381 - copied, &pos); 1409 + rc = cifs_write(cfile, pid, page_data + offset, copied, &pos); 1382 1410 /* if (rc < 0) should we set writebehind rc? */ 1383 1411 kunmap(page); 1384 1412 ··· 1405 1435 { 1406 1436 int xid; 1407 1437 int rc = 0; 1408 - struct cifsTconInfo *tcon; 1438 + struct cifs_tcon *tcon; 1409 1439 struct cifsFileInfo *smbfile = file->private_data; 1410 1440 struct inode *inode = file->f_path.dentry->d_inode; 1411 1441 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); ··· 1435 1465 { 1436 1466 int xid; 1437 1467 int rc = 0; 1438 - struct cifsTconInfo *tcon; 1468 + struct cifs_tcon *tcon; 1439 1469 struct cifsFileInfo *smbfile = file->private_data; 1440 1470 struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1441 1471 ··· 1526 1556 struct iov_iter it; 1527 1557 struct inode *inode; 1528 1558 struct cifsFileInfo *open_file; 1529 - struct cifsTconInfo *pTcon; 1559 + struct cifs_tcon *pTcon; 1530 1560 struct cifs_sb_info *cifs_sb; 1561 + struct cifs_io_parms io_parms; 1531 1562 int xid, rc; 1563 + __u32 pid; 1532 1564 1533 1565 len = iov_length(iov, nr_segs); 1534 1566 if (!len) ··· 1562 1590 1563 1591 xid = GetXid(); 1564 1592 open_file = file->private_data; 1593 + 1594 + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 1595 + pid = open_file->pid; 1596 + else 1597 + pid = current->tgid; 1598 + 1565 1599 pTcon = tlink_tcon(open_file->tlink); 1566 1600 inode = file->f_path.dentry->d_inode; 1567 1601 ··· 1594 1616 if (rc != 0) 1595 1617 break; 1596 1618 } 1597 - rc = CIFSSMBWrite2(xid, pTcon, open_file->netfid, 1598 - cur_len, *poffset, &written, 1599 - to_send, npages, 0); 1619 + io_parms.netfid = open_file->netfid; 1620 + io_parms.pid = pid; 1621 + io_parms.tcon = pTcon; 1622 + io_parms.offset = *poffset; 1623 + io_parms.length = cur_len; 1624 + rc = CIFSSMBWrite2(xid, &io_parms, &written, to_send, 1625 + npages, 0); 1600 1626 } while (rc == -EAGAIN); 1601 1627 1602 1628 for (i = 0; i < npages; i++) ··· 1693 1711 size_t len, cur_len; 1694 1712 int iov_offset = 0; 1695 1713 struct cifs_sb_info *cifs_sb; 1696 - struct cifsTconInfo *pTcon; 1714 + struct cifs_tcon *pTcon; 1697 1715 struct cifsFileInfo *open_file; 1698 1716 struct smb_com_read_rsp *pSMBr; 1717 + struct cifs_io_parms io_parms; 1699 1718 char *read_data; 1719 + __u32 pid; 1700 1720 1701 1721 if (!nr_segs) 1702 1722 return 0; ··· 1712 1728 1713 1729 open_file = file->private_data; 1714 1730 pTcon = tlink_tcon(open_file->tlink); 1731 + 1732 + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 1733 + pid = open_file->pid; 1734 + else 1735 + pid = current->tgid; 1715 1736 1716 1737 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 1717 1738 cFYI(1, "attempting read on write only file instance"); ··· 1733 1744 if (rc != 0) 1734 1745 break; 1735 1746 } 1736 - rc = CIFSSMBRead(xid, pTcon, open_file->netfid, 1737 - cur_len, *poffset, &bytes_read, 1747 + io_parms.netfid = open_file->netfid; 1748 + io_parms.pid = pid; 1749 + io_parms.tcon = pTcon; 1750 + io_parms.offset = *poffset; 1751 + io_parms.length = len; 1752 + rc = CIFSSMBRead(xid, &io_parms, &bytes_read, 1738 1753 &read_data, &buf_type); 1739 1754 pSMBr = (struct smb_com_read_rsp *)read_data; 1740 1755 if (read_data) { ··· 1815 1822 unsigned int total_read; 1816 1823 unsigned int current_read_size; 1817 1824 struct cifs_sb_info *cifs_sb; 1818 - struct cifsTconInfo *pTcon; 1825 + struct cifs_tcon *pTcon; 1819 1826 int xid; 1820 1827 char *current_offset; 1821 1828 struct cifsFileInfo *open_file; 1829 + struct cifs_io_parms io_parms; 1822 1830 int buf_type = CIFS_NO_BUFFER; 1831 + __u32 pid; 1823 1832 1824 1833 xid = GetXid(); 1825 1834 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); ··· 1833 1838 } 1834 1839 open_file = file->private_data; 1835 1840 pTcon = tlink_tcon(open_file->tlink); 1841 + 1842 + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 1843 + pid = open_file->pid; 1844 + else 1845 + pid = current->tgid; 1836 1846 1837 1847 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 1838 1848 cFYI(1, "attempting read on write only file instance"); ··· 1861 1861 if (rc != 0) 1862 1862 break; 1863 1863 } 1864 - rc = CIFSSMBRead(xid, pTcon, 1865 - open_file->netfid, 1866 - current_read_size, *poffset, 1867 - &bytes_read, &current_offset, 1868 - &buf_type); 1864 + io_parms.netfid = open_file->netfid; 1865 + io_parms.pid = pid; 1866 + io_parms.tcon = pTcon; 1867 + io_parms.offset = *poffset; 1868 + io_parms.length = current_read_size; 1869 + rc = CIFSSMBRead(xid, &io_parms, &bytes_read, 1870 + &current_offset, &buf_type); 1869 1871 } 1870 1872 if (rc || (bytes_read == 0)) { 1871 1873 if (total_read) { ··· 1998 1996 loff_t offset; 1999 1997 struct page *page; 2000 1998 struct cifs_sb_info *cifs_sb; 2001 - struct cifsTconInfo *pTcon; 1999 + struct cifs_tcon *pTcon; 2002 2000 unsigned int bytes_read = 0; 2003 2001 unsigned int read_size, i; 2004 2002 char *smb_read_data = NULL; 2005 2003 struct smb_com_read_rsp *pSMBr; 2006 2004 struct cifsFileInfo *open_file; 2005 + struct cifs_io_parms io_parms; 2007 2006 int buf_type = CIFS_NO_BUFFER; 2007 + __u32 pid; 2008 2008 2009 2009 xid = GetXid(); 2010 2010 if (file->private_data == NULL) { ··· 2028 2024 goto read_complete; 2029 2025 2030 2026 cFYI(DBG2, "rpages: num pages %d", num_pages); 2027 + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 2028 + pid = open_file->pid; 2029 + else 2030 + pid = current->tgid; 2031 + 2031 2032 for (i = 0; i < num_pages; ) { 2032 2033 unsigned contig_pages; 2033 2034 struct page *tmp_page; ··· 2074 2065 if (rc != 0) 2075 2066 break; 2076 2067 } 2077 - 2078 - rc = CIFSSMBRead(xid, pTcon, 2079 - open_file->netfid, 2080 - read_size, offset, 2081 - &bytes_read, &smb_read_data, 2082 - &buf_type); 2068 + io_parms.netfid = open_file->netfid; 2069 + io_parms.pid = pid; 2070 + io_parms.tcon = pTcon; 2071 + io_parms.offset = offset; 2072 + io_parms.length = read_size; 2073 + rc = CIFSSMBRead(xid, &io_parms, &bytes_read, 2074 + &smb_read_data, &buf_type); 2083 2075 /* BB more RC checks ? */ 2084 2076 if (rc == -EAGAIN) { 2085 2077 if (smb_read_data) {
+3 -3
fs/cifs/fscache.c
··· 40 40 server->fscache = NULL; 41 41 } 42 42 43 - void cifs_fscache_get_super_cookie(struct cifsTconInfo *tcon) 43 + void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon) 44 44 { 45 45 struct TCP_Server_Info *server = tcon->ses->server; 46 46 ··· 51 51 server->fscache, tcon->fscache); 52 52 } 53 53 54 - void cifs_fscache_release_super_cookie(struct cifsTconInfo *tcon) 54 + void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon) 55 55 { 56 56 cFYI(1, "CIFS: releasing superblock cookie (0x%p)", tcon->fscache); 57 57 fscache_relinquish_cookie(tcon->fscache, 0); ··· 62 62 { 63 63 struct cifsInodeInfo *cifsi = CIFS_I(inode); 64 64 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 65 - struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb); 65 + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 66 66 67 67 if (cifsi->fscache) 68 68 return;
+4 -4
fs/cifs/fscache.h
··· 40 40 */ 41 41 extern void cifs_fscache_get_client_cookie(struct TCP_Server_Info *); 42 42 extern void cifs_fscache_release_client_cookie(struct TCP_Server_Info *); 43 - extern void cifs_fscache_get_super_cookie(struct cifsTconInfo *); 44 - extern void cifs_fscache_release_super_cookie(struct cifsTconInfo *); 43 + extern void cifs_fscache_get_super_cookie(struct cifs_tcon *); 44 + extern void cifs_fscache_release_super_cookie(struct cifs_tcon *); 45 45 46 46 extern void cifs_fscache_release_inode_cookie(struct inode *); 47 47 extern void cifs_fscache_set_inode_cookie(struct inode *, struct file *); ··· 99 99 cifs_fscache_get_client_cookie(struct TCP_Server_Info *server) {} 100 100 static inline void 101 101 cifs_fscache_release_client_cookie(struct TCP_Server_Info *server) {} 102 - static inline void cifs_fscache_get_super_cookie(struct cifsTconInfo *tcon) {} 102 + static inline void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon) {} 103 103 static inline void 104 - cifs_fscache_release_super_cookie(struct cifsTconInfo *tcon) {} 104 + cifs_fscache_release_super_cookie(struct cifs_tcon *tcon) {} 105 105 106 106 static inline void cifs_fscache_release_inode_cookie(struct inode *inode) {} 107 107 static inline void cifs_fscache_set_inode_cookie(struct inode *inode,
+51 -41
fs/cifs/inode.c
··· 295 295 struct inode *inode = filp->f_path.dentry->d_inode; 296 296 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 297 297 struct cifsFileInfo *cfile = filp->private_data; 298 - struct cifsTconInfo *tcon = tlink_tcon(cfile->tlink); 298 + struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 299 299 300 300 xid = GetXid(); 301 301 rc = CIFSSMBUnixQFileInfo(xid, tcon, cfile->netfid, &find_data); ··· 318 318 int rc; 319 319 FILE_UNIX_BASIC_INFO find_data; 320 320 struct cifs_fattr fattr; 321 - struct cifsTconInfo *tcon; 321 + struct cifs_tcon *tcon; 322 322 struct tcon_link *tlink; 323 323 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 324 324 ··· 373 373 int oplock = 0; 374 374 __u16 netfid; 375 375 struct tcon_link *tlink; 376 - struct cifsTconInfo *tcon; 376 + struct cifs_tcon *tcon; 377 + struct cifs_io_parms io_parms; 377 378 char buf[24]; 378 379 unsigned int bytes_read; 379 380 char *pbuf; ··· 406 405 if (rc == 0) { 407 406 int buf_type = CIFS_NO_BUFFER; 408 407 /* Read header */ 409 - rc = CIFSSMBRead(xid, tcon, netfid, 410 - 24 /* length */, 0 /* offset */, 411 - &bytes_read, &pbuf, &buf_type); 408 + io_parms.netfid = netfid; 409 + io_parms.pid = current->tgid; 410 + io_parms.tcon = tcon; 411 + io_parms.offset = 0; 412 + io_parms.length = 24; 413 + rc = CIFSSMBRead(xid, &io_parms, &bytes_read, &pbuf, 414 + &buf_type); 412 415 if ((rc == 0) && (bytes_read >= 8)) { 413 416 if (memcmp("IntxBLK", pbuf, 8) == 0) { 414 417 cFYI(1, "Block device"); ··· 473 468 char ea_value[4]; 474 469 __u32 mode; 475 470 struct tcon_link *tlink; 476 - struct cifsTconInfo *tcon; 471 + struct cifs_tcon *tcon; 477 472 478 473 tlink = cifs_sb_tlink(cifs_sb); 479 474 if (IS_ERR(tlink)) ··· 507 502 cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, 508 503 struct cifs_sb_info *cifs_sb, bool adjust_tz) 509 504 { 510 - struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb); 505 + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 511 506 512 507 memset(fattr, 0, sizeof(*fattr)); 513 508 fattr->cf_cifsattrs = le32_to_cpu(info->Attributes); ··· 558 553 struct inode *inode = filp->f_path.dentry->d_inode; 559 554 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 560 555 struct cifsFileInfo *cfile = filp->private_data; 561 - struct cifsTconInfo *tcon = tlink_tcon(cfile->tlink); 556 + struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 562 557 563 558 xid = GetXid(); 564 559 rc = CIFSSMBQFileInfo(xid, tcon, cfile->netfid, &find_data); ··· 595 590 struct super_block *sb, int xid, const __u16 *pfid) 596 591 { 597 592 int rc = 0, tmprc; 598 - struct cifsTconInfo *pTcon; 593 + struct cifs_tcon *pTcon; 599 594 struct tcon_link *tlink; 600 595 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 601 596 char *buf = NULL; ··· 740 735 .lookup = cifs_lookup, 741 736 }; 742 737 743 - char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb, 744 - struct cifsTconInfo *tcon) 738 + char *cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb, 739 + struct cifs_tcon *tcon) 745 740 { 746 - int pplen = cifs_sb->prepathlen; 741 + int pplen = vol->prepath ? strlen(vol->prepath) : 0; 747 742 int dfsplen; 748 743 char *full_path = NULL; 749 744 ··· 777 772 } 778 773 } 779 774 } 780 - strncpy(full_path + dfsplen, cifs_sb->prepath, pplen); 775 + strncpy(full_path + dfsplen, vol->prepath, pplen); 781 776 full_path[dfsplen + pplen] = 0; /* add trailing null */ 782 777 return full_path; 783 778 } ··· 889 884 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 890 885 struct inode *inode = NULL; 891 886 long rc; 892 - char *full_path; 893 - struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb); 894 - 895 - full_path = cifs_build_path_to_root(cifs_sb, tcon); 896 - if (full_path == NULL) 897 - return ERR_PTR(-ENOMEM); 887 + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 898 888 899 889 xid = GetXid(); 900 890 if (tcon->unix_ext) 901 - rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid); 891 + rc = cifs_get_inode_info_unix(&inode, "", sb, xid); 902 892 else 903 - rc = cifs_get_inode_info(&inode, full_path, NULL, sb, 904 - xid, NULL); 893 + rc = cifs_get_inode_info(&inode, "", NULL, sb, xid, NULL); 905 894 906 895 if (!inode) { 907 896 inode = ERR_PTR(rc); ··· 921 922 } 922 923 923 924 out: 924 - kfree(full_path); 925 925 /* can not call macro FreeXid here since in a void func 926 926 * TODO: This is no longer true 927 927 */ ··· 941 943 struct cifsInodeInfo *cifsInode = CIFS_I(inode); 942 944 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 943 945 struct tcon_link *tlink = NULL; 944 - struct cifsTconInfo *pTcon; 946 + struct cifs_tcon *pTcon; 945 947 FILE_BASIC_INFO info_buf; 946 948 947 949 if (attrs == NULL) ··· 1059 1061 struct cifsInodeInfo *cifsInode = CIFS_I(inode); 1060 1062 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1061 1063 struct tcon_link *tlink; 1062 - struct cifsTconInfo *tcon; 1064 + struct cifs_tcon *tcon; 1063 1065 __u32 dosattr, origattr; 1064 1066 FILE_BASIC_INFO *info_buf = NULL; 1065 1067 ··· 1177 1179 struct super_block *sb = dir->i_sb; 1178 1180 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 1179 1181 struct tcon_link *tlink; 1180 - struct cifsTconInfo *tcon; 1182 + struct cifs_tcon *tcon; 1181 1183 struct iattr *attrs = NULL; 1182 1184 __u32 dosattr = 0, origattr = 0; 1183 1185 ··· 1275 1277 int xid; 1276 1278 struct cifs_sb_info *cifs_sb; 1277 1279 struct tcon_link *tlink; 1278 - struct cifsTconInfo *pTcon; 1280 + struct cifs_tcon *pTcon; 1279 1281 char *full_path = NULL; 1280 1282 struct inode *newinode = NULL; 1281 1283 struct cifs_fattr fattr; ··· 1453 1455 int xid; 1454 1456 struct cifs_sb_info *cifs_sb; 1455 1457 struct tcon_link *tlink; 1456 - struct cifsTconInfo *pTcon; 1458 + struct cifs_tcon *pTcon; 1457 1459 char *full_path = NULL; 1458 1460 struct cifsInodeInfo *cifsInode; 1459 1461 ··· 1510 1512 { 1511 1513 struct cifs_sb_info *cifs_sb = CIFS_SB(from_dentry->d_sb); 1512 1514 struct tcon_link *tlink; 1513 - struct cifsTconInfo *pTcon; 1515 + struct cifs_tcon *pTcon; 1514 1516 __u16 srcfid; 1515 1517 int oplock, rc; 1516 1518 ··· 1562 1564 char *toName = NULL; 1563 1565 struct cifs_sb_info *cifs_sb; 1564 1566 struct tcon_link *tlink; 1565 - struct cifsTconInfo *tcon; 1567 + struct cifs_tcon *tcon; 1566 1568 FILE_UNIX_BASIC_INFO *info_buf_source = NULL; 1567 1569 FILE_UNIX_BASIC_INFO *info_buf_target; 1568 1570 int xid, rc, tmprc; ··· 1792 1794 struct kstat *stat) 1793 1795 { 1794 1796 struct cifs_sb_info *cifs_sb = CIFS_SB(dentry->d_sb); 1795 - struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb); 1797 + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 1796 1798 struct inode *inode = dentry->d_inode; 1797 1799 int rc; 1798 1800 ··· 1870 1872 struct cifsInodeInfo *cifsInode = CIFS_I(inode); 1871 1873 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1872 1874 struct tcon_link *tlink = NULL; 1873 - struct cifsTconInfo *pTcon = NULL; 1875 + struct cifs_tcon *pTcon = NULL; 1876 + struct cifs_io_parms io_parms; 1874 1877 1875 1878 /* 1876 1879 * To avoid spurious oplock breaks from server, in the case of ··· 1893 1894 cFYI(1, "SetFSize for attrs rc = %d", rc); 1894 1895 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { 1895 1896 unsigned int bytes_written; 1896 - rc = CIFSSMBWrite(xid, pTcon, nfid, 0, attrs->ia_size, 1897 - &bytes_written, NULL, NULL, 1); 1897 + 1898 + io_parms.netfid = nfid; 1899 + io_parms.pid = npid; 1900 + io_parms.tcon = pTcon; 1901 + io_parms.offset = 0; 1902 + io_parms.length = attrs->ia_size; 1903 + rc = CIFSSMBWrite(xid, &io_parms, &bytes_written, 1904 + NULL, NULL, 1); 1898 1905 cFYI(1, "Wrt seteof rc %d", rc); 1899 1906 } 1900 1907 } else ··· 1935 1930 CIFS_MOUNT_MAP_SPECIAL_CHR); 1936 1931 if (rc == 0) { 1937 1932 unsigned int bytes_written; 1938 - rc = CIFSSMBWrite(xid, pTcon, netfid, 0, 1939 - attrs->ia_size, 1940 - &bytes_written, NULL, 1941 - NULL, 1); 1933 + 1934 + io_parms.netfid = netfid; 1935 + io_parms.pid = current->tgid; 1936 + io_parms.tcon = pTcon; 1937 + io_parms.offset = 0; 1938 + io_parms.length = attrs->ia_size; 1939 + rc = CIFSSMBWrite(xid, &io_parms, 1940 + &bytes_written, 1941 + NULL, NULL, 1); 1942 1942 cFYI(1, "wrt seteof rc %d", rc); 1943 1943 CIFSSMBClose(xid, pTcon, netfid); 1944 1944 } ··· 1971 1961 struct cifsInodeInfo *cifsInode = CIFS_I(inode); 1972 1962 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1973 1963 struct tcon_link *tlink; 1974 - struct cifsTconInfo *pTcon; 1964 + struct cifs_tcon *pTcon; 1975 1965 struct cifs_unix_set_info_args *args = NULL; 1976 1966 struct cifsFileInfo *open_file; 1977 1967 ··· 2257 2247 { 2258 2248 struct inode *inode = direntry->d_inode; 2259 2249 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2260 - struct cifsTconInfo *pTcon = cifs_sb_master_tcon(cifs_sb); 2250 + struct cifs_tcon *pTcon = cifs_sb_master_tcon(cifs_sb); 2261 2251 2262 2252 if (pTcon->unix_ext) 2263 2253 return cifs_setattr_unix(direntry, attrs);
+1 -1
fs/cifs/ioctl.c
··· 38 38 struct cifs_sb_info *cifs_sb; 39 39 #ifdef CONFIG_CIFS_POSIX 40 40 struct cifsFileInfo *pSMBFile = filep->private_data; 41 - struct cifsTconInfo *tcon; 41 + struct cifs_tcon *tcon; 42 42 __u64 ExtAttrBits = 0; 43 43 __u64 ExtAttrMask = 0; 44 44 __u64 caps;
+28 -18
fs/cifs/link.c
··· 175 175 } 176 176 177 177 static int 178 - CIFSCreateMFSymLink(const int xid, struct cifsTconInfo *tcon, 178 + CIFSCreateMFSymLink(const int xid, struct cifs_tcon *tcon, 179 179 const char *fromName, const char *toName, 180 180 const struct nls_table *nls_codepage, int remap) 181 181 { ··· 184 184 __u16 netfid = 0; 185 185 u8 *buf; 186 186 unsigned int bytes_written = 0; 187 + struct cifs_io_parms io_parms; 187 188 188 189 buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL); 189 190 if (!buf) ··· 204 203 return rc; 205 204 } 206 205 207 - rc = CIFSSMBWrite(xid, tcon, netfid, 208 - CIFS_MF_SYMLINK_FILE_SIZE /* length */, 209 - 0 /* offset */, 210 - &bytes_written, buf, NULL, 0); 206 + io_parms.netfid = netfid; 207 + io_parms.pid = current->tgid; 208 + io_parms.tcon = tcon; 209 + io_parms.offset = 0; 210 + io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE; 211 + 212 + rc = CIFSSMBWrite(xid, &io_parms, &bytes_written, buf, NULL, 0); 211 213 CIFSSMBClose(xid, tcon, netfid); 212 214 kfree(buf); 213 215 if (rc != 0) ··· 223 219 } 224 220 225 221 static int 226 - CIFSQueryMFSymLink(const int xid, struct cifsTconInfo *tcon, 222 + CIFSQueryMFSymLink(const int xid, struct cifs_tcon *tcon, 227 223 const unsigned char *searchName, char **symlinkinfo, 228 224 const struct nls_table *nls_codepage, int remap) 229 225 { ··· 235 231 unsigned int bytes_read = 0; 236 232 int buf_type = CIFS_NO_BUFFER; 237 233 unsigned int link_len = 0; 234 + struct cifs_io_parms io_parms; 238 235 FILE_ALL_INFO file_info; 239 236 240 237 rc = CIFSSMBOpen(xid, tcon, searchName, FILE_OPEN, GENERIC_READ, ··· 254 249 if (!buf) 255 250 return -ENOMEM; 256 251 pbuf = buf; 252 + io_parms.netfid = netfid; 253 + io_parms.pid = current->tgid; 254 + io_parms.tcon = tcon; 255 + io_parms.offset = 0; 256 + io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE; 257 257 258 - rc = CIFSSMBRead(xid, tcon, netfid, 259 - CIFS_MF_SYMLINK_FILE_SIZE /* length */, 260 - 0 /* offset */, 261 - &bytes_read, &pbuf, &buf_type); 258 + rc = CIFSSMBRead(xid, &io_parms, &bytes_read, &pbuf, &buf_type); 262 259 CIFSSMBClose(xid, tcon, netfid); 263 260 if (rc != 0) { 264 261 kfree(buf); ··· 298 291 int oplock = 0; 299 292 __u16 netfid = 0; 300 293 struct tcon_link *tlink; 301 - struct cifsTconInfo *pTcon; 294 + struct cifs_tcon *pTcon; 295 + struct cifs_io_parms io_parms; 302 296 u8 *buf; 303 297 char *pbuf; 304 298 unsigned int bytes_read = 0; ··· 336 328 goto out; 337 329 } 338 330 pbuf = buf; 331 + io_parms.netfid = netfid; 332 + io_parms.pid = current->tgid; 333 + io_parms.tcon = pTcon; 334 + io_parms.offset = 0; 335 + io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE; 339 336 340 - rc = CIFSSMBRead(xid, pTcon, netfid, 341 - CIFS_MF_SYMLINK_FILE_SIZE /* length */, 342 - 0 /* offset */, 343 - &bytes_read, &pbuf, &buf_type); 337 + rc = CIFSSMBRead(xid, &io_parms, &bytes_read, &pbuf, &buf_type); 344 338 CIFSSMBClose(xid, pTcon, netfid); 345 339 if (rc != 0) { 346 340 kfree(buf); ··· 380 370 char *toName = NULL; 381 371 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 382 372 struct tcon_link *tlink; 383 - struct cifsTconInfo *pTcon; 373 + struct cifs_tcon *pTcon; 384 374 struct cifsInodeInfo *cifsInode; 385 375 386 376 tlink = cifs_sb_tlink(cifs_sb); ··· 455 445 char *target_path = NULL; 456 446 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 457 447 struct tcon_link *tlink = NULL; 458 - struct cifsTconInfo *tcon; 448 + struct cifs_tcon *tcon; 459 449 460 450 xid = GetXid(); 461 451 ··· 528 518 int xid; 529 519 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 530 520 struct tcon_link *tlink; 531 - struct cifsTconInfo *pTcon; 521 + struct cifs_tcon *pTcon; 532 522 char *full_path = NULL; 533 523 struct inode *newinode = NULL; 534 524
+16 -16
fs/cifs/misc.c
··· 67 67 spin_unlock(&GlobalMid_Lock); 68 68 } 69 69 70 - struct cifsSesInfo * 70 + struct cifs_ses * 71 71 sesInfoAlloc(void) 72 72 { 73 - struct cifsSesInfo *ret_buf; 73 + struct cifs_ses *ret_buf; 74 74 75 - ret_buf = kzalloc(sizeof(struct cifsSesInfo), GFP_KERNEL); 75 + ret_buf = kzalloc(sizeof(struct cifs_ses), GFP_KERNEL); 76 76 if (ret_buf) { 77 77 atomic_inc(&sesInfoAllocCount); 78 78 ret_buf->status = CifsNew; ··· 85 85 } 86 86 87 87 void 88 - sesInfoFree(struct cifsSesInfo *buf_to_free) 88 + sesInfoFree(struct cifs_ses *buf_to_free) 89 89 { 90 90 if (buf_to_free == NULL) { 91 91 cFYI(1, "Null buffer passed to sesInfoFree"); ··· 105 105 kfree(buf_to_free); 106 106 } 107 107 108 - struct cifsTconInfo * 108 + struct cifs_tcon * 109 109 tconInfoAlloc(void) 110 110 { 111 - struct cifsTconInfo *ret_buf; 112 - ret_buf = kzalloc(sizeof(struct cifsTconInfo), GFP_KERNEL); 111 + struct cifs_tcon *ret_buf; 112 + ret_buf = kzalloc(sizeof(struct cifs_tcon), GFP_KERNEL); 113 113 if (ret_buf) { 114 114 atomic_inc(&tconInfoAllocCount); 115 115 ret_buf->tidStatus = CifsNew; ··· 124 124 } 125 125 126 126 void 127 - tconInfoFree(struct cifsTconInfo *buf_to_free) 127 + tconInfoFree(struct cifs_tcon *buf_to_free) 128 128 { 129 129 if (buf_to_free == NULL) { 130 130 cFYI(1, "Null buffer passed to tconInfoFree"); ··· 295 295 case it is responsbility of caller to set the mid */ 296 296 void 297 297 header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , 298 - const struct cifsTconInfo *treeCon, int word_count 298 + const struct cifs_tcon *treeCon, int word_count 299 299 /* length of fixed section (word count) in two byte units */) 300 300 { 301 301 struct list_head *temp_item; 302 - struct cifsSesInfo *ses; 302 + struct cifs_ses *ses; 303 303 char *temp = (char *) buffer; 304 304 305 305 memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */ ··· 359 359 "did not match tcon uid"); 360 360 spin_lock(&cifs_tcp_ses_lock); 361 361 list_for_each(temp_item, &treeCon->ses->server->smb_ses_list) { 362 - ses = list_entry(temp_item, struct cifsSesInfo, smb_ses_list); 362 + ses = list_entry(temp_item, struct cifs_ses, smb_ses_list); 363 363 if (ses->linux_uid == current_fsuid()) { 364 364 if (ses->server == treeCon->ses->server) { 365 365 cFYI(1, "found matching uid substitute right smb_uid"); ··· 380 380 if (treeCon->nocase) 381 381 buffer->Flags |= SMBFLG_CASELESS; 382 382 if ((treeCon->ses) && (treeCon->ses->server)) 383 - if (treeCon->ses->server->secMode & 383 + if (treeCon->ses->server->sec_mode & 384 384 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 385 385 buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 386 386 } ··· 507 507 { 508 508 struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf; 509 509 struct list_head *tmp, *tmp1, *tmp2; 510 - struct cifsSesInfo *ses; 511 - struct cifsTconInfo *tcon; 510 + struct cifs_ses *ses; 511 + struct cifs_tcon *tcon; 512 512 struct cifsInodeInfo *pCifsInode; 513 513 struct cifsFileInfo *netfile; 514 514 ··· 566 566 /* look up tcon based on tid & uid */ 567 567 spin_lock(&cifs_tcp_ses_lock); 568 568 list_for_each(tmp, &srv->smb_ses_list) { 569 - ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); 569 + ses = list_entry(tmp, struct cifs_ses, smb_ses_list); 570 570 list_for_each(tmp1, &ses->tcon_list) { 571 - tcon = list_entry(tmp1, struct cifsTconInfo, tcon_list); 571 + tcon = list_entry(tmp1, struct cifs_tcon, tcon_list); 572 572 if (tcon->tid != buf->Tid) 573 573 continue; 574 574
+1 -1
fs/cifs/netmisc.c
··· 836 836 } 837 837 838 838 int 839 - map_smb_to_linux_error(struct smb_hdr *smb, int logErr) 839 + map_smb_to_linux_error(struct smb_hdr *smb, bool logErr) 840 840 { 841 841 unsigned int i; 842 842 int rc = -EIO; /* if transport error smb error may not be set */
+4 -4
fs/cifs/readdir.c
··· 195 195 int len; 196 196 int oplock = 0; 197 197 int rc; 198 - struct cifsTconInfo *ptcon = cifs_sb_tcon(cifs_sb); 198 + struct cifs_tcon *ptcon = cifs_sb_tcon(cifs_sb); 199 199 char *tmpbuffer; 200 200 201 201 rc = CIFSSMBOpen(xid, ptcon, full_path, FILE_OPEN, GENERIC_READ, ··· 223 223 struct cifsFileInfo *cifsFile; 224 224 struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 225 225 struct tcon_link *tlink = NULL; 226 - struct cifsTconInfo *pTcon; 226 + struct cifs_tcon *pTcon; 227 227 228 228 if (file->private_data == NULL) { 229 229 tlink = cifs_sb_tlink(cifs_sb); ··· 496 496 assume that they are located in the findfirst return buffer.*/ 497 497 /* We start counting in the buffer with entry 2 and increment for every 498 498 entry (do not increment for . or .. entry) */ 499 - static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, 499 + static int find_cifs_entry(const int xid, struct cifs_tcon *pTcon, 500 500 struct file *file, char **ppCurrentEntry, int *num_to_ret) 501 501 { 502 502 int rc = 0; ··· 764 764 { 765 765 int rc = 0; 766 766 int xid, i; 767 - struct cifsTconInfo *pTcon; 767 + struct cifs_tcon *pTcon; 768 768 struct cifsFileInfo *cifsFile = NULL; 769 769 char *current_entry; 770 770 int num_to_fill = 0;
+21 -21
fs/cifs/sess.c
··· 37 37 * the socket has been reestablished (so we know whether to use vc 0). 38 38 * Called while holding the cifs_tcp_ses_lock, so do not block 39 39 */ 40 - static bool is_first_ses_reconnect(struct cifsSesInfo *ses) 40 + static bool is_first_ses_reconnect(struct cifs_ses *ses) 41 41 { 42 42 struct list_head *tmp; 43 - struct cifsSesInfo *tmp_ses; 43 + struct cifs_ses *tmp_ses; 44 44 45 45 list_for_each(tmp, &ses->server->smb_ses_list) { 46 - tmp_ses = list_entry(tmp, struct cifsSesInfo, 46 + tmp_ses = list_entry(tmp, struct cifs_ses, 47 47 smb_ses_list); 48 48 if (tmp_ses->need_reconnect == false) 49 49 return false; ··· 61 61 * any vc but zero (some servers reset the connection on vcnum zero) 62 62 * 63 63 */ 64 - static __le16 get_next_vcnum(struct cifsSesInfo *ses) 64 + static __le16 get_next_vcnum(struct cifs_ses *ses) 65 65 { 66 66 __u16 vcnum = 0; 67 67 struct list_head *tmp; 68 - struct cifsSesInfo *tmp_ses; 68 + struct cifs_ses *tmp_ses; 69 69 __u16 max_vcs = ses->server->max_vcs; 70 70 __u16 i; 71 71 int free_vc_found = 0; ··· 87 87 free_vc_found = 1; 88 88 89 89 list_for_each(tmp, &ses->server->smb_ses_list) { 90 - tmp_ses = list_entry(tmp, struct cifsSesInfo, 90 + tmp_ses = list_entry(tmp, struct cifs_ses, 91 91 smb_ses_list); 92 92 if (tmp_ses->vcnum == i) { 93 93 free_vc_found = 0; ··· 114 114 return cpu_to_le16(vcnum); 115 115 } 116 116 117 - static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB) 117 + static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, SESSION_SETUP_ANDX *pSMB) 118 118 { 119 119 __u32 capabilities = 0; 120 120 ··· 136 136 capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | 137 137 CAP_LARGE_WRITE_X | CAP_LARGE_READ_X; 138 138 139 - if (ses->server->secMode & 139 + if (ses->server->sec_mode & 140 140 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 141 141 pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 142 142 ··· 181 181 *pbcc_area = bcc_ptr; 182 182 } 183 183 184 - static void unicode_domain_string(char **pbcc_area, struct cifsSesInfo *ses, 184 + static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses, 185 185 const struct nls_table *nls_cp) 186 186 { 187 187 char *bcc_ptr = *pbcc_area; ··· 204 204 } 205 205 206 206 207 - static void unicode_ssetup_strings(char **pbcc_area, struct cifsSesInfo *ses, 207 + static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, 208 208 const struct nls_table *nls_cp) 209 209 { 210 210 char *bcc_ptr = *pbcc_area; ··· 236 236 *pbcc_area = bcc_ptr; 237 237 } 238 238 239 - static void ascii_ssetup_strings(char **pbcc_area, struct cifsSesInfo *ses, 239 + static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, 240 240 const struct nls_table *nls_cp) 241 241 { 242 242 char *bcc_ptr = *pbcc_area; ··· 276 276 } 277 277 278 278 static void 279 - decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifsSesInfo *ses, 279 + decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses, 280 280 const struct nls_table *nls_cp) 281 281 { 282 282 int len; ··· 310 310 } 311 311 312 312 static int decode_ascii_ssetup(char **pbcc_area, __u16 bleft, 313 - struct cifsSesInfo *ses, 313 + struct cifs_ses *ses, 314 314 const struct nls_table *nls_cp) 315 315 { 316 316 int rc = 0; ··· 364 364 } 365 365 366 366 static int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, 367 - struct cifsSesInfo *ses) 367 + struct cifs_ses *ses) 368 368 { 369 369 unsigned int tioffset; /* challenge message target info area */ 370 370 unsigned int tilen; /* challenge message target info area length */ ··· 411 411 /* We do not malloc the blob, it is passed in pbuffer, because 412 412 it is fixed size, and small, making this approach cleaner */ 413 413 static void build_ntlmssp_negotiate_blob(unsigned char *pbuffer, 414 - struct cifsSesInfo *ses) 414 + struct cifs_ses *ses) 415 415 { 416 416 NEGOTIATE_MESSAGE *sec_blob = (NEGOTIATE_MESSAGE *)pbuffer; 417 417 __u32 flags; ··· 424 424 flags = NTLMSSP_NEGOTIATE_56 | NTLMSSP_REQUEST_TARGET | 425 425 NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | 426 426 NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC; 427 - if (ses->server->secMode & 427 + if (ses->server->sec_mode & 428 428 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) { 429 429 flags |= NTLMSSP_NEGOTIATE_SIGN; 430 430 if (!ses->server->session_estab) ··· 449 449 This function returns the length of the data in the blob */ 450 450 static int build_ntlmssp_auth_blob(unsigned char *pbuffer, 451 451 u16 *buflen, 452 - struct cifsSesInfo *ses, 452 + struct cifs_ses *ses, 453 453 const struct nls_table *nls_cp) 454 454 { 455 455 int rc; ··· 464 464 NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_TARGET_INFO | 465 465 NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | 466 466 NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC; 467 - if (ses->server->secMode & 467 + if (ses->server->sec_mode & 468 468 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 469 469 flags |= NTLMSSP_NEGOTIATE_SIGN; 470 - if (ses->server->secMode & SECMODE_SIGN_REQUIRED) 470 + if (ses->server->sec_mode & SECMODE_SIGN_REQUIRED) 471 471 flags |= NTLMSSP_NEGOTIATE_ALWAYS_SIGN; 472 472 473 473 tmp = pbuffer + sizeof(AUTHENTICATE_MESSAGE); ··· 551 551 } 552 552 553 553 int 554 - CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, 554 + CIFS_SessSetup(unsigned int xid, struct cifs_ses *ses, 555 555 const struct nls_table *nls_cp) 556 556 { 557 557 int rc = 0; ··· 657 657 */ 658 658 659 659 rc = calc_lanman_hash(ses->password, ses->server->cryptkey, 660 - ses->server->secMode & SECMODE_PW_ENCRYPT ? 660 + ses->server->sec_mode & SECMODE_PW_ENCRYPT ? 661 661 true : false, lnm_session_key); 662 662 663 663 ses->flags |= CIFS_SES_LANMAN;
+67 -147
fs/cifs/transport.c
··· 295 295 return 0; 296 296 } 297 297 298 - static int allocate_mid(struct cifsSesInfo *ses, struct smb_hdr *in_buf, 298 + static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf, 299 299 struct mid_q_entry **ppmidQ) 300 300 { 301 301 if (ses->server->tcpStatus == CifsExiting) { ··· 342 342 * the result. Caller is responsible for dealing with timeouts. 343 343 */ 344 344 int 345 - cifs_call_async(struct TCP_Server_Info *server, struct smb_hdr *in_buf, 346 - mid_callback_t *callback, void *cbdata) 345 + cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, 346 + unsigned int nvec, mid_callback_t *callback, void *cbdata, 347 + bool ignore_pend) 347 348 { 348 349 int rc; 349 350 struct mid_q_entry *mid; 351 + struct smb_hdr *hdr = (struct smb_hdr *)iov[0].iov_base; 350 352 351 - rc = wait_for_free_request(server, CIFS_ASYNC_OP); 353 + rc = wait_for_free_request(server, ignore_pend ? CIFS_ASYNC_OP : 0); 352 354 if (rc) 353 355 return rc; 354 356 355 357 /* enable signing if server requires it */ 356 - if (server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 357 - in_buf->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 358 + if (server->sec_mode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 359 + hdr->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 358 360 359 361 mutex_lock(&server->srv_mutex); 360 - mid = AllocMidQEntry(in_buf, server); 362 + mid = AllocMidQEntry(hdr, server); 361 363 if (mid == NULL) { 362 364 mutex_unlock(&server->srv_mutex); 363 365 return -ENOMEM; ··· 370 368 list_add_tail(&mid->qhead, &server->pending_mid_q); 371 369 spin_unlock(&GlobalMid_Lock); 372 370 373 - rc = cifs_sign_smb(in_buf, server, &mid->sequence_number); 371 + rc = cifs_sign_smb2(iov, nvec, server, &mid->sequence_number); 374 372 if (rc) { 375 373 mutex_unlock(&server->srv_mutex); 376 374 goto out_err; ··· 382 380 #ifdef CONFIG_CIFS_STATS2 383 381 atomic_inc(&server->inSend); 384 382 #endif 385 - rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); 383 + rc = smb_sendv(server, iov, nvec); 386 384 #ifdef CONFIG_CIFS_STATS2 387 385 atomic_dec(&server->inSend); 388 386 mid->when_sent = jiffies; ··· 409 407 * 410 408 */ 411 409 int 412 - SendReceiveNoRsp(const unsigned int xid, struct cifsSesInfo *ses, 410 + SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses, 413 411 struct smb_hdr *in_buf, int flags) 414 412 { 415 413 int rc; ··· 426 424 } 427 425 428 426 static int 429 - sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server) 427 + cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server) 430 428 { 431 429 int rc = 0; 432 430 ··· 434 432 mid->mid, mid->midState); 435 433 436 434 spin_lock(&GlobalMid_Lock); 437 - /* ensure that it's no longer on the pending_mid_q */ 438 - list_del_init(&mid->qhead); 439 - 440 435 switch (mid->midState) { 441 436 case MID_RESPONSE_RECEIVED: 442 437 spin_unlock(&GlobalMid_Lock); 443 438 return rc; 444 - case MID_REQUEST_SUBMITTED: 445 - /* socket is going down, reject all calls */ 446 - if (server->tcpStatus == CifsExiting) { 447 - cERROR(1, "%s: canceling mid=%d cmd=0x%x state=%d", 448 - __func__, mid->mid, mid->command, mid->midState); 449 - rc = -EHOSTDOWN; 450 - break; 451 - } 452 439 case MID_RETRY_NEEDED: 453 440 rc = -EAGAIN; 454 441 break; 455 442 case MID_RESPONSE_MALFORMED: 456 443 rc = -EIO; 457 444 break; 445 + case MID_SHUTDOWN: 446 + rc = -EHOSTDOWN; 447 + break; 458 448 default: 449 + list_del_init(&mid->qhead); 459 450 cERROR(1, "%s: invalid mid state mid=%d state=%d", __func__, 460 451 mid->mid, mid->midState); 461 452 rc = -EIO; ··· 497 502 } 498 503 499 504 int 500 - SendReceive2(const unsigned int xid, struct cifsSesInfo *ses, 505 + cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, 506 + bool log_error) 507 + { 508 + dump_smb(mid->resp_buf, 509 + min_t(u32, 92, be32_to_cpu(mid->resp_buf->smb_buf_length))); 510 + 511 + /* convert the length into a more usable form */ 512 + if (server->sec_mode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) { 513 + /* FIXME: add code to kill session */ 514 + if (cifs_verify_signature(mid->resp_buf, server, 515 + mid->sequence_number + 1) != 0) 516 + cERROR(1, "Unexpected SMB signature"); 517 + } 518 + 519 + /* BB special case reconnect tid and uid here? */ 520 + return map_smb_to_linux_error(mid->resp_buf, log_error); 521 + } 522 + 523 + int 524 + SendReceive2(const unsigned int xid, struct cifs_ses *ses, 501 525 struct kvec *iov, int n_vec, int *pRespBufType /* ret */, 502 526 const int flags) 503 527 { 504 528 int rc = 0; 505 529 int long_op; 506 - unsigned int receive_len; 507 530 struct mid_q_entry *midQ; 508 531 struct smb_hdr *in_buf = iov[0].iov_base; 509 532 ··· 611 598 612 599 cifs_small_buf_release(in_buf); 613 600 614 - rc = sync_mid_result(midQ, ses->server); 601 + rc = cifs_sync_mid_result(midQ, ses->server); 615 602 if (rc != 0) { 616 603 atomic_dec(&ses->server->inFlight); 617 604 wake_up(&ses->server->request_q); 618 605 return rc; 619 606 } 620 607 621 - receive_len = be32_to_cpu(midQ->resp_buf->smb_buf_length); 622 - 623 - if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { 624 - cERROR(1, "Frame too large received. Length: %d Xid: %d", 625 - receive_len, xid); 608 + if (!midQ->resp_buf || midQ->midState != MID_RESPONSE_RECEIVED) { 626 609 rc = -EIO; 610 + cFYI(1, "Bad MID state?"); 627 611 goto out; 628 612 } 629 613 630 - /* rcvd frame is ok */ 614 + iov[0].iov_base = (char *)midQ->resp_buf; 615 + iov[0].iov_len = be32_to_cpu(midQ->resp_buf->smb_buf_length) + 4; 616 + if (midQ->largeBuf) 617 + *pRespBufType = CIFS_LARGE_BUFFER; 618 + else 619 + *pRespBufType = CIFS_SMALL_BUFFER; 631 620 632 - if (midQ->resp_buf && 633 - (midQ->midState == MID_RESPONSE_RECEIVED)) { 621 + rc = cifs_check_receive(midQ, ses->server, flags & CIFS_LOG_ERROR); 634 622 635 - iov[0].iov_base = (char *)midQ->resp_buf; 636 - if (midQ->largeBuf) 637 - *pRespBufType = CIFS_LARGE_BUFFER; 638 - else 639 - *pRespBufType = CIFS_SMALL_BUFFER; 640 - iov[0].iov_len = receive_len + 4; 641 - 642 - dump_smb(midQ->resp_buf, 80); 643 - /* convert the length into a more usable form */ 644 - if ((receive_len > 24) && 645 - (ses->server->secMode & (SECMODE_SIGN_REQUIRED | 646 - SECMODE_SIGN_ENABLED))) { 647 - rc = cifs_verify_signature(midQ->resp_buf, 648 - ses->server, 649 - midQ->sequence_number+1); 650 - if (rc) { 651 - cERROR(1, "Unexpected SMB signature"); 652 - /* BB FIXME add code to kill session */ 653 - } 654 - } 655 - 656 - /* BB special case reconnect tid and uid here? */ 657 - rc = map_smb_to_linux_error(midQ->resp_buf, 658 - flags & CIFS_LOG_ERROR); 659 - 660 - if ((flags & CIFS_NO_RESP) == 0) 661 - midQ->resp_buf = NULL; /* mark it so buf will 662 - not be freed by 663 - delete_mid */ 664 - } else { 665 - rc = -EIO; 666 - cFYI(1, "Bad MID state?"); 667 - } 668 - 623 + /* mark it so buf will not be freed by delete_mid */ 624 + if ((flags & CIFS_NO_RESP) == 0) 625 + midQ->resp_buf = NULL; 669 626 out: 670 627 delete_mid(midQ); 671 628 atomic_dec(&ses->server->inFlight); ··· 645 662 } 646 663 647 664 int 648 - SendReceive(const unsigned int xid, struct cifsSesInfo *ses, 665 + SendReceive(const unsigned int xid, struct cifs_ses *ses, 649 666 struct smb_hdr *in_buf, struct smb_hdr *out_buf, 650 667 int *pbytes_returned, const int long_op) 651 668 { 652 669 int rc = 0; 653 - unsigned int receive_len; 654 670 struct mid_q_entry *midQ; 655 671 656 672 if (ses == NULL) { ··· 732 750 spin_unlock(&GlobalMid_Lock); 733 751 } 734 752 735 - rc = sync_mid_result(midQ, ses->server); 753 + rc = cifs_sync_mid_result(midQ, ses->server); 736 754 if (rc != 0) { 737 755 atomic_dec(&ses->server->inFlight); 738 756 wake_up(&ses->server->request_q); 739 757 return rc; 740 758 } 741 759 742 - receive_len = be32_to_cpu(midQ->resp_buf->smb_buf_length); 743 - 744 - if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { 745 - cERROR(1, "Frame too large received. Length: %d Xid: %d", 746 - receive_len, xid); 760 + if (!midQ->resp_buf || !out_buf || 761 + midQ->midState != MID_RESPONSE_RECEIVED) { 747 762 rc = -EIO; 763 + cERROR(1, "Bad MID state?"); 748 764 goto out; 749 765 } 750 766 751 - /* rcvd frame is ok */ 752 - 753 - if (midQ->resp_buf && out_buf 754 - && (midQ->midState == MID_RESPONSE_RECEIVED)) { 755 - out_buf->smb_buf_length = cpu_to_be32(receive_len); 756 - memcpy((char *)out_buf + 4, 757 - (char *)midQ->resp_buf + 4, 758 - receive_len); 759 - 760 - dump_smb(out_buf, 92); 761 - /* convert the length into a more usable form */ 762 - if ((receive_len > 24) && 763 - (ses->server->secMode & (SECMODE_SIGN_REQUIRED | 764 - SECMODE_SIGN_ENABLED))) { 765 - rc = cifs_verify_signature(out_buf, 766 - ses->server, 767 - midQ->sequence_number+1); 768 - if (rc) { 769 - cERROR(1, "Unexpected SMB signature"); 770 - /* BB FIXME add code to kill session */ 771 - } 772 - } 773 - 774 - *pbytes_returned = be32_to_cpu(out_buf->smb_buf_length); 775 - 776 - /* BB special case reconnect tid and uid here? */ 777 - rc = map_smb_to_linux_error(out_buf, 0 /* no log */ ); 778 - } else { 779 - rc = -EIO; 780 - cERROR(1, "Bad MID state?"); 781 - } 782 - 767 + *pbytes_returned = be32_to_cpu(midQ->resp_buf->smb_buf_length); 768 + memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); 769 + rc = cifs_check_receive(midQ, ses->server, 0); 783 770 out: 784 771 delete_mid(midQ); 785 772 atomic_dec(&ses->server->inFlight); ··· 761 810 blocking lock to return. */ 762 811 763 812 static int 764 - send_lock_cancel(const unsigned int xid, struct cifsTconInfo *tcon, 813 + send_lock_cancel(const unsigned int xid, struct cifs_tcon *tcon, 765 814 struct smb_hdr *in_buf, 766 815 struct smb_hdr *out_buf) 767 816 { 768 817 int bytes_returned; 769 - struct cifsSesInfo *ses = tcon->ses; 818 + struct cifs_ses *ses = tcon->ses; 770 819 LOCK_REQ *pSMB = (LOCK_REQ *)in_buf; 771 820 772 821 /* We just modify the current in_buf to change ··· 783 832 } 784 833 785 834 int 786 - SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon, 835 + SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, 787 836 struct smb_hdr *in_buf, struct smb_hdr *out_buf, 788 837 int *pbytes_returned) 789 838 { 790 839 int rc = 0; 791 840 int rstart = 0; 792 - unsigned int receive_len; 793 841 struct mid_q_entry *midQ; 794 - struct cifsSesInfo *ses; 842 + struct cifs_ses *ses; 795 843 796 844 if (tcon == NULL || tcon->ses == NULL) { 797 845 cERROR(1, "Null smb session"); ··· 907 957 rstart = 1; 908 958 } 909 959 910 - rc = sync_mid_result(midQ, ses->server); 960 + rc = cifs_sync_mid_result(midQ, ses->server); 911 961 if (rc != 0) 912 962 return rc; 913 963 914 - receive_len = be32_to_cpu(midQ->resp_buf->smb_buf_length); 915 - if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { 916 - cERROR(1, "Frame too large received. Length: %d Xid: %d", 917 - receive_len, xid); 918 - rc = -EIO; 919 - goto out; 920 - } 921 - 922 964 /* rcvd frame is ok */ 923 - 924 - if ((out_buf == NULL) || (midQ->midState != MID_RESPONSE_RECEIVED)) { 965 + if (out_buf == NULL || midQ->midState != MID_RESPONSE_RECEIVED) { 925 966 rc = -EIO; 926 967 cERROR(1, "Bad MID state?"); 927 968 goto out; 928 969 } 929 970 930 - out_buf->smb_buf_length = cpu_to_be32(receive_len); 931 - memcpy((char *)out_buf + 4, 932 - (char *)midQ->resp_buf + 4, 933 - receive_len); 934 - 935 - dump_smb(out_buf, 92); 936 - /* convert the length into a more usable form */ 937 - if ((receive_len > 24) && 938 - (ses->server->secMode & (SECMODE_SIGN_REQUIRED | 939 - SECMODE_SIGN_ENABLED))) { 940 - rc = cifs_verify_signature(out_buf, 941 - ses->server, 942 - midQ->sequence_number+1); 943 - if (rc) { 944 - cERROR(1, "Unexpected SMB signature"); 945 - /* BB FIXME add code to kill session */ 946 - } 947 - } 948 - 949 - *pbytes_returned = be32_to_cpu(out_buf->smb_buf_length); 950 - 951 - /* BB special case reconnect tid and uid here? */ 952 - rc = map_smb_to_linux_error(out_buf, 0 /* no log */ ); 953 - 971 + *pbytes_returned = be32_to_cpu(midQ->resp_buf->smb_buf_length); 972 + memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); 973 + rc = cifs_check_receive(midQ, ses->server, 0); 954 974 out: 955 975 delete_mid(midQ); 956 976 if (rstart && rc == -EACCES)
+4 -4
fs/cifs/xattr.c
··· 49 49 int xid; 50 50 struct cifs_sb_info *cifs_sb; 51 51 struct tcon_link *tlink; 52 - struct cifsTconInfo *pTcon; 52 + struct cifs_tcon *pTcon; 53 53 struct super_block *sb; 54 54 char *full_path = NULL; 55 55 ··· 109 109 int xid; 110 110 struct cifs_sb_info *cifs_sb; 111 111 struct tcon_link *tlink; 112 - struct cifsTconInfo *pTcon; 112 + struct cifs_tcon *pTcon; 113 113 struct super_block *sb; 114 114 char *full_path; 115 115 struct cifs_ntsd *pacl; ··· 240 240 int xid; 241 241 struct cifs_sb_info *cifs_sb; 242 242 struct tcon_link *tlink; 243 - struct cifsTconInfo *pTcon; 243 + struct cifs_tcon *pTcon; 244 244 struct super_block *sb; 245 245 char *full_path; 246 246 ··· 372 372 int xid; 373 373 struct cifs_sb_info *cifs_sb; 374 374 struct tcon_link *tlink; 375 - struct cifsTconInfo *pTcon; 375 + struct cifs_tcon *pTcon; 376 376 struct super_block *sb; 377 377 char *full_path; 378 378