[2/4] xfs: simplify args to xfs_get_defquota
diff mbox series

Message ID 26218bfd-b003-c1fc-3ea3-e53d9c35187d@redhat.com
State New
Headers show
Series
  • xfs: enable per-type quota timers and warn limits
Related show

Commit Message

Eric Sandeen Feb. 8, 2020, 9:11 p.m. UTC
There's no real reason to pass both xfs_dquot and xfs_quotainfo to
xfs_get_defquota, because the latter can be obtained from the former.
This simplifies a bit more of the argument passing.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/xfs_dquot.c       |  3 +--
 fs/xfs/xfs_qm.c          | 17 ++++++++---------
 fs/xfs/xfs_qm.h          |  3 ++-
 fs/xfs/xfs_qm_syscalls.c |  2 +-
 fs/xfs/xfs_trans_dquot.c |  3 +--
 5 files changed, 13 insertions(+), 15 deletions(-)

Comments

Allison Collins Feb. 11, 2020, 5:30 a.m. UTC | #1
On 2/8/20 2:11 PM, Eric Sandeen wrote:
> There's no real reason to pass both xfs_dquot and xfs_quotainfo to
> xfs_get_defquota, because the latter can be obtained from the former.
> This simplifies a bit more of the argument passing.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Looks ok to me
Reviewed-by: Allison Collins <allison.henderson@oracle.com>

> ---
>   fs/xfs/xfs_dquot.c       |  3 +--
>   fs/xfs/xfs_qm.c          | 17 ++++++++---------
>   fs/xfs/xfs_qm.h          |  3 ++-
>   fs/xfs/xfs_qm_syscalls.c |  2 +-
>   fs/xfs/xfs_trans_dquot.c |  3 +--
>   5 files changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 02f433d1f13a..ddf41c24efcd 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -69,13 +69,12 @@ xfs_qm_adjust_dqlimits(
>   	struct xfs_mount	*mp,
>   	struct xfs_dquot	*dq)
>   {
> -	struct xfs_quotainfo	*q = mp->m_quotainfo;
>   	struct xfs_disk_dquot	*d = &dq->q_core;
>   	struct xfs_def_quota	*defq;
>   	int			prealloc = 0;
>   
>   	ASSERT(d->d_id);
> -	defq = xfs_get_defquota(dq, q);
> +	defq = xfs_get_defquota(dq);
>   
>   	if (defq->bsoftlimit && !d->d_blk_softlimit) {
>   		d->d_blk_softlimit = cpu_to_be64(defq->bsoftlimit);
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index 0b0909657bad..b3cd87d0bccb 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -541,8 +541,7 @@ xfs_qm_shrink_count(
>   STATIC void
>   xfs_qm_set_defquota(
>   	struct xfs_mount	*mp,
> -	uint			type,
> -	struct xfs_quotainfo	*qinf)
> +	uint			type)
>   {
>   	struct xfs_dquot	*dqp;
>   	struct xfs_def_quota	*defq;
> @@ -554,7 +553,7 @@ xfs_qm_set_defquota(
>   		return;
>   
>   	ddqp = &dqp->q_core;
> -	defq = xfs_get_defquota(dqp, qinf);
> +	defq = xfs_get_defquota(dqp);
>   
>   	/*
>   	 * Timers and warnings have been already set, let's just set the
> @@ -572,9 +571,9 @@ xfs_qm_set_defquota(
>   /* Initialize quota time limits from the root dquot. */
>   static void
>   xfs_qm_init_timelimits(
> -	struct xfs_mount	*mp,
> -	struct xfs_quotainfo	*qinf)
> +	struct xfs_mount	*mp)
>   {
> +	struct xfs_quotainfo	*qinf = mp->m_quotainfo;
>   	struct xfs_disk_dquot	*ddqp;
>   	struct xfs_dquot	*dqp;
>   	uint			type;
> @@ -671,14 +670,14 @@ xfs_qm_init_quotainfo(
>   
>   	mp->m_qflags |= (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_CHKD);
>   
> -	xfs_qm_init_timelimits(mp, qinf);
> +	xfs_qm_init_timelimits(mp);
>   
>   	if (XFS_IS_UQUOTA_RUNNING(mp))
> -		xfs_qm_set_defquota(mp, XFS_DQ_USER, qinf);
> +		xfs_qm_set_defquota(mp, XFS_DQ_USER);
>   	if (XFS_IS_GQUOTA_RUNNING(mp))
> -		xfs_qm_set_defquota(mp, XFS_DQ_GROUP, qinf);
> +		xfs_qm_set_defquota(mp, XFS_DQ_GROUP);
>   	if (XFS_IS_PQUOTA_RUNNING(mp))
> -		xfs_qm_set_defquota(mp, XFS_DQ_PROJ, qinf);
> +		xfs_qm_set_defquota(mp, XFS_DQ_PROJ);
>   
>   	qinf->qi_shrinker.count_objects = xfs_qm_shrink_count;
>   	qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan;
> diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h
> index 3a850401b102..4cefe1abb1d4 100644
> --- a/fs/xfs/xfs_qm.h
> +++ b/fs/xfs/xfs_qm.h
> @@ -164,9 +164,10 @@ extern int		xfs_qm_scall_quotaon(struct xfs_mount *, uint);
>   extern int		xfs_qm_scall_quotaoff(struct xfs_mount *, uint);
>   
>   static inline struct xfs_def_quota *
> -xfs_get_defquota(struct xfs_dquot *dqp, struct xfs_quotainfo *qi)
> +xfs_get_defquota(struct xfs_dquot *dqp)
>   {
>   	struct xfs_def_quota *defq;
> +	struct xfs_quotainfo *qi = dqp->q_mount->m_quotainfo;
>   
>   	if (XFS_QM_ISUDQ(dqp))
>   		defq = &qi->qi_usr_default;
> diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
> index 1ea82764bf89..e08c2f04f3ab 100644
> --- a/fs/xfs/xfs_qm_syscalls.c
> +++ b/fs/xfs/xfs_qm_syscalls.c
> @@ -478,7 +478,7 @@ xfs_qm_scall_setqlim(
>   		goto out_unlock;
>   	}
>   
> -	defq = xfs_get_defquota(dqp, q);
> +	defq = xfs_get_defquota(dqp);
>   	xfs_dqunlock(dqp);
>   
>   	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_setqlim, 0, 0, 0, &tp);
> diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
> index d1b9869bc5fa..7470b02c5198 100644
> --- a/fs/xfs/xfs_trans_dquot.c
> +++ b/fs/xfs/xfs_trans_dquot.c
> @@ -585,13 +585,12 @@ xfs_trans_dqresv(
>   	xfs_qwarncnt_t		warnlimit;
>   	xfs_qcnt_t		total_count;
>   	xfs_qcnt_t		*resbcountp;
> -	struct xfs_quotainfo	*q = mp->m_quotainfo;
>   	struct xfs_def_quota	*defq;
>   
>   
>   	xfs_dqlock(dqp);
>   
> -	defq = xfs_get_defquota(dqp, q);
> +	defq = xfs_get_defquota(dqp);
>   
>   	if (flags & XFS_TRANS_DQ_RES_BLKS) {
>   		hardlimit = be64_to_cpu(dqp->q_core.d_blk_hardlimit);
>
hch@infradead.org Feb. 17, 2020, 1:38 p.m. UTC | #2
> -	struct xfs_quotainfo	*q = mp->m_quotainfo;
>  	struct xfs_disk_dquot	*d = &dq->q_core;
>  	struct xfs_def_quota	*defq;
>  	int			prealloc = 0;
>  
>  	ASSERT(d->d_id);
> -	defq = xfs_get_defquota(dq, q);
> +	defq = xfs_get_defquota(dq);

Move this up to the declaration line while you're at it?

>  {
>  	struct xfs_dquot	*dqp;
>  	struct xfs_def_quota	*defq;
> @@ -554,7 +553,7 @@ xfs_qm_set_defquota(
>  		return;
>  
>  	ddqp = &dqp->q_core;
> -	defq = xfs_get_defquota(dqp, qinf);
> +	defq = xfs_get_defquota(dqp);

Same here.

> @@ -585,13 +585,12 @@ xfs_trans_dqresv(
>  	xfs_qwarncnt_t		warnlimit;
>  	xfs_qcnt_t		total_count;
>  	xfs_qcnt_t		*resbcountp;
> -	struct xfs_quotainfo	*q = mp->m_quotainfo;
>  	struct xfs_def_quota	*defq;
>  
>  
>  	xfs_dqlock(dqp);
>  
> -	defq = xfs_get_defquota(dqp, q);
> +	defq = xfs_get_defquota(dqp);

And here.

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Eric Sandeen Feb. 18, 2020, 8:16 p.m. UTC | #3
On 2/17/20 7:38 AM, Christoph Hellwig wrote:
>> -	struct xfs_quotainfo	*q = mp->m_quotainfo;
>>  	struct xfs_disk_dquot	*d = &dq->q_core;
>>  	struct xfs_def_quota	*defq;
>>  	int			prealloc = 0;
>>  
>>  	ASSERT(d->d_id);
>> -	defq = xfs_get_defquota(dq, q);
>> +	defq = xfs_get_defquota(dq);
> 
> Move this up to the declaration line while you're at it?

ok

>>  {
>>  	struct xfs_dquot	*dqp;
>>  	struct xfs_def_quota	*defq;
>> @@ -554,7 +553,7 @@ xfs_qm_set_defquota(
>>  		return;
>>  
>>  	ddqp = &dqp->q_core;
>> -	defq = xfs_get_defquota(dqp, qinf);
>> +	defq = xfs_get_defquota(dqp);

can't do that here.  have to call xfs_qm_dqget_uncached(&dqp) first.

> Same here.
> 
>> @@ -585,13 +585,12 @@ xfs_trans_dqresv(
>>  	xfs_qwarncnt_t		warnlimit;
>>  	xfs_qcnt_t		total_count;
>>  	xfs_qcnt_t		*resbcountp;
>> -	struct xfs_quotainfo	*q = mp->m_quotainfo;
>>  	struct xfs_def_quota	*defq;
>>  
>>  
>>  	xfs_dqlock(dqp);
>>  
>> -	defq = xfs_get_defquota(dqp, q);
>> +	defq = xfs_get_defquota(dqp);
> 
> And here.

I ... guess this doesn't have to be under the lock?  I guess I'd rather not make
anything approaching a functional change in this otherwise cosmetic patch by moving
it tho.

> 
> Otherwise looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>

Patch
diff mbox series

diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 02f433d1f13a..ddf41c24efcd 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -69,13 +69,12 @@  xfs_qm_adjust_dqlimits(
 	struct xfs_mount	*mp,
 	struct xfs_dquot	*dq)
 {
-	struct xfs_quotainfo	*q = mp->m_quotainfo;
 	struct xfs_disk_dquot	*d = &dq->q_core;
 	struct xfs_def_quota	*defq;
 	int			prealloc = 0;
 
 	ASSERT(d->d_id);
-	defq = xfs_get_defquota(dq, q);
+	defq = xfs_get_defquota(dq);
 
 	if (defq->bsoftlimit && !d->d_blk_softlimit) {
 		d->d_blk_softlimit = cpu_to_be64(defq->bsoftlimit);
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 0b0909657bad..b3cd87d0bccb 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -541,8 +541,7 @@  xfs_qm_shrink_count(
 STATIC void
 xfs_qm_set_defquota(
 	struct xfs_mount	*mp,
-	uint			type,
-	struct xfs_quotainfo	*qinf)
+	uint			type)
 {
 	struct xfs_dquot	*dqp;
 	struct xfs_def_quota	*defq;
@@ -554,7 +553,7 @@  xfs_qm_set_defquota(
 		return;
 
 	ddqp = &dqp->q_core;
-	defq = xfs_get_defquota(dqp, qinf);
+	defq = xfs_get_defquota(dqp);
 
 	/*
 	 * Timers and warnings have been already set, let's just set the
@@ -572,9 +571,9 @@  xfs_qm_set_defquota(
 /* Initialize quota time limits from the root dquot. */
 static void
 xfs_qm_init_timelimits(
-	struct xfs_mount	*mp,
-	struct xfs_quotainfo	*qinf)
+	struct xfs_mount	*mp)
 {
+	struct xfs_quotainfo	*qinf = mp->m_quotainfo;
 	struct xfs_disk_dquot	*ddqp;
 	struct xfs_dquot	*dqp;
 	uint			type;
@@ -671,14 +670,14 @@  xfs_qm_init_quotainfo(
 
 	mp->m_qflags |= (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_CHKD);
 
-	xfs_qm_init_timelimits(mp, qinf);
+	xfs_qm_init_timelimits(mp);
 
 	if (XFS_IS_UQUOTA_RUNNING(mp))
-		xfs_qm_set_defquota(mp, XFS_DQ_USER, qinf);
+		xfs_qm_set_defquota(mp, XFS_DQ_USER);
 	if (XFS_IS_GQUOTA_RUNNING(mp))
-		xfs_qm_set_defquota(mp, XFS_DQ_GROUP, qinf);
+		xfs_qm_set_defquota(mp, XFS_DQ_GROUP);
 	if (XFS_IS_PQUOTA_RUNNING(mp))
-		xfs_qm_set_defquota(mp, XFS_DQ_PROJ, qinf);
+		xfs_qm_set_defquota(mp, XFS_DQ_PROJ);
 
 	qinf->qi_shrinker.count_objects = xfs_qm_shrink_count;
 	qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan;
diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h
index 3a850401b102..4cefe1abb1d4 100644
--- a/fs/xfs/xfs_qm.h
+++ b/fs/xfs/xfs_qm.h
@@ -164,9 +164,10 @@  extern int		xfs_qm_scall_quotaon(struct xfs_mount *, uint);
 extern int		xfs_qm_scall_quotaoff(struct xfs_mount *, uint);
 
 static inline struct xfs_def_quota *
-xfs_get_defquota(struct xfs_dquot *dqp, struct xfs_quotainfo *qi)
+xfs_get_defquota(struct xfs_dquot *dqp)
 {
 	struct xfs_def_quota *defq;
+	struct xfs_quotainfo *qi = dqp->q_mount->m_quotainfo;
 
 	if (XFS_QM_ISUDQ(dqp))
 		defq = &qi->qi_usr_default;
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index 1ea82764bf89..e08c2f04f3ab 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -478,7 +478,7 @@  xfs_qm_scall_setqlim(
 		goto out_unlock;
 	}
 
-	defq = xfs_get_defquota(dqp, q);
+	defq = xfs_get_defquota(dqp);
 	xfs_dqunlock(dqp);
 
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_setqlim, 0, 0, 0, &tp);
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index d1b9869bc5fa..7470b02c5198 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -585,13 +585,12 @@  xfs_trans_dqresv(
 	xfs_qwarncnt_t		warnlimit;
 	xfs_qcnt_t		total_count;
 	xfs_qcnt_t		*resbcountp;
-	struct xfs_quotainfo	*q = mp->m_quotainfo;
 	struct xfs_def_quota	*defq;
 
 
 	xfs_dqlock(dqp);
 
-	defq = xfs_get_defquota(dqp, q);
+	defq = xfs_get_defquota(dqp);
 
 	if (flags & XFS_TRANS_DQ_RES_BLKS) {
 		hardlimit = be64_to_cpu(dqp->q_core.d_blk_hardlimit);