- * Fetch grace time for either inode or block.
- *
- * \param env - is the environment passed by the caller
- * \param qmt - is the quota master target
- * \param pool_id - is the 16-bit pool identifier
- * \param restype - is the pool type, either block (i.e. LQUOTA_RES_DT) or inode
- * (i.e. LQUOTA_RES_MD)
- * \param qtype - is the quota type
- * \param time - is the output variable where to copy the grace time
- */
-static int qmt_getinfo(const struct lu_env *env, struct qmt_device *qmt,
- __u16 pool_id, __u8 restype, __u8 qtype, __u64 *time)
-{
- struct qmt_thread_info *qti = qmt_info(env);
- union lquota_id *id = &qti->qti_id;
- struct lquota_entry *lqe;
- ENTRY;
-
- /* Global grace time is stored in quota settings of ID 0. */
- id->qid_uid = 0;
-
- /* look-up quota entry storing grace time */
- lqe = qmt_pool_lqe_lookup(env, qmt, pool_id, restype, qtype, id);
- if (IS_ERR(lqe))
- RETURN(PTR_ERR(lqe));
-
- lqe_read_lock(lqe);
- LQUOTA_DEBUG(lqe, "getinfo");
- /* copy grace time */
- *time = lqe->lqe_gracetime;
- lqe_read_unlock(lqe);
-
- lqe_putref(lqe);
- RETURN(0);
-}
-
-/*
- * Update grace time for either inode or block.
- * Global grace time is stored in quota settings of ID 0.
- *
- * \param env - is the environment passed by the caller
- * \param qmt - is the quota master target
- * \param pool_id - is the 16-bit pool identifier
- * \param restype - is the pool type, either block (i.e. LQUOTA_RES_DT) or inode
- * (i.e. LQUOTA_RES_MD)
- * \param qtype - is the quota type
- * \param time - is the new grace time
- */
-static int qmt_setinfo(const struct lu_env *env, struct qmt_device *qmt,
- __u16 pool_id, __u8 restype, __u8 qtype, __u64 time)
-{
- struct qmt_thread_info *qti = qmt_info(env);
- union lquota_id *id = &qti->qti_id;
- struct lquota_entry *lqe;
- struct thandle *th = NULL;
- int rc;
- ENTRY;
-
- /* Global grace time is stored in quota settings of ID 0. */
- id->qid_uid = 0;
-
- /* look-up quota entry storing the global grace time */
- lqe = qmt_pool_lqe_lookup(env, qmt, pool_id, restype, qtype, id);
- if (IS_ERR(lqe))
- RETURN(PTR_ERR(lqe));
-
- /* allocate & start transaction with enough credits to update grace
- * time in the global index file */
- th = qmt_trans_start(env, lqe, &qti->qti_restore);
- if (IS_ERR(th))
- GOTO(out_nolock, rc = PTR_ERR(th));
-
- /* write lock quota entry storing the grace time */
- lqe_write_lock(lqe);
- if (lqe->lqe_gracetime == time)
- /* grace time is the same */
- GOTO(out, rc = 0);
-
- LQUOTA_DEBUG(lqe, "setinfo time:"LPU64, time);
-
- /* set new grace time */
- lqe->lqe_gracetime = time;
- /* always set enforced bit for ID 0 to make sure it does not go away */
- lqe->lqe_enforced = true;
-
- /* write new grace time to disk, no need for version bump */
- rc = qmt_glb_write(env, th, lqe, 0, NULL);
- if (rc) {
- /* restore initial grace time */
- qmt_restore(lqe, &qti->qti_restore);
- GOTO(out, rc);
- }
- EXIT;
-out:
- lqe_write_unlock(lqe);
-out_nolock:
- lqe_putref(lqe);
- if (th != NULL && !IS_ERR(th))
- dt_trans_stop(env, qmt->qmt_child, th);
- return rc;
-}
-
-/*