Re: [PATCH 25/27] quota: Inline dquot_[re]claim_reserved_space() into callsite

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

 



On Aug 16, 2017, at 9:41 AM, Jan Kara <jack@xxxxxxx> wrote:
> 
> dquot_claim_reserved_space() and dquot_reclaim_reserved_space() have
> only a single callsite. Inline them there.
> 
> Signed-off-by: Jan Kara <jack@xxxxxxx>
> ---
> fs/quota/dquot.c | 43 ++++++++++++++++++-------------------------
> 1 file changed, 18 insertions(+), 25 deletions(-)
> 
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 038f70c1ebff..9f4cf78096e4 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -1082,27 +1082,6 @@ static inline void dquot_resv_space(struct dquot *dquot, qsize_t number)
> 	dquot->dq_dqb.dqb_rsvspace += number;
> }
> 
> -/*
> - * Claim reserved quota space
> - */
> -static void dquot_claim_reserved_space(struct dquot *dquot, qsize_t number)
> -{
> -	if (dquot->dq_dqb.dqb_rsvspace < number) {
> -		WARN_ON_ONCE(1);
> -		number = dquot->dq_dqb.dqb_rsvspace;
> -	}
> -	dquot->dq_dqb.dqb_curspace += number;
> -	dquot->dq_dqb.dqb_rsvspace -= number;
> -}
> -
> -static void dquot_reclaim_reserved_space(struct dquot *dquot, qsize_t number)
> -{
> -	if (WARN_ON_ONCE(dquot->dq_dqb.dqb_curspace < number))
> -		number = dquot->dq_dqb.dqb_curspace;
> -	dquot->dq_dqb.dqb_rsvspace += number;
> -	dquot->dq_dqb.dqb_curspace -= number;
> -}
> -
> static inline
> void dquot_free_reserved_space(struct dquot *dquot, qsize_t number)
> {
> @@ -1726,8 +1705,16 @@ int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
> 	spin_lock(&dq_data_lock);
> 	/* Claim reserved quotas to allocated quotas */
> 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
> -		if (dquots[cnt])
> -			dquot_claim_reserved_space(dquots[cnt], number);
> +		if (dquots[cnt]) {
> +			struct dquot *dquot = dquots[cnt];
> +
> +			if (dquot->dq_dqb.dqb_rsvspace < number) {
> +				WARN_ON_ONCE(1);

Here it checks if (rsvspace < number) and calls WARN_ON_ONCE(1), but below it
instead calls if (WARN_ON_ONCE(curspace < number)).  It probably makes sense for
these to be consistent (I prefer the second form).

Cheers, Andreas

> +				number = dquot->dq_dqb.dqb_rsvspace;
> +			}
> +			dquot->dq_dqb.dqb_curspace += number;
> +			dquot->dq_dqb.dqb_rsvspace -= number;
> +		}
> 	}
> 	/* Update inode bytes */
> 	spin_lock(&inode->i_lock);
> @@ -1762,8 +1749,14 @@ void dquot_reclaim_space_nodirty(struct inode *inode, qsize_t number)
> 	spin_lock(&dq_data_lock);
> 	/* Claim reserved quotas to allocated quotas */
> 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
> -		if (dquots[cnt])
> -			dquot_reclaim_reserved_space(dquots[cnt], number);
> +		if (dquots[cnt]) {
> +			struct dquot *dquot = dquots[cnt];
> +
> +			if (WARN_ON_ONCE(dquot->dq_dqb.dqb_curspace < number))
> +				number = dquot->dq_dqb.dqb_curspace;
> +			dquot->dq_dqb.dqb_rsvspace += number;
> +			dquot->dq_dqb.dqb_curspace -= number;
> +		}
> 	}
> 	/* Update inode bytes */
> 	spin_lock(&inode->i_lock);
> --
> 2.12.3
> 


Cheers, Andreas





Attachment: signature.asc
Description: Message signed with OpenPGP


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux