@@ -350,8 +350,7 @@ static void ceph_osdc_release_request(struct kref *kref)
350350 for (which = 0 ; which < req -> r_num_ops ; which ++ )
351351 osd_req_op_data_release (req , which );
352352
353- ceph_oid_destroy (& req -> r_base_oid );
354- ceph_oid_destroy (& req -> r_target_oid );
353+ target_destroy (& req -> r_t );
355354 ceph_put_snap_context (req -> r_snapc );
356355
357356 if (req -> r_mempool )
@@ -420,10 +419,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
420419 INIT_LIST_HEAD (& req -> r_req_lru_item );
421420 INIT_LIST_HEAD (& req -> r_osd_item );
422421
423- ceph_oid_init (& req -> r_base_oid );
424- req -> r_base_oloc .pool = -1 ;
425- ceph_oid_init (& req -> r_target_oid );
426- req -> r_target_oloc .pool = -1 ;
422+ target_init (& req -> r_t );
427423
428424 dout ("%s req %p\n" , __func__ , req );
429425 return req ;
@@ -1308,16 +1304,6 @@ static bool __pool_full(struct ceph_pg_pool_info *pi)
13081304 *
13091305 * Caller should hold map_sem for read.
13101306 */
1311- static bool __req_should_be_paused (struct ceph_osd_client * osdc ,
1312- struct ceph_osd_request * req )
1313- {
1314- bool pauserd = ceph_osdmap_flag (osdc -> osdmap , CEPH_OSDMAP_PAUSERD );
1315- bool pausewr = ceph_osdmap_flag (osdc -> osdmap , CEPH_OSDMAP_PAUSEWR ) ||
1316- ceph_osdmap_flag (osdc -> osdmap , CEPH_OSDMAP_FULL );
1317- return (req -> r_flags & CEPH_OSD_FLAG_READ && pauserd ) ||
1318- (req -> r_flags & CEPH_OSD_FLAG_WRITE && pausewr );
1319- }
1320-
13211307static bool target_should_be_paused (struct ceph_osd_client * osdc ,
13221308 const struct ceph_osd_request_target * t ,
13231309 struct ceph_pg_pool_info * pi )
@@ -1332,45 +1318,6 @@ static bool target_should_be_paused(struct ceph_osd_client *osdc,
13321318 (t -> flags & CEPH_OSD_FLAG_WRITE && pausewr );
13331319}
13341320
1335- /*
1336- * Calculate mapping of a request to a PG. Takes tiering into account.
1337- */
1338- static int __calc_request_pg (struct ceph_osdmap * osdmap ,
1339- struct ceph_osd_request * req ,
1340- struct ceph_pg * pg_out )
1341- {
1342- bool need_check_tiering ;
1343-
1344- need_check_tiering = false;
1345- if (req -> r_target_oloc .pool == -1 ) {
1346- req -> r_target_oloc = req -> r_base_oloc ; /* struct */
1347- need_check_tiering = true;
1348- }
1349- if (ceph_oid_empty (& req -> r_target_oid )) {
1350- ceph_oid_copy (& req -> r_target_oid , & req -> r_base_oid );
1351- need_check_tiering = true;
1352- }
1353-
1354- if (need_check_tiering &&
1355- (req -> r_flags & CEPH_OSD_FLAG_IGNORE_OVERLAY ) == 0 ) {
1356- struct ceph_pg_pool_info * pi ;
1357-
1358- pi = ceph_pg_pool_by_id (osdmap , req -> r_target_oloc .pool );
1359- if (pi ) {
1360- if ((req -> r_flags & CEPH_OSD_FLAG_READ ) &&
1361- pi -> read_tier >= 0 )
1362- req -> r_target_oloc .pool = pi -> read_tier ;
1363- if ((req -> r_flags & CEPH_OSD_FLAG_WRITE ) &&
1364- pi -> write_tier >= 0 )
1365- req -> r_target_oloc .pool = pi -> write_tier ;
1366- }
1367- /* !pi is caught in ceph_oloc_oid_to_pg() */
1368- }
1369-
1370- return ceph_object_locator_to_pg (osdmap , & req -> r_target_oid ,
1371- & req -> r_target_oloc , pg_out );
1372- }
1373-
13741321enum calc_target_result {
13751322 CALC_TARGET_NO_ACTION = 0 ,
13761323 CALC_TARGET_NEED_RESEND ,
@@ -1510,69 +1457,49 @@ static void __enqueue_request(struct ceph_osd_request *req)
15101457static int __map_request (struct ceph_osd_client * osdc ,
15111458 struct ceph_osd_request * req , int force_resend )
15121459{
1513- struct ceph_pg pgid ;
1514- struct ceph_osds up , acting ;
1460+ enum calc_target_result ct_res ;
15151461 int err ;
1516- bool was_paused ;
15171462
15181463 dout ("map_request %p tid %lld\n" , req , req -> r_tid );
15191464
1520- err = __calc_request_pg (osdc -> osdmap , req , & pgid );
1521- if (err ) {
1465+ ct_res = calc_target (osdc , & req -> r_t , NULL , force_resend );
1466+ switch (ct_res ) {
1467+ case CALC_TARGET_POOL_DNE :
15221468 list_move (& req -> r_req_lru_item , & osdc -> req_notarget );
1523- return err ;
1524- }
1525- req -> r_pgid = pgid ;
1526-
1527- ceph_pg_to_up_acting_osds (osdc -> osdmap , & pgid , & up , & acting );
1528-
1529- was_paused = req -> r_paused ;
1530- req -> r_paused = __req_should_be_paused (osdc , req );
1531- if (was_paused && !req -> r_paused )
1532- force_resend = 1 ;
1533-
1534- if ((!force_resend &&
1535- req -> r_osd && req -> r_osd -> o_osd == acting .primary &&
1536- req -> r_sent >= req -> r_osd -> o_incarnation &&
1537- req -> r_num_pg_osds == acting .size &&
1538- memcmp (req -> r_pg_osds , acting .osds ,
1539- acting .size * sizeof (acting .osds [0 ])) == 0 ) ||
1540- (req -> r_osd == NULL && acting .primary == -1 ) ||
1541- req -> r_paused )
1469+ return - EIO ;
1470+ case CALC_TARGET_NO_ACTION :
15421471 return 0 ; /* no change */
1472+ default :
1473+ BUG_ON (ct_res != CALC_TARGET_NEED_RESEND );
1474+ }
15431475
15441476 dout ("map_request tid %llu pgid %lld.%x osd%d (was osd%d)\n" ,
1545- req -> r_tid , pgid .pool , pgid .seed , acting . primary ,
1477+ req -> r_tid , req -> r_t . pgid .pool , req -> r_t . pgid .seed , req -> r_t . osd ,
15461478 req -> r_osd ? req -> r_osd -> o_osd : -1 );
15471479
1548- /* record full pg acting set */
1549- memcpy (req -> r_pg_osds , acting .osds ,
1550- acting .size * sizeof (acting .osds [0 ]));
1551- req -> r_num_pg_osds = acting .size ;
1552-
15531480 if (req -> r_osd ) {
15541481 __cancel_request (req );
15551482 list_del_init (& req -> r_osd_item );
15561483 list_del_init (& req -> r_linger_osd_item );
15571484 req -> r_osd = NULL ;
15581485 }
15591486
1560- req -> r_osd = lookup_osd (& osdc -> osds , acting . primary );
1561- if (!req -> r_osd && acting . primary >= 0 ) {
1487+ req -> r_osd = lookup_osd (& osdc -> osds , req -> r_t . osd );
1488+ if (!req -> r_osd && req -> r_t . osd >= 0 ) {
15621489 err = - ENOMEM ;
1563- req -> r_osd = create_osd (osdc , acting . primary );
1490+ req -> r_osd = create_osd (osdc , req -> r_t . osd );
15641491 if (!req -> r_osd ) {
15651492 list_move (& req -> r_req_lru_item , & osdc -> req_notarget );
15661493 goto out ;
15671494 }
15681495
15691496 dout ("map_request osd %p is osd%d\n" , req -> r_osd ,
1570- acting . primary );
1497+ req -> r_osd -> o_osd );
15711498 insert_osd (& osdc -> osds , req -> r_osd );
15721499
15731500 ceph_con_open (& req -> r_osd -> o_con ,
1574- CEPH_ENTITY_TYPE_OSD , acting . primary ,
1575- & osdc -> osdmap -> osd_addr [acting . primary ]);
1501+ CEPH_ENTITY_TYPE_OSD , req -> r_osd -> o_osd ,
1502+ & osdc -> osdmap -> osd_addr [req -> r_osd -> o_osd ]);
15761503 }
15771504
15781505 __enqueue_request (req );
@@ -1592,15 +1519,15 @@ static void __send_request(struct ceph_osd_client *osdc,
15921519
15931520 dout ("send_request %p tid %llu to osd%d flags %d pg %lld.%x\n" ,
15941521 req , req -> r_tid , req -> r_osd -> o_osd , req -> r_flags ,
1595- ( unsigned long long ) req -> r_pgid . pool , req -> r_pgid .seed );
1522+ req -> r_t . pgid . pool , req -> r_t . pgid .seed );
15961523
15971524 /* fill in message content that changes each time we send it */
15981525 put_unaligned_le32 (osdc -> osdmap -> epoch , req -> r_request_osdmap_epoch );
15991526 put_unaligned_le32 (req -> r_flags , req -> r_request_flags );
1600- put_unaligned_le64 (req -> r_target_oloc .pool , req -> r_request_pool );
1527+ put_unaligned_le64 (req -> r_t . target_oloc .pool , req -> r_request_pool );
16011528 p = req -> r_request_pgid ;
1602- ceph_encode_64 (& p , req -> r_pgid .pool );
1603- ceph_encode_32 (& p , req -> r_pgid .seed );
1529+ ceph_encode_64 (& p , req -> r_t . pgid .pool );
1530+ ceph_encode_32 (& p , req -> r_t . pgid .seed );
16041531 put_unaligned_le64 (1 , req -> r_request_attempts ); /* FIXME */
16051532 memcpy (req -> r_request_reassert_version , & req -> r_reassert_version ,
16061533 sizeof (req -> r_reassert_version ));
@@ -1963,7 +1890,7 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg)
19631890
19641891 __unregister_request (osdc , req );
19651892
1966- ceph_oloc_copy (& req -> r_target_oloc , & redir .oloc );
1893+ ceph_oloc_copy (& req -> r_t . target_oloc , & redir .oloc );
19671894
19681895 /*
19691896 * Start redirect requests with nofail=true. If
0 commit comments