@@ -329,25 +329,32 @@ static bool osd_req_opcode_valid(u16 opcode)
329329 * other information associated with them. It also serves as a
330330 * common init routine for all the other init functions, below.
331331 */
332- void osd_req_op_init (struct ceph_osd_req_op * op , u16 opcode )
332+ static struct ceph_osd_req_op *
333+ osd_req_op_init (struct ceph_osd_request * osd_req , unsigned int which ,
334+ u16 opcode )
333335{
336+ struct ceph_osd_req_op * op ;
337+
338+ BUG_ON (which >= osd_req -> r_num_ops );
334339 BUG_ON (!osd_req_opcode_valid (opcode ));
335340
341+ op = & osd_req -> r_ops [which ];
336342 memset (op , 0 , sizeof (* op ));
337-
338343 op -> op = opcode ;
344+
345+ return op ;
339346}
340347
341- void osd_req_op_extent_init (struct ceph_osd_req_op * op , u16 opcode ,
348+ void osd_req_op_extent_init (struct ceph_osd_request * osd_req ,
349+ unsigned int which , u16 opcode ,
342350 u64 offset , u64 length ,
343351 u64 truncate_size , u32 truncate_seq )
344352{
353+ struct ceph_osd_req_op * op = osd_req_op_init (osd_req , which , opcode );
345354 size_t payload_len = 0 ;
346355
347356 BUG_ON (opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE );
348357
349- osd_req_op_init (op , opcode );
350-
351358 op -> extent .offset = offset ;
352359 op -> extent .length = length ;
353360 op -> extent .truncate_size = truncate_size ;
@@ -359,9 +366,15 @@ void osd_req_op_extent_init(struct ceph_osd_req_op *op, u16 opcode,
359366}
360367EXPORT_SYMBOL (osd_req_op_extent_init );
361368
362- void osd_req_op_extent_update (struct ceph_osd_req_op * op , u64 length )
369+ void osd_req_op_extent_update (struct ceph_osd_request * osd_req ,
370+ unsigned int which , u64 length )
363371{
364- u64 previous = op -> extent .length ;
372+ struct ceph_osd_req_op * op ;
373+ u64 previous ;
374+
375+ BUG_ON (which >= osd_req -> r_num_ops );
376+ op = & osd_req -> r_ops [which ];
377+ previous = op -> extent .length ;
365378
366379 if (length == previous )
367380 return ; /* Nothing to do */
@@ -372,24 +385,25 @@ void osd_req_op_extent_update(struct ceph_osd_req_op *op, u64 length)
372385}
373386EXPORT_SYMBOL (osd_req_op_extent_update );
374387
375- void osd_req_op_extent_osd_data (struct ceph_osd_req_op * op ,
388+ void osd_req_op_extent_osd_data (struct ceph_osd_request * osd_req ,
389+ unsigned int which ,
376390 struct ceph_osd_data * osd_data )
377391{
378- op -> extent .osd_data = osd_data ;
392+ BUG_ON (which >= osd_req -> r_num_ops );
393+ osd_req -> r_ops [which ].extent .osd_data = osd_data ;
379394}
380395EXPORT_SYMBOL (osd_req_op_extent_osd_data );
381396
382- void osd_req_op_cls_init (struct ceph_osd_req_op * op , u16 opcode ,
383- const char * class , const char * method ,
397+ void osd_req_op_cls_init (struct ceph_osd_request * osd_req , unsigned int which ,
398+ u16 opcode , const char * class , const char * method ,
384399 const void * request_data , size_t request_data_size )
385400{
401+ struct ceph_osd_req_op * op = osd_req_op_init (osd_req , which , opcode );
386402 size_t payload_len = 0 ;
387403 size_t size ;
388404
389405 BUG_ON (opcode != CEPH_OSD_OP_CALL );
390406
391- osd_req_op_init (op , opcode );
392-
393407 op -> cls .class_name = class ;
394408 size = strlen (class );
395409 BUG_ON (size > (size_t ) U8_MAX );
@@ -412,26 +426,28 @@ void osd_req_op_cls_init(struct ceph_osd_req_op *op, u16 opcode,
412426 op -> payload_len = payload_len ;
413427}
414428EXPORT_SYMBOL (osd_req_op_cls_init );
415-
416- void osd_req_op_cls_response_data ( struct ceph_osd_req_op * op ,
429+ void osd_req_op_cls_response_data ( struct ceph_osd_request * osd_req ,
430+ unsigned int which ,
417431 struct ceph_osd_data * response_data )
418432{
419- op -> cls .response_data = response_data ;
433+ BUG_ON (which >= osd_req -> r_num_ops );
434+ osd_req -> r_ops [which ].cls .response_data = response_data ;
420435}
421436EXPORT_SYMBOL (osd_req_op_cls_response_data );
422437
423- void osd_req_op_watch_init (struct ceph_osd_req_op * op , u16 opcode ,
438+ void osd_req_op_watch_init (struct ceph_osd_request * osd_req ,
439+ unsigned int which , u16 opcode ,
424440 u64 cookie , u64 version , int flag )
425441{
426- BUG_ON ( opcode != CEPH_OSD_OP_NOTIFY_ACK && opcode != CEPH_OSD_OP_WATCH );
442+ struct ceph_osd_req_op * op = osd_req_op_init ( osd_req , which , opcode );
427443
428- osd_req_op_init ( op , opcode );
444+ BUG_ON ( opcode != CEPH_OSD_OP_NOTIFY_ACK && opcode != CEPH_OSD_OP_WATCH );
429445
430446 op -> watch .cookie = cookie ;
431447 /* op->watch.ver = version; */ /* XXX 3847 */
432448 op -> watch .ver = cpu_to_le64 (version );
433449 if (opcode == CEPH_OSD_OP_WATCH && flag )
434- op -> watch .flag = (u8 ) 1 ;
450+ op -> watch .flag = (u8 )1 ;
435451}
436452EXPORT_SYMBOL (osd_req_op_watch_init );
437453
@@ -629,7 +645,6 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
629645{
630646 struct ceph_osd_request * req ;
631647 struct ceph_osd_data * osd_data ;
632- struct ceph_osd_req_op * op ;
633648 u64 objnum = 0 ;
634649 u64 objoff = 0 ;
635650 u64 objlen = 0 ;
@@ -665,18 +680,17 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
665680 truncate_size = object_size ;
666681 }
667682
668- op = & req -> r_ops [0 ];
669- osd_req_op_extent_init (op , opcode , objoff , objlen ,
683+ osd_req_op_extent_init (req , 0 , opcode , objoff , objlen ,
670684 truncate_size , truncate_seq );
671- osd_req_op_extent_osd_data (op , osd_data );
685+ osd_req_op_extent_osd_data (req , 0 , osd_data );
672686
673687 /*
674688 * A second op in the ops array means the caller wants to
675689 * also issue a include a 'startsync' command so that the
676690 * osd will flush data quickly.
677691 */
678692 if (num_ops > 1 )
679- osd_req_op_init (++ op , CEPH_OSD_OP_STARTSYNC );
693+ osd_req_op_init (req , 1 , CEPH_OSD_OP_STARTSYNC );
680694
681695 req -> r_file_layout = * layout ; /* keep a copy */
682696
0 commit comments