forked from mirrors/linux
		
	blkcg: rename blkg_try_get to blkg_tryget
blkg reference counting now uses percpu_ref rather than atomic_t. Let's make this consistent with css_tryget. This renames blkg_try_get to blkg_tryget and now returns a bool rather than the blkg or NULL. Signed-off-by: Dennis Zhou <dennisszhou@gmail.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
		
							parent
							
								
									b3b9f24f5f
								
							
						
					
					
						commit
						101246ec02
					
				
					 4 changed files with 9 additions and 12 deletions
				
			
		|  | @ -1974,7 +1974,7 @@ int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg) | ||||||
| { | { | ||||||
| 	if (unlikely(bio->bi_blkg)) | 	if (unlikely(bio->bi_blkg)) | ||||||
| 		return -EBUSY; | 		return -EBUSY; | ||||||
| 	bio->bi_blkg = blkg_try_get_closest(blkg); | 	bio->bi_blkg = blkg_tryget_closest(blkg); | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1794,8 +1794,7 @@ void blkcg_maybe_throttle_current(void) | ||||||
| 	blkg = blkg_lookup(blkcg, q); | 	blkg = blkg_lookup(blkcg, q); | ||||||
| 	if (!blkg) | 	if (!blkg) | ||||||
| 		goto out; | 		goto out; | ||||||
| 	blkg = blkg_try_get(blkg); | 	if (!blkg_tryget(blkg)) | ||||||
| 	if (!blkg) |  | ||||||
| 		goto out; | 		goto out; | ||||||
| 	rcu_read_unlock(); | 	rcu_read_unlock(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -625,7 +625,7 @@ static void blkiolatency_timer_fn(struct timer_list *t) | ||||||
| 		 * We could be exiting, don't access the pd unless we have a | 		 * We could be exiting, don't access the pd unless we have a | ||||||
| 		 * ref on the blkg. | 		 * ref on the blkg. | ||||||
| 		 */ | 		 */ | ||||||
| 		if (!blkg_try_get(blkg)) | 		if (!blkg_tryget(blkg)) | ||||||
| 			continue; | 			continue; | ||||||
| 
 | 
 | ||||||
| 		iolat = blkg_to_lat(blkg); | 		iolat = blkg_to_lat(blkg); | ||||||
|  |  | ||||||
|  | @ -494,27 +494,25 @@ static inline void blkg_get(struct blkcg_gq *blkg) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * blkg_try_get - try and get a blkg reference |  * blkg_tryget - try and get a blkg reference | ||||||
|  * @blkg: blkg to get |  * @blkg: blkg to get | ||||||
|  * |  * | ||||||
|  * This is for use when doing an RCU lookup of the blkg.  We may be in the midst |  * This is for use when doing an RCU lookup of the blkg.  We may be in the midst | ||||||
|  * of freeing this blkg, so we can only use it if the refcnt is not zero. |  * of freeing this blkg, so we can only use it if the refcnt is not zero. | ||||||
|  */ |  */ | ||||||
| static inline struct blkcg_gq *blkg_try_get(struct blkcg_gq *blkg) | static inline bool blkg_tryget(struct blkcg_gq *blkg) | ||||||
| { | { | ||||||
| 	if (percpu_ref_tryget(&blkg->refcnt)) | 	return percpu_ref_tryget(&blkg->refcnt); | ||||||
| 		return blkg; |  | ||||||
| 	return NULL; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * blkg_try_get_closest - try and get a blkg ref on the closet blkg |  * blkg_tryget_closest - try and get a blkg ref on the closet blkg | ||||||
|  * @blkg: blkg to get |  * @blkg: blkg to get | ||||||
|  * |  * | ||||||
|  * This walks up the blkg tree to find the closest non-dying blkg and returns |  * This walks up the blkg tree to find the closest non-dying blkg and returns | ||||||
|  * the blkg that it did association with as it may not be the passed in blkg. |  * the blkg that it did association with as it may not be the passed in blkg. | ||||||
|  */ |  */ | ||||||
| static inline struct blkcg_gq *blkg_try_get_closest(struct blkcg_gq *blkg) | static inline struct blkcg_gq *blkg_tryget_closest(struct blkcg_gq *blkg) | ||||||
| { | { | ||||||
| 	while (!percpu_ref_tryget(&blkg->refcnt)) | 	while (!percpu_ref_tryget(&blkg->refcnt)) | ||||||
| 		blkg = blkg->parent; | 		blkg = blkg->parent; | ||||||
|  | @ -599,7 +597,7 @@ static inline struct request_list *blk_get_rl(struct request_queue *q, | ||||||
| 	if (unlikely(!blkg)) | 	if (unlikely(!blkg)) | ||||||
| 		blkg = __blkg_lookup_create(blkcg, q); | 		blkg = __blkg_lookup_create(blkcg, q); | ||||||
| 
 | 
 | ||||||
| 	if (!blkg_try_get(blkg)) | 	if (!blkg_tryget(blkg)) | ||||||
| 		goto rl_use_root; | 		goto rl_use_root; | ||||||
| 
 | 
 | ||||||
| 	rcu_read_unlock(); | 	rcu_read_unlock(); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Dennis Zhou (Facebook)
						Dennis Zhou (Facebook)