Skip to contentSkip to conversation

quota: set init_needed flag only when successfully getting dquot

PATCH In review Chengguang Xu 2 participants 3 messages Apr 28, 2019 – Apr 30, 2019 Diskquota

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 quota: set init_needed flag only when successfully getting dquot

Set init_needed flag only when successfully getting dquot, so that we can skip unnecessary subsequent operation.

---
 fs/quota/dquot.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/quota/dquot.c +3 -2
index fc20e06c56ba..8d4ce2a2b5c8 100644
@@ -1449,8 +1449,6 @@ static int __dquot_initialize(struct inode *inode, int type)
 		if (!sb_has_quota_active(sb, cnt))
 			continue;
 
-		init_needed = 1;
-
 		switch (cnt) {
 		case USRQUOTA:
 			qid = make_kqid_uid(inode->i_uid);
@@ -1475,6 +1473,9 @@ static int __dquot_initialize(struct inode *inode, int type)
 			dquot = NULL;
 		}
 		got[cnt] = dquot;
+
+		if (got[cnt])
+			init_needed = 1;
 	}
 
 	/* All required i_dquot has been initialized */

--
2.20.1

#1 lore raw
Quoted 4 lines · Chengguang Xu

Set init_needed flag only when successfully getting dquot, so that we can skip unnecessary subsequent operation.

Thanks for the patch but I don't think it's really useful. It will be very rare that we race with quotaoff of dqget() fails due to error. So the additional overhead of iterating over dquots doesn't really matter in that case.

Honza

Quoted 31 lines
---
 fs/quota/dquot.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/quota/dquot.c +3 -3
index fc20e06c56ba..8d4ce2a2b5c8 100644
@@ -1449,8 +1449,6 @@ static int __dquot_initialize(struct inode *inode, int type)
 		if (!sb_has_quota_active(sb, cnt))
 			continue;
 
-		init_needed = 1;
-
 		switch (cnt) {
 		case USRQUOTA:
 			qid = make_kqid_uid(inode->i_uid);
@@ -1475,6 +1473,9 @@ static int __dquot_initialize(struct inode *inode, int type)
 			dquot = NULL;
 		}
 		got[cnt] = dquot;
+
+		if (got[cnt])
+			init_needed = 1;
 	}
 
 	/* All required i_dquot has been initialized */
--

2.20.1

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#2 lore raw
Quoted 9 lines · Jan Kara
Quoted 4 lines · Chengguang Xu

Set init_needed flag only when successfully getting dquot, so that we can skip unnecessary subsequent operation.

Thanks for the patch but I don't think it's really useful. It will be very rare that we race with quotaoff of dqget() fails due to error. So the additional overhead of iterating over dquots doesn't really matter in that case.

Hi Jan,

Thanks for the comment, I got it.

Chengguang.