@@ -821,7 +821,6 @@ create_posix_buf(umode_t mode)
821
821
static int
822
822
add_posix_context (struct kvec * iov , unsigned int * num_iovec , umode_t mode )
823
823
{
824
- struct smb2_create_req * req = iov [0 ].iov_base ;
825
824
unsigned int num = * num_iovec ;
826
825
827
826
iov [num ].iov_base = create_posix_buf (mode );
@@ -830,11 +829,6 @@ add_posix_context(struct kvec *iov, unsigned int *num_iovec, umode_t mode)
830
829
if (iov [num ].iov_base == NULL )
831
830
return - ENOMEM ;
832
831
iov [num ].iov_len = sizeof (struct create_posix );
833
- if (!req -> CreateContextsOffset )
834
- req -> CreateContextsOffset = cpu_to_le32 (
835
- sizeof (struct smb2_create_req ) +
836
- iov [num - 1 ].iov_len );
837
- le32_add_cpu (& req -> CreateContextsLength , sizeof (struct create_posix ));
838
832
* num_iovec = num + 1 ;
839
833
return 0 ;
840
834
}
@@ -2069,7 +2063,7 @@ create_reconnect_durable_buf(struct cifs_fid *fid)
2069
2063
static void
2070
2064
parse_query_id_ctxt (struct create_context * cc , struct smb2_file_all_info * buf )
2071
2065
{
2072
- struct create_on_disk_id * pdisk_id = (struct create_on_disk_id * )cc ;
2066
+ struct create_disk_id_rsp * pdisk_id = (struct create_disk_id_rsp * )cc ;
2073
2067
2074
2068
cifs_dbg (FYI , "parse query id context 0x%llx 0x%llx\n" ,
2075
2069
pdisk_id -> DiskFileId , pdisk_id -> VolumeId );
@@ -2172,23 +2166,18 @@ smb2_parse_contexts(struct TCP_Server_Info *server,
2172
2166
}
2173
2167
2174
2168
static int
2175
- add_lease_context (struct TCP_Server_Info * server , struct kvec * iov ,
2169
+ add_lease_context (struct TCP_Server_Info * server ,
2170
+ struct smb2_create_req * req ,
2171
+ struct kvec * iov ,
2176
2172
unsigned int * num_iovec , u8 * lease_key , __u8 * oplock )
2177
2173
{
2178
- struct smb2_create_req * req = iov [0 ].iov_base ;
2179
2174
unsigned int num = * num_iovec ;
2180
2175
2181
2176
iov [num ].iov_base = server -> ops -> create_lease_buf (lease_key , * oplock );
2182
2177
if (iov [num ].iov_base == NULL )
2183
2178
return - ENOMEM ;
2184
2179
iov [num ].iov_len = server -> vals -> create_lease_size ;
2185
2180
req -> RequestedOplockLevel = SMB2_OPLOCK_LEVEL_LEASE ;
2186
- if (!req -> CreateContextsOffset )
2187
- req -> CreateContextsOffset = cpu_to_le32 (
2188
- sizeof (struct smb2_create_req ) +
2189
- iov [num - 1 ].iov_len );
2190
- le32_add_cpu (& req -> CreateContextsLength ,
2191
- server -> vals -> create_lease_size );
2192
2181
* num_iovec = num + 1 ;
2193
2182
return 0 ;
2194
2183
}
@@ -2267,18 +2256,12 @@ static int
2267
2256
add_durable_v2_context (struct kvec * iov , unsigned int * num_iovec ,
2268
2257
struct cifs_open_parms * oparms )
2269
2258
{
2270
- struct smb2_create_req * req = iov [0 ].iov_base ;
2271
2259
unsigned int num = * num_iovec ;
2272
2260
2273
2261
iov [num ].iov_base = create_durable_v2_buf (oparms );
2274
2262
if (iov [num ].iov_base == NULL )
2275
2263
return - ENOMEM ;
2276
2264
iov [num ].iov_len = sizeof (struct create_durable_v2 );
2277
- if (!req -> CreateContextsOffset )
2278
- req -> CreateContextsOffset =
2279
- cpu_to_le32 (sizeof (struct smb2_create_req ) +
2280
- iov [1 ].iov_len );
2281
- le32_add_cpu (& req -> CreateContextsLength , sizeof (struct create_durable_v2 ));
2282
2265
* num_iovec = num + 1 ;
2283
2266
return 0 ;
2284
2267
}
@@ -2287,7 +2270,6 @@ static int
2287
2270
add_durable_reconnect_v2_context (struct kvec * iov , unsigned int * num_iovec ,
2288
2271
struct cifs_open_parms * oparms )
2289
2272
{
2290
- struct smb2_create_req * req = iov [0 ].iov_base ;
2291
2273
unsigned int num = * num_iovec ;
2292
2274
2293
2275
/* indicate that we don't need to relock the file */
@@ -2297,12 +2279,6 @@ add_durable_reconnect_v2_context(struct kvec *iov, unsigned int *num_iovec,
2297
2279
if (iov [num ].iov_base == NULL )
2298
2280
return - ENOMEM ;
2299
2281
iov [num ].iov_len = sizeof (struct create_durable_handle_reconnect_v2 );
2300
- if (!req -> CreateContextsOffset )
2301
- req -> CreateContextsOffset =
2302
- cpu_to_le32 (sizeof (struct smb2_create_req ) +
2303
- iov [1 ].iov_len );
2304
- le32_add_cpu (& req -> CreateContextsLength ,
2305
- sizeof (struct create_durable_handle_reconnect_v2 ));
2306
2282
* num_iovec = num + 1 ;
2307
2283
return 0 ;
2308
2284
}
@@ -2311,7 +2287,6 @@ static int
2311
2287
add_durable_context (struct kvec * iov , unsigned int * num_iovec ,
2312
2288
struct cifs_open_parms * oparms , bool use_persistent )
2313
2289
{
2314
- struct smb2_create_req * req = iov [0 ].iov_base ;
2315
2290
unsigned int num = * num_iovec ;
2316
2291
2317
2292
if (use_persistent ) {
@@ -2331,11 +2306,6 @@ add_durable_context(struct kvec *iov, unsigned int *num_iovec,
2331
2306
if (iov [num ].iov_base == NULL )
2332
2307
return - ENOMEM ;
2333
2308
iov [num ].iov_len = sizeof (struct create_durable );
2334
- if (!req -> CreateContextsOffset )
2335
- req -> CreateContextsOffset =
2336
- cpu_to_le32 (sizeof (struct smb2_create_req ) +
2337
- iov [1 ].iov_len );
2338
- le32_add_cpu (& req -> CreateContextsLength , sizeof (struct create_durable ));
2339
2309
* num_iovec = num + 1 ;
2340
2310
return 0 ;
2341
2311
}
@@ -2369,18 +2339,12 @@ create_twarp_buf(__u64 timewarp)
2369
2339
static int
2370
2340
add_twarp_context (struct kvec * iov , unsigned int * num_iovec , __u64 timewarp )
2371
2341
{
2372
- struct smb2_create_req * req = iov [0 ].iov_base ;
2373
2342
unsigned int num = * num_iovec ;
2374
2343
2375
2344
iov [num ].iov_base = create_twarp_buf (timewarp );
2376
2345
if (iov [num ].iov_base == NULL )
2377
2346
return - ENOMEM ;
2378
2347
iov [num ].iov_len = sizeof (struct crt_twarp_ctxt );
2379
- if (!req -> CreateContextsOffset )
2380
- req -> CreateContextsOffset = cpu_to_le32 (
2381
- sizeof (struct smb2_create_req ) +
2382
- iov [num - 1 ].iov_len );
2383
- le32_add_cpu (& req -> CreateContextsLength , sizeof (struct crt_twarp_ctxt ));
2384
2348
* num_iovec = num + 1 ;
2385
2349
return 0 ;
2386
2350
}
@@ -2503,19 +2467,13 @@ create_sd_buf(umode_t mode, bool set_owner, unsigned int *len)
2503
2467
static int
2504
2468
add_sd_context (struct kvec * iov , unsigned int * num_iovec , umode_t mode , bool set_owner )
2505
2469
{
2506
- struct smb2_create_req * req = iov [0 ].iov_base ;
2507
2470
unsigned int num = * num_iovec ;
2508
2471
unsigned int len = 0 ;
2509
2472
2510
2473
iov [num ].iov_base = create_sd_buf (mode , set_owner , & len );
2511
2474
if (iov [num ].iov_base == NULL )
2512
2475
return - ENOMEM ;
2513
2476
iov [num ].iov_len = len ;
2514
- if (!req -> CreateContextsOffset )
2515
- req -> CreateContextsOffset = cpu_to_le32 (
2516
- sizeof (struct smb2_create_req ) +
2517
- iov [num - 1 ].iov_len );
2518
- le32_add_cpu (& req -> CreateContextsLength , len );
2519
2477
* num_iovec = num + 1 ;
2520
2478
return 0 ;
2521
2479
}
@@ -2546,18 +2504,12 @@ create_query_id_buf(void)
2546
2504
static int
2547
2505
add_query_id_context (struct kvec * iov , unsigned int * num_iovec )
2548
2506
{
2549
- struct smb2_create_req * req = iov [0 ].iov_base ;
2550
2507
unsigned int num = * num_iovec ;
2551
2508
2552
2509
iov [num ].iov_base = create_query_id_buf ();
2553
2510
if (iov [num ].iov_base == NULL )
2554
2511
return - ENOMEM ;
2555
2512
iov [num ].iov_len = sizeof (struct crt_query_id_ctxt );
2556
- if (!req -> CreateContextsOffset )
2557
- req -> CreateContextsOffset = cpu_to_le32 (
2558
- sizeof (struct smb2_create_req ) +
2559
- iov [num - 1 ].iov_len );
2560
- le32_add_cpu (& req -> CreateContextsLength , sizeof (struct crt_query_id_ctxt ));
2561
2513
* num_iovec = num + 1 ;
2562
2514
return 0 ;
2563
2515
}
@@ -2720,6 +2672,9 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
2720
2672
rc = add_posix_context (iov , & n_iov , mode );
2721
2673
if (rc )
2722
2674
goto err_free_req ;
2675
+ req -> CreateContextsOffset = cpu_to_le32 (
2676
+ sizeof (struct smb2_create_req ) +
2677
+ iov [1 ].iov_len );
2723
2678
pc_buf = iov [n_iov - 1 ].iov_base ;
2724
2679
}
2725
2680
@@ -2857,49 +2812,27 @@ SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
2857
2812
(oparms -> create_options & CREATE_NOT_FILE ))
2858
2813
req -> RequestedOplockLevel = * oplock ; /* no srv lease support */
2859
2814
else {
2860
- rc = add_lease_context (server , iov , & n_iov ,
2815
+ rc = add_lease_context (server , req , iov , & n_iov ,
2861
2816
oparms -> fid -> lease_key , oplock );
2862
2817
if (rc )
2863
2818
return rc ;
2864
2819
}
2865
2820
2866
2821
if (* oplock == SMB2_OPLOCK_LEVEL_BATCH ) {
2867
- /* need to set Next field of lease context if we request it */
2868
- if (server -> capabilities & SMB2_GLOBAL_CAP_LEASING ) {
2869
- struct create_context * ccontext =
2870
- (struct create_context * )iov [n_iov - 1 ].iov_base ;
2871
- ccontext -> Next =
2872
- cpu_to_le32 (server -> vals -> create_lease_size );
2873
- }
2874
-
2875
2822
rc = add_durable_context (iov , & n_iov , oparms ,
2876
2823
tcon -> use_persistent );
2877
2824
if (rc )
2878
2825
return rc ;
2879
2826
}
2880
2827
2881
2828
if (tcon -> posix_extensions ) {
2882
- if (n_iov > 2 ) {
2883
- struct create_context * ccontext =
2884
- (struct create_context * )iov [n_iov - 1 ].iov_base ;
2885
- ccontext -> Next =
2886
- cpu_to_le32 (iov [n_iov - 1 ].iov_len );
2887
- }
2888
-
2889
2829
rc = add_posix_context (iov , & n_iov , oparms -> mode );
2890
2830
if (rc )
2891
2831
return rc ;
2892
2832
}
2893
2833
2894
2834
if (tcon -> snapshot_time ) {
2895
2835
cifs_dbg (FYI , "adding snapshot context\n" );
2896
- if (n_iov > 2 ) {
2897
- struct create_context * ccontext =
2898
- (struct create_context * )iov [n_iov - 1 ].iov_base ;
2899
- ccontext -> Next =
2900
- cpu_to_le32 (iov [n_iov - 1 ].iov_len );
2901
- }
2902
-
2903
2836
rc = add_twarp_context (iov , & n_iov , tcon -> snapshot_time );
2904
2837
if (rc )
2905
2838
return rc ;
@@ -2923,25 +2856,37 @@ SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
2923
2856
set_owner = false;
2924
2857
2925
2858
if (set_owner | set_mode ) {
2926
- if (n_iov > 2 ) {
2927
- struct create_context * ccontext =
2928
- (struct create_context * )iov [n_iov - 1 ].iov_base ;
2929
- ccontext -> Next = cpu_to_le32 (iov [n_iov - 1 ].iov_len );
2930
- }
2931
-
2932
2859
cifs_dbg (FYI , "add sd with mode 0x%x\n" , oparms -> mode );
2933
2860
rc = add_sd_context (iov , & n_iov , oparms -> mode , set_owner );
2934
2861
if (rc )
2935
2862
return rc ;
2936
2863
}
2937
2864
}
2938
2865
2866
+ add_query_id_context (iov , & n_iov );
2867
+
2939
2868
if (n_iov > 2 ) {
2940
- struct create_context * ccontext =
2941
- (struct create_context * )iov [n_iov - 1 ].iov_base ;
2942
- ccontext -> Next = cpu_to_le32 (iov [n_iov - 1 ].iov_len );
2869
+ /*
2870
+ * We have create contexts behind iov[1] (the file
2871
+ * name), point at them from the main create request
2872
+ */
2873
+ req -> CreateContextsOffset = cpu_to_le32 (
2874
+ sizeof (struct smb2_create_req ) +
2875
+ iov [1 ].iov_len );
2876
+ req -> CreateContextsLength = 0 ;
2877
+
2878
+ for (unsigned int i = 2 ; i < (n_iov - 1 ); i ++ ) {
2879
+ struct kvec * v = & iov [i ];
2880
+ size_t len = v -> iov_len ;
2881
+ struct create_context * cctx =
2882
+ (struct create_context * )v -> iov_base ;
2883
+
2884
+ cctx -> Next = cpu_to_le32 (len );
2885
+ le32_add_cpu (& req -> CreateContextsLength , len );
2886
+ }
2887
+ le32_add_cpu (& req -> CreateContextsLength ,
2888
+ iov [n_iov - 1 ].iov_len );
2943
2889
}
2944
- add_query_id_context (iov , & n_iov );
2945
2890
2946
2891
rqst -> rq_nvec = n_iov ;
2947
2892
return 0 ;
0 commit comments