[Devel] [PATCH RHEL7 COMMIT] ploop: Do not forget to put io context

Konstantin Khorenko khorenko at virtuozzo.com
Fri Mar 22 23:58:54 MSK 2019


Just for the record, a task for the ReadyKernel patch:
https://jira.sw.ru/browse/PSBM-92976

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 03/22/2019 07:38 PM, Konstantin Khorenko wrote:
> The commit is pushed to "branch-rh7-3.10.0-957.10.1.vz7.85.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
> after rh7-3.10.0-957.10.1.vz7.85.2
> ------>
> commit cf65c124b54899c62885cc2677c2bd3ad4fe309a
> Author: Kirill Tkhai <ktkhai at virtuozzo.com>
> Date:   Fri Mar 22 19:37:57 2019 +0300
>
>     ploop: Do not forget to put io context
>
>     We have to put saved_ioc before we return from
>     this ploop_req_state_process(). Otherwise, it
>     becomes leaked.
>
>     So, move discard check into ploop_entry_request(),
>     and then just go by generic way to bottom of
>     ploop_req_state_process().
>
>     This is not connected with recent discard changes,
>     and it should go to RK too (small adoptation is
>     required).
>
>     Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
>     Acked-by: Konstantin Khorenko <khorenko at virtuozzo.com>
> ---
>  drivers/block/ploop/dev.c | 48 +++++++++++++++++++++--------------------------
>  1 file changed, 21 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
> index 26745d9fc81f..f8b9b0bcba78 100644
> --- a/drivers/block/ploop/dev.c
> +++ b/drivers/block/ploop/dev.c
> @@ -2181,6 +2181,21 @@ complete_unsupported_discard_req(struct ploop_request * preq)
>  	ploop_complete_io_state(preq);
>  }
>
> +static bool ploop_can_issue_discard(struct ploop_device *plo,
> +				    struct ploop_request *preq)
> +{
> +	if (test_bit(PLOOP_REQ_DISCARD, &preq->state))
> +		return true;
> +
> +	if (test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
> +		return false;
> +
> +	if (!list_is_singular(&plo->map.delta_list))
> +		return false;
> +
> +	return whole_block(plo, preq);
> +}
> +
>  static void
>  ploop_entry_request(struct ploop_request * preq)
>  {
> @@ -2192,6 +2207,12 @@ ploop_entry_request(struct ploop_request * preq)
>  	int err;
>  	iblock_t iblk;
>
> +	if ((preq->req_rw & REQ_DISCARD) &&
> +	    !ploop_can_issue_discard(plo, preq)) {
> +		complete_unsupported_discard_req(preq);
> +		return;
> +	}
> +
>  	if (!preq_is_special(preq)) {
>  		/* Control request */
>  		if (unlikely(preq->bl.head == NULL)) {
> @@ -2539,21 +2560,6 @@ ploop_entry_request(struct ploop_request * preq)
>  	PLOOP_REQ_FAIL_IMMEDIATE(preq, err);
>  }
>
> -static bool ploop_can_issue_discard(struct ploop_device *plo,
> -				    struct ploop_request *preq)
> -{
> -	if (test_bit(PLOOP_REQ_DISCARD, &preq->state))
> -		return true;
> -
> -	if (test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
> -		return false;
> -
> -	if (!list_is_singular(&plo->map.delta_list))
> -		return false;
> -
> -	return whole_block(plo, preq);
> -}
> -
>  static void ploop_req_state_process(struct ploop_request * preq)
>  {
>  	struct ploop_device * plo = preq->plo;
> @@ -2632,18 +2638,6 @@ static void ploop_req_state_process(struct ploop_request * preq)
>  			break;
>  		}
>
> -		if ((preq->req_rw & REQ_DISCARD) &&
> -		    !ploop_can_issue_discard(plo, preq)) {
> -			complete_unsupported_discard_req(preq);
> -#ifdef CONFIG_BEANCOUNTERS
> -			if (saved_ub) {
> -				saved_ub = set_exec_ub(saved_ub);
> -				put_beancounter(saved_ub);
> -			}
> -#endif
> -			return;
> -		}
> -
>  		ploop_entry_request(preq);
>  		break;
>
> .
>



More information about the Devel mailing list