Skip to content

Commit

Permalink
xfs: remove support for disabling quota accounting on a mounted file …
Browse files Browse the repository at this point in the history
…system

Disabling quota accounting is hairy, racy code with all kinds of pitfalls.
And it has a very strange mind set, as quota accounting (unlike
enforcement) really is a propery of the on-disk format.  There is no good
use case for supporting this.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Carlos Maiolino <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>
  • Loading branch information
Christoph Hellwig authored and Darrick J. Wong committed Aug 6, 2021
1 parent c500bee commit 40b5222
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 454 deletions.
30 changes: 0 additions & 30 deletions fs/xfs/libxfs/xfs_trans_resv.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,29 +798,6 @@ xfs_calc_qm_dqalloc_reservation(
XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) - 1);
}

/*
* Turning off quotas.
* the quota off logitems: sizeof(struct xfs_qoff_logitem) * 2
* the superblock for the quota flags: sector size
*/
STATIC uint
xfs_calc_qm_quotaoff_reservation(
struct xfs_mount *mp)
{
return sizeof(struct xfs_qoff_logitem) * 2 +
xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
}

/*
* End of turning off quotas.
* the quota off logitems: sizeof(struct xfs_qoff_logitem) * 2
*/
STATIC uint
xfs_calc_qm_quotaoff_end_reservation(void)
{
return sizeof(struct xfs_qoff_logitem) * 2;
}

/*
* Syncing the incore super block changes to disk.
* the super block to reflect the changes: sector size
Expand Down Expand Up @@ -923,13 +900,6 @@ xfs_trans_resv_calc(
resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation();
resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT;

resp->tr_qm_quotaoff.tr_logres = xfs_calc_qm_quotaoff_reservation(mp);
resp->tr_qm_quotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT;

resp->tr_qm_equotaoff.tr_logres =
xfs_calc_qm_quotaoff_end_reservation();
resp->tr_qm_equotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT;

resp->tr_sb.tr_logres = xfs_calc_sb_reservation(mp);
resp->tr_sb.tr_logcount = XFS_DEFAULT_LOG_COUNT;

Expand Down
2 changes: 0 additions & 2 deletions fs/xfs/libxfs/xfs_trans_resv.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ struct xfs_trans_resv {
struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */
struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */
struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */
struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */
struct xfs_trans_res tr_qm_equotaoff;/* end of turn quota off */
struct xfs_trans_res tr_sb; /* modify superblock */
struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */
};
Expand Down
134 changes: 0 additions & 134 deletions fs/xfs/xfs_dquot_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,137 +218,3 @@ xfs_qm_dquot_logitem_init(
&xfs_dquot_item_ops);
lp->qli_dquot = dqp;
}

/*------------------ QUOTAOFF LOG ITEMS -------------------*/

static inline struct xfs_qoff_logitem *QOFF_ITEM(struct xfs_log_item *lip)
{
return container_of(lip, struct xfs_qoff_logitem, qql_item);
}


/*
* This returns the number of iovecs needed to log the given quotaoff item.
* We only need 1 iovec for an quotaoff item. It just logs the
* quotaoff_log_format structure.
*/
STATIC void
xfs_qm_qoff_logitem_size(
struct xfs_log_item *lip,
int *nvecs,
int *nbytes)
{
*nvecs += 1;
*nbytes += sizeof(struct xfs_qoff_logitem);
}

STATIC void
xfs_qm_qoff_logitem_format(
struct xfs_log_item *lip,
struct xfs_log_vec *lv)
{
struct xfs_qoff_logitem *qflip = QOFF_ITEM(lip);
struct xfs_log_iovec *vecp = NULL;
struct xfs_qoff_logformat *qlf;

qlf = xlog_prepare_iovec(lv, &vecp, XLOG_REG_TYPE_QUOTAOFF);
qlf->qf_type = XFS_LI_QUOTAOFF;
qlf->qf_size = 1;
qlf->qf_flags = qflip->qql_flags;
xlog_finish_iovec(lv, vecp, sizeof(struct xfs_qoff_logitem));
}

/*
* There isn't much you can do to push a quotaoff item. It is simply
* stuck waiting for the log to be flushed to disk.
*/
STATIC uint
xfs_qm_qoff_logitem_push(
struct xfs_log_item *lip,
struct list_head *buffer_list)
{
return XFS_ITEM_LOCKED;
}

STATIC xfs_lsn_t
xfs_qm_qoffend_logitem_committed(
struct xfs_log_item *lip,
xfs_lsn_t lsn)
{
struct xfs_qoff_logitem *qfe = QOFF_ITEM(lip);
struct xfs_qoff_logitem *qfs = qfe->qql_start_lip;

xfs_qm_qoff_logitem_relse(qfs);

kmem_free(lip->li_lv_shadow);
kmem_free(qfe);
return (xfs_lsn_t)-1;
}

STATIC void
xfs_qm_qoff_logitem_release(
struct xfs_log_item *lip)
{
struct xfs_qoff_logitem *qoff = QOFF_ITEM(lip);

if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) {
if (qoff->qql_start_lip)
xfs_qm_qoff_logitem_relse(qoff->qql_start_lip);
xfs_qm_qoff_logitem_relse(qoff);
}
}

static const struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
.iop_size = xfs_qm_qoff_logitem_size,
.iop_format = xfs_qm_qoff_logitem_format,
.iop_committed = xfs_qm_qoffend_logitem_committed,
.iop_push = xfs_qm_qoff_logitem_push,
.iop_release = xfs_qm_qoff_logitem_release,
};

static const struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
.iop_size = xfs_qm_qoff_logitem_size,
.iop_format = xfs_qm_qoff_logitem_format,
.iop_push = xfs_qm_qoff_logitem_push,
.iop_release = xfs_qm_qoff_logitem_release,
};

/*
* Delete the quotaoff intent from the AIL and free it. On success,
* this should only be called for the start item. It can be used for
* either on shutdown or abort.
*/
void
xfs_qm_qoff_logitem_relse(
struct xfs_qoff_logitem *qoff)
{
struct xfs_log_item *lip = &qoff->qql_item;

ASSERT(test_bit(XFS_LI_IN_AIL, &lip->li_flags) ||
test_bit(XFS_LI_ABORTED, &lip->li_flags) ||
XFS_FORCED_SHUTDOWN(lip->li_mountp));
xfs_trans_ail_delete(lip, 0);
kmem_free(lip->li_lv_shadow);
kmem_free(qoff);
}

/*
* Allocate and initialize an quotaoff item of the correct quota type(s).
*/
struct xfs_qoff_logitem *
xfs_qm_qoff_logitem_init(
struct xfs_mount *mp,
struct xfs_qoff_logitem *start,
uint flags)
{
struct xfs_qoff_logitem *qf;

qf = kmem_zalloc(sizeof(struct xfs_qoff_logitem), 0);

xfs_log_item_init(mp, &qf->qql_item, XFS_LI_QUOTAOFF, start ?
&xfs_qm_qoffend_logitem_ops : &xfs_qm_qoff_logitem_ops);
qf->qql_item.li_mountp = mp;
qf->qql_start_lip = start;
qf->qql_flags = flags;
return qf;
}
17 changes: 0 additions & 17 deletions fs/xfs/xfs_dquot_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,13 @@
struct xfs_dquot;
struct xfs_trans;
struct xfs_mount;
struct xfs_qoff_logitem;

struct xfs_dq_logitem {
struct xfs_log_item qli_item; /* common portion */
struct xfs_dquot *qli_dquot; /* dquot ptr */
xfs_lsn_t qli_flush_lsn; /* lsn at last flush */
};

struct xfs_qoff_logitem {
struct xfs_log_item qql_item; /* common portion */
struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */
unsigned int qql_flags;
};


void xfs_qm_dquot_logitem_init(struct xfs_dquot *dqp);
struct xfs_qoff_logitem *xfs_qm_qoff_logitem_init(struct xfs_mount *mp,
struct xfs_qoff_logitem *start,
uint flags);
void xfs_qm_qoff_logitem_relse(struct xfs_qoff_logitem *);
struct xfs_qoff_logitem *xfs_trans_get_qoff_item(struct xfs_trans *tp,
struct xfs_qoff_logitem *startqoff,
uint flags);
void xfs_trans_log_quotaoff_item(struct xfs_trans *tp,
struct xfs_qoff_logitem *qlp);

#endif /* __XFS_DQUOT_ITEM_H__ */
2 changes: 1 addition & 1 deletion fs/xfs/xfs_qm.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ xfs_qm_dqpurge(
/*
* Purge the dquot cache.
*/
void
static void
xfs_qm_dqpurge_all(
struct xfs_mount *mp,
uint flags)
Expand Down
3 changes: 0 additions & 3 deletions fs/xfs/xfs_qm.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ struct xfs_dquot_acct {

extern void xfs_qm_destroy_quotainfo(struct xfs_mount *);

/* dquot stuff */
extern void xfs_qm_dqpurge_all(struct xfs_mount *, uint);

/* quota ops */
extern int xfs_qm_scall_trunc_qfiles(struct xfs_mount *, uint);
extern int xfs_qm_scall_getquota(struct xfs_mount *mp,
Expand Down
Loading

0 comments on commit 40b5222

Please sign in to comment.