提交 1ea06bec 编写于 作者: N Niu Yawei 提交者: Jan Kara

quota: avoid unnecessary dqget()/dqput() calls

Avoid unnecessary dqget()/dqput() calls in __dquot_initialize(),
that will introduce global lock contention otherwise.
Signed-off-by: NLai Siyao <lai.siyao@intel.com>
Signed-off-by: NNiu Yawei <yawei.niu@intel.com>
Signed-off-by: NJan Kara <jack@suse.cz>
上级 606cdcca
...@@ -1402,7 +1402,7 @@ static int dquot_active(const struct inode *inode) ...@@ -1402,7 +1402,7 @@ static int dquot_active(const struct inode *inode)
*/ */
static void __dquot_initialize(struct inode *inode, int type) static void __dquot_initialize(struct inode *inode, int type)
{ {
int cnt; int cnt, init_needed = 0;
struct dquot *got[MAXQUOTAS]; struct dquot *got[MAXQUOTAS];
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
qsize_t rsv; qsize_t rsv;
...@@ -1418,6 +1418,15 @@ static void __dquot_initialize(struct inode *inode, int type) ...@@ -1418,6 +1418,15 @@ static void __dquot_initialize(struct inode *inode, int type)
got[cnt] = NULL; got[cnt] = NULL;
if (type != -1 && cnt != type) if (type != -1 && cnt != type)
continue; continue;
/*
* The i_dquot should have been initialized in most cases,
* we check it without locking here to avoid unnecessary
* dqget()/dqput() calls.
*/
if (inode->i_dquot[cnt])
continue;
init_needed = 1;
switch (cnt) { switch (cnt) {
case USRQUOTA: case USRQUOTA:
qid = make_kqid_uid(inode->i_uid); qid = make_kqid_uid(inode->i_uid);
...@@ -1429,6 +1438,10 @@ static void __dquot_initialize(struct inode *inode, int type) ...@@ -1429,6 +1438,10 @@ static void __dquot_initialize(struct inode *inode, int type)
got[cnt] = dqget(sb, qid); got[cnt] = dqget(sb, qid);
} }
/* All required i_dquot has been initialized */
if (!init_needed)
return;
down_write(&sb_dqopt(sb)->dqptr_sem); down_write(&sb_dqopt(sb)->dqptr_sem);
if (IS_NOQUOTA(inode)) if (IS_NOQUOTA(inode))
goto out_err; goto out_err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册