smb2ops.c 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042
  1. /*
  2. * SMB2 version specific operations
  3. *
  4. * Copyright (c) 2012, Jeff Layton <[email protected]>
  5. *
  6. * This library is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License v2 as published
  8. * by the Free Software Foundation.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13. * the GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/pagemap.h>
  20. #include <linux/vfs.h>
  21. #include <linux/falloc.h>
  22. #include "cifsglob.h"
  23. #include "smb2pdu.h"
  24. #include "smb2proto.h"
  25. #include "cifsproto.h"
  26. #include "cifs_debug.h"
  27. #include "cifs_unicode.h"
  28. #include "smb2status.h"
  29. #include "smb2glob.h"
  30. #include "cifs_ioctl.h"
  31. static int
  32. change_conf(struct TCP_Server_Info *server)
  33. {
  34. server->credits += server->echo_credits + server->oplock_credits;
  35. server->oplock_credits = server->echo_credits = 0;
  36. switch (server->credits) {
  37. case 0:
  38. return -1;
  39. case 1:
  40. server->echoes = false;
  41. server->oplocks = false;
  42. cifs_dbg(VFS, "disabling echoes and oplocks\n");
  43. break;
  44. case 2:
  45. server->echoes = true;
  46. server->oplocks = false;
  47. server->echo_credits = 1;
  48. cifs_dbg(FYI, "disabling oplocks\n");
  49. break;
  50. default:
  51. server->echoes = true;
  52. if (enable_oplocks) {
  53. server->oplocks = true;
  54. server->oplock_credits = 1;
  55. } else
  56. server->oplocks = false;
  57. server->echo_credits = 1;
  58. }
  59. server->credits -= server->echo_credits + server->oplock_credits;
  60. return 0;
  61. }
  62. static void
  63. smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add,
  64. const int optype)
  65. {
  66. int *val, rc = 0;
  67. spin_lock(&server->req_lock);
  68. val = server->ops->get_credits_field(server, optype);
  69. *val += add;
  70. if (*val > 65000) {
  71. *val = 65000; /* Don't get near 64K credits, avoid srv bugs */
  72. printk_once(KERN_WARNING "server overflowed SMB3 credits\n");
  73. }
  74. server->in_flight--;
  75. if (server->in_flight == 0 && (optype & CIFS_OP_MASK) != CIFS_NEG_OP)
  76. rc = change_conf(server);
  77. /*
  78. * Sometimes server returns 0 credits on oplock break ack - we need to
  79. * rebalance credits in this case.
  80. */
  81. else if (server->in_flight > 0 && server->oplock_credits == 0 &&
  82. server->oplocks) {
  83. if (server->credits > 1) {
  84. server->credits--;
  85. server->oplock_credits++;
  86. }
  87. }
  88. spin_unlock(&server->req_lock);
  89. wake_up(&server->request_q);
  90. if (rc)
  91. cifs_reconnect(server);
  92. }
  93. static void
  94. smb2_set_credits(struct TCP_Server_Info *server, const int val)
  95. {
  96. spin_lock(&server->req_lock);
  97. server->credits = val;
  98. spin_unlock(&server->req_lock);
  99. }
  100. static int *
  101. smb2_get_credits_field(struct TCP_Server_Info *server, const int optype)
  102. {
  103. switch (optype) {
  104. case CIFS_ECHO_OP:
  105. return &server->echo_credits;
  106. case CIFS_OBREAK_OP:
  107. return &server->oplock_credits;
  108. default:
  109. return &server->credits;
  110. }
  111. }
  112. static unsigned int
  113. smb2_get_credits(struct mid_q_entry *mid)
  114. {
  115. return le16_to_cpu(((struct smb2_hdr *)mid->resp_buf)->CreditRequest);
  116. }
  117. static int
  118. smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,
  119. unsigned int *num, unsigned int *credits)
  120. {
  121. int rc = 0;
  122. unsigned int scredits;
  123. spin_lock(&server->req_lock);
  124. while (1) {
  125. if (server->credits <= 0) {
  126. spin_unlock(&server->req_lock);
  127. cifs_num_waiters_inc(server);
  128. rc = wait_event_killable(server->request_q,
  129. has_credits(server, &server->credits));
  130. cifs_num_waiters_dec(server);
  131. if (rc)
  132. return rc;
  133. spin_lock(&server->req_lock);
  134. } else {
  135. if (server->tcpStatus == CifsExiting) {
  136. spin_unlock(&server->req_lock);
  137. return -ENOENT;
  138. }
  139. scredits = server->credits;
  140. /* can deadlock with reopen */
  141. if (scredits <= 8) {
  142. *num = SMB2_MAX_BUFFER_SIZE;
  143. *credits = 0;
  144. break;
  145. }
  146. /* leave some credits for reopen and other ops */
  147. scredits -= 8;
  148. *num = min_t(unsigned int, size,
  149. scredits * SMB2_MAX_BUFFER_SIZE);
  150. *credits = DIV_ROUND_UP(*num, SMB2_MAX_BUFFER_SIZE);
  151. server->credits -= *credits;
  152. server->in_flight++;
  153. break;
  154. }
  155. }
  156. spin_unlock(&server->req_lock);
  157. return rc;
  158. }
  159. static __u64
  160. smb2_get_next_mid(struct TCP_Server_Info *server)
  161. {
  162. __u64 mid;
  163. /* for SMB2 we need the current value */
  164. spin_lock(&GlobalMid_Lock);
  165. mid = server->CurrentMid++;
  166. spin_unlock(&GlobalMid_Lock);
  167. return mid;
  168. }
  169. static struct mid_q_entry *
  170. smb2_find_mid(struct TCP_Server_Info *server, char *buf)
  171. {
  172. struct mid_q_entry *mid;
  173. struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
  174. __u64 wire_mid = le64_to_cpu(hdr->MessageId);
  175. if (hdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) {
  176. cifs_dbg(VFS, "encrypted frame parsing not supported yet");
  177. return NULL;
  178. }
  179. spin_lock(&GlobalMid_Lock);
  180. list_for_each_entry(mid, &server->pending_mid_q, qhead) {
  181. if ((mid->mid == wire_mid) &&
  182. (mid->mid_state == MID_REQUEST_SUBMITTED) &&
  183. (mid->command == hdr->Command)) {
  184. spin_unlock(&GlobalMid_Lock);
  185. return mid;
  186. }
  187. }
  188. spin_unlock(&GlobalMid_Lock);
  189. return NULL;
  190. }
  191. static void
  192. smb2_dump_detail(void *buf)
  193. {
  194. #ifdef CONFIG_CIFS_DEBUG2
  195. struct smb2_hdr *smb = (struct smb2_hdr *)buf;
  196. cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n",
  197. smb->Command, smb->Status, smb->Flags, smb->MessageId,
  198. smb->ProcessId);
  199. cifs_dbg(VFS, "smb buf %p len %u\n", smb, smb2_calc_size(smb));
  200. #endif
  201. }
  202. static bool
  203. smb2_need_neg(struct TCP_Server_Info *server)
  204. {
  205. return server->max_read == 0;
  206. }
  207. static int
  208. smb2_negotiate(const unsigned int xid, struct cifs_ses *ses)
  209. {
  210. int rc;
  211. ses->server->CurrentMid = 0;
  212. rc = SMB2_negotiate(xid, ses);
  213. /* BB we probably don't need to retry with modern servers */
  214. if (rc == -EAGAIN)
  215. rc = -EHOSTDOWN;
  216. return rc;
  217. }
  218. static unsigned int
  219. smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
  220. {
  221. struct TCP_Server_Info *server = tcon->ses->server;
  222. unsigned int wsize;
  223. /* start with specified wsize, or default */
  224. wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
  225. wsize = min_t(unsigned int, wsize, server->max_write);
  226. if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
  227. wsize = min_t(unsigned int, wsize, SMB2_MAX_BUFFER_SIZE);
  228. return wsize;
  229. }
  230. static unsigned int
  231. smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
  232. {
  233. struct TCP_Server_Info *server = tcon->ses->server;
  234. unsigned int rsize;
  235. /* start with specified rsize, or default */
  236. rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
  237. rsize = min_t(unsigned int, rsize, server->max_read);
  238. if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
  239. rsize = min_t(unsigned int, rsize, SMB2_MAX_BUFFER_SIZE);
  240. return rsize;
  241. }
  242. #ifdef CONFIG_CIFS_STATS2
  243. static int
  244. SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
  245. {
  246. int rc;
  247. unsigned int ret_data_len = 0;
  248. struct network_interface_info_ioctl_rsp *out_buf;
  249. rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
  250. FSCTL_QUERY_NETWORK_INTERFACE_INFO, true /* is_fsctl */,
  251. NULL /* no data input */, 0 /* no data input */,
  252. (char **)&out_buf, &ret_data_len);
  253. if (rc != 0)
  254. cifs_dbg(VFS, "error %d on ioctl to get interface list\n", rc);
  255. else if (ret_data_len < sizeof(struct network_interface_info_ioctl_rsp)) {
  256. cifs_dbg(VFS, "server returned bad net interface info buf\n");
  257. rc = -EINVAL;
  258. } else {
  259. /* Dump info on first interface */
  260. cifs_dbg(FYI, "Adapter Capability 0x%x\t",
  261. le32_to_cpu(out_buf->Capability));
  262. cifs_dbg(FYI, "Link Speed %lld\n",
  263. le64_to_cpu(out_buf->LinkSpeed));
  264. }
  265. kfree(out_buf);
  266. return rc;
  267. }
  268. #endif /* STATS2 */
  269. static void
  270. smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
  271. {
  272. int rc;
  273. __le16 srch_path = 0; /* Null - open root of share */
  274. u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
  275. struct cifs_open_parms oparms;
  276. struct cifs_fid fid;
  277. oparms.tcon = tcon;
  278. oparms.desired_access = FILE_READ_ATTRIBUTES;
  279. oparms.disposition = FILE_OPEN;
  280. oparms.create_options = 0;
  281. oparms.fid = &fid;
  282. oparms.reconnect = false;
  283. rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
  284. if (rc)
  285. return;
  286. #ifdef CONFIG_CIFS_STATS2
  287. SMB3_request_interfaces(xid, tcon);
  288. #endif /* STATS2 */
  289. SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
  290. FS_ATTRIBUTE_INFORMATION);
  291. SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
  292. FS_DEVICE_INFORMATION);
  293. SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
  294. FS_SECTOR_SIZE_INFORMATION); /* SMB3 specific */
  295. SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
  296. return;
  297. }
  298. static void
  299. smb2_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
  300. {
  301. int rc;
  302. __le16 srch_path = 0; /* Null - open root of share */
  303. u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
  304. struct cifs_open_parms oparms;
  305. struct cifs_fid fid;
  306. oparms.tcon = tcon;
  307. oparms.desired_access = FILE_READ_ATTRIBUTES;
  308. oparms.disposition = FILE_OPEN;
  309. oparms.create_options = 0;
  310. oparms.fid = &fid;
  311. oparms.reconnect = false;
  312. rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
  313. if (rc)
  314. return;
  315. SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
  316. FS_ATTRIBUTE_INFORMATION);
  317. SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
  318. FS_DEVICE_INFORMATION);
  319. SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
  320. return;
  321. }
  322. static int
  323. smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
  324. struct cifs_sb_info *cifs_sb, const char *full_path)
  325. {
  326. int rc;
  327. __le16 *utf16_path;
  328. __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
  329. struct cifs_open_parms oparms;
  330. struct cifs_fid fid;
  331. utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
  332. if (!utf16_path)
  333. return -ENOMEM;
  334. oparms.tcon = tcon;
  335. oparms.desired_access = FILE_READ_ATTRIBUTES;
  336. oparms.disposition = FILE_OPEN;
  337. oparms.create_options = 0;
  338. oparms.fid = &fid;
  339. oparms.reconnect = false;
  340. rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
  341. if (rc) {
  342. kfree(utf16_path);
  343. return rc;
  344. }
  345. rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
  346. kfree(utf16_path);
  347. return rc;
  348. }
  349. static int
  350. smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
  351. struct cifs_sb_info *cifs_sb, const char *full_path,
  352. u64 *uniqueid, FILE_ALL_INFO *data)
  353. {
  354. *uniqueid = le64_to_cpu(data->IndexNumber);
  355. return 0;
  356. }
  357. static int
  358. smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
  359. struct cifs_fid *fid, FILE_ALL_INFO *data)
  360. {
  361. int rc;
  362. struct smb2_file_all_info *smb2_data;
  363. smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
  364. GFP_KERNEL);
  365. if (smb2_data == NULL)
  366. return -ENOMEM;
  367. rc = SMB2_query_info(xid, tcon, fid->persistent_fid, fid->volatile_fid,
  368. smb2_data);
  369. if (!rc)
  370. move_smb2_info_to_cifs(data, smb2_data);
  371. kfree(smb2_data);
  372. return rc;
  373. }
  374. static bool
  375. smb2_can_echo(struct TCP_Server_Info *server)
  376. {
  377. return server->echoes;
  378. }
  379. static void
  380. smb2_clear_stats(struct cifs_tcon *tcon)
  381. {
  382. #ifdef CONFIG_CIFS_STATS
  383. int i;
  384. for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
  385. atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
  386. atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
  387. }
  388. #endif
  389. }
  390. static void
  391. smb2_dump_share_caps(struct seq_file *m, struct cifs_tcon *tcon)
  392. {
  393. seq_puts(m, "\n\tShare Capabilities:");
  394. if (tcon->capabilities & SMB2_SHARE_CAP_DFS)
  395. seq_puts(m, " DFS,");
  396. if (tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
  397. seq_puts(m, " CONTINUOUS AVAILABILITY,");
  398. if (tcon->capabilities & SMB2_SHARE_CAP_SCALEOUT)
  399. seq_puts(m, " SCALEOUT,");
  400. if (tcon->capabilities & SMB2_SHARE_CAP_CLUSTER)
  401. seq_puts(m, " CLUSTER,");
  402. if (tcon->capabilities & SMB2_SHARE_CAP_ASYMMETRIC)
  403. seq_puts(m, " ASYMMETRIC,");
  404. if (tcon->capabilities == 0)
  405. seq_puts(m, " None");
  406. if (tcon->ss_flags & SSINFO_FLAGS_ALIGNED_DEVICE)
  407. seq_puts(m, " Aligned,");
  408. if (tcon->ss_flags & SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE)
  409. seq_puts(m, " Partition Aligned,");
  410. if (tcon->ss_flags & SSINFO_FLAGS_NO_SEEK_PENALTY)
  411. seq_puts(m, " SSD,");
  412. if (tcon->ss_flags & SSINFO_FLAGS_TRIM_ENABLED)
  413. seq_puts(m, " TRIM-support,");
  414. seq_printf(m, "\tShare Flags: 0x%x", tcon->share_flags);
  415. if (tcon->perf_sector_size)
  416. seq_printf(m, "\tOptimal sector size: 0x%x",
  417. tcon->perf_sector_size);
  418. }
  419. static void
  420. smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
  421. {
  422. #ifdef CONFIG_CIFS_STATS
  423. atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
  424. atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
  425. seq_printf(m, "\nNegotiates: %d sent %d failed",
  426. atomic_read(&sent[SMB2_NEGOTIATE_HE]),
  427. atomic_read(&failed[SMB2_NEGOTIATE_HE]));
  428. seq_printf(m, "\nSessionSetups: %d sent %d failed",
  429. atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
  430. atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
  431. seq_printf(m, "\nLogoffs: %d sent %d failed",
  432. atomic_read(&sent[SMB2_LOGOFF_HE]),
  433. atomic_read(&failed[SMB2_LOGOFF_HE]));
  434. seq_printf(m, "\nTreeConnects: %d sent %d failed",
  435. atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
  436. atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
  437. seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
  438. atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
  439. atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
  440. seq_printf(m, "\nCreates: %d sent %d failed",
  441. atomic_read(&sent[SMB2_CREATE_HE]),
  442. atomic_read(&failed[SMB2_CREATE_HE]));
  443. seq_printf(m, "\nCloses: %d sent %d failed",
  444. atomic_read(&sent[SMB2_CLOSE_HE]),
  445. atomic_read(&failed[SMB2_CLOSE_HE]));
  446. seq_printf(m, "\nFlushes: %d sent %d failed",
  447. atomic_read(&sent[SMB2_FLUSH_HE]),
  448. atomic_read(&failed[SMB2_FLUSH_HE]));
  449. seq_printf(m, "\nReads: %d sent %d failed",
  450. atomic_read(&sent[SMB2_READ_HE]),
  451. atomic_read(&failed[SMB2_READ_HE]));
  452. seq_printf(m, "\nWrites: %d sent %d failed",
  453. atomic_read(&sent[SMB2_WRITE_HE]),
  454. atomic_read(&failed[SMB2_WRITE_HE]));
  455. seq_printf(m, "\nLocks: %d sent %d failed",
  456. atomic_read(&sent[SMB2_LOCK_HE]),
  457. atomic_read(&failed[SMB2_LOCK_HE]));
  458. seq_printf(m, "\nIOCTLs: %d sent %d failed",
  459. atomic_read(&sent[SMB2_IOCTL_HE]),
  460. atomic_read(&failed[SMB2_IOCTL_HE]));
  461. seq_printf(m, "\nCancels: %d sent %d failed",
  462. atomic_read(&sent[SMB2_CANCEL_HE]),
  463. atomic_read(&failed[SMB2_CANCEL_HE]));
  464. seq_printf(m, "\nEchos: %d sent %d failed",
  465. atomic_read(&sent[SMB2_ECHO_HE]),
  466. atomic_read(&failed[SMB2_ECHO_HE]));
  467. seq_printf(m, "\nQueryDirectories: %d sent %d failed",
  468. atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
  469. atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
  470. seq_printf(m, "\nChangeNotifies: %d sent %d failed",
  471. atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
  472. atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
  473. seq_printf(m, "\nQueryInfos: %d sent %d failed",
  474. atomic_read(&sent[SMB2_QUERY_INFO_HE]),
  475. atomic_read(&failed[SMB2_QUERY_INFO_HE]));
  476. seq_printf(m, "\nSetInfos: %d sent %d failed",
  477. atomic_read(&sent[SMB2_SET_INFO_HE]),
  478. atomic_read(&failed[SMB2_SET_INFO_HE]));
  479. seq_printf(m, "\nOplockBreaks: %d sent %d failed",
  480. atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
  481. atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
  482. #endif
  483. }
  484. static void
  485. smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
  486. {
  487. struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
  488. struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
  489. cfile->fid.persistent_fid = fid->persistent_fid;
  490. cfile->fid.volatile_fid = fid->volatile_fid;
  491. server->ops->set_oplock_level(cinode, oplock, fid->epoch,
  492. &fid->purge_cache);
  493. cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode);
  494. memcpy(cfile->fid.create_guid, fid->create_guid, 16);
  495. }
  496. static void
  497. smb2_close_file(const unsigned int xid, struct cifs_tcon *tcon,
  498. struct cifs_fid *fid)
  499. {
  500. SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
  501. }
  502. static int
  503. SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
  504. u64 persistent_fid, u64 volatile_fid,
  505. struct copychunk_ioctl *pcchunk)
  506. {
  507. int rc;
  508. unsigned int ret_data_len;
  509. struct resume_key_req *res_key;
  510. rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid,
  511. FSCTL_SRV_REQUEST_RESUME_KEY, true /* is_fsctl */,
  512. NULL, 0 /* no input */,
  513. (char **)&res_key, &ret_data_len);
  514. if (rc) {
  515. cifs_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc);
  516. goto req_res_key_exit;
  517. }
  518. if (ret_data_len < sizeof(struct resume_key_req)) {
  519. cifs_dbg(VFS, "Invalid refcopy resume key length\n");
  520. rc = -EINVAL;
  521. goto req_res_key_exit;
  522. }
  523. memcpy(pcchunk->SourceKey, res_key->ResumeKey, COPY_CHUNK_RES_KEY_SIZE);
  524. req_res_key_exit:
  525. kfree(res_key);
  526. return rc;
  527. }
  528. static int
  529. smb2_clone_range(const unsigned int xid,
  530. struct cifsFileInfo *srcfile,
  531. struct cifsFileInfo *trgtfile, u64 src_off,
  532. u64 len, u64 dest_off)
  533. {
  534. int rc;
  535. unsigned int ret_data_len;
  536. struct copychunk_ioctl *pcchunk;
  537. struct copychunk_ioctl_rsp *retbuf = NULL;
  538. struct cifs_tcon *tcon;
  539. int chunks_copied = 0;
  540. bool chunk_sizes_updated = false;
  541. pcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL);
  542. if (pcchunk == NULL)
  543. return -ENOMEM;
  544. cifs_dbg(FYI, "in smb2_clone_range - about to call request res key\n");
  545. /* Request a key from the server to identify the source of the copy */
  546. rc = SMB2_request_res_key(xid, tlink_tcon(srcfile->tlink),
  547. srcfile->fid.persistent_fid,
  548. srcfile->fid.volatile_fid, pcchunk);
  549. /* Note: request_res_key sets res_key null only if rc !=0 */
  550. if (rc)
  551. goto cchunk_out;
  552. /* For now array only one chunk long, will make more flexible later */
  553. pcchunk->ChunkCount = cpu_to_le32(1);
  554. pcchunk->Reserved = 0;
  555. pcchunk->Reserved2 = 0;
  556. tcon = tlink_tcon(trgtfile->tlink);
  557. while (len > 0) {
  558. pcchunk->SourceOffset = cpu_to_le64(src_off);
  559. pcchunk->TargetOffset = cpu_to_le64(dest_off);
  560. pcchunk->Length =
  561. cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk));
  562. /* Request server copy to target from src identified by key */
  563. rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
  564. trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,
  565. true /* is_fsctl */, (char *)pcchunk,
  566. sizeof(struct copychunk_ioctl), (char **)&retbuf,
  567. &ret_data_len);
  568. if (rc == 0) {
  569. if (ret_data_len !=
  570. sizeof(struct copychunk_ioctl_rsp)) {
  571. cifs_dbg(VFS, "invalid cchunk response size\n");
  572. rc = -EIO;
  573. goto cchunk_out;
  574. }
  575. if (retbuf->TotalBytesWritten == 0) {
  576. cifs_dbg(FYI, "no bytes copied\n");
  577. rc = -EIO;
  578. goto cchunk_out;
  579. }
  580. /*
  581. * Check if server claimed to write more than we asked
  582. */
  583. if (le32_to_cpu(retbuf->TotalBytesWritten) >
  584. le32_to_cpu(pcchunk->Length)) {
  585. cifs_dbg(VFS, "invalid copy chunk response\n");
  586. rc = -EIO;
  587. goto cchunk_out;
  588. }
  589. if (le32_to_cpu(retbuf->ChunksWritten) != 1) {
  590. cifs_dbg(VFS, "invalid num chunks written\n");
  591. rc = -EIO;
  592. goto cchunk_out;
  593. }
  594. chunks_copied++;
  595. src_off += le32_to_cpu(retbuf->TotalBytesWritten);
  596. dest_off += le32_to_cpu(retbuf->TotalBytesWritten);
  597. len -= le32_to_cpu(retbuf->TotalBytesWritten);
  598. cifs_dbg(FYI, "Chunks %d PartialChunk %d Total %d\n",
  599. le32_to_cpu(retbuf->ChunksWritten),
  600. le32_to_cpu(retbuf->ChunkBytesWritten),
  601. le32_to_cpu(retbuf->TotalBytesWritten));
  602. } else if (rc == -EINVAL) {
  603. if (ret_data_len != sizeof(struct copychunk_ioctl_rsp))
  604. goto cchunk_out;
  605. cifs_dbg(FYI, "MaxChunks %d BytesChunk %d MaxCopy %d\n",
  606. le32_to_cpu(retbuf->ChunksWritten),
  607. le32_to_cpu(retbuf->ChunkBytesWritten),
  608. le32_to_cpu(retbuf->TotalBytesWritten));
  609. /*
  610. * Check if this is the first request using these sizes,
  611. * (ie check if copy succeed once with original sizes
  612. * and check if the server gave us different sizes after
  613. * we already updated max sizes on previous request).
  614. * if not then why is the server returning an error now
  615. */
  616. if ((chunks_copied != 0) || chunk_sizes_updated)
  617. goto cchunk_out;
  618. /* Check that server is not asking us to grow size */
  619. if (le32_to_cpu(retbuf->ChunkBytesWritten) <
  620. tcon->max_bytes_chunk)
  621. tcon->max_bytes_chunk =
  622. le32_to_cpu(retbuf->ChunkBytesWritten);
  623. else
  624. goto cchunk_out; /* server gave us bogus size */
  625. /* No need to change MaxChunks since already set to 1 */
  626. chunk_sizes_updated = true;
  627. } else
  628. goto cchunk_out;
  629. }
  630. cchunk_out:
  631. kfree(pcchunk);
  632. kfree(retbuf);
  633. return rc;
  634. }
  635. static int
  636. smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
  637. struct cifs_fid *fid)
  638. {
  639. return SMB2_flush(xid, tcon, fid->persistent_fid, fid->volatile_fid);
  640. }
  641. static unsigned int
  642. smb2_read_data_offset(char *buf)
  643. {
  644. struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
  645. return rsp->DataOffset;
  646. }
  647. static unsigned int
  648. smb2_read_data_length(char *buf)
  649. {
  650. struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
  651. return le32_to_cpu(rsp->DataLength);
  652. }
  653. static int
  654. smb2_sync_read(const unsigned int xid, struct cifs_fid *pfid,
  655. struct cifs_io_parms *parms, unsigned int *bytes_read,
  656. char **buf, int *buf_type)
  657. {
  658. parms->persistent_fid = pfid->persistent_fid;
  659. parms->volatile_fid = pfid->volatile_fid;
  660. return SMB2_read(xid, parms, bytes_read, buf, buf_type);
  661. }
  662. static int
  663. smb2_sync_write(const unsigned int xid, struct cifs_fid *pfid,
  664. struct cifs_io_parms *parms, unsigned int *written,
  665. struct kvec *iov, unsigned long nr_segs)
  666. {
  667. parms->persistent_fid = pfid->persistent_fid;
  668. parms->volatile_fid = pfid->volatile_fid;
  669. return SMB2_write(xid, parms, written, iov, nr_segs);
  670. }
  671. /* Set or clear the SPARSE_FILE attribute based on value passed in setsparse */
  672. static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon,
  673. struct cifsFileInfo *cfile, struct inode *inode, __u8 setsparse)
  674. {
  675. struct cifsInodeInfo *cifsi;
  676. int rc;
  677. cifsi = CIFS_I(inode);
  678. /* if file already sparse don't bother setting sparse again */
  679. if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) && setsparse)
  680. return true; /* already sparse */
  681. if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) && !setsparse)
  682. return true; /* already not sparse */
  683. /*
  684. * Can't check for sparse support on share the usual way via the
  685. * FS attribute info (FILE_SUPPORTS_SPARSE_FILES) on the share
  686. * since Samba server doesn't set the flag on the share, yet
  687. * supports the set sparse FSCTL and returns sparse correctly
  688. * in the file attributes. If we fail setting sparse though we
  689. * mark that server does not support sparse files for this share
  690. * to avoid repeatedly sending the unsupported fsctl to server
  691. * if the file is repeatedly extended.
  692. */
  693. if (tcon->broken_sparse_sup)
  694. return false;
  695. rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
  696. cfile->fid.volatile_fid, FSCTL_SET_SPARSE,
  697. true /* is_fctl */, &setsparse, 1, NULL, NULL);
  698. if (rc) {
  699. tcon->broken_sparse_sup = true;
  700. cifs_dbg(FYI, "set sparse rc = %d\n", rc);
  701. return false;
  702. }
  703. if (setsparse)
  704. cifsi->cifsAttrs |= FILE_ATTRIBUTE_SPARSE_FILE;
  705. else
  706. cifsi->cifsAttrs &= (~FILE_ATTRIBUTE_SPARSE_FILE);
  707. return true;
  708. }
  709. static int
  710. smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon,
  711. struct cifsFileInfo *cfile, __u64 size, bool set_alloc)
  712. {
  713. __le64 eof = cpu_to_le64(size);
  714. struct inode *inode;
  715. /*
  716. * If extending file more than one page make sparse. Many Linux fs
  717. * make files sparse by default when extending via ftruncate
  718. */
  719. inode = d_inode(cfile->dentry);
  720. if (!set_alloc && (size > inode->i_size + 8192)) {
  721. __u8 set_sparse = 1;
  722. /* whether set sparse succeeds or not, extend the file */
  723. smb2_set_sparse(xid, tcon, cfile, inode, set_sparse);
  724. }
  725. return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
  726. cfile->fid.volatile_fid, cfile->pid, &eof, false);
  727. }
  728. static int
  729. smb2_duplicate_extents(const unsigned int xid,
  730. struct cifsFileInfo *srcfile,
  731. struct cifsFileInfo *trgtfile, u64 src_off,
  732. u64 len, u64 dest_off)
  733. {
  734. int rc;
  735. unsigned int ret_data_len;
  736. struct duplicate_extents_to_file dup_ext_buf;
  737. struct cifs_tcon *tcon = tlink_tcon(trgtfile->tlink);
  738. /* server fileays advertise duplicate extent support with this flag */
  739. if ((le32_to_cpu(tcon->fsAttrInfo.Attributes) &
  740. FILE_SUPPORTS_BLOCK_REFCOUNTING) == 0)
  741. return -EOPNOTSUPP;
  742. dup_ext_buf.VolatileFileHandle = srcfile->fid.volatile_fid;
  743. dup_ext_buf.PersistentFileHandle = srcfile->fid.persistent_fid;
  744. dup_ext_buf.SourceFileOffset = cpu_to_le64(src_off);
  745. dup_ext_buf.TargetFileOffset = cpu_to_le64(dest_off);
  746. dup_ext_buf.ByteCount = cpu_to_le64(len);
  747. cifs_dbg(FYI, "duplicate extents: src off %lld dst off %lld len %lld",
  748. src_off, dest_off, len);
  749. rc = smb2_set_file_size(xid, tcon, trgtfile, dest_off + len, false);
  750. if (rc)
  751. goto duplicate_extents_out;
  752. rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
  753. trgtfile->fid.volatile_fid,
  754. FSCTL_DUPLICATE_EXTENTS_TO_FILE,
  755. true /* is_fsctl */, (char *)&dup_ext_buf,
  756. sizeof(struct duplicate_extents_to_file),
  757. NULL,
  758. &ret_data_len);
  759. if (ret_data_len > 0)
  760. cifs_dbg(FYI, "non-zero response length in duplicate extents");
  761. duplicate_extents_out:
  762. return rc;
  763. }
  764. static int
  765. smb2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
  766. struct cifsFileInfo *cfile)
  767. {
  768. return SMB2_set_compression(xid, tcon, cfile->fid.persistent_fid,
  769. cfile->fid.volatile_fid);
  770. }
  771. static int
  772. smb3_set_integrity(const unsigned int xid, struct cifs_tcon *tcon,
  773. struct cifsFileInfo *cfile)
  774. {
  775. struct fsctl_set_integrity_information_req integr_info;
  776. unsigned int ret_data_len;
  777. integr_info.ChecksumAlgorithm = cpu_to_le16(CHECKSUM_TYPE_UNCHANGED);
  778. integr_info.Flags = 0;
  779. integr_info.Reserved = 0;
  780. return SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
  781. cfile->fid.volatile_fid,
  782. FSCTL_SET_INTEGRITY_INFORMATION,
  783. true /* is_fsctl */, (char *)&integr_info,
  784. sizeof(struct fsctl_set_integrity_information_req),
  785. NULL,
  786. &ret_data_len);
  787. }
  788. /* GMT Token is @GMT-YYYY.MM.DD-HH.MM.SS Unicode which is 48 bytes + null */
  789. #define GMT_TOKEN_SIZE 50
  790. /*
  791. * Input buffer contains (empty) struct smb_snapshot array with size filled in
  792. * For output see struct SRV_SNAPSHOT_ARRAY in MS-SMB2 section 2.2.32.2
  793. */
  794. static int
  795. smb3_enum_snapshots(const unsigned int xid, struct cifs_tcon *tcon,
  796. struct cifsFileInfo *cfile, void __user *ioc_buf)
  797. {
  798. char *retbuf = NULL;
  799. unsigned int ret_data_len = 0;
  800. int rc;
  801. struct smb_snapshot_array snapshot_in;
  802. rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
  803. cfile->fid.volatile_fid,
  804. FSCTL_SRV_ENUMERATE_SNAPSHOTS,
  805. true /* is_fsctl */, NULL, 0 /* no input data */,
  806. (char **)&retbuf,
  807. &ret_data_len);
  808. cifs_dbg(FYI, "enum snaphots ioctl returned %d and ret buflen is %d\n",
  809. rc, ret_data_len);
  810. if (rc)
  811. return rc;
  812. if (ret_data_len && (ioc_buf != NULL) && (retbuf != NULL)) {
  813. /* Fixup buffer */
  814. if (copy_from_user(&snapshot_in, ioc_buf,
  815. sizeof(struct smb_snapshot_array))) {
  816. rc = -EFAULT;
  817. kfree(retbuf);
  818. return rc;
  819. }
  820. /*
  821. * Check for min size, ie not large enough to fit even one GMT
  822. * token (snapshot). On the first ioctl some users may pass in
  823. * smaller size (or zero) to simply get the size of the array
  824. * so the user space caller can allocate sufficient memory
  825. * and retry the ioctl again with larger array size sufficient
  826. * to hold all of the snapshot GMT tokens on the second try.
  827. */
  828. if (snapshot_in.snapshot_array_size < GMT_TOKEN_SIZE)
  829. ret_data_len = sizeof(struct smb_snapshot_array);
  830. /*
  831. * We return struct SRV_SNAPSHOT_ARRAY, followed by
  832. * the snapshot array (of 50 byte GMT tokens) each
  833. * representing an available previous version of the data
  834. */
  835. if (ret_data_len > (snapshot_in.snapshot_array_size +
  836. sizeof(struct smb_snapshot_array)))
  837. ret_data_len = snapshot_in.snapshot_array_size +
  838. sizeof(struct smb_snapshot_array);
  839. if (copy_to_user(ioc_buf, retbuf, ret_data_len))
  840. rc = -EFAULT;
  841. }
  842. kfree(retbuf);
  843. return rc;
  844. }
  845. static int
  846. smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
  847. const char *path, struct cifs_sb_info *cifs_sb,
  848. struct cifs_fid *fid, __u16 search_flags,
  849. struct cifs_search_info *srch_inf)
  850. {
  851. __le16 *utf16_path;
  852. int rc;
  853. __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
  854. struct cifs_open_parms oparms;
  855. utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
  856. if (!utf16_path)
  857. return -ENOMEM;
  858. oparms.tcon = tcon;
  859. oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
  860. oparms.disposition = FILE_OPEN;
  861. oparms.create_options = 0;
  862. oparms.fid = fid;
  863. oparms.reconnect = false;
  864. rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
  865. kfree(utf16_path);
  866. if (rc) {
  867. cifs_dbg(FYI, "open dir failed rc=%d\n", rc);
  868. return rc;
  869. }
  870. srch_inf->entries_in_buffer = 0;
  871. srch_inf->index_of_last_entry = 2;
  872. rc = SMB2_query_directory(xid, tcon, fid->persistent_fid,
  873. fid->volatile_fid, 0, srch_inf);
  874. if (rc) {
  875. cifs_dbg(FYI, "query directory failed rc=%d\n", rc);
  876. SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
  877. }
  878. return rc;
  879. }
  880. static int
  881. smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon,
  882. struct cifs_fid *fid, __u16 search_flags,
  883. struct cifs_search_info *srch_inf)
  884. {
  885. return SMB2_query_directory(xid, tcon, fid->persistent_fid,
  886. fid->volatile_fid, 0, srch_inf);
  887. }
  888. static int
  889. smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
  890. struct cifs_fid *fid)
  891. {
  892. return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
  893. }
  894. /*
  895. * If we negotiate SMB2 protocol and get STATUS_PENDING - update
  896. * the number of credits and return true. Otherwise - return false.
  897. */
  898. static bool
  899. smb2_is_status_pending(char *buf, struct TCP_Server_Info *server, int length)
  900. {
  901. struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
  902. if (hdr->Status != STATUS_PENDING)
  903. return false;
  904. if (!length) {
  905. spin_lock(&server->req_lock);
  906. server->credits += le16_to_cpu(hdr->CreditRequest);
  907. spin_unlock(&server->req_lock);
  908. wake_up(&server->request_q);
  909. }
  910. return true;
  911. }
  912. static bool
  913. smb2_is_session_expired(char *buf)
  914. {
  915. struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
  916. if (hdr->Status != STATUS_NETWORK_SESSION_EXPIRED)
  917. return false;
  918. cifs_dbg(FYI, "Session expired\n");
  919. return true;
  920. }
  921. static int
  922. smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid,
  923. struct cifsInodeInfo *cinode)
  924. {
  925. if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
  926. return SMB2_lease_break(0, tcon, cinode->lease_key,
  927. smb2_get_lease_state(cinode));
  928. return SMB2_oplock_break(0, tcon, fid->persistent_fid,
  929. fid->volatile_fid,
  930. CIFS_CACHE_READ(cinode) ? 1 : 0);
  931. }
  932. static int
  933. smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
  934. struct kstatfs *buf)
  935. {
  936. int rc;
  937. __le16 srch_path = 0; /* Null - open root of share */
  938. u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
  939. struct cifs_open_parms oparms;
  940. struct cifs_fid fid;
  941. oparms.tcon = tcon;
  942. oparms.desired_access = FILE_READ_ATTRIBUTES;
  943. oparms.disposition = FILE_OPEN;
  944. oparms.create_options = 0;
  945. oparms.fid = &fid;
  946. oparms.reconnect = false;
  947. rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
  948. if (rc)
  949. return rc;
  950. buf->f_type = SMB2_MAGIC_NUMBER;
  951. rc = SMB2_QFS_info(xid, tcon, fid.persistent_fid, fid.volatile_fid,
  952. buf);
  953. SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
  954. return rc;
  955. }
  956. static bool
  957. smb2_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
  958. {
  959. return ob1->fid.persistent_fid == ob2->fid.persistent_fid &&
  960. ob1->fid.volatile_fid == ob2->fid.volatile_fid;
  961. }
  962. static int
  963. smb2_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
  964. __u64 length, __u32 type, int lock, int unlock, bool wait)
  965. {
  966. if (unlock && !lock)
  967. type = SMB2_LOCKFLAG_UNLOCK;
  968. return SMB2_lock(xid, tlink_tcon(cfile->tlink),
  969. cfile->fid.persistent_fid, cfile->fid.volatile_fid,
  970. current->tgid, length, offset, type, wait);
  971. }
  972. static void
  973. smb2_get_lease_key(struct inode *inode, struct cifs_fid *fid)
  974. {
  975. memcpy(fid->lease_key, CIFS_I(inode)->lease_key, SMB2_LEASE_KEY_SIZE);
  976. }
  977. static void
  978. smb2_set_lease_key(struct inode *inode, struct cifs_fid *fid)
  979. {
  980. memcpy(CIFS_I(inode)->lease_key, fid->lease_key, SMB2_LEASE_KEY_SIZE);
  981. }
  982. static void
  983. smb2_new_lease_key(struct cifs_fid *fid)
  984. {
  985. generate_random_uuid(fid->lease_key);
  986. }
  987. #define SMB2_SYMLINK_STRUCT_SIZE \
  988. (sizeof(struct smb2_err_rsp) - 1 + sizeof(struct smb2_symlink_err_rsp))
  989. static int
  990. smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
  991. const char *full_path, char **target_path,
  992. struct cifs_sb_info *cifs_sb)
  993. {
  994. int rc;
  995. __le16 *utf16_path;
  996. __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
  997. struct cifs_open_parms oparms;
  998. struct cifs_fid fid;
  999. struct smb2_err_rsp *err_buf = NULL;
  1000. struct smb2_symlink_err_rsp *symlink;
  1001. unsigned int sub_len;
  1002. unsigned int sub_offset;
  1003. unsigned int print_len;
  1004. unsigned int print_offset;
  1005. cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
  1006. utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
  1007. if (!utf16_path)
  1008. return -ENOMEM;
  1009. oparms.tcon = tcon;
  1010. oparms.desired_access = FILE_READ_ATTRIBUTES;
  1011. oparms.disposition = FILE_OPEN;
  1012. oparms.create_options = 0;
  1013. oparms.fid = &fid;
  1014. oparms.reconnect = false;
  1015. rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_buf);
  1016. if (!rc || !err_buf) {
  1017. kfree(utf16_path);
  1018. return -ENOENT;
  1019. }
  1020. if (le32_to_cpu(err_buf->ByteCount) < sizeof(struct smb2_symlink_err_rsp) ||
  1021. get_rfc1002_length(err_buf) + 4 < SMB2_SYMLINK_STRUCT_SIZE) {
  1022. kfree(utf16_path);
  1023. return -ENOENT;
  1024. }
  1025. /* open must fail on symlink - reset rc */
  1026. rc = 0;
  1027. symlink = (struct smb2_symlink_err_rsp *)err_buf->ErrorData;
  1028. sub_len = le16_to_cpu(symlink->SubstituteNameLength);
  1029. sub_offset = le16_to_cpu(symlink->SubstituteNameOffset);
  1030. print_len = le16_to_cpu(symlink->PrintNameLength);
  1031. print_offset = le16_to_cpu(symlink->PrintNameOffset);
  1032. if (get_rfc1002_length(err_buf) + 4 <
  1033. SMB2_SYMLINK_STRUCT_SIZE + sub_offset + sub_len) {
  1034. kfree(utf16_path);
  1035. return -ENOENT;
  1036. }
  1037. if (get_rfc1002_length(err_buf) + 4 <
  1038. SMB2_SYMLINK_STRUCT_SIZE + print_offset + print_len) {
  1039. kfree(utf16_path);
  1040. return -ENOENT;
  1041. }
  1042. *target_path = cifs_strndup_from_utf16(
  1043. (char *)symlink->PathBuffer + sub_offset,
  1044. sub_len, true, cifs_sb->local_nls);
  1045. if (!(*target_path)) {
  1046. kfree(utf16_path);
  1047. return -ENOMEM;
  1048. }
  1049. convert_delimiter(*target_path, '/');
  1050. cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
  1051. kfree(utf16_path);
  1052. return rc;
  1053. }
  1054. static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
  1055. loff_t offset, loff_t len, bool keep_size)
  1056. {
  1057. struct inode *inode;
  1058. struct cifsInodeInfo *cifsi;
  1059. struct cifsFileInfo *cfile = file->private_data;
  1060. struct file_zero_data_information fsctl_buf;
  1061. long rc;
  1062. unsigned int xid;
  1063. xid = get_xid();
  1064. inode = d_inode(cfile->dentry);
  1065. cifsi = CIFS_I(inode);
  1066. /* if file not oplocked can't be sure whether asking to extend size */
  1067. if (!CIFS_CACHE_READ(cifsi))
  1068. if (keep_size == false)
  1069. return -EOPNOTSUPP;
  1070. /*
  1071. * Must check if file sparse since fallocate -z (zero range) assumes
  1072. * non-sparse allocation
  1073. */
  1074. if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE))
  1075. return -EOPNOTSUPP;
  1076. /*
  1077. * need to make sure we are not asked to extend the file since the SMB3
  1078. * fsctl does not change the file size. In the future we could change
  1079. * this to zero the first part of the range then set the file size
  1080. * which for a non sparse file would zero the newly extended range
  1081. */
  1082. if (keep_size == false)
  1083. if (i_size_read(inode) < offset + len)
  1084. return -EOPNOTSUPP;
  1085. cifs_dbg(FYI, "offset %lld len %lld", offset, len);
  1086. fsctl_buf.FileOffset = cpu_to_le64(offset);
  1087. fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);
  1088. rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
  1089. cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
  1090. true /* is_fctl */, (char *)&fsctl_buf,
  1091. sizeof(struct file_zero_data_information), NULL, NULL);
  1092. free_xid(xid);
  1093. return rc;
  1094. }
  1095. static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
  1096. loff_t offset, loff_t len)
  1097. {
  1098. struct inode *inode;
  1099. struct cifsInodeInfo *cifsi;
  1100. struct cifsFileInfo *cfile = file->private_data;
  1101. struct file_zero_data_information fsctl_buf;
  1102. long rc;
  1103. unsigned int xid;
  1104. __u8 set_sparse = 1;
  1105. xid = get_xid();
  1106. inode = d_inode(cfile->dentry);
  1107. cifsi = CIFS_I(inode);
  1108. /* Need to make file sparse, if not already, before freeing range. */
  1109. /* Consider adding equivalent for compressed since it could also work */
  1110. if (!smb2_set_sparse(xid, tcon, cfile, inode, set_sparse))
  1111. return -EOPNOTSUPP;
  1112. cifs_dbg(FYI, "offset %lld len %lld", offset, len);
  1113. fsctl_buf.FileOffset = cpu_to_le64(offset);
  1114. fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);
  1115. rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
  1116. cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
  1117. true /* is_fctl */, (char *)&fsctl_buf,
  1118. sizeof(struct file_zero_data_information), NULL, NULL);
  1119. free_xid(xid);
  1120. return rc;
  1121. }
  1122. static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
  1123. loff_t off, loff_t len, bool keep_size)
  1124. {
  1125. struct inode *inode;
  1126. struct cifsInodeInfo *cifsi;
  1127. struct cifsFileInfo *cfile = file->private_data;
  1128. long rc = -EOPNOTSUPP;
  1129. unsigned int xid;
  1130. xid = get_xid();
  1131. inode = d_inode(cfile->dentry);
  1132. cifsi = CIFS_I(inode);
  1133. /* if file not oplocked can't be sure whether asking to extend size */
  1134. if (!CIFS_CACHE_READ(cifsi))
  1135. if (keep_size == false)
  1136. return -EOPNOTSUPP;
  1137. /*
  1138. * Files are non-sparse by default so falloc may be a no-op
  1139. * Must check if file sparse. If not sparse, and not extending
  1140. * then no need to do anything since file already allocated
  1141. */
  1142. if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0) {
  1143. if (keep_size == true)
  1144. return 0;
  1145. /* check if extending file */
  1146. else if (i_size_read(inode) >= off + len)
  1147. /* not extending file and already not sparse */
  1148. return 0;
  1149. /* BB: in future add else clause to extend file */
  1150. else
  1151. return -EOPNOTSUPP;
  1152. }
  1153. if ((keep_size == true) || (i_size_read(inode) >= off + len)) {
  1154. /*
  1155. * Check if falloc starts within first few pages of file
  1156. * and ends within a few pages of the end of file to
  1157. * ensure that most of file is being forced to be
  1158. * fallocated now. If so then setting whole file sparse
  1159. * ie potentially making a few extra pages at the beginning
  1160. * or end of the file non-sparse via set_sparse is harmless.
  1161. */
  1162. if ((off > 8192) || (off + len + 8192 < i_size_read(inode)))
  1163. return -EOPNOTSUPP;
  1164. rc = smb2_set_sparse(xid, tcon, cfile, inode, false);
  1165. }
  1166. /* BB: else ... in future add code to extend file and set sparse */
  1167. free_xid(xid);
  1168. return rc;
  1169. }
  1170. static long smb3_fallocate(struct file *file, struct cifs_tcon *tcon, int mode,
  1171. loff_t off, loff_t len)
  1172. {
  1173. /* KEEP_SIZE already checked for by do_fallocate */
  1174. if (mode & FALLOC_FL_PUNCH_HOLE)
  1175. return smb3_punch_hole(file, tcon, off, len);
  1176. else if (mode & FALLOC_FL_ZERO_RANGE) {
  1177. if (mode & FALLOC_FL_KEEP_SIZE)
  1178. return smb3_zero_range(file, tcon, off, len, true);
  1179. return smb3_zero_range(file, tcon, off, len, false);
  1180. } else if (mode == FALLOC_FL_KEEP_SIZE)
  1181. return smb3_simple_falloc(file, tcon, off, len, true);
  1182. else if (mode == 0)
  1183. return smb3_simple_falloc(file, tcon, off, len, false);
  1184. return -EOPNOTSUPP;
  1185. }
  1186. static void
  1187. smb2_downgrade_oplock(struct TCP_Server_Info *server,
  1188. struct cifsInodeInfo *cinode, bool set_level2)
  1189. {
  1190. if (set_level2)
  1191. server->ops->set_oplock_level(cinode, SMB2_OPLOCK_LEVEL_II,
  1192. 0, NULL);
  1193. else
  1194. server->ops->set_oplock_level(cinode, 0, 0, NULL);
  1195. }
  1196. static void
  1197. smb21_downgrade_oplock(struct TCP_Server_Info *server,
  1198. struct cifsInodeInfo *cinode, bool set_level2)
  1199. {
  1200. server->ops->set_oplock_level(cinode,
  1201. set_level2 ? SMB2_LEASE_READ_CACHING_HE :
  1202. 0, 0, NULL);
  1203. }
  1204. static void
  1205. smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
  1206. unsigned int epoch, bool *purge_cache)
  1207. {
  1208. oplock &= 0xFF;
  1209. if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
  1210. return;
  1211. if (oplock == SMB2_OPLOCK_LEVEL_BATCH) {
  1212. cinode->oplock = CIFS_CACHE_RHW_FLG;
  1213. cifs_dbg(FYI, "Batch Oplock granted on inode %p\n",
  1214. &cinode->vfs_inode);
  1215. } else if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE) {
  1216. cinode->oplock = CIFS_CACHE_RW_FLG;
  1217. cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n",
  1218. &cinode->vfs_inode);
  1219. } else if (oplock == SMB2_OPLOCK_LEVEL_II) {
  1220. cinode->oplock = CIFS_CACHE_READ_FLG;
  1221. cifs_dbg(FYI, "Level II Oplock granted on inode %p\n",
  1222. &cinode->vfs_inode);
  1223. } else
  1224. cinode->oplock = 0;
  1225. }
  1226. static void
  1227. smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
  1228. unsigned int epoch, bool *purge_cache)
  1229. {
  1230. char message[5] = {0};
  1231. unsigned int new_oplock = 0;
  1232. oplock &= 0xFF;
  1233. if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
  1234. return;
  1235. /* Check if the server granted an oplock rather than a lease */
  1236. if (oplock & SMB2_OPLOCK_LEVEL_EXCLUSIVE)
  1237. return smb2_set_oplock_level(cinode, oplock, epoch,
  1238. purge_cache);
  1239. if (oplock & SMB2_LEASE_READ_CACHING_HE) {
  1240. new_oplock |= CIFS_CACHE_READ_FLG;
  1241. strcat(message, "R");
  1242. }
  1243. if (oplock & SMB2_LEASE_HANDLE_CACHING_HE) {
  1244. new_oplock |= CIFS_CACHE_HANDLE_FLG;
  1245. strcat(message, "H");
  1246. }
  1247. if (oplock & SMB2_LEASE_WRITE_CACHING_HE) {
  1248. new_oplock |= CIFS_CACHE_WRITE_FLG;
  1249. strcat(message, "W");
  1250. }
  1251. if (!new_oplock)
  1252. strncpy(message, "None", sizeof(message));
  1253. cinode->oplock = new_oplock;
  1254. cifs_dbg(FYI, "%s Lease granted on inode %p\n", message,
  1255. &cinode->vfs_inode);
  1256. }
  1257. static void
  1258. smb3_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
  1259. unsigned int epoch, bool *purge_cache)
  1260. {
  1261. unsigned int old_oplock = cinode->oplock;
  1262. smb21_set_oplock_level(cinode, oplock, epoch, purge_cache);
  1263. if (purge_cache) {
  1264. *purge_cache = false;
  1265. if (old_oplock == CIFS_CACHE_READ_FLG) {
  1266. if (cinode->oplock == CIFS_CACHE_READ_FLG &&
  1267. (epoch - cinode->epoch > 0))
  1268. *purge_cache = true;
  1269. else if (cinode->oplock == CIFS_CACHE_RH_FLG &&
  1270. (epoch - cinode->epoch > 1))
  1271. *purge_cache = true;
  1272. else if (cinode->oplock == CIFS_CACHE_RHW_FLG &&
  1273. (epoch - cinode->epoch > 1))
  1274. *purge_cache = true;
  1275. else if (cinode->oplock == 0 &&
  1276. (epoch - cinode->epoch > 0))
  1277. *purge_cache = true;
  1278. } else if (old_oplock == CIFS_CACHE_RH_FLG) {
  1279. if (cinode->oplock == CIFS_CACHE_RH_FLG &&
  1280. (epoch - cinode->epoch > 0))
  1281. *purge_cache = true;
  1282. else if (cinode->oplock == CIFS_CACHE_RHW_FLG &&
  1283. (epoch - cinode->epoch > 1))
  1284. *purge_cache = true;
  1285. }
  1286. cinode->epoch = epoch;
  1287. }
  1288. }
  1289. static bool
  1290. smb2_is_read_op(__u32 oplock)
  1291. {
  1292. return oplock == SMB2_OPLOCK_LEVEL_II;
  1293. }
  1294. static bool
  1295. smb21_is_read_op(__u32 oplock)
  1296. {
  1297. return (oplock & SMB2_LEASE_READ_CACHING_HE) &&
  1298. !(oplock & SMB2_LEASE_WRITE_CACHING_HE);
  1299. }
  1300. static __le32
  1301. map_oplock_to_lease(u8 oplock)
  1302. {
  1303. if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE)
  1304. return SMB2_LEASE_WRITE_CACHING | SMB2_LEASE_READ_CACHING;
  1305. else if (oplock == SMB2_OPLOCK_LEVEL_II)
  1306. return SMB2_LEASE_READ_CACHING;
  1307. else if (oplock == SMB2_OPLOCK_LEVEL_BATCH)
  1308. return SMB2_LEASE_HANDLE_CACHING | SMB2_LEASE_READ_CACHING |
  1309. SMB2_LEASE_WRITE_CACHING;
  1310. return 0;
  1311. }
  1312. static char *
  1313. smb2_create_lease_buf(u8 *lease_key, u8 oplock)
  1314. {
  1315. struct create_lease *buf;
  1316. buf = kzalloc(sizeof(struct create_lease), GFP_KERNEL);
  1317. if (!buf)
  1318. return NULL;
  1319. buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
  1320. buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
  1321. buf->lcontext.LeaseState = map_oplock_to_lease(oplock);
  1322. buf->ccontext.DataOffset = cpu_to_le16(offsetof
  1323. (struct create_lease, lcontext));
  1324. buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context));
  1325. buf->ccontext.NameOffset = cpu_to_le16(offsetof
  1326. (struct create_lease, Name));
  1327. buf->ccontext.NameLength = cpu_to_le16(4);
  1328. /* SMB2_CREATE_REQUEST_LEASE is "RqLs" */
  1329. buf->Name[0] = 'R';
  1330. buf->Name[1] = 'q';
  1331. buf->Name[2] = 'L';
  1332. buf->Name[3] = 's';
  1333. return (char *)buf;
  1334. }
  1335. static char *
  1336. smb3_create_lease_buf(u8 *lease_key, u8 oplock)
  1337. {
  1338. struct create_lease_v2 *buf;
  1339. buf = kzalloc(sizeof(struct create_lease_v2), GFP_KERNEL);
  1340. if (!buf)
  1341. return NULL;
  1342. buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
  1343. buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
  1344. buf->lcontext.LeaseState = map_oplock_to_lease(oplock);
  1345. buf->ccontext.DataOffset = cpu_to_le16(offsetof
  1346. (struct create_lease_v2, lcontext));
  1347. buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context_v2));
  1348. buf->ccontext.NameOffset = cpu_to_le16(offsetof
  1349. (struct create_lease_v2, Name));
  1350. buf->ccontext.NameLength = cpu_to_le16(4);
  1351. /* SMB2_CREATE_REQUEST_LEASE is "RqLs" */
  1352. buf->Name[0] = 'R';
  1353. buf->Name[1] = 'q';
  1354. buf->Name[2] = 'L';
  1355. buf->Name[3] = 's';
  1356. return (char *)buf;
  1357. }
  1358. static __u8
  1359. smb2_parse_lease_buf(void *buf, unsigned int *epoch)
  1360. {
  1361. struct create_lease *lc = (struct create_lease *)buf;
  1362. *epoch = 0; /* not used */
  1363. if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
  1364. return SMB2_OPLOCK_LEVEL_NOCHANGE;
  1365. return le32_to_cpu(lc->lcontext.LeaseState);
  1366. }
  1367. static __u8
  1368. smb3_parse_lease_buf(void *buf, unsigned int *epoch)
  1369. {
  1370. struct create_lease_v2 *lc = (struct create_lease_v2 *)buf;
  1371. *epoch = le16_to_cpu(lc->lcontext.Epoch);
  1372. if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
  1373. return SMB2_OPLOCK_LEVEL_NOCHANGE;
  1374. return le32_to_cpu(lc->lcontext.LeaseState);
  1375. }
  1376. static unsigned int
  1377. smb2_wp_retry_size(struct inode *inode)
  1378. {
  1379. return min_t(unsigned int, CIFS_SB(inode->i_sb)->wsize,
  1380. SMB2_MAX_BUFFER_SIZE);
  1381. }
  1382. static bool
  1383. smb2_dir_needs_close(struct cifsFileInfo *cfile)
  1384. {
  1385. return !cfile->invalidHandle;
  1386. }
  1387. struct smb_version_operations smb20_operations = {
  1388. .compare_fids = smb2_compare_fids,
  1389. .setup_request = smb2_setup_request,
  1390. .setup_async_request = smb2_setup_async_request,
  1391. .check_receive = smb2_check_receive,
  1392. .add_credits = smb2_add_credits,
  1393. .set_credits = smb2_set_credits,
  1394. .get_credits_field = smb2_get_credits_field,
  1395. .get_credits = smb2_get_credits,
  1396. .wait_mtu_credits = cifs_wait_mtu_credits,
  1397. .get_next_mid = smb2_get_next_mid,
  1398. .read_data_offset = smb2_read_data_offset,
  1399. .read_data_length = smb2_read_data_length,
  1400. .map_error = map_smb2_to_linux_error,
  1401. .find_mid = smb2_find_mid,
  1402. .check_message = smb2_check_message,
  1403. .dump_detail = smb2_dump_detail,
  1404. .clear_stats = smb2_clear_stats,
  1405. .print_stats = smb2_print_stats,
  1406. .is_oplock_break = smb2_is_valid_oplock_break,
  1407. .handle_cancelled_mid = smb2_handle_cancelled_mid,
  1408. .downgrade_oplock = smb2_downgrade_oplock,
  1409. .need_neg = smb2_need_neg,
  1410. .negotiate = smb2_negotiate,
  1411. .negotiate_wsize = smb2_negotiate_wsize,
  1412. .negotiate_rsize = smb2_negotiate_rsize,
  1413. .sess_setup = SMB2_sess_setup,
  1414. .logoff = SMB2_logoff,
  1415. .tree_connect = SMB2_tcon,
  1416. .tree_disconnect = SMB2_tdis,
  1417. .qfs_tcon = smb2_qfs_tcon,
  1418. .is_path_accessible = smb2_is_path_accessible,
  1419. .can_echo = smb2_can_echo,
  1420. .echo = SMB2_echo,
  1421. .query_path_info = smb2_query_path_info,
  1422. .get_srv_inum = smb2_get_srv_inum,
  1423. .query_file_info = smb2_query_file_info,
  1424. .set_path_size = smb2_set_path_size,
  1425. .set_file_size = smb2_set_file_size,
  1426. .set_file_info = smb2_set_file_info,
  1427. .set_compression = smb2_set_compression,
  1428. .mkdir = smb2_mkdir,
  1429. .mkdir_setinfo = smb2_mkdir_setinfo,
  1430. .rmdir = smb2_rmdir,
  1431. .unlink = smb2_unlink,
  1432. .rename = smb2_rename_path,
  1433. .create_hardlink = smb2_create_hardlink,
  1434. .query_symlink = smb2_query_symlink,
  1435. .query_mf_symlink = smb3_query_mf_symlink,
  1436. .create_mf_symlink = smb3_create_mf_symlink,
  1437. .open = smb2_open_file,
  1438. .set_fid = smb2_set_fid,
  1439. .close = smb2_close_file,
  1440. .flush = smb2_flush_file,
  1441. .async_readv = smb2_async_readv,
  1442. .async_writev = smb2_async_writev,
  1443. .sync_read = smb2_sync_read,
  1444. .sync_write = smb2_sync_write,
  1445. .query_dir_first = smb2_query_dir_first,
  1446. .query_dir_next = smb2_query_dir_next,
  1447. .close_dir = smb2_close_dir,
  1448. .calc_smb_size = smb2_calc_size,
  1449. .is_status_pending = smb2_is_status_pending,
  1450. .is_session_expired = smb2_is_session_expired,
  1451. .oplock_response = smb2_oplock_response,
  1452. .queryfs = smb2_queryfs,
  1453. .mand_lock = smb2_mand_lock,
  1454. .mand_unlock_range = smb2_unlock_range,
  1455. .push_mand_locks = smb2_push_mandatory_locks,
  1456. .get_lease_key = smb2_get_lease_key,
  1457. .set_lease_key = smb2_set_lease_key,
  1458. .new_lease_key = smb2_new_lease_key,
  1459. .calc_signature = smb2_calc_signature,
  1460. .is_read_op = smb2_is_read_op,
  1461. .set_oplock_level = smb2_set_oplock_level,
  1462. .create_lease_buf = smb2_create_lease_buf,
  1463. .parse_lease_buf = smb2_parse_lease_buf,
  1464. .clone_range = smb2_clone_range,
  1465. .wp_retry_size = smb2_wp_retry_size,
  1466. .dir_needs_close = smb2_dir_needs_close,
  1467. };
  1468. struct smb_version_operations smb21_operations = {
  1469. .compare_fids = smb2_compare_fids,
  1470. .setup_request = smb2_setup_request,
  1471. .setup_async_request = smb2_setup_async_request,
  1472. .check_receive = smb2_check_receive,
  1473. .add_credits = smb2_add_credits,
  1474. .set_credits = smb2_set_credits,
  1475. .get_credits_field = smb2_get_credits_field,
  1476. .get_credits = smb2_get_credits,
  1477. .wait_mtu_credits = smb2_wait_mtu_credits,
  1478. .get_next_mid = smb2_get_next_mid,
  1479. .read_data_offset = smb2_read_data_offset,
  1480. .read_data_length = smb2_read_data_length,
  1481. .map_error = map_smb2_to_linux_error,
  1482. .find_mid = smb2_find_mid,
  1483. .check_message = smb2_check_message,
  1484. .dump_detail = smb2_dump_detail,
  1485. .clear_stats = smb2_clear_stats,
  1486. .print_stats = smb2_print_stats,
  1487. .is_oplock_break = smb2_is_valid_oplock_break,
  1488. .handle_cancelled_mid = smb2_handle_cancelled_mid,
  1489. .downgrade_oplock = smb21_downgrade_oplock,
  1490. .need_neg = smb2_need_neg,
  1491. .negotiate = smb2_negotiate,
  1492. .negotiate_wsize = smb2_negotiate_wsize,
  1493. .negotiate_rsize = smb2_negotiate_rsize,
  1494. .sess_setup = SMB2_sess_setup,
  1495. .logoff = SMB2_logoff,
  1496. .tree_connect = SMB2_tcon,
  1497. .tree_disconnect = SMB2_tdis,
  1498. .qfs_tcon = smb2_qfs_tcon,
  1499. .is_path_accessible = smb2_is_path_accessible,
  1500. .can_echo = smb2_can_echo,
  1501. .echo = SMB2_echo,
  1502. .query_path_info = smb2_query_path_info,
  1503. .get_srv_inum = smb2_get_srv_inum,
  1504. .query_file_info = smb2_query_file_info,
  1505. .set_path_size = smb2_set_path_size,
  1506. .set_file_size = smb2_set_file_size,
  1507. .set_file_info = smb2_set_file_info,
  1508. .set_compression = smb2_set_compression,
  1509. .mkdir = smb2_mkdir,
  1510. .mkdir_setinfo = smb2_mkdir_setinfo,
  1511. .rmdir = smb2_rmdir,
  1512. .unlink = smb2_unlink,
  1513. .rename = smb2_rename_path,
  1514. .create_hardlink = smb2_create_hardlink,
  1515. .query_symlink = smb2_query_symlink,
  1516. .query_mf_symlink = smb3_query_mf_symlink,
  1517. .create_mf_symlink = smb3_create_mf_symlink,
  1518. .open = smb2_open_file,
  1519. .set_fid = smb2_set_fid,
  1520. .close = smb2_close_file,
  1521. .flush = smb2_flush_file,
  1522. .async_readv = smb2_async_readv,
  1523. .async_writev = smb2_async_writev,
  1524. .sync_read = smb2_sync_read,
  1525. .sync_write = smb2_sync_write,
  1526. .query_dir_first = smb2_query_dir_first,
  1527. .query_dir_next = smb2_query_dir_next,
  1528. .close_dir = smb2_close_dir,
  1529. .calc_smb_size = smb2_calc_size,
  1530. .is_status_pending = smb2_is_status_pending,
  1531. .is_session_expired = smb2_is_session_expired,
  1532. .oplock_response = smb2_oplock_response,
  1533. .queryfs = smb2_queryfs,
  1534. .mand_lock = smb2_mand_lock,
  1535. .mand_unlock_range = smb2_unlock_range,
  1536. .push_mand_locks = smb2_push_mandatory_locks,
  1537. .get_lease_key = smb2_get_lease_key,
  1538. .set_lease_key = smb2_set_lease_key,
  1539. .new_lease_key = smb2_new_lease_key,
  1540. .calc_signature = smb2_calc_signature,
  1541. .is_read_op = smb21_is_read_op,
  1542. .set_oplock_level = smb21_set_oplock_level,
  1543. .create_lease_buf = smb2_create_lease_buf,
  1544. .parse_lease_buf = smb2_parse_lease_buf,
  1545. .clone_range = smb2_clone_range,
  1546. .wp_retry_size = smb2_wp_retry_size,
  1547. .dir_needs_close = smb2_dir_needs_close,
  1548. .enum_snapshots = smb3_enum_snapshots,
  1549. };
  1550. struct smb_version_operations smb30_operations = {
  1551. .compare_fids = smb2_compare_fids,
  1552. .setup_request = smb2_setup_request,
  1553. .setup_async_request = smb2_setup_async_request,
  1554. .check_receive = smb2_check_receive,
  1555. .add_credits = smb2_add_credits,
  1556. .set_credits = smb2_set_credits,
  1557. .get_credits_field = smb2_get_credits_field,
  1558. .get_credits = smb2_get_credits,
  1559. .wait_mtu_credits = smb2_wait_mtu_credits,
  1560. .get_next_mid = smb2_get_next_mid,
  1561. .read_data_offset = smb2_read_data_offset,
  1562. .read_data_length = smb2_read_data_length,
  1563. .map_error = map_smb2_to_linux_error,
  1564. .find_mid = smb2_find_mid,
  1565. .check_message = smb2_check_message,
  1566. .dump_detail = smb2_dump_detail,
  1567. .clear_stats = smb2_clear_stats,
  1568. .print_stats = smb2_print_stats,
  1569. .dump_share_caps = smb2_dump_share_caps,
  1570. .is_oplock_break = smb2_is_valid_oplock_break,
  1571. .handle_cancelled_mid = smb2_handle_cancelled_mid,
  1572. .downgrade_oplock = smb21_downgrade_oplock,
  1573. .need_neg = smb2_need_neg,
  1574. .negotiate = smb2_negotiate,
  1575. .negotiate_wsize = smb2_negotiate_wsize,
  1576. .negotiate_rsize = smb2_negotiate_rsize,
  1577. .sess_setup = SMB2_sess_setup,
  1578. .logoff = SMB2_logoff,
  1579. .tree_connect = SMB2_tcon,
  1580. .tree_disconnect = SMB2_tdis,
  1581. .qfs_tcon = smb3_qfs_tcon,
  1582. .is_path_accessible = smb2_is_path_accessible,
  1583. .can_echo = smb2_can_echo,
  1584. .echo = SMB2_echo,
  1585. .query_path_info = smb2_query_path_info,
  1586. .get_srv_inum = smb2_get_srv_inum,
  1587. .query_file_info = smb2_query_file_info,
  1588. .set_path_size = smb2_set_path_size,
  1589. .set_file_size = smb2_set_file_size,
  1590. .set_file_info = smb2_set_file_info,
  1591. .set_compression = smb2_set_compression,
  1592. .mkdir = smb2_mkdir,
  1593. .mkdir_setinfo = smb2_mkdir_setinfo,
  1594. .rmdir = smb2_rmdir,
  1595. .unlink = smb2_unlink,
  1596. .rename = smb2_rename_path,
  1597. .create_hardlink = smb2_create_hardlink,
  1598. .query_symlink = smb2_query_symlink,
  1599. .query_mf_symlink = smb3_query_mf_symlink,
  1600. .create_mf_symlink = smb3_create_mf_symlink,
  1601. .open = smb2_open_file,
  1602. .set_fid = smb2_set_fid,
  1603. .close = smb2_close_file,
  1604. .flush = smb2_flush_file,
  1605. .async_readv = smb2_async_readv,
  1606. .async_writev = smb2_async_writev,
  1607. .sync_read = smb2_sync_read,
  1608. .sync_write = smb2_sync_write,
  1609. .query_dir_first = smb2_query_dir_first,
  1610. .query_dir_next = smb2_query_dir_next,
  1611. .close_dir = smb2_close_dir,
  1612. .calc_smb_size = smb2_calc_size,
  1613. .is_status_pending = smb2_is_status_pending,
  1614. .is_session_expired = smb2_is_session_expired,
  1615. .oplock_response = smb2_oplock_response,
  1616. .queryfs = smb2_queryfs,
  1617. .mand_lock = smb2_mand_lock,
  1618. .mand_unlock_range = smb2_unlock_range,
  1619. .push_mand_locks = smb2_push_mandatory_locks,
  1620. .get_lease_key = smb2_get_lease_key,
  1621. .set_lease_key = smb2_set_lease_key,
  1622. .new_lease_key = smb2_new_lease_key,
  1623. .generate_signingkey = generate_smb30signingkey,
  1624. .calc_signature = smb3_calc_signature,
  1625. .set_integrity = smb3_set_integrity,
  1626. .is_read_op = smb21_is_read_op,
  1627. .set_oplock_level = smb3_set_oplock_level,
  1628. .create_lease_buf = smb3_create_lease_buf,
  1629. .parse_lease_buf = smb3_parse_lease_buf,
  1630. .clone_range = smb2_clone_range,
  1631. .duplicate_extents = smb2_duplicate_extents,
  1632. .validate_negotiate = smb3_validate_negotiate,
  1633. .wp_retry_size = smb2_wp_retry_size,
  1634. .dir_needs_close = smb2_dir_needs_close,
  1635. .fallocate = smb3_fallocate,
  1636. .enum_snapshots = smb3_enum_snapshots,
  1637. };
  1638. #ifdef CONFIG_CIFS_SMB311
  1639. struct smb_version_operations smb311_operations = {
  1640. .compare_fids = smb2_compare_fids,
  1641. .setup_request = smb2_setup_request,
  1642. .setup_async_request = smb2_setup_async_request,
  1643. .check_receive = smb2_check_receive,
  1644. .add_credits = smb2_add_credits,
  1645. .set_credits = smb2_set_credits,
  1646. .get_credits_field = smb2_get_credits_field,
  1647. .get_credits = smb2_get_credits,
  1648. .wait_mtu_credits = smb2_wait_mtu_credits,
  1649. .get_next_mid = smb2_get_next_mid,
  1650. .read_data_offset = smb2_read_data_offset,
  1651. .read_data_length = smb2_read_data_length,
  1652. .map_error = map_smb2_to_linux_error,
  1653. .find_mid = smb2_find_mid,
  1654. .check_message = smb2_check_message,
  1655. .dump_detail = smb2_dump_detail,
  1656. .clear_stats = smb2_clear_stats,
  1657. .print_stats = smb2_print_stats,
  1658. .dump_share_caps = smb2_dump_share_caps,
  1659. .is_oplock_break = smb2_is_valid_oplock_break,
  1660. .handle_cancelled_mid = smb2_handle_cancelled_mid,
  1661. .downgrade_oplock = smb21_downgrade_oplock,
  1662. .need_neg = smb2_need_neg,
  1663. .negotiate = smb2_negotiate,
  1664. .negotiate_wsize = smb2_negotiate_wsize,
  1665. .negotiate_rsize = smb2_negotiate_rsize,
  1666. .sess_setup = SMB2_sess_setup,
  1667. .logoff = SMB2_logoff,
  1668. .tree_connect = SMB2_tcon,
  1669. .tree_disconnect = SMB2_tdis,
  1670. .qfs_tcon = smb3_qfs_tcon,
  1671. .is_path_accessible = smb2_is_path_accessible,
  1672. .can_echo = smb2_can_echo,
  1673. .echo = SMB2_echo,
  1674. .query_path_info = smb2_query_path_info,
  1675. .get_srv_inum = smb2_get_srv_inum,
  1676. .query_file_info = smb2_query_file_info,
  1677. .set_path_size = smb2_set_path_size,
  1678. .set_file_size = smb2_set_file_size,
  1679. .set_file_info = smb2_set_file_info,
  1680. .set_compression = smb2_set_compression,
  1681. .mkdir = smb2_mkdir,
  1682. .mkdir_setinfo = smb2_mkdir_setinfo,
  1683. .rmdir = smb2_rmdir,
  1684. .unlink = smb2_unlink,
  1685. .rename = smb2_rename_path,
  1686. .create_hardlink = smb2_create_hardlink,
  1687. .query_symlink = smb2_query_symlink,
  1688. .query_mf_symlink = smb3_query_mf_symlink,
  1689. .create_mf_symlink = smb3_create_mf_symlink,
  1690. .open = smb2_open_file,
  1691. .set_fid = smb2_set_fid,
  1692. .close = smb2_close_file,
  1693. .flush = smb2_flush_file,
  1694. .async_readv = smb2_async_readv,
  1695. .async_writev = smb2_async_writev,
  1696. .sync_read = smb2_sync_read,
  1697. .sync_write = smb2_sync_write,
  1698. .query_dir_first = smb2_query_dir_first,
  1699. .query_dir_next = smb2_query_dir_next,
  1700. .close_dir = smb2_close_dir,
  1701. .calc_smb_size = smb2_calc_size,
  1702. .is_status_pending = smb2_is_status_pending,
  1703. .is_session_expired = smb2_is_session_expired,
  1704. .oplock_response = smb2_oplock_response,
  1705. .queryfs = smb2_queryfs,
  1706. .mand_lock = smb2_mand_lock,
  1707. .mand_unlock_range = smb2_unlock_range,
  1708. .push_mand_locks = smb2_push_mandatory_locks,
  1709. .get_lease_key = smb2_get_lease_key,
  1710. .set_lease_key = smb2_set_lease_key,
  1711. .new_lease_key = smb2_new_lease_key,
  1712. .generate_signingkey = generate_smb311signingkey,
  1713. .calc_signature = smb3_calc_signature,
  1714. .set_integrity = smb3_set_integrity,
  1715. .is_read_op = smb21_is_read_op,
  1716. .set_oplock_level = smb3_set_oplock_level,
  1717. .create_lease_buf = smb3_create_lease_buf,
  1718. .parse_lease_buf = smb3_parse_lease_buf,
  1719. .clone_range = smb2_clone_range,
  1720. .duplicate_extents = smb2_duplicate_extents,
  1721. /* .validate_negotiate = smb3_validate_negotiate, */ /* not used in 3.11 */
  1722. .wp_retry_size = smb2_wp_retry_size,
  1723. .dir_needs_close = smb2_dir_needs_close,
  1724. .fallocate = smb3_fallocate,
  1725. .enum_snapshots = smb3_enum_snapshots,
  1726. };
  1727. #endif /* CIFS_SMB311 */
  1728. struct smb_version_values smb20_values = {
  1729. .version_string = SMB20_VERSION_STRING,
  1730. .protocol_id = SMB20_PROT_ID,
  1731. .req_capabilities = 0, /* MBZ */
  1732. .large_lock_type = 0,
  1733. .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
  1734. .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
  1735. .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
  1736. .header_size = sizeof(struct smb2_hdr),
  1737. .max_header_size = MAX_SMB2_HDR_SIZE,
  1738. .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
  1739. .lock_cmd = SMB2_LOCK,
  1740. .cap_unix = 0,
  1741. .cap_nt_find = SMB2_NT_FIND,
  1742. .cap_large_files = SMB2_LARGE_FILES,
  1743. .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
  1744. .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
  1745. .create_lease_size = sizeof(struct create_lease),
  1746. };
  1747. struct smb_version_values smb21_values = {
  1748. .version_string = SMB21_VERSION_STRING,
  1749. .protocol_id = SMB21_PROT_ID,
  1750. .req_capabilities = 0, /* MBZ on negotiate req until SMB3 dialect */
  1751. .large_lock_type = 0,
  1752. .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
  1753. .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
  1754. .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
  1755. .header_size = sizeof(struct smb2_hdr),
  1756. .max_header_size = MAX_SMB2_HDR_SIZE,
  1757. .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
  1758. .lock_cmd = SMB2_LOCK,
  1759. .cap_unix = 0,
  1760. .cap_nt_find = SMB2_NT_FIND,
  1761. .cap_large_files = SMB2_LARGE_FILES,
  1762. .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
  1763. .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
  1764. .create_lease_size = sizeof(struct create_lease),
  1765. };
  1766. struct smb_version_values smb30_values = {
  1767. .version_string = SMB30_VERSION_STRING,
  1768. .protocol_id = SMB30_PROT_ID,
  1769. .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION,
  1770. .large_lock_type = 0,
  1771. .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
  1772. .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
  1773. .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
  1774. .header_size = sizeof(struct smb2_hdr),
  1775. .max_header_size = MAX_SMB2_HDR_SIZE,
  1776. .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
  1777. .lock_cmd = SMB2_LOCK,
  1778. .cap_unix = 0,
  1779. .cap_nt_find = SMB2_NT_FIND,
  1780. .cap_large_files = SMB2_LARGE_FILES,
  1781. .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
  1782. .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
  1783. .create_lease_size = sizeof(struct create_lease_v2),
  1784. };
  1785. struct smb_version_values smb302_values = {
  1786. .version_string = SMB302_VERSION_STRING,
  1787. .protocol_id = SMB302_PROT_ID,
  1788. .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION,
  1789. .large_lock_type = 0,
  1790. .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
  1791. .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
  1792. .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
  1793. .header_size = sizeof(struct smb2_hdr),
  1794. .max_header_size = MAX_SMB2_HDR_SIZE,
  1795. .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
  1796. .lock_cmd = SMB2_LOCK,
  1797. .cap_unix = 0,
  1798. .cap_nt_find = SMB2_NT_FIND,
  1799. .cap_large_files = SMB2_LARGE_FILES,
  1800. .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
  1801. .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
  1802. .create_lease_size = sizeof(struct create_lease_v2),
  1803. };
  1804. #ifdef CONFIG_CIFS_SMB311
  1805. struct smb_version_values smb311_values = {
  1806. .version_string = SMB311_VERSION_STRING,
  1807. .protocol_id = SMB311_PROT_ID,
  1808. .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES,
  1809. .large_lock_type = 0,
  1810. .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
  1811. .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
  1812. .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
  1813. .header_size = sizeof(struct smb2_hdr),
  1814. .max_header_size = MAX_SMB2_HDR_SIZE,
  1815. .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
  1816. .lock_cmd = SMB2_LOCK,
  1817. .cap_unix = 0,
  1818. .cap_nt_find = SMB2_NT_FIND,
  1819. .cap_large_files = SMB2_LARGE_FILES,
  1820. .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
  1821. .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
  1822. .create_lease_size = sizeof(struct create_lease_v2),
  1823. };
  1824. #endif /* SMB311 */