Whamcloud - gitweb
LU-13974 llog: check stale osp object
[fs/lustre-release.git] / lustre / osd-zfs / osd_quota.c
index 45b68ff..243e3e2 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012, 2015, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  * Use is subject to license terms.
  *
  * Author: Johann Lombardi <johann@whamcloud.com>
@@ -515,16 +515,26 @@ const struct dt_index_operations osd_acct_index_ops = {
  */
 int osd_declare_quota(const struct lu_env *env, struct osd_device *osd,
                      qid_t uid, qid_t gid, qid_t projid, long long space,
-                     struct osd_thandle *oh, int *flags,
+                     struct osd_thandle *oh,
+                     enum osd_quota_local_flags *local_flags,
                      enum osd_qid_declare_flags osd_qid_declare_flags)
 {
        struct osd_thread_info *info = osd_oti_get(env);
        struct lquota_id_info *qi = &info->oti_qi;
-       struct qsd_instance *qsd = osd->od_quota_slave;
+       struct qsd_instance *qsd = NULL;
        int rcu, rcg, rcp = 0; /* user & group & project rc */
-       bool force = !!(osd_qid_declare_flags & OSD_QID_FORCE);
+       struct thandle *th = &oh->ot_super;
+       bool force = !!(osd_qid_declare_flags & OSD_QID_FORCE) ||
+                       th->th_ignore_quota;
        ENTRY;
 
+       if (osd_qid_declare_flags & OSD_QID_INODE)
+               qsd = osd->od_quota_slave_md;
+       else if (osd_qid_declare_flags & OSD_QID_BLK)
+               qsd = osd->od_quota_slave_dt;
+       else
+               RETURN(0);
+
        if (unlikely(qsd == NULL))
                /* quota slave instance hasn't been allocated yet */
                RETURN(0);
@@ -534,7 +544,7 @@ int osd_declare_quota(const struct lu_env *env, struct osd_device *osd,
        qi->lqi_type       = USRQUOTA;
        qi->lqi_space      = space;
        qi->lqi_is_blk     = !!(osd_qid_declare_flags & OSD_QID_BLK);
-       rcu = qsd_op_begin(env, qsd, &oh->ot_quota_trans, qi, flags);
+       rcu = qsd_op_begin(env, qsd, &oh->ot_quota_trans, qi, local_flags);
        if (force && (rcu == -EDQUOT || rcu == -EINPROGRESS))
                /* ignore EDQUOT & EINPROGRESS when changes are done by root */
                rcu = 0;
@@ -543,26 +553,27 @@ int osd_declare_quota(const struct lu_env *env, struct osd_device *osd,
         * for group id. This is only for commit write, which has @flags passed
         * in. See osd_declare_write_commit().
         * When force is set to true, we also want to proceed with the gid */
-       if (rcu && (rcu != -EDQUOT || flags == NULL))
+       if (rcu && (rcu != -EDQUOT || local_flags == NULL))
                RETURN(rcu);
 
        /* and now group quota */
        qi->lqi_id.qid_gid = gid;
        qi->lqi_type       = GRPQUOTA;
-       rcg = qsd_op_begin(env, qsd, &oh->ot_quota_trans, qi, flags);
+       rcg = qsd_op_begin(env, qsd, &oh->ot_quota_trans, qi, local_flags);
        if (force && (rcg == -EDQUOT || rcg == -EINPROGRESS))
                /* as before, ignore EDQUOT & EINPROGRESS for root */
                rcg = 0;
 
 #ifdef ZFS_PROJINHERIT
-       if (rcg && (rcg != -EDQUOT || flags == NULL))
+       if (rcg && (rcg != -EDQUOT || local_flags == NULL))
                RETURN(rcg);
 
        /* for project quota */
        if (osd->od_projectused_dn) {
                qi->lqi_id.qid_projid = projid;
                qi->lqi_type = PRJQUOTA;
-               rcp = qsd_op_begin(env, qsd, &oh->ot_quota_trans, qi, flags);
+               rcp = qsd_op_begin(env, qsd, &oh->ot_quota_trans, qi,
+                                  local_flags);
                if (force && (rcp == -EDQUOT || rcp == -EINPROGRESS))
                        rcp = 0;
        }