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