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