Skip to contentSkip to conversation

quota: Move down dqptr_sem read after initializing default warn[] type at __dquot_alloc_space().

PATCH In review Jeff Liu 2 participants 2 messages Jul 18, 2012 – Aug 14, 2012

Subsystems (2)
lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH 1/1 quota: Move down dqptr_sem read after initializing default warn[] type at __dquot_alloc_space().

Hello,

sb->s_dqout->dqptr_sem is used to serialize ops using quota_info for pointers from inode to dquots. But for __dquot_alloc_space(), it could be safely moved down after the default warn[] array got initialized IMHO.

Thanks,
-Jeff

---
 fs/quota/dquot.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/quota/dquot.c +1 -1
index 10cbe84..510ae87 100644
@@ -1571,10 +1571,10 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)
 		goto out;
 	}
 
-	down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++)
 		warn[cnt].w_type = QUOTA_NL_NOWARN;
 
+	down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
 	spin_lock(&dq_data_lock);
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		if (!dquots[cnt])
Signature · 1 line
1.7.4.1
reviewer
#1 lore raw

Hello,

Quoted 2 lines · Jeff Liu

sb->s_dqout->dqptr_sem is used to serialize ops using quota_info for pointers from inode to dquots. But for __dquot_alloc_space(), it could be safely moved down after the default warn[] array got initialized IMHO.

Yes, you are right. Although practically the difference will be rather
minimal... Thanks for the patch. I've added it to my tree.

Honza

Quoted 32 lines

Thanks,
-Jeff

---
 fs/quota/dquot.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/quota/dquot.c +1 -1
index 10cbe84..510ae87 100644
@@ -1571,10 +1571,10 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)
 		goto out;
 	}
 
-	down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++)
 		warn[cnt].w_type = QUOTA_NL_NOWARN;
 
+	down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
 	spin_lock(&dq_data_lock);
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		if (!dquots[cnt])
Signature · 1 line
1.7.4.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR