函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:fs\quota\dquot.c Create Date:2022-07-29 11:08:50
首页 Copyright©Brick

1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
/*
 * Convert in-memory reserved quotas to real consumed quotas
 */
int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
{
    struct dquot **dquots;
    int cnt, index;
 
    if (!dquot_active(inode)) {
        spin_lock(&inode->i_lock);
        *inode_reserved_space(inode) -= number;
        __inode_add_bytes(inode, number);
        spin_unlock(&inode->i_lock);
        return 0;
    }
 
    dquots = i_dquot(inode);
    index = srcu_read_lock(&dquot_srcu);
    spin_lock(&inode->i_lock);
    /* Claim reserved quotas to allocated quotas */
    for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
        if (dquots[cnt]) {
            struct dquot *dquot = dquots[cnt];
 
            spin_lock(&dquot->dq_dqb_lock);
            if (WARN_ON_ONCE(dquot->dq_dqb.dqb_rsvspace < number))
                number = dquot->dq_dqb.dqb_rsvspace;
            dquot->dq_dqb.dqb_curspace += number;
            dquot->dq_dqb.dqb_rsvspace -= number;
            spin_unlock(&dquot->dq_dqb_lock);
        }
    }
    /* Update inode bytes */
    *inode_reserved_space(inode) -= number;
    __inode_add_bytes(inode, number);
    spin_unlock(&inode->i_lock);
    mark_all_dquot_dirty(dquots);
    srcu_read_unlock(&dquot_srcu, index);
    return 0;
}