linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] ext4: reorganize if statement of ext4_mb_release_context()
@ 2020-08-05  1:01 brookxu
  2020-08-05  4:43 ` Andreas Dilger
  0 siblings, 1 reply; 2+ messages in thread
From: brookxu @ 2020-08-05  1:01 UTC (permalink / raw)
  To: tytso, adilger.kernel, linux-kernel; +Cc: linux-ext4

Reorganize the if statement of ext4_mb_release_context(), make it
easier to read.

Signed-off-by: Chunguang Xu <brookxu@tencent.com>
---
 fs/ext4/mballoc.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index c0a331e..4f21f34 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4564,20 +4564,19 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac)
             pa->pa_free -= ac->ac_b_ex.fe_len;
             pa->pa_len -= ac->ac_b_ex.fe_len;
             spin_unlock(&pa->pa_lock);
-        }
-    }
-    if (pa) {
-        /*
-         * We want to add the pa to the right bucket.
-         * Remove it from the list and while adding
-         * make sure the list to which we are adding
-         * doesn't grow big.
-         */
-        if ((pa->pa_type == MB_GROUP_PA) && likely(pa->pa_free)) {
-            spin_lock(pa->pa_obj_lock);
-            list_del_rcu(&pa->pa_inode_list);
-            spin_unlock(pa->pa_obj_lock);
-            ext4_mb_add_n_trim(ac);
+
+            /*
+             * We want to add the pa to the right bucket.
+             * Remove it from the list and while adding
+             * make sure the list to which we are adding
+             * doesn't grow big.
+             */
+            if (likely(pa->pa_free)) {
+                spin_lock(pa->pa_obj_lock);
+                list_del_rcu(&pa->pa_inode_list);
+                spin_unlock(pa->pa_obj_lock);
+                ext4_mb_add_n_trim(ac);
+            }
         }
         ext4_mb_put_pa(ac, ac->ac_sb, pa);
     }

-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 1/3] ext4: reorganize if statement of ext4_mb_release_context()
  2020-08-05  1:01 [PATCH v2 1/3] ext4: reorganize if statement of ext4_mb_release_context() brookxu
@ 2020-08-05  4:43 ` Andreas Dilger
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Dilger @ 2020-08-05  4:43 UTC (permalink / raw)
  To: brookxu
  Cc: Theodore Ts'o, Linux Kernel Mailing List, Ext4 Developers List

[-- Attachment #1: Type: text/plain, Size: 1948 bytes --]

On Aug 4, 2020, at 7:01 PM, brookxu <brookxu.cn@gmail.com> wrote:
> 
> Reorganize the if statement of ext4_mb_release_context(), make it
> easier to read.
> 
> Signed-off-by: Chunguang Xu <brookxu@tencent.com>

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
>  fs/ext4/mballoc.c | 27 +++++++++++++--------------
>  1 file changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index c0a331e..4f21f34 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4564,20 +4564,19 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac)
>              pa->pa_free -= ac->ac_b_ex.fe_len;
>              pa->pa_len -= ac->ac_b_ex.fe_len;
>              spin_unlock(&pa->pa_lock);
> -        }
> -    }
> -    if (pa) {
> -        /*
> -         * We want to add the pa to the right bucket.
> -         * Remove it from the list and while adding
> -         * make sure the list to which we are adding
> -         * doesn't grow big.
> -         */
> -        if ((pa->pa_type == MB_GROUP_PA) && likely(pa->pa_free)) {
> -            spin_lock(pa->pa_obj_lock);
> -            list_del_rcu(&pa->pa_inode_list);
> -            spin_unlock(pa->pa_obj_lock);
> -            ext4_mb_add_n_trim(ac);
> +
> +            /*
> +             * We want to add the pa to the right bucket.
> +             * Remove it from the list and while adding
> +             * make sure the list to which we are adding
> +             * doesn't grow big.
> +             */
> +            if (likely(pa->pa_free)) {
> +                spin_lock(pa->pa_obj_lock);
> +                list_del_rcu(&pa->pa_inode_list);
> +                spin_unlock(pa->pa_obj_lock);
> +                ext4_mb_add_n_trim(ac);
> +            }
>          }
>          ext4_mb_put_pa(ac, ac->ac_sb, pa);
>      }
> 
> --
> 1.8.3.1
> 


Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-05  4:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05  1:01 [PATCH v2 1/3] ext4: reorganize if statement of ext4_mb_release_context() brookxu
2020-08-05  4:43 ` Andreas Dilger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).