linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: brookxu <brookxu.cn@gmail.com>
To: adilger.kernel@dilger.ca, tytso@mit.edu
Cc: riteshh@linux.ibm.com, jack@suse.cz, linux-ext4@vger.kernel.org
Subject: [PATCH v5 1/2] ext4: reorganize if statement of ext4_mb_release_context()
Date: Mon, 17 Aug 2020 15:36:06 +0800	[thread overview]
Message-ID: <5439ac6f-db79-ad68-76c1-a4dda9aa0cc3@gmail.com> (raw)
In-Reply-To: <20200815133212.8D164A4057@d06av23.portsmouth.uk.ibm.com>

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 70b110f..51f37f1 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4567,20 +4567,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



  parent reply	other threads:[~2020-08-17  7:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07  8:44 [PATCH v4 2/2] ext4: limit the length of per-inode prealloc list brookxu
2020-08-13  8:46 ` Andreas Dilger
2020-08-13 13:52 ` Ritesh Harjani
2020-08-14  1:11   ` brookxu
2020-08-14  6:22     ` Ritesh Harjani
2020-08-15 13:32 ` Ritesh Harjani
2020-08-15 21:52   ` Andreas Dilger
2020-08-17  7:36   ` brookxu [this message]
2020-08-24 21:34     ` [PATCH v5 1/2] ext4: reorganize if statement of ext4_mb_release_context() Andreas Dilger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5439ac6f-db79-ad68-76c1-a4dda9aa0cc3@gmail.com \
    --to=brookxu.cn@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=riteshh@linux.ibm.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).