Skip to contentSkip to conversation

quota: minor optimization for __dquot_initialize()

PATCH New Chengguang Xu 1 participant 1 message Jun 21, 2020 Diskquota

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 quota: minor optimization for __dquot_initialize()

Count the number of quotas which are needed to initialize, instead of just setting to 1 so that we may avoid unnecessary process in special case.

---
 fs/quota/dquot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/quota/dquot.c +2 -1
index 7b4bac91146b..f93bd60c3998 100644
@@ -1459,7 +1459,7 @@ static int __dquot_initialize(struct inode *inode, int type)
 		if (!sb_has_quota_active(sb, cnt))
 			continue;
 
-		init_needed = 1;
+		init_needed++;
 
 		switch (cnt) {
 		case USRQUOTA:
@@ -1483,6 +1483,7 @@ static int __dquot_initialize(struct inode *inode, int type)
 				goto out_put;
 			}
 			dquot = NULL;
+			init_needed--;
 		}
 		got[cnt] = dquot;
 	}
Signature · 1 line
2.17.2