Whamcloud - gitweb
LU-16518 rsync: fix new clang error in lustre_rsync.c
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_quota.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 021110-1307, USA
20  *
21  * GPL HEADER END
22  */
23 /*
24  * Copyright (c) 2012, 2017, Intel Corporation.
25  * Use is subject to license terms.
26  *
27  * Author: Johann Lombardi <johann@whamcloud.com>
28  * Author: Niu    Yawei    <niu@whamcloud.com>
29  */
30
31 #include <dt_object.h>
32 #include <lustre_quota.h>
33 #include "osd_internal.h"
34
35 /**
36  * Helpers function to find out the quota type (USRQUOTA/GRPQUOTA) of a
37  * given object
38  */
39 static inline int fid2type(const struct lu_fid *fid)
40 {
41         LASSERT(fid_is_acct(fid));
42         switch (fid_oid(fid)) {
43         case ACCT_USER_OID:
44                 return USRQUOTA;
45         case ACCT_GROUP_OID:
46                 return GRPQUOTA;
47         case ACCT_PROJECT_OID:
48                 return PRJQUOTA;
49         }
50
51         LASSERTF(0, "invalid fid for quota type: %u\n", fid_oid(fid));
52         return USRQUOTA;
53 }
54
55 /**
56  * Space Accounting Management
57  */
58
59 /**
60  * Look up an accounting object based on its fid.
61  *
62  * \param info - is the osd thread info passed by the caller
63  * \param osd  - is the osd device
64  * \param fid  - is the fid of the accounting object we want to look up
65  * \param id   - is the osd_inode_id struct to fill with the inode number of
66  *               the quota file if the lookup is successful
67  */
68 int osd_acct_obj_lookup(struct osd_thread_info *info, struct osd_device *osd,
69                         const struct lu_fid *fid, struct osd_inode_id *id)
70 {
71         struct super_block *sb = osd_sb(osd);
72
73         ENTRY;
74         LASSERT(fid_is_acct(fid));
75
76         if (!ldiskfs_has_feature_quota(sb))
77                 RETURN(-ENOENT);
78
79         /**
80          * ldiskfs won't load quota inodes on RO mount,
81          * So disable it in osd-ldiskfs to keep same behavior
82          * like lower layer to avoid further confusions.
83          */
84         if (osd->od_dt_dev.dd_rdonly)
85                 RETURN(-ENOENT);
86
87         id->oii_gen = OSD_OII_NOGEN;
88         switch (fid2type(fid)) {
89         case USRQUOTA:
90                 id->oii_ino =
91                         le32_to_cpu(LDISKFS_SB(sb)->s_es->s_usr_quota_inum);
92                 break;
93         case GRPQUOTA:
94                 id->oii_ino =
95                         le32_to_cpu(LDISKFS_SB(sb)->s_es->s_grp_quota_inum);
96                 break;
97         case PRJQUOTA:
98 #ifdef HAVE_PROJECT_QUOTA
99                 if (ldiskfs_has_feature_project(sb)) {
100                         __le32 prj_quota;
101
102                         prj_quota = LDISKFS_SB(sb)->s_es->s_prj_quota_inum;
103                         id->oii_ino = le32_to_cpu(prj_quota);
104                 } else
105 #endif
106                         RETURN(-ENOENT);
107                 break;
108         }
109
110         if (!ldiskfs_valid_inum(sb, id->oii_ino) &&
111             id->oii_ino != LDISKFS_USR_QUOTA_INO &&
112             id->oii_ino != LDISKFS_GRP_QUOTA_INO)
113                 RETURN(-ENOENT);
114
115         RETURN(0);
116 }
117
118 /**
119  * Return space usage (#blocks & #inodes) consumed by a given uid or gid.
120  *
121  * \param env   - is the environment passed by the caller
122  * \param dtobj - is the accounting object
123  * \param dtrec - is the record to fill with space usage information
124  * \param dtkey - is the id of the user or group for which we would
125  *                like to access disk usage.
126  *
127  * \retval +ve - success : exact match
128  * \retval -ve - failure
129  */
130 static int osd_acct_index_lookup(const struct lu_env *env,
131                                  struct dt_object *dtobj,
132                                  struct dt_rec *dtrec,
133                                  const struct dt_key *dtkey)
134 {
135         struct osd_thread_info *info = osd_oti_get(env);
136 #if defined(HAVE_DQUOT_QC_DQBLK)
137         struct qc_dqblk *dqblk = &info->oti_qdq;
138 #else
139         struct fs_disk_quota *dqblk = &info->oti_fdq;
140 #endif
141         struct super_block *sb = osd_sb(osd_obj2dev(osd_dt_obj(dtobj)));
142         struct lquota_acct_rec *rec = (struct lquota_acct_rec *)dtrec;
143         __u64 id = *((__u64 *)dtkey);
144         int rc;
145         struct kqid qid;
146         int type;
147
148         ENTRY;
149
150         type = fid2type(lu_object_fid(&dtobj->do_lu));
151         memset(dqblk, 0, sizeof(*dqblk));
152         qid = make_kqid(&init_user_ns, type, id);
153         rc = sb->s_qcop->get_dqblk(sb, qid, dqblk);
154         if (rc)
155                 RETURN(rc);
156 #if defined(HAVE_DQUOT_QC_DQBLK)
157         rec->bspace = dqblk->d_space;
158         rec->ispace = dqblk->d_ino_count;
159 #else
160         rec->bspace = dqblk->d_bcount;
161         rec->ispace = dqblk->d_icount;
162 #endif
163         RETURN(+1);
164 }
165
166 #define QUOTA_IT_READ_ERROR(it, rc)                                    \
167         CERROR("%s: Error while trying to read quota information, "    \
168                "failed with %d\n",                                     \
169                osd_dev(it->oiq_obj->oo_dt.do_lu.lo_dev)->od_svname, rc) \
170
171 /**
172  * Initialize osd Iterator for given osd index object.
173  *
174  * \param  dt    - osd index object
175  * \param  attr  - not used
176  */
177 static struct dt_it *osd_it_acct_init(const struct lu_env *env,
178                                       struct dt_object *dt,
179                                       __u32 attr)
180 {
181         struct osd_it_quota *it;
182         struct lu_object *lo = &dt->do_lu;
183         struct osd_object *obj = osd_dt_obj(dt);
184
185         ENTRY;
186
187         LASSERT(lu_object_exists(lo));
188
189         OBD_ALLOC_PTR(it);
190         if (it == NULL)
191                 RETURN(ERR_PTR(-ENOMEM));
192
193         lu_object_get(lo);
194         it->oiq_obj = obj;
195         INIT_LIST_HEAD(&it->oiq_list);
196
197         /* LUSTRE_DQTREEOFF is the initial offset where the tree can be found */
198         it->oiq_blk[0] = LUSTRE_DQTREEOFF;
199
200         /*
201          * NB: we don't need to store the tree depth since it is always
202          * equal to LUSTRE_DQTREEDEPTH - 1 (root has depth = 0) for a leaf
203          * block.
204          */
205         RETURN((struct dt_it *)it);
206 }
207
208 /**
209  * Free given iterator.
210  *
211  * \param  di   - osd iterator
212  */
213 static void osd_it_acct_fini(const struct lu_env *env, struct dt_it *di)
214 {
215         struct osd_it_quota *it = (struct osd_it_quota *)di;
216         struct osd_quota_leaf *leaf, *tmp;
217
218         ENTRY;
219
220         osd_object_put(env, it->oiq_obj);
221
222         list_for_each_entry_safe(leaf, tmp, &it->oiq_list, oql_link) {
223                 list_del_init(&leaf->oql_link);
224                 OBD_FREE_PTR(leaf);
225         }
226
227         OBD_FREE_PTR(it);
228
229         EXIT;
230 }
231
232 /**
233  * Move Iterator to record specified by \a key, if the \a key isn't found,
234  * move to the first valid record.
235  *
236  * \param  di   - osd iterator
237  * \param  key  - uid or gid
238  *
239  * \retval +ve  - di points to the first valid record
240  * \retval  +1  - di points to exact matched key
241  * \retval -ve  - failure
242  */
243 static int osd_it_acct_get(const struct lu_env *env, struct dt_it *di,
244                            const struct dt_key *key)
245 {
246         struct osd_it_quota *it = (struct osd_it_quota *)di;
247         const struct lu_fid *fid = lu_object_fid(&it->oiq_obj->oo_dt.do_lu);
248         int type;
249         qid_t dqid = *(qid_t *)key;
250         loff_t offset;
251         int rc;
252
253         ENTRY;
254         type = fid2type(fid);
255
256         offset = find_tree_dqentry(env, it->oiq_obj, type, dqid,
257                                    LUSTRE_DQTREEOFF, 0, it);
258         if (offset > 0) { /* Found */
259                 RETURN(+1);
260         } else if (offset < 0) { /* Error */
261                 QUOTA_IT_READ_ERROR(it, (int)offset);
262                 RETURN((int)offset);
263         }
264
265         /* The @key is not found, move to the first valid entry */
266         rc = walk_tree_dqentry(env, it->oiq_obj, type, it->oiq_blk[0], 0,
267                                0, it);
268         if (rc == 0)
269                 rc = 1;
270         else if (rc > 0)
271                 rc = -ENOENT;
272
273         RETURN(rc);
274 }
275
276 /**
277  * Release Iterator
278  *
279  * \param  di   - osd iterator
280  */
281 static void osd_it_acct_put(const struct lu_env *env, struct dt_it *di)
282 {
283         return;
284 }
285
286 static int osd_it_add_processed(struct osd_it_quota *it, int depth)
287 {
288         struct osd_quota_leaf *leaf;
289
290         OBD_ALLOC_PTR(leaf);
291         if (leaf == NULL)
292                 RETURN(-ENOMEM);
293         INIT_LIST_HEAD(&leaf->oql_link);
294         leaf->oql_blk = it->oiq_blk[depth];
295         list_add_tail(&leaf->oql_link, &it->oiq_list);
296         RETURN(0);
297 }
298
299 /**
300  * Move on to the next valid entry.
301  *
302  * \param  di   - osd iterator
303  *
304  * \retval +ve  - iterator reached the end
305  * \retval   0  - iterator has not reached the end yet
306  * \retval -ve  - unexpected failure
307  */
308 static int osd_it_acct_next(const struct lu_env *env, struct dt_it *di)
309 {
310         struct osd_it_quota *it = (struct osd_it_quota *)di;
311         const struct lu_fid *fid = lu_object_fid(&it->oiq_obj->oo_dt.do_lu);
312         int type;
313         int depth, rc;
314         uint index;
315
316         ENTRY;
317
318         type = fid2type(fid);
319
320         /*
321          * Let's first check if there are any remaining valid entry in the
322          * current leaf block. Start with the next entry after the current one.
323          */
324         depth = LUSTRE_DQTREEDEPTH;
325         index = it->oiq_index[depth];
326         if (++index < LUSTRE_DQSTRINBLK) {
327                 /* Search for the next valid entry from current index */
328                 rc = walk_block_dqentry(env, it->oiq_obj, type,
329                                         it->oiq_blk[depth], index, it);
330                 if (rc < 0) {
331                         QUOTA_IT_READ_ERROR(it, rc);
332                         RETURN(rc);
333                 } else if (rc == 0) {
334                         /*
335                          * Found on entry, @it is already updated to the
336                          * new position in walk_block_dqentry().
337                          */
338                         RETURN(0);
339                 } else {
340                         rc = osd_it_add_processed(it, depth);
341                         if (rc)
342                                 RETURN(rc);
343                 }
344         } else {
345                 rc = osd_it_add_processed(it, depth);
346                 if (rc)
347                         RETURN(rc);
348         }
349         rc = 1;
350
351         /*
352          * We have consumed all the entries of the current leaf block, move on
353          * to the next one.
354          */
355         depth--;
356
357         /*
358          * We keep searching as long as walk_tree_dqentry() returns +1
359          * (= no valid entry found).
360          */
361         for (; depth >= 0 && rc > 0; depth--) {
362                 index = it->oiq_index[depth];
363                 if (++index > 0xff)
364                         continue;
365                 rc = walk_tree_dqentry(env, it->oiq_obj, type,
366                                        it->oiq_blk[depth], depth, index, it);
367         }
368
369         if (rc < 0)
370                 QUOTA_IT_READ_ERROR(it, rc);
371         RETURN(rc);
372 }
373
374 /**
375  * Return pointer to the key under iterator.
376  *
377  * \param  di   - osd iterator
378  */
379 static struct dt_key *osd_it_acct_key(const struct lu_env *env,
380                                       const struct dt_it *di)
381 {
382         struct osd_it_quota *it = (struct osd_it_quota *)di;
383
384         ENTRY;
385         RETURN((struct dt_key *)&it->oiq_id);
386 }
387
388 /**
389  * Return size of key under iterator (in bytes)
390  *
391  * \param  di   - osd iterator
392  */
393 static int osd_it_acct_key_size(const struct lu_env *env,
394                                 const struct dt_it *di)
395 {
396         struct osd_it_quota *it = (struct osd_it_quota *)di;
397
398         ENTRY;
399         RETURN((int)sizeof(it->oiq_id));
400 }
401
402 /**
403  * Return pointer to the record under iterator.
404  *
405  * \param  di    - osd iterator
406  * \param  attr  - not used
407  */
408 static int osd_it_acct_rec(const struct lu_env *env,
409                            const struct dt_it *di,
410                            struct dt_rec *dtrec, __u32 attr)
411 {
412         struct osd_it_quota *it = (struct osd_it_quota *)di;
413         const struct dt_key *key = osd_it_acct_key(env, di);
414         int rc;
415
416         ENTRY;
417
418         rc = osd_acct_index_lookup(env, &it->oiq_obj->oo_dt, dtrec, key);
419         RETURN(rc > 0 ? 0 : rc);
420 }
421
422 /**
423  * Returns cookie for current Iterator position.
424  *
425  * \param  di    - osd iterator
426  */
427 static __u64 osd_it_acct_store(const struct lu_env *env,
428                                const struct dt_it *di)
429 {
430         struct osd_it_quota *it = (struct osd_it_quota *)di;
431
432         ENTRY;
433         RETURN(it->oiq_id);
434 }
435
436 /**
437  * Restore iterator from cookie. if the \a hash isn't found,
438  * restore the first valid record.
439  *
440  * \param  di    - osd iterator
441  * \param  hash  - iterator location cookie
442  *
443  * \retval +ve   - di points to the first valid record
444  * \retval  +1   - di points to exact matched hash
445  * \retval -ve   - failure
446  */
447 static int osd_it_acct_load(const struct lu_env *env,
448                             const struct dt_it *di, __u64 hash)
449 {
450         struct osd_it_quota *it = (struct osd_it_quota *)di;
451
452         ENTRY;
453
454         /*
455          * LU-8999 - If it is called to resume the iteration, calling
456          * osd_it_acct_get could change the block orders in the lower level
457          * of the quota tree, which are saved in osd_it_quota->oiq_blk.
458          */
459         if (it->oiq_id != 0 && it->oiq_id == hash)
460                 RETURN(1);
461
462         RETURN(osd_it_acct_get(env, (struct dt_it *)di,
463                                (const struct dt_key *)&hash));
464 }
465
466 /**
467  * Index and Iterator operations for accounting objects
468  */
469 const struct dt_index_operations osd_acct_index_ops = {
470         .dio_lookup = osd_acct_index_lookup,
471         .dio_it = {
472                 .init           = osd_it_acct_init,
473                 .fini           = osd_it_acct_fini,
474                 .get            = osd_it_acct_get,
475                 .put            = osd_it_acct_put,
476                 .next           = osd_it_acct_next,
477                 .key            = osd_it_acct_key,
478                 .key_size       = osd_it_acct_key_size,
479                 .rec            = osd_it_acct_rec,
480                 .store          = osd_it_acct_store,
481                 .load           = osd_it_acct_load
482         }
483 };
484
485 static inline void osd_quota_swab(char *ptr, size_t size)
486 {
487         int offset;
488
489         LASSERT((size & (sizeof(__u64) - 1)) == 0);
490
491         for (offset = 0; offset < size; offset += sizeof(__u64))
492                 __swab64s((__u64 *)(ptr + offset));
493 }
494
495 const struct dt_rec *osd_quota_pack(struct osd_object *obj,
496                                     const struct dt_rec *rec,
497                                     union lquota_rec *quota_rec)
498 {
499 #ifdef __BIG_ENDIAN
500         struct iam_descr        *descr;
501
502         LASSERT(obj->oo_dir != NULL);
503         descr = obj->oo_dir->od_container.ic_descr;
504
505         memcpy(quota_rec, rec, descr->id_rec_size);
506
507         osd_quota_swab((char *)quota_rec, descr->id_rec_size);
508         return (const struct dt_rec *)quota_rec;
509 #else
510         return rec;
511 #endif
512 }
513
514 void osd_quota_unpack(struct osd_object *obj, const struct dt_rec *rec)
515 {
516 #ifdef __BIG_ENDIAN
517         struct iam_descr *descr;
518
519         LASSERT(obj->oo_dir != NULL);
520         descr = obj->oo_dir->od_container.ic_descr;
521
522         osd_quota_swab((char *)rec, descr->id_rec_size);
523 #endif
524 }
525
526 static inline int osd_qid_type(struct osd_thandle *oh, int i)
527 {
528         return oh->ot_id_types[i];
529 }
530
531 /**
532  * Reserve journal credits for quota files update first, then call
533  * ->op_begin() to perform quota enforcement.
534  *
535  * \param  env     - the environment passed by the caller
536  * \param  oh      - osd transaction handle
537  * \param  qi      - quota id & space required for this operation
538  * \param  obj     - osd object, could be NULL when it's under create
539  * \param  enforce - whether to perform quota enforcement
540  * \param  flags   - if the operation is write, return no user quota, no
541  *                   group quota, or sync commit flags to the caller
542  *
543  * \retval 0       - success
544  * \retval -ve     - failure
545  */
546 int osd_declare_qid(const struct lu_env *env, struct osd_thandle *oh,
547                     struct lquota_id_info *qi, struct osd_object *obj,
548                     bool enforce, enum osd_quota_local_flags *local_flags)
549 {
550         struct osd_device *dev;
551         struct qsd_instance *qsd;
552         struct lu_fid fid = { 0 };
553         struct inode *inode = NULL;
554         unsigned long long ino =  0;
555         int i, rc = 0, crd;
556         __u8 res = qi->lqi_is_blk ? LQUOTA_RES_DT : LQUOTA_RES_MD;
557         bool found = false;
558
559         ENTRY;
560         if (obj) {
561                 fid = *lu_object_fid(&obj->oo_dt.do_lu);
562                 inode = obj->oo_inode;
563                 ino = inode ? inode->i_ino : 0;
564         }
565         CDEBUG(D_QUOTA, "fid="DFID" ino=%llu type=%u, id=%llu\n",
566                PFID(&fid), ino, qi->lqi_type, qi->lqi_id.qid_uid);
567
568         LASSERT(oh != NULL);
569         LASSERTF(oh->ot_id_cnt <= OSD_MAX_UGID_CNT, "count=%d\n",
570                  oh->ot_id_cnt);
571
572         dev = osd_dt_dev(oh->ot_super.th_dev);
573         LASSERT(dev != NULL);
574
575         if (res == LQUOTA_RES_DT)
576                 qsd = dev->od_quota_slave_dt;
577         else
578                 qsd = dev->od_quota_slave_md;
579
580         for (i = 0; i < oh->ot_id_cnt; i++) {
581                 if (oh->ot_id_array[i] == qi->lqi_id.qid_uid &&
582                     oh->ot_id_res[i] == res &&
583                     oh->ot_id_types[i] == qi->lqi_type) {
584                         found = true;
585                         break;
586                 }
587         }
588
589         if (!found) {
590                 /* we need to account for credits for this new ID */
591                 if (i >= OSD_MAX_UGID_CNT) {
592                         rc = -EOVERFLOW;
593                         CERROR("%s: too many qids %u > %u on "DFID": rc = %d\n",
594                                osd_name(dev), i + 1, OSD_MAX_UGID_CNT,
595                                PFID(&fid), rc);
596                         RETURN(rc);
597                 }
598
599                 if (qi->lqi_id.qid_uid == 0) {
600                         /* root ID should be always present in the quota file */
601                         crd = 1;
602                 } else {
603                         /* can't rely on the current state as it can change
604                          * by the execution.
605                          * if used space for this ID could be dropped to zero,
606                          * reserve extra credits for removing ID entry from
607                          * the quota file
608                          */
609                         if (qi->lqi_space < 0)
610                                 crd = LDISKFS_QUOTA_DEL_BLOCKS(osd_sb(dev));
611                         else
612                                 crd = LDISKFS_QUOTA_INIT_BLOCKS(osd_sb(dev));
613                 }
614
615                 osd_trans_declare_op(env, oh, OSD_OT_QUOTA, crd);
616
617                 oh->ot_id_array[i] = qi->lqi_id.qid_uid;
618                 oh->ot_id_types[i] = qi->lqi_type;
619                 oh->ot_id_res[i] = res;
620                 oh->ot_id_cnt++;
621         }
622
623         if (unlikely(qsd == NULL))
624                 /* quota slave instance hasn't been allocated yet */
625                 RETURN(0);
626
627         /* check quota */
628         if (enforce)
629                 rc = qsd_op_begin(env, qsd, oh->ot_quota_trans, qi,
630                                   local_flags);
631         RETURN(rc);
632 }
633
634 /**
635  * Wrapper for osd_declare_qid()
636  *
637  * \param  env    - the environment passed by the caller
638  * \param  uid    - user id of the inode
639  * \param  gid    - group id of the inode
640  * \param  space  - how many blocks/inodes will be consumed/released
641  * \param  oh     - osd transaction handle
642  * \param  obj    - osd object, could be NULL when it's under create
643  * \param  flags  - if the operation is write, return no user quota, no
644  *                  group quota, or sync commit flags to the caller
645  * \param osd_qid_flags - indicate this is a inode/block accounting
646  *                      and whether changes are performed by root user
647  *
648  * \retval 0      - success
649  * \retval -ve    - failure
650  */
651 int osd_declare_inode_qid(const struct lu_env *env, qid_t uid, qid_t gid,
652                           __u32 projid, long long space, struct osd_thandle *oh,
653                           struct osd_object *obj,
654                           enum osd_quota_local_flags *local_flags,
655                           enum osd_qid_declare_flags osd_qid_declare_flags)
656 {
657         struct osd_thread_info *info = osd_oti_get(env);
658         struct lquota_id_info *qi = &info->oti_qi;
659         int rcu, rcg, rcp = 0; /* user & group & project rc */
660         struct thandle *th = &oh->ot_super;
661         bool force = !!(osd_qid_declare_flags & OSD_QID_FORCE) ||
662                         th->th_ignore_quota;
663         ENTRY;
664
665         /* very fast path for special files like llog */
666         if (uid == 0 && gid == 0 && projid == 0)
667                 return 0;
668
669         /* let's start with user quota */
670         qi->lqi_id.qid_uid = uid;
671         qi->lqi_type = USRQUOTA;
672         qi->lqi_space = space;
673         qi->lqi_is_blk = !!(osd_qid_declare_flags & OSD_QID_BLK);
674         rcu = osd_declare_qid(env, oh, qi, obj, true, local_flags);
675
676         if (force && (rcu == -EDQUOT || rcu == -EINPROGRESS))
677                 /* ignore EDQUOT & EINPROGRESS when changes are done by root */
678                 rcu = 0;
679
680         /*
681          * For non-fatal error, we want to continue to get the noquota flags
682          * for group id. This is only for commit write, which has @flags passed
683          * in. See osd_declare_write_commit().
684          * When force is set to true, we also want to proceed with the gid
685          */
686         if (rcu && (rcu != -EDQUOT || local_flags == NULL))
687                 RETURN(rcu);
688
689         /* and now group quota */
690         qi->lqi_id.qid_gid = gid;
691         qi->lqi_type = GRPQUOTA;
692         rcg = osd_declare_qid(env, oh, qi, obj, true, local_flags);
693
694         if (force && (rcg == -EDQUOT || rcg == -EINPROGRESS))
695                 /* as before, ignore EDQUOT & EINPROGRESS for root */
696                 rcg = 0;
697
698 #ifdef HAVE_PROJECT_QUOTA
699         if (rcg && (rcg != -EDQUOT || local_flags == NULL))
700                 RETURN(rcg);
701
702         /* and now project quota */
703         qi->lqi_id.qid_projid = projid;
704         qi->lqi_type = PRJQUOTA;
705         rcp = osd_declare_qid(env, oh, qi, obj, true, local_flags);
706
707         if (local_flags && *local_flags & QUOTA_FL_ROOT_PRJQUOTA)
708                 force = th->th_ignore_quota;
709         if (force && (rcp == -EDQUOT || rcp == -EINPROGRESS)) {
710                 CDEBUG(D_QUOTA, "forced to ignore quota flags = %#x\n",
711                        local_flags ? *local_flags : -1);
712                 /* as before, ignore EDQUOT & EINPROGRESS for root */
713                 rcp = 0;
714         }
715 #endif
716
717         RETURN(rcu ? rcu : (rcg ? rcg : rcp));
718 }