From c4b630355f5e5a62c02dab6debeb4f6483058c8b Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Thu, 7 Jan 2021 21:34:00 +0800 Subject: [PATCH] LU-15873 quota: don't release for RO device There is no need to release quota space for readonly device. And further problem is there is inconsistency between Lustre osd and ldiskfs, ldiskfs won't load quota inode on Readonly mount, however Lustre osd is not aware of this and load accounting objects even in RO. this might potentially cause problems when Lustre want to access quota. Change-Id: I7db5fe3f3bed3103ed62f6beba1d6f47fce12a21 Signed-off-by: Wang Shilong Reviewed-by: Andreas Dilger Reviewed-by: Li Xi Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48096 Reviewed-by: Oleg Drokin Reviewed-by: Arshad Hussain Tested-by: jenkins Tested-by: Maloo --- lustre/osd-ldiskfs/osd_quota.c | 8 ++++++++ lustre/quota/qsd_handler.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lustre/osd-ldiskfs/osd_quota.c b/lustre/osd-ldiskfs/osd_quota.c index 75a26ac..d8f0fb4 100644 --- a/lustre/osd-ldiskfs/osd_quota.c +++ b/lustre/osd-ldiskfs/osd_quota.c @@ -76,6 +76,14 @@ int osd_acct_obj_lookup(struct osd_thread_info *info, struct osd_device *osd, if (!ldiskfs_has_feature_quota(sb)) RETURN(-ENOENT); + /** + * ldiskfs won't load quota inodes on RO mount, + * So disable it in osd-ldiskfs to keep same behavior + * like lower layer to avoid further confusions. + */ + if (osd->od_dt_dev.dd_rdonly) + RETURN(-ENOENT); + id->oii_gen = OSD_OII_NOGEN; switch (fid2type(fid)) { case USRQUOTA: diff --git a/lustre/quota/qsd_handler.c b/lustre/quota/qsd_handler.c index b12d495..c6db0de 100644 --- a/lustre/quota/qsd_handler.c +++ b/lustre/quota/qsd_handler.c @@ -1259,7 +1259,7 @@ void qsd_op_adjust(const struct lu_env *env, struct qsd_instance *qsd, LASSERT(qqi); if (!qsd_type_enabled(qsd, qtype) || qqi->qqi_acct_obj == NULL || - qid->qid_uid == 0) + qid->qid_uid == 0 || qsd->qsd_dev->dd_rdonly) RETURN_EXIT; read_lock(&qsd->qsd_lock); -- 1.8.3.1