misc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /*
  2. * fs/cifs/misc.c
  3. *
  4. * Copyright (C) International Business Machines Corp., 2002,2008
  5. * Author(s): Steve French (sfrench@us.ibm.com)
  6. *
  7. * This library is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published
  9. * by the Free Software Foundation; either version 2.1 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  15. * the GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/slab.h>
  22. #include <linux/ctype.h>
  23. #include <linux/mempool.h>
  24. #include "cifspdu.h"
  25. #include "cifsglob.h"
  26. #include "cifsproto.h"
  27. #include "cifs_debug.h"
  28. #include "smberr.h"
  29. #include "nterr.h"
  30. #include "cifs_unicode.h"
  31. #ifdef CONFIG_CIFS_SMB2
  32. #include "smb2pdu.h"
  33. #endif
  34. extern mempool_t *cifs_sm_req_poolp;
  35. extern mempool_t *cifs_req_poolp;
  36. /* The xid serves as a useful identifier for each incoming vfs request,
  37. in a similar way to the mid which is useful to track each sent smb,
  38. and CurrentXid can also provide a running counter (although it
  39. will eventually wrap past zero) of the total vfs operations handled
  40. since the cifs fs was mounted */
  41. unsigned int
  42. _get_xid(void)
  43. {
  44. unsigned int xid;
  45. spin_lock(&GlobalMid_Lock);
  46. GlobalTotalActiveXid++;
  47. /* keep high water mark for number of simultaneous ops in filesystem */
  48. if (GlobalTotalActiveXid > GlobalMaxActiveXid)
  49. GlobalMaxActiveXid = GlobalTotalActiveXid;
  50. if (GlobalTotalActiveXid > 65000)
  51. cFYI(1, "warning: more than 65000 requests active");
  52. xid = GlobalCurrentXid++;
  53. spin_unlock(&GlobalMid_Lock);
  54. return xid;
  55. }
  56. void
  57. _free_xid(unsigned int xid)
  58. {
  59. spin_lock(&GlobalMid_Lock);
  60. /* if (GlobalTotalActiveXid == 0)
  61. BUG(); */
  62. GlobalTotalActiveXid--;
  63. spin_unlock(&GlobalMid_Lock);
  64. }
  65. struct cifs_ses *
  66. sesInfoAlloc(void)
  67. {
  68. struct cifs_ses *ret_buf;
  69. ret_buf = kzalloc(sizeof(struct cifs_ses), GFP_KERNEL);
  70. if (ret_buf) {
  71. atomic_inc(&sesInfoAllocCount);
  72. ret_buf->status = CifsNew;
  73. ++ret_buf->ses_count;
  74. INIT_LIST_HEAD(&ret_buf->smb_ses_list);
  75. INIT_LIST_HEAD(&ret_buf->tcon_list);
  76. mutex_init(&ret_buf->session_mutex);
  77. }
  78. return ret_buf;
  79. }
  80. void
  81. sesInfoFree(struct cifs_ses *buf_to_free)
  82. {
  83. if (buf_to_free == NULL) {
  84. cFYI(1, "Null buffer passed to sesInfoFree");
  85. return;
  86. }
  87. atomic_dec(&sesInfoAllocCount);
  88. kfree(buf_to_free->serverOS);
  89. kfree(buf_to_free->serverDomain);
  90. kfree(buf_to_free->serverNOS);
  91. if (buf_to_free->password) {
  92. memset(buf_to_free->password, 0, strlen(buf_to_free->password));
  93. kfree(buf_to_free->password);
  94. }
  95. kfree(buf_to_free->user_name);
  96. kfree(buf_to_free->domainName);
  97. kfree(buf_to_free);
  98. }
  99. struct cifs_tcon *
  100. tconInfoAlloc(void)
  101. {
  102. struct cifs_tcon *ret_buf;
  103. ret_buf = kzalloc(sizeof(struct cifs_tcon), GFP_KERNEL);
  104. if (ret_buf) {
  105. atomic_inc(&tconInfoAllocCount);
  106. ret_buf->tidStatus = CifsNew;
  107. ++ret_buf->tc_count;
  108. INIT_LIST_HEAD(&ret_buf->openFileList);
  109. INIT_LIST_HEAD(&ret_buf->tcon_list);
  110. #ifdef CONFIG_CIFS_STATS
  111. spin_lock_init(&ret_buf->stat_lock);
  112. #endif
  113. }
  114. return ret_buf;
  115. }
  116. void
  117. tconInfoFree(struct cifs_tcon *buf_to_free)
  118. {
  119. if (buf_to_free == NULL) {
  120. cFYI(1, "Null buffer passed to tconInfoFree");
  121. return;
  122. }
  123. atomic_dec(&tconInfoAllocCount);
  124. kfree(buf_to_free->nativeFileSystem);
  125. if (buf_to_free->password) {
  126. memset(buf_to_free->password, 0, strlen(buf_to_free->password));
  127. kfree(buf_to_free->password);
  128. }
  129. kfree(buf_to_free);
  130. }
  131. struct smb_hdr *
  132. cifs_buf_get(void)
  133. {
  134. struct smb_hdr *ret_buf = NULL;
  135. size_t buf_size = sizeof(struct smb_hdr);
  136. #ifdef CONFIG_CIFS_SMB2
  137. /*
  138. * SMB2 header is bigger than CIFS one - no problems to clean some
  139. * more bytes for CIFS.
  140. */
  141. buf_size = sizeof(struct smb2_hdr);
  142. #endif
  143. /*
  144. * We could use negotiated size instead of max_msgsize -
  145. * but it may be more efficient to always alloc same size
  146. * albeit slightly larger than necessary and maxbuffersize
  147. * defaults to this and can not be bigger.
  148. */
  149. ret_buf = mempool_alloc(cifs_req_poolp, GFP_NOFS);
  150. /* clear the first few header bytes */
  151. /* for most paths, more is cleared in header_assemble */
  152. if (ret_buf) {
  153. memset(ret_buf, 0, buf_size + 3);
  154. atomic_inc(&bufAllocCount);
  155. #ifdef CONFIG_CIFS_STATS2
  156. atomic_inc(&totBufAllocCount);
  157. #endif /* CONFIG_CIFS_STATS2 */
  158. }
  159. return ret_buf;
  160. }
  161. void
  162. cifs_buf_release(void *buf_to_free)
  163. {
  164. if (buf_to_free == NULL) {
  165. /* cFYI(1, "Null buffer passed to cifs_buf_release");*/
  166. return;
  167. }
  168. mempool_free(buf_to_free, cifs_req_poolp);
  169. atomic_dec(&bufAllocCount);
  170. return;
  171. }
  172. struct smb_hdr *
  173. cifs_small_buf_get(void)
  174. {
  175. struct smb_hdr *ret_buf = NULL;
  176. /* We could use negotiated size instead of max_msgsize -
  177. but it may be more efficient to always alloc same size
  178. albeit slightly larger than necessary and maxbuffersize
  179. defaults to this and can not be bigger */
  180. ret_buf = mempool_alloc(cifs_sm_req_poolp, GFP_NOFS);
  181. if (ret_buf) {
  182. /* No need to clear memory here, cleared in header assemble */
  183. /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
  184. atomic_inc(&smBufAllocCount);
  185. #ifdef CONFIG_CIFS_STATS2
  186. atomic_inc(&totSmBufAllocCount);
  187. #endif /* CONFIG_CIFS_STATS2 */
  188. }
  189. return ret_buf;
  190. }
  191. void
  192. cifs_small_buf_release(void *buf_to_free)
  193. {
  194. if (buf_to_free == NULL) {
  195. cFYI(1, "Null buffer passed to cifs_small_buf_release");
  196. return;
  197. }
  198. mempool_free(buf_to_free, cifs_sm_req_poolp);
  199. atomic_dec(&smBufAllocCount);
  200. return;
  201. }
  202. /* NB: MID can not be set if treeCon not passed in, in that
  203. case it is responsbility of caller to set the mid */
  204. void
  205. header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
  206. const struct cifs_tcon *treeCon, int word_count
  207. /* length of fixed section (word count) in two byte units */)
  208. {
  209. char *temp = (char *) buffer;
  210. memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */
  211. buffer->smb_buf_length = cpu_to_be32(
  212. (2 * word_count) + sizeof(struct smb_hdr) -
  213. 4 /* RFC 1001 length field does not count */ +
  214. 2 /* for bcc field itself */) ;
  215. buffer->Protocol[0] = 0xFF;
  216. buffer->Protocol[1] = 'S';
  217. buffer->Protocol[2] = 'M';
  218. buffer->Protocol[3] = 'B';
  219. buffer->Command = smb_command;
  220. buffer->Flags = 0x00; /* case sensitive */
  221. buffer->Flags2 = SMBFLG2_KNOWS_LONG_NAMES;
  222. buffer->Pid = cpu_to_le16((__u16)current->tgid);
  223. buffer->PidHigh = cpu_to_le16((__u16)(current->tgid >> 16));
  224. if (treeCon) {
  225. buffer->Tid = treeCon->tid;
  226. if (treeCon->ses) {
  227. if (treeCon->ses->capabilities & CAP_UNICODE)
  228. buffer->Flags2 |= SMBFLG2_UNICODE;
  229. if (treeCon->ses->capabilities & CAP_STATUS32)
  230. buffer->Flags2 |= SMBFLG2_ERR_STATUS;
  231. /* Uid is not converted */
  232. buffer->Uid = treeCon->ses->Suid;
  233. buffer->Mid = get_next_mid(treeCon->ses->server);
  234. }
  235. if (treeCon->Flags & SMB_SHARE_IS_IN_DFS)
  236. buffer->Flags2 |= SMBFLG2_DFS;
  237. if (treeCon->nocase)
  238. buffer->Flags |= SMBFLG_CASELESS;
  239. if ((treeCon->ses) && (treeCon->ses->server))
  240. if (treeCon->ses->server->sec_mode &
  241. (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
  242. buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
  243. }
  244. /* endian conversion of flags is now done just before sending */
  245. buffer->WordCount = (char) word_count;
  246. return;
  247. }
  248. static int
  249. check_smb_hdr(struct smb_hdr *smb, __u16 mid)
  250. {
  251. /* does it have the right SMB "signature" ? */
  252. if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff)) {
  253. cERROR(1, "Bad protocol string signature header 0x%x",
  254. *(unsigned int *)smb->Protocol);
  255. return 1;
  256. }
  257. /* Make sure that message ids match */
  258. if (mid != smb->Mid) {
  259. cERROR(1, "Mids do not match. received=%u expected=%u",
  260. smb->Mid, mid);
  261. return 1;
  262. }
  263. /* if it's a response then accept */
  264. if (smb->Flags & SMBFLG_RESPONSE)
  265. return 0;
  266. /* only one valid case where server sends us request */
  267. if (smb->Command == SMB_COM_LOCKING_ANDX)
  268. return 0;
  269. cERROR(1, "Server sent request, not response. mid=%u", smb->Mid);
  270. return 1;
  271. }
  272. int
  273. checkSMB(char *buf, unsigned int total_read)
  274. {
  275. struct smb_hdr *smb = (struct smb_hdr *)buf;
  276. __u16 mid = smb->Mid;
  277. __u32 rfclen = be32_to_cpu(smb->smb_buf_length);
  278. __u32 clc_len; /* calculated length */
  279. cFYI(0, "checkSMB Length: 0x%x, smb_buf_length: 0x%x",
  280. total_read, rfclen);
  281. /* is this frame too small to even get to a BCC? */
  282. if (total_read < 2 + sizeof(struct smb_hdr)) {
  283. if ((total_read >= sizeof(struct smb_hdr) - 1)
  284. && (smb->Status.CifsError != 0)) {
  285. /* it's an error return */
  286. smb->WordCount = 0;
  287. /* some error cases do not return wct and bcc */
  288. return 0;
  289. } else if ((total_read == sizeof(struct smb_hdr) + 1) &&
  290. (smb->WordCount == 0)) {
  291. char *tmp = (char *)smb;
  292. /* Need to work around a bug in two servers here */
  293. /* First, check if the part of bcc they sent was zero */
  294. if (tmp[sizeof(struct smb_hdr)] == 0) {
  295. /* some servers return only half of bcc
  296. * on simple responses (wct, bcc both zero)
  297. * in particular have seen this on
  298. * ulogoffX and FindClose. This leaves
  299. * one byte of bcc potentially unitialized
  300. */
  301. /* zero rest of bcc */
  302. tmp[sizeof(struct smb_hdr)+1] = 0;
  303. return 0;
  304. }
  305. cERROR(1, "rcvd invalid byte count (bcc)");
  306. } else {
  307. cERROR(1, "Length less than smb header size");
  308. }
  309. return -EIO;
  310. }
  311. /* otherwise, there is enough to get to the BCC */
  312. if (check_smb_hdr(smb, mid))
  313. return -EIO;
  314. clc_len = smbCalcSize(smb);
  315. if (4 + rfclen != total_read) {
  316. cERROR(1, "Length read does not match RFC1001 length %d",
  317. rfclen);
  318. return -EIO;
  319. }
  320. if (4 + rfclen != clc_len) {
  321. /* check if bcc wrapped around for large read responses */
  322. if ((rfclen > 64 * 1024) && (rfclen > clc_len)) {
  323. /* check if lengths match mod 64K */
  324. if (((4 + rfclen) & 0xFFFF) == (clc_len & 0xFFFF))
  325. return 0; /* bcc wrapped */
  326. }
  327. cFYI(1, "Calculated size %u vs length %u mismatch for mid=%u",
  328. clc_len, 4 + rfclen, smb->Mid);
  329. if (4 + rfclen < clc_len) {
  330. cERROR(1, "RFC1001 size %u smaller than SMB for mid=%u",
  331. rfclen, smb->Mid);
  332. return -EIO;
  333. } else if (rfclen > clc_len + 512) {
  334. /*
  335. * Some servers (Windows XP in particular) send more
  336. * data than the lengths in the SMB packet would
  337. * indicate on certain calls (byte range locks and
  338. * trans2 find first calls in particular). While the
  339. * client can handle such a frame by ignoring the
  340. * trailing data, we choose limit the amount of extra
  341. * data to 512 bytes.
  342. */
  343. cERROR(1, "RFC1001 size %u more than 512 bytes larger "
  344. "than SMB for mid=%u", rfclen, smb->Mid);
  345. return -EIO;
  346. }
  347. }
  348. return 0;
  349. }
  350. bool
  351. is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv)
  352. {
  353. struct smb_hdr *buf = (struct smb_hdr *)buffer;
  354. struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf;
  355. struct list_head *tmp, *tmp1, *tmp2;
  356. struct cifs_ses *ses;
  357. struct cifs_tcon *tcon;
  358. struct cifsInodeInfo *pCifsInode;
  359. struct cifsFileInfo *netfile;
  360. cFYI(1, "Checking for oplock break or dnotify response");
  361. if ((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) &&
  362. (pSMB->hdr.Flags & SMBFLG_RESPONSE)) {
  363. struct smb_com_transaction_change_notify_rsp *pSMBr =
  364. (struct smb_com_transaction_change_notify_rsp *)buf;
  365. struct file_notify_information *pnotify;
  366. __u32 data_offset = 0;
  367. if (get_bcc(buf) > sizeof(struct file_notify_information)) {
  368. data_offset = le32_to_cpu(pSMBr->DataOffset);
  369. pnotify = (struct file_notify_information *)
  370. ((char *)&pSMBr->hdr.Protocol + data_offset);
  371. cFYI(1, "dnotify on %s Action: 0x%x",
  372. pnotify->FileName, pnotify->Action);
  373. /* cifs_dump_mem("Rcvd notify Data: ",buf,
  374. sizeof(struct smb_hdr)+60); */
  375. return true;
  376. }
  377. if (pSMBr->hdr.Status.CifsError) {
  378. cFYI(1, "notify err 0x%d",
  379. pSMBr->hdr.Status.CifsError);
  380. return true;
  381. }
  382. return false;
  383. }
  384. if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX)
  385. return false;
  386. if (pSMB->hdr.Flags & SMBFLG_RESPONSE) {
  387. /* no sense logging error on invalid handle on oplock
  388. break - harmless race between close request and oplock
  389. break response is expected from time to time writing out
  390. large dirty files cached on the client */
  391. if ((NT_STATUS_INVALID_HANDLE) ==
  392. le32_to_cpu(pSMB->hdr.Status.CifsError)) {
  393. cFYI(1, "invalid handle on oplock break");
  394. return true;
  395. } else if (ERRbadfid ==
  396. le16_to_cpu(pSMB->hdr.Status.DosError.Error)) {
  397. return true;
  398. } else {
  399. return false; /* on valid oplock brk we get "request" */
  400. }
  401. }
  402. if (pSMB->hdr.WordCount != 8)
  403. return false;
  404. cFYI(1, "oplock type 0x%d level 0x%d",
  405. pSMB->LockType, pSMB->OplockLevel);
  406. if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE))
  407. return false;
  408. /* look up tcon based on tid & uid */
  409. spin_lock(&cifs_tcp_ses_lock);
  410. list_for_each(tmp, &srv->smb_ses_list) {
  411. ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
  412. list_for_each(tmp1, &ses->tcon_list) {
  413. tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
  414. if (tcon->tid != buf->Tid)
  415. continue;
  416. cifs_stats_inc(&tcon->stats.cifs_stats.num_oplock_brks);
  417. spin_lock(&cifs_file_list_lock);
  418. list_for_each(tmp2, &tcon->openFileList) {
  419. netfile = list_entry(tmp2, struct cifsFileInfo,
  420. tlist);
  421. if (pSMB->Fid != netfile->fid.netfid)
  422. continue;
  423. cFYI(1, "file id match, oplock break");
  424. pCifsInode = CIFS_I(netfile->dentry->d_inode);
  425. cifs_set_oplock_level(pCifsInode,
  426. pSMB->OplockLevel ? OPLOCK_READ : 0);
  427. queue_work(cifsiod_wq,
  428. &netfile->oplock_break);
  429. netfile->oplock_break_cancelled = false;
  430. spin_unlock(&cifs_file_list_lock);
  431. spin_unlock(&cifs_tcp_ses_lock);
  432. return true;
  433. }
  434. spin_unlock(&cifs_file_list_lock);
  435. spin_unlock(&cifs_tcp_ses_lock);
  436. cFYI(1, "No matching file for oplock break");
  437. return true;
  438. }
  439. }
  440. spin_unlock(&cifs_tcp_ses_lock);
  441. cFYI(1, "Can not process oplock break for non-existent connection");
  442. return true;
  443. }
  444. void
  445. dump_smb(void *buf, int smb_buf_length)
  446. {
  447. int i, j;
  448. char debug_line[17];
  449. unsigned char *buffer = buf;
  450. if (traceSMB == 0)
  451. return;
  452. for (i = 0, j = 0; i < smb_buf_length; i++, j++) {
  453. if (i % 8 == 0) {
  454. /* have reached the beginning of line */
  455. printk(KERN_DEBUG "| ");
  456. j = 0;
  457. }
  458. printk("%0#4x ", buffer[i]);
  459. debug_line[2 * j] = ' ';
  460. if (isprint(buffer[i]))
  461. debug_line[1 + (2 * j)] = buffer[i];
  462. else
  463. debug_line[1 + (2 * j)] = '_';
  464. if (i % 8 == 7) {
  465. /* reached end of line, time to print ascii */
  466. debug_line[16] = 0;
  467. printk(" | %s\n", debug_line);
  468. }
  469. }
  470. for (; j < 8; j++) {
  471. printk(" ");
  472. debug_line[2 * j] = ' ';
  473. debug_line[1 + (2 * j)] = ' ';
  474. }
  475. printk(" | %s\n", debug_line);
  476. return;
  477. }
  478. void
  479. cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)
  480. {
  481. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
  482. cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
  483. cERROR(1, "Autodisabling the use of server inode numbers on "
  484. "%s. This server doesn't seem to support them "
  485. "properly. Hardlinks will not be recognized on this "
  486. "mount. Consider mounting with the \"noserverino\" "
  487. "option to silence this message.",
  488. cifs_sb_master_tcon(cifs_sb)->treeName);
  489. }
  490. }
  491. void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)
  492. {
  493. oplock &= 0xF;
  494. if (oplock == OPLOCK_EXCLUSIVE) {
  495. cinode->clientCanCacheAll = true;
  496. cinode->clientCanCacheRead = true;
  497. cFYI(1, "Exclusive Oplock granted on inode %p",
  498. &cinode->vfs_inode);
  499. } else if (oplock == OPLOCK_READ) {
  500. cinode->clientCanCacheAll = false;
  501. cinode->clientCanCacheRead = true;
  502. cFYI(1, "Level II Oplock granted on inode %p",
  503. &cinode->vfs_inode);
  504. } else {
  505. cinode->clientCanCacheAll = false;
  506. cinode->clientCanCacheRead = false;
  507. }
  508. }
  509. bool
  510. backup_cred(struct cifs_sb_info *cifs_sb)
  511. {
  512. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID) {
  513. if (uid_eq(cifs_sb->mnt_backupuid, current_fsuid()))
  514. return true;
  515. }
  516. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID) {
  517. if (in_group_p(cifs_sb->mnt_backupgid))
  518. return true;
  519. }
  520. return false;
  521. }
  522. void
  523. cifs_del_pending_open(struct cifs_pending_open *open)
  524. {
  525. spin_lock(&cifs_file_list_lock);
  526. list_del(&open->olist);
  527. spin_unlock(&cifs_file_list_lock);
  528. }
  529. void
  530. cifs_add_pending_open_locked(struct cifs_fid *fid, struct tcon_link *tlink,
  531. struct cifs_pending_open *open)
  532. {
  533. #ifdef CONFIG_CIFS_SMB2
  534. memcpy(open->lease_key, fid->lease_key, SMB2_LEASE_KEY_SIZE);
  535. #endif
  536. open->oplock = CIFS_OPLOCK_NO_CHANGE;
  537. open->tlink = tlink;
  538. fid->pending_open = open;
  539. list_add_tail(&open->olist, &tlink_tcon(tlink)->pending_opens);
  540. }
  541. void
  542. cifs_add_pending_open(struct cifs_fid *fid, struct tcon_link *tlink,
  543. struct cifs_pending_open *open)
  544. {
  545. spin_lock(&cifs_file_list_lock);
  546. cifs_add_pending_open_locked(fid, tlink, open);
  547. spin_unlock(&cifs_file_list_lock);
  548. }