From ef90a02d126312b0d2f28b8c6eb2d299c68eb936 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Tue, 14 Jan 2020 22:38:51 +0300 Subject: [PATCH] LU-13135 quota: improve checks in OSDs to ignore quota for root-owned files. sanity/60a: zfs before 80s, after 66s ldiskfs before 65s, after 38s ave.write declaration in sanity/60a: zfs before 3.21 usec, after 1.16 usec ldiskfs before 4.06 usec, after 0.66 usec Change-Id: Ib9ba50d260eac408f1f5e43c4d722ff5024135cf Signed-off-by: Alex Zhuravlev Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/37232 Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: Wang Shilong Tested-by: jenkins Tested-by: Maloo --- lustre/osd-ldiskfs/osd_handler.c | 6 ++++++ lustre/osd-ldiskfs/osd_quota.c | 4 ++++ lustre/osd-zfs/osd_quota.c | 4 ++++ lustre/quota/qsd_handler.c | 6 +++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 661690a..dd7dcf9 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -1932,6 +1932,12 @@ static int osd_trans_start(const struct lu_env *env, struct dt_device *d, if (OBD_FAIL_CHECK(OBD_FAIL_OSD_TXN_START)) GOTO(out, rc = -EIO); + /* + * we ignore quota checks for system-owned files, but still + * need to count blocks for uid/gid/projid + */ + osd_trans_declare_op(env, oh, OSD_OT_QUOTA, 3); + /* * XXX temporary stuff. Some abstraction layer should * be used. diff --git a/lustre/osd-ldiskfs/osd_quota.c b/lustre/osd-ldiskfs/osd_quota.c index c69cfcd..b28338c 100644 --- a/lustre/osd-ldiskfs/osd_quota.c +++ b/lustre/osd-ldiskfs/osd_quota.c @@ -654,6 +654,10 @@ int osd_declare_inode_qid(const struct lu_env *env, qid_t uid, qid_t gid, th->th_ignore_quota; ENTRY; + /* very fast path for special files like llog */ + if (uid == 0 && gid == 0 && projid == 0) + return 0; + /* let's start with user quota */ qi->lqi_id.qid_uid = uid; qi->lqi_type = USRQUOTA; diff --git a/lustre/osd-zfs/osd_quota.c b/lustre/osd-zfs/osd_quota.c index 2e75b8c..7296f3e 100644 --- a/lustre/osd-zfs/osd_quota.c +++ b/lustre/osd-zfs/osd_quota.c @@ -529,6 +529,10 @@ int osd_declare_quota(const struct lu_env *env, struct osd_device *osd, th->th_ignore_quota; ENTRY; + /* very fast path for special files like llog */ + if (uid == 0 && gid == 0 && projid == 0) + return 0; + if (osd_qid_declare_flags & OSD_QID_INODE) qsd = osd->od_quota_slave_md; else if (osd_qid_declare_flags & OSD_QID_BLK) diff --git a/lustre/quota/qsd_handler.c b/lustre/quota/qsd_handler.c index 0c34e6c..01433b6 100644 --- a/lustre/quota/qsd_handler.c +++ b/lustre/quota/qsd_handler.c @@ -857,6 +857,10 @@ int qsd_op_begin(const struct lu_env *env, struct qsd_instance *qsd, bool found = false; ENTRY; + /* fast path, ignore quota enforcement request for root owned files */ + if (qi->lqi_id.qid_uid == 0) + return 0; + if (unlikely(qsd == NULL)) RETURN(0); @@ -880,7 +884,7 @@ int qsd_op_begin(const struct lu_env *env, struct qsd_instance *qsd, * - quota isn't enforced for this quota type * or - the user/group is root * or - quota accounting isn't enabled */ - if (!qsd_type_enabled(qsd, qi->lqi_type) || qi->lqi_id.qid_uid == 0 || + if (!qsd_type_enabled(qsd, qi->lqi_type) || (qsd->qsd_type_array[qi->lqi_type])->qqi_acct_failed) RETURN(0); -- 1.8.3.1