Re: [PATCH 3/3] blk-wbt: throttle discards like background writes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -static inline struct rq_wait *get_rq_wait(struct rq_wb *rwb, bool is_kswapd)
> +static inline struct rq_wait *get_rq_wait(struct rq_wb *rwb, bool is_trim,
> +					  bool is_kswapd)
>  {
> -	return &rwb->rq_wait[is_kswapd];
> +	if (is_trim)
> +		return &rwb->rq_wait[WBT_REQ_DISCARD];
> +	else if (is_kswapd)
> +		return &rwb->rq_wait[WBT_REQ_KSWAPD];
> +	else
> +		return &rwb->rq_wait[WBT_REQ_BG];
>  }

Wouldn't it be more useful to pass a enum wbt_flag here?

Or just have a wbt_flag_to_wait_idx helper and do the array indexing
in the callers?

>  {
>  	const int op = bio_op(bio);
>  
> -	/*
> -	 * If not a WRITE, do nothing
> -	 */
> -	if (op != REQ_OP_WRITE)
> -		return false;
> +	if (op == REQ_OP_WRITE) {
> +		/*
> +		 * Don't throttle WRITE_ODIRECT
> +		 */
> +		if ((bio->bi_opf & (REQ_SYNC | REQ_IDLE)) ==
> +		    (REQ_SYNC | REQ_IDLE))
> +			return false;
>  
> -	/*
> -	 * Don't throttle WRITE_ODIRECT
> -	 */
> -	if ((bio->bi_opf & (REQ_SYNC | REQ_IDLE)) == (REQ_SYNC | REQ_IDLE))
> -		return false;
> +		return true;
> +	} else if (op == REQ_OP_DISCARD)
> +		return true;

what about:

	switch (bio_op(bio)) {
	case REQ_OP_WRITE:
		/*
		 * Don't throttle WRITE_ODIRECT
		 */
		if ((bio->bi_opf & (REQ_SYNC | REQ_IDLE)) ==
		    (REQ_SYNC | REQ_IDLE))
			return false;
		/*FALLTHROUGH*/
	case REQ_OP_DISCARD:
		return true;
	default:
		return false;



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux