From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752152AbcLEUzO (ORCPT ); Mon, 5 Dec 2016 15:55:14 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:19791 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751161AbcLEUzN (ORCPT ); Mon, 5 Dec 2016 15:55:13 -0500 Date: Mon, 5 Dec 2016 23:54:36 +0300 From: Dan Carpenter To: James Simmons Cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger , Oleg Drokin , Ben Evans , Linux Kernel Mailing List , Lustre Development List Subject: Re: [PATCH 5/6] staging: lustre: headers: Move functions out of lustre_idl.h Message-ID: <20161205205435.GD31243@mwanda> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> <1480707650-24089-6-git-send-email-jsimmons@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1480707650-24089-6-git-send-email-jsimmons@infradead.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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