Re: [PATCH 5/6] staging: lustre: headers: Move functions out of lustre_idl.h

From: Dan Carpenter
Date: Mon Dec 05 2016 - 15:55:17 EST


On Fri, Dec 02, 2016 at 02:40:49PM -0500, James Simmons wrote:
> -/* If LDLM_ENQUEUE, 1 slot is already occupied, 1 is available.
> - * Otherwise, 2 are available.
> - */
> -#define ldlm_request_bufsize(count, type) \
> -({ \
> - int _avail = LDLM_LOCKREQ_HANDLES; \
> - _avail -= (type == LDLM_ENQUEUE ? LDLM_ENQUEUE_CANCEL_OFF : 0); \
> - sizeof(struct ldlm_request) + \
> - (count > _avail ? count - _avail : 0) * \
> - sizeof(struct lustre_handle); \
> -})
> -

> +/**
> + * ldlm_request_bufsize
> + *
> + * @count: number of ldlm handles
> + * @type: ldlm opcode
> + *
> + * If opcode=LDLM_ENQUEUE, 1 slot is already occupied,
> + * LDLM_LOCKREQ_HANDLE -1 slots are available.
> + * Otherwise, LDLM_LOCKREQ_HANDLE slots are available.
> + *
> + * Return: size of the request buffer
> + */
> +int ldlm_request_bufsize(int count, int type)
> +{
> + int avail = LDLM_LOCKREQ_HANDLES;
> +
> + if (type == LDLM_ENQUEUE)
> + avail -= LDLM_ENQUEUE_CANCEL_OFF;
> +
> + if (count > avail)
> + avail = (count - avail) * sizeof(struct lustre_handle);
> + else
> + avail = 0;
> +
> + return sizeof(struct ldlm_request) + avail;
> +}
> +

This is a nice cleanup.

regards,
dan carpenter