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