Each time we perform full initialization procedure regardless to whenever quota was already initialized for a given inode. In fact dquot_initialize() called many times during inode life time, which result in many useless quota lookup/dqput actions. It is reasonable to optimize the case where inode already has quota initialized. We can avoid locking here because: * Serialization between dquot_initialize() and dquot_drop() is guaranteed by caller. * Other races (quota_off/quota_on) result in incorrect quota regardless to locking in dquot_initialize(). Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx> --- fs/quota/dquot.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index d7ec471..c06f969 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -1462,10 +1462,23 @@ out_err: /* Drop unused references */ dqput_all(got); } - void dquot_initialize(struct inode *inode) { - __dquot_initialize(inode, -1); + int cnt; + /* + * We can check inodes quota pointers without lock, because + * serialization between dquot_init/dquot_drop is guaranteed by caller. + */ + if (IS_NOQUOTA(inode)) + return; + for (cnt = 0; cnt < MAXQUOTAS; cnt++) { + if (!sb_has_quota_active(inode->i_sb, cnt)) + continue; + if (!inode->i_dquot[cnt]) + break; + } + if (cnt < MAXQUOTAS) + __dquot_initialize(inode, -1); } EXPORT_SYMBOL(dquot_initialize); -- 1.6.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html