1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
29e33d69fSJan Kara /*
39e33d69fSJan Kara * Implementation of operations over global quota file
49e33d69fSJan Kara */
5171bf93cSMark Fasheh #include <linux/spinlock.h>
69e33d69fSJan Kara #include <linux/fs.h>
75a0e3ad6STejun Heo #include <linux/slab.h>
89e33d69fSJan Kara #include <linux/quota.h>
99e33d69fSJan Kara #include <linux/quotaops.h>
109e33d69fSJan Kara #include <linux/dqblk_qtree.h>
11171bf93cSMark Fasheh #include <linux/jiffies.h>
12171bf93cSMark Fasheh #include <linux/writeback.h>
13171bf93cSMark Fasheh #include <linux/workqueue.h>
14e3a767b6SJan Kara #include <linux/llist.h>
15cc56c33eSJeff Layton #include <linux/iversion.h>
169e33d69fSJan Kara
179e33d69fSJan Kara #include <cluster/masklog.h>
189e33d69fSJan Kara
199e33d69fSJan Kara #include "ocfs2_fs.h"
209e33d69fSJan Kara #include "ocfs2.h"
219e33d69fSJan Kara #include "alloc.h"
22d6b32bbbSJoel Becker #include "blockcheck.h"
239e33d69fSJan Kara #include "inode.h"
249e33d69fSJan Kara #include "journal.h"
259e33d69fSJan Kara #include "file.h"
269e33d69fSJan Kara #include "sysfile.h"
279e33d69fSJan Kara #include "dlmglue.h"
289e33d69fSJan Kara #include "uptodate.h"
29ada50827SJan Kara #include "super.h"
30f64dd44eSJan Kara #include "buffer_head_io.h"
319e33d69fSJan Kara #include "quota.h"
321db986a8STao Ma #include "ocfs2_trace.h"
339e33d69fSJan Kara
34fb8dd8d7SJan Kara /*
35fb8dd8d7SJan Kara * Locking of quotas with OCFS2 is rather complex. Here are rules that
36fb8dd8d7SJan Kara * should be obeyed by all the functions:
37fb8dd8d7SJan Kara * - any write of quota structure (either to local or global file) is protected
38bc8230eeSJan Kara * by dqio_sem or dquot->dq_lock.
39137cebf9Shongnanli * - any modification of global quota file holds inode cluster lock, i_rwsem,
40fb8dd8d7SJan Kara * and ip_alloc_sem of the global quota file (achieved by
41fb8dd8d7SJan Kara * ocfs2_lock_global_qf). It also has to hold qinfo_lock.
42fb8dd8d7SJan Kara * - an allocation of new blocks for local quota file is protected by
43fb8dd8d7SJan Kara * its ip_alloc_sem
44fb8dd8d7SJan Kara *
45fb8dd8d7SJan Kara * A rough sketch of locking dependencies (lf = local file, gf = global file):
46fb8dd8d7SJan Kara * Normal filesystem operation:
47bc8230eeSJan Kara * start_trans -> dqio_sem -> write to lf
48fb8dd8d7SJan Kara * Syncing of local and global file:
49bc8230eeSJan Kara * ocfs2_lock_global_qf -> start_trans -> dqio_sem -> qinfo_lock ->
50fb8dd8d7SJan Kara * write to gf
51fb8dd8d7SJan Kara * -> write to lf
52fb8dd8d7SJan Kara * Acquire dquot for the first time:
53fb8dd8d7SJan Kara * dq_lock -> ocfs2_lock_global_qf -> qinfo_lock -> read from gf
54fb8dd8d7SJan Kara * -> alloc space for gf
55fb8dd8d7SJan Kara * -> start_trans -> qinfo_lock -> write to gf
56fb8dd8d7SJan Kara * -> ip_alloc_sem of lf -> alloc space for lf
57fb8dd8d7SJan Kara * -> write to lf
58fb8dd8d7SJan Kara * Release last reference to dquot:
59fb8dd8d7SJan Kara * dq_lock -> ocfs2_lock_global_qf -> start_trans -> qinfo_lock -> write to gf
60fb8dd8d7SJan Kara * -> write to lf
61fb8dd8d7SJan Kara * Note that all the above operations also hold the inode cluster lock of lf.
62fb8dd8d7SJan Kara * Recovery:
63fb8dd8d7SJan Kara * inode cluster lock of recovered lf
64fb8dd8d7SJan Kara * -> read bitmaps -> ip_alloc_sem of lf
65bc8230eeSJan Kara * -> ocfs2_lock_global_qf -> start_trans -> dqio_sem -> qinfo_lock ->
66fb8dd8d7SJan Kara * write to gf
67fb8dd8d7SJan Kara */
68fb8dd8d7SJan Kara
69171bf93cSMark Fasheh static void qsync_work_fn(struct work_struct *work);
70171bf93cSMark Fasheh
ocfs2_global_disk2memdqb(struct dquot * dquot,void * dp)719e33d69fSJan Kara static void ocfs2_global_disk2memdqb(struct dquot *dquot, void *dp)
729e33d69fSJan Kara {
739e33d69fSJan Kara struct ocfs2_global_disk_dqblk *d = dp;
749e33d69fSJan Kara struct mem_dqblk *m = &dquot->dq_dqb;
759e33d69fSJan Kara
769e33d69fSJan Kara /* Update from disk only entries not set by the admin */
779e33d69fSJan Kara if (!test_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags)) {
789e33d69fSJan Kara m->dqb_ihardlimit = le64_to_cpu(d->dqb_ihardlimit);
799e33d69fSJan Kara m->dqb_isoftlimit = le64_to_cpu(d->dqb_isoftlimit);
809e33d69fSJan Kara }
819e33d69fSJan Kara if (!test_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags))
829e33d69fSJan Kara m->dqb_curinodes = le64_to_cpu(d->dqb_curinodes);
839e33d69fSJan Kara if (!test_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags)) {
849e33d69fSJan Kara m->dqb_bhardlimit = le64_to_cpu(d->dqb_bhardlimit);
859e33d69fSJan Kara m->dqb_bsoftlimit = le64_to_cpu(d->dqb_bsoftlimit);
869e33d69fSJan Kara }
879e33d69fSJan Kara if (!test_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags))
889e33d69fSJan Kara m->dqb_curspace = le64_to_cpu(d->dqb_curspace);
899e33d69fSJan Kara if (!test_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags))
909e33d69fSJan Kara m->dqb_btime = le64_to_cpu(d->dqb_btime);
919e33d69fSJan Kara if (!test_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags))
929e33d69fSJan Kara m->dqb_itime = le64_to_cpu(d->dqb_itime);
939e33d69fSJan Kara OCFS2_DQUOT(dquot)->dq_use_count = le32_to_cpu(d->dqb_use_count);
949e33d69fSJan Kara }
959e33d69fSJan Kara
ocfs2_global_mem2diskdqb(void * dp,struct dquot * dquot)969e33d69fSJan Kara static void ocfs2_global_mem2diskdqb(void *dp, struct dquot *dquot)
979e33d69fSJan Kara {
989e33d69fSJan Kara struct ocfs2_global_disk_dqblk *d = dp;
999e33d69fSJan Kara struct mem_dqblk *m = &dquot->dq_dqb;
1009e33d69fSJan Kara
1014c376dcaSEric W. Biederman d->dqb_id = cpu_to_le32(from_kqid(&init_user_ns, dquot->dq_id));
1029e33d69fSJan Kara d->dqb_use_count = cpu_to_le32(OCFS2_DQUOT(dquot)->dq_use_count);
1039e33d69fSJan Kara d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit);
1049e33d69fSJan Kara d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit);
1059e33d69fSJan Kara d->dqb_curinodes = cpu_to_le64(m->dqb_curinodes);
1069e33d69fSJan Kara d->dqb_bhardlimit = cpu_to_le64(m->dqb_bhardlimit);
1079e33d69fSJan Kara d->dqb_bsoftlimit = cpu_to_le64(m->dqb_bsoftlimit);
1089e33d69fSJan Kara d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
1099e33d69fSJan Kara d->dqb_btime = cpu_to_le64(m->dqb_btime);
1109e33d69fSJan Kara d->dqb_itime = cpu_to_le64(m->dqb_itime);
1117669f54cSJan Kara d->dqb_pad1 = d->dqb_pad2 = 0;
1129e33d69fSJan Kara }
1139e33d69fSJan Kara
ocfs2_global_is_id(void * dp,struct dquot * dquot)1149e33d69fSJan Kara static int ocfs2_global_is_id(void *dp, struct dquot *dquot)
1159e33d69fSJan Kara {
1169e33d69fSJan Kara struct ocfs2_global_disk_dqblk *d = dp;
1179e33d69fSJan Kara struct ocfs2_mem_dqinfo *oinfo =
1184c376dcaSEric W. Biederman sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;
1199e33d69fSJan Kara
1209e33d69fSJan Kara if (qtree_entry_unused(&oinfo->dqi_gi, dp))
1219e33d69fSJan Kara return 0;
1224c376dcaSEric W. Biederman
1234c376dcaSEric W. Biederman return qid_eq(make_kqid(&init_user_ns, dquot->dq_id.type,
1244c376dcaSEric W. Biederman le32_to_cpu(d->dqb_id)),
1254c376dcaSEric W. Biederman dquot->dq_id);
1269e33d69fSJan Kara }
1279e33d69fSJan Kara
128d1b98c23SJulia Lawall const struct qtree_fmt_operations ocfs2_global_ops = {
1299e33d69fSJan Kara .mem2disk_dqblk = ocfs2_global_mem2diskdqb,
1309e33d69fSJan Kara .disk2mem_dqblk = ocfs2_global_disk2memdqb,
1319e33d69fSJan Kara .is_id = ocfs2_global_is_id,
1329e33d69fSJan Kara };
1339e33d69fSJan Kara
ocfs2_validate_quota_block(struct super_block * sb,struct buffer_head * bh)134fb8dd8d7SJan Kara int ocfs2_validate_quota_block(struct super_block *sb, struct buffer_head *bh)
135684ef278SJoel Becker {
136d6b32bbbSJoel Becker struct ocfs2_disk_dqtrailer *dqt =
137d6b32bbbSJoel Becker ocfs2_block_dqtrailer(sb->s_blocksize, bh->b_data);
138684ef278SJoel Becker
1391db986a8STao Ma trace_ocfs2_validate_quota_block((unsigned long long)bh->b_blocknr);
140684ef278SJoel Becker
141d6b32bbbSJoel Becker BUG_ON(!buffer_uptodate(bh));
142d6b32bbbSJoel Becker
143d6b32bbbSJoel Becker /*
144d6b32bbbSJoel Becker * If the ecc fails, we return the error but otherwise
145d6b32bbbSJoel Becker * leave the filesystem running. We know any error is
146d6b32bbbSJoel Becker * local to this block.
147d6b32bbbSJoel Becker */
148d6b32bbbSJoel Becker return ocfs2_validate_meta_ecc(sb, bh->b_data, &dqt->dq_check);
149684ef278SJoel Becker }
150684ef278SJoel Becker
ocfs2_read_quota_phys_block(struct inode * inode,u64 p_block,struct buffer_head ** bhp)151f64dd44eSJan Kara int ocfs2_read_quota_phys_block(struct inode *inode, u64 p_block,
152f64dd44eSJan Kara struct buffer_head **bhp)
153f64dd44eSJan Kara {
154f64dd44eSJan Kara int rc;
155f64dd44eSJan Kara
156f64dd44eSJan Kara *bhp = NULL;
157f64dd44eSJan Kara rc = ocfs2_read_blocks(INODE_CACHE(inode), p_block, 1, bhp, 0,
158f64dd44eSJan Kara ocfs2_validate_quota_block);
159f64dd44eSJan Kara if (rc)
160f64dd44eSJan Kara mlog_errno(rc);
161f64dd44eSJan Kara return rc;
162f64dd44eSJan Kara }
163f64dd44eSJan Kara
1649e33d69fSJan Kara /* Read data from global quotafile - avoid pagecache and such because we cannot
1659e33d69fSJan Kara * afford acquiring the locks... We use quota cluster lock to serialize
1669e33d69fSJan Kara * operations. Caller is responsible for acquiring it. */
ocfs2_quota_read(struct super_block * sb,int type,char * data,size_t len,loff_t off)1679e33d69fSJan Kara ssize_t ocfs2_quota_read(struct super_block *sb, int type, char *data,
1689e33d69fSJan Kara size_t len, loff_t off)
1699e33d69fSJan Kara {
1709e33d69fSJan Kara struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
1719e33d69fSJan Kara struct inode *gqinode = oinfo->dqi_gqinode;
1729e33d69fSJan Kara loff_t i_size = i_size_read(gqinode);
1739e33d69fSJan Kara int offset = off & (sb->s_blocksize - 1);
1749e33d69fSJan Kara sector_t blk = off >> sb->s_blocksize_bits;
1759e33d69fSJan Kara int err = 0;
1769e33d69fSJan Kara struct buffer_head *bh;
1779e33d69fSJan Kara size_t toread, tocopy;
178fb8dd8d7SJan Kara u64 pblock = 0, pcount = 0;
1799e33d69fSJan Kara
1809e33d69fSJan Kara if (off > i_size)
1819e33d69fSJan Kara return 0;
1829e33d69fSJan Kara if (off + len > i_size)
1839e33d69fSJan Kara len = i_size - off;
1849e33d69fSJan Kara toread = len;
1859e33d69fSJan Kara while (toread > 0) {
186dad7d975SMark Fasheh tocopy = min_t(size_t, (sb->s_blocksize - offset), toread);
187fb8dd8d7SJan Kara if (!pcount) {
188fb8dd8d7SJan Kara err = ocfs2_extent_map_get_blocks(gqinode, blk, &pblock,
189fb8dd8d7SJan Kara &pcount, NULL);
190fb8dd8d7SJan Kara if (err) {
191fb8dd8d7SJan Kara mlog_errno(err);
192fb8dd8d7SJan Kara return err;
193fb8dd8d7SJan Kara }
194fb8dd8d7SJan Kara } else {
195fb8dd8d7SJan Kara pcount--;
196fb8dd8d7SJan Kara pblock++;
197fb8dd8d7SJan Kara }
19885eb8b73SJoel Becker bh = NULL;
199fb8dd8d7SJan Kara err = ocfs2_read_quota_phys_block(gqinode, pblock, &bh);
20085eb8b73SJoel Becker if (err) {
2019e33d69fSJan Kara mlog_errno(err);
2029e33d69fSJan Kara return err;
2039e33d69fSJan Kara }
2049e33d69fSJan Kara memcpy(data, bh->b_data + offset, tocopy);
2059e33d69fSJan Kara brelse(bh);
2069e33d69fSJan Kara offset = 0;
2079e33d69fSJan Kara toread -= tocopy;
2089e33d69fSJan Kara data += tocopy;
2099e33d69fSJan Kara blk++;
2109e33d69fSJan Kara }
2119e33d69fSJan Kara return len;
2129e33d69fSJan Kara }
2139e33d69fSJan Kara
2149e33d69fSJan Kara /* Write to quotafile (we know the transaction is already started and has
2159e33d69fSJan Kara * enough credits) */
ocfs2_quota_write(struct super_block * sb,int type,const char * data,size_t len,loff_t off)2169e33d69fSJan Kara ssize_t ocfs2_quota_write(struct super_block *sb, int type,
2179e33d69fSJan Kara const char *data, size_t len, loff_t off)
2189e33d69fSJan Kara {
2199e33d69fSJan Kara struct mem_dqinfo *info = sb_dqinfo(sb, type);
2209e33d69fSJan Kara struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
2219e33d69fSJan Kara struct inode *gqinode = oinfo->dqi_gqinode;
2229e33d69fSJan Kara int offset = off & (sb->s_blocksize - 1);
2239e33d69fSJan Kara sector_t blk = off >> sb->s_blocksize_bits;
224af09e51bSJan Kara int err = 0, new = 0, ja_type;
22585eb8b73SJoel Becker struct buffer_head *bh = NULL;
2269e33d69fSJan Kara handle_t *handle = journal_current_handle();
227fb8dd8d7SJan Kara u64 pblock, pcount;
2289e33d69fSJan Kara
2299e33d69fSJan Kara if (!handle) {
2309e33d69fSJan Kara mlog(ML_ERROR, "Quota write (off=%llu, len=%llu) cancelled "
2319e33d69fSJan Kara "because transaction was not started.\n",
2329e33d69fSJan Kara (unsigned long long)off, (unsigned long long)len);
2339e33d69fSJan Kara return -EIO;
2349e33d69fSJan Kara }
2359e33d69fSJan Kara if (len > sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE - offset) {
2369e33d69fSJan Kara WARN_ON(1);
2379e33d69fSJan Kara len = sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE - offset;
2389e33d69fSJan Kara }
2399e33d69fSJan Kara
240f17c20ddSJunxiao Bi if (i_size_read(gqinode) < off + len) {
241b57ac2c4SJan Kara loff_t rounded_end =
242b57ac2c4SJan Kara ocfs2_align_bytes_to_blocks(sb, off + len);
243b57ac2c4SJan Kara
244fb8dd8d7SJan Kara /* Space is already allocated in ocfs2_acquire_dquot() */
2459e33d69fSJan Kara err = ocfs2_simple_size_update(gqinode,
2469e33d69fSJan Kara oinfo->dqi_gqi_bh,
247b57ac2c4SJan Kara rounded_end);
2489e33d69fSJan Kara if (err < 0)
2499e33d69fSJan Kara goto out;
2509e33d69fSJan Kara new = 1;
2519e33d69fSJan Kara }
252fb8dd8d7SJan Kara err = ocfs2_extent_map_get_blocks(gqinode, blk, &pblock, &pcount, NULL);
253fb8dd8d7SJan Kara if (err) {
254fb8dd8d7SJan Kara mlog_errno(err);
255fb8dd8d7SJan Kara goto out;
256fb8dd8d7SJan Kara }
2579e33d69fSJan Kara /* Not rewriting whole block? */
2589e33d69fSJan Kara if ((offset || len < sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE) &&
2599e33d69fSJan Kara !new) {
260fb8dd8d7SJan Kara err = ocfs2_read_quota_phys_block(gqinode, pblock, &bh);
261af09e51bSJan Kara ja_type = OCFS2_JOURNAL_ACCESS_WRITE;
262af09e51bSJan Kara } else {
263fb8dd8d7SJan Kara bh = sb_getblk(sb, pblock);
264fb8dd8d7SJan Kara if (!bh)
265fb8dd8d7SJan Kara err = -ENOMEM;
266af09e51bSJan Kara ja_type = OCFS2_JOURNAL_ACCESS_CREATE;
267af09e51bSJan Kara }
26885eb8b73SJoel Becker if (err) {
2699e33d69fSJan Kara mlog_errno(err);
270e9956faeSTao Ma goto out;
2719e33d69fSJan Kara }
2729e33d69fSJan Kara lock_buffer(bh);
2739e33d69fSJan Kara if (new)
2749e33d69fSJan Kara memset(bh->b_data, 0, sb->s_blocksize);
2759e33d69fSJan Kara memcpy(bh->b_data + offset, data, len);
2769e33d69fSJan Kara flush_dcache_page(bh->b_page);
277af09e51bSJan Kara set_buffer_uptodate(bh);
2789e33d69fSJan Kara unlock_buffer(bh);
2798cb471e8SJoel Becker ocfs2_set_buffer_uptodate(INODE_CACHE(gqinode), bh);
2800cf2f763SJoel Becker err = ocfs2_journal_access_dq(handle, INODE_CACHE(gqinode), bh,
2810cf2f763SJoel Becker ja_type);
282af09e51bSJan Kara if (err < 0) {
283af09e51bSJan Kara brelse(bh);
284af09e51bSJan Kara goto out;
285af09e51bSJan Kara }
286ec20cec7SJoel Becker ocfs2_journal_dirty(handle, bh);
2879e33d69fSJan Kara brelse(bh);
2889e33d69fSJan Kara out:
2899e33d69fSJan Kara if (err) {
2909e33d69fSJan Kara mlog_errno(err);
2919e33d69fSJan Kara return err;
2929e33d69fSJan Kara }
293cc56c33eSJeff Layton inode_inc_iversion(gqinode);
2949e33d69fSJan Kara ocfs2_mark_inode_dirty(handle, gqinode, oinfo->dqi_gqi_bh);
2959e33d69fSJan Kara return len;
2969e33d69fSJan Kara }
2979e33d69fSJan Kara
ocfs2_lock_global_qf(struct ocfs2_mem_dqinfo * oinfo,int ex)2989e33d69fSJan Kara int ocfs2_lock_global_qf(struct ocfs2_mem_dqinfo *oinfo, int ex)
2999e33d69fSJan Kara {
3009e33d69fSJan Kara int status;
3019e33d69fSJan Kara struct buffer_head *bh = NULL;
3029e33d69fSJan Kara
3039e33d69fSJan Kara status = ocfs2_inode_lock(oinfo->dqi_gqinode, &bh, ex);
3049e33d69fSJan Kara if (status < 0)
3059e33d69fSJan Kara return status;
3069e33d69fSJan Kara spin_lock(&dq_data_lock);
3079e33d69fSJan Kara if (!oinfo->dqi_gqi_count++)
3089e33d69fSJan Kara oinfo->dqi_gqi_bh = bh;
3099e33d69fSJan Kara else
3109e33d69fSJan Kara WARN_ON(bh != oinfo->dqi_gqi_bh);
3119e33d69fSJan Kara spin_unlock(&dq_data_lock);
312fb8dd8d7SJan Kara if (ex) {
3135955102cSAl Viro inode_lock(oinfo->dqi_gqinode);
314fb8dd8d7SJan Kara down_write(&OCFS2_I(oinfo->dqi_gqinode)->ip_alloc_sem);
315fb8dd8d7SJan Kara } else {
316fb8dd8d7SJan Kara down_read(&OCFS2_I(oinfo->dqi_gqinode)->ip_alloc_sem);
317fb8dd8d7SJan Kara }
3189e33d69fSJan Kara return 0;
3199e33d69fSJan Kara }
3209e33d69fSJan Kara
ocfs2_unlock_global_qf(struct ocfs2_mem_dqinfo * oinfo,int ex)3219e33d69fSJan Kara void ocfs2_unlock_global_qf(struct ocfs2_mem_dqinfo *oinfo, int ex)
3229e33d69fSJan Kara {
323fb8dd8d7SJan Kara if (ex) {
324fb8dd8d7SJan Kara up_write(&OCFS2_I(oinfo->dqi_gqinode)->ip_alloc_sem);
3255955102cSAl Viro inode_unlock(oinfo->dqi_gqinode);
326fb8dd8d7SJan Kara } else {
327fb8dd8d7SJan Kara up_read(&OCFS2_I(oinfo->dqi_gqinode)->ip_alloc_sem);
328fb8dd8d7SJan Kara }
3299e33d69fSJan Kara ocfs2_inode_unlock(oinfo->dqi_gqinode, ex);
3309e33d69fSJan Kara brelse(oinfo->dqi_gqi_bh);
3319e33d69fSJan Kara spin_lock(&dq_data_lock);
3329e33d69fSJan Kara if (!--oinfo->dqi_gqi_count)
3339e33d69fSJan Kara oinfo->dqi_gqi_bh = NULL;
3349e33d69fSJan Kara spin_unlock(&dq_data_lock);
3359e33d69fSJan Kara }
3369e33d69fSJan Kara
3379e33d69fSJan Kara /* Read information header from global quota file */
ocfs2_global_read_info(struct super_block * sb,int type)3389e33d69fSJan Kara int ocfs2_global_read_info(struct super_block *sb, int type)
3399e33d69fSJan Kara {
34052362810SJan Kara unsigned int ino[OCFS2_MAXQUOTAS] = { USER_QUOTA_SYSTEM_INODE,
3419e33d69fSJan Kara GROUP_QUOTA_SYSTEM_INODE };
3429e33d69fSJan Kara struct ocfs2_global_disk_dqinfo dinfo;
3439e33d69fSJan Kara struct mem_dqinfo *info = sb_dqinfo(sb, type);
3449e33d69fSJan Kara struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
345ae4f6ef1SJan Kara u64 pcount;
3469e33d69fSJan Kara int status;
3479e33d69fSJan Kara
348de194334SJoseph Qi oinfo->dqi_gi.dqi_sb = sb;
349de194334SJoseph Qi oinfo->dqi_gi.dqi_type = type;
350de194334SJoseph Qi ocfs2_qinfo_lock_res_init(&oinfo->dqi_gqlock, oinfo);
351de194334SJoseph Qi oinfo->dqi_gi.dqi_entry_size = sizeof(struct ocfs2_global_disk_dqblk);
352de194334SJoseph Qi oinfo->dqi_gi.dqi_ops = &ocfs2_global_ops;
353de194334SJoseph Qi oinfo->dqi_gqi_bh = NULL;
354de194334SJoseph Qi oinfo->dqi_gqi_count = 0;
355de194334SJoseph Qi
3569e33d69fSJan Kara /* Read global header */
357de194334SJoseph Qi oinfo->dqi_gqinode = ocfs2_get_system_file_inode(OCFS2_SB(sb), ino[type],
3589e33d69fSJan Kara OCFS2_INVALID_SLOT);
359de194334SJoseph Qi if (!oinfo->dqi_gqinode) {
3609e33d69fSJan Kara mlog(ML_ERROR, "failed to get global quota inode (type=%d)\n",
3619e33d69fSJan Kara type);
3629e33d69fSJan Kara status = -EINVAL;
3639e33d69fSJan Kara goto out_err;
3649e33d69fSJan Kara }
365de194334SJoseph Qi
3669e33d69fSJan Kara status = ocfs2_lock_global_qf(oinfo, 0);
3679e33d69fSJan Kara if (status < 0) {
3689e33d69fSJan Kara mlog_errno(status);
3699e33d69fSJan Kara goto out_err;
3709e33d69fSJan Kara }
371ae4f6ef1SJan Kara
372de194334SJoseph Qi status = ocfs2_extent_map_get_blocks(oinfo->dqi_gqinode, 0, &oinfo->dqi_giblk,
373ae4f6ef1SJan Kara &pcount, NULL);
374ae4f6ef1SJan Kara if (status < 0)
375ae4f6ef1SJan Kara goto out_unlock;
376ae4f6ef1SJan Kara
377ae4f6ef1SJan Kara status = ocfs2_qinfo_lock(oinfo, 0);
378ae4f6ef1SJan Kara if (status < 0)
379ae4f6ef1SJan Kara goto out_unlock;
3809e33d69fSJan Kara status = sb->s_op->quota_read(sb, type, (char *)&dinfo,
3819e33d69fSJan Kara sizeof(struct ocfs2_global_disk_dqinfo),
3829e33d69fSJan Kara OCFS2_GLOBAL_INFO_OFF);
383ae4f6ef1SJan Kara ocfs2_qinfo_unlock(oinfo, 0);
3849e33d69fSJan Kara ocfs2_unlock_global_qf(oinfo, 0);
3859e33d69fSJan Kara if (status != sizeof(struct ocfs2_global_disk_dqinfo)) {
3869e33d69fSJan Kara mlog(ML_ERROR, "Cannot read global quota info (%d).\n",
3879e33d69fSJan Kara status);
3889e33d69fSJan Kara if (status >= 0)
3899e33d69fSJan Kara status = -EIO;
3909e33d69fSJan Kara mlog_errno(status);
3919e33d69fSJan Kara goto out_err;
3929e33d69fSJan Kara }
3939e33d69fSJan Kara info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
3949e33d69fSJan Kara info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
3959e33d69fSJan Kara oinfo->dqi_syncms = le32_to_cpu(dinfo.dqi_syncms);
3969e33d69fSJan Kara oinfo->dqi_gi.dqi_blocks = le32_to_cpu(dinfo.dqi_blocks);
3979e33d69fSJan Kara oinfo->dqi_gi.dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk);
3989e33d69fSJan Kara oinfo->dqi_gi.dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry);
3999e33d69fSJan Kara oinfo->dqi_gi.dqi_blocksize_bits = sb->s_blocksize_bits;
4009e33d69fSJan Kara oinfo->dqi_gi.dqi_usable_bs = sb->s_blocksize -
4019e33d69fSJan Kara OCFS2_QBLK_RESERVED_SPACE;
4029e33d69fSJan Kara oinfo->dqi_gi.dqi_qtree_depth = qtree_depth(&oinfo->dqi_gi);
403171bf93cSMark Fasheh INIT_DELAYED_WORK(&oinfo->dqi_sync_work, qsync_work_fn);
404316873c9STejun Heo schedule_delayed_work(&oinfo->dqi_sync_work,
4054539f1dfSJan Kara msecs_to_jiffies(oinfo->dqi_syncms));
406171bf93cSMark Fasheh
4079e33d69fSJan Kara out_err:
4089e33d69fSJan Kara return status;
409ae4f6ef1SJan Kara out_unlock:
410ae4f6ef1SJan Kara ocfs2_unlock_global_qf(oinfo, 0);
411ae4f6ef1SJan Kara mlog_errno(status);
412ae4f6ef1SJan Kara goto out_err;
4139e33d69fSJan Kara }
4149e33d69fSJan Kara
415233eb8d6SJiangshan Yi /* Write information to global quota file. Expects exclusive lock on quota
4169e33d69fSJan Kara * file inode and quota info */
__ocfs2_global_write_info(struct super_block * sb,int type)4179e33d69fSJan Kara static int __ocfs2_global_write_info(struct super_block *sb, int type)
4189e33d69fSJan Kara {
4199e33d69fSJan Kara struct mem_dqinfo *info = sb_dqinfo(sb, type);
4209e33d69fSJan Kara struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
4219e33d69fSJan Kara struct ocfs2_global_disk_dqinfo dinfo;
4229e33d69fSJan Kara ssize_t size;
4239e33d69fSJan Kara
4249e33d69fSJan Kara spin_lock(&dq_data_lock);
4259e33d69fSJan Kara info->dqi_flags &= ~DQF_INFO_DIRTY;
4269e33d69fSJan Kara dinfo.dqi_bgrace = cpu_to_le32(info->dqi_bgrace);
4279e33d69fSJan Kara dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace);
4289e33d69fSJan Kara spin_unlock(&dq_data_lock);
4299e33d69fSJan Kara dinfo.dqi_syncms = cpu_to_le32(oinfo->dqi_syncms);
4309e33d69fSJan Kara dinfo.dqi_blocks = cpu_to_le32(oinfo->dqi_gi.dqi_blocks);
4319e33d69fSJan Kara dinfo.dqi_free_blk = cpu_to_le32(oinfo->dqi_gi.dqi_free_blk);
4329e33d69fSJan Kara dinfo.dqi_free_entry = cpu_to_le32(oinfo->dqi_gi.dqi_free_entry);
4339e33d69fSJan Kara size = sb->s_op->quota_write(sb, type, (char *)&dinfo,
4349e33d69fSJan Kara sizeof(struct ocfs2_global_disk_dqinfo),
4359e33d69fSJan Kara OCFS2_GLOBAL_INFO_OFF);
4369e33d69fSJan Kara if (size != sizeof(struct ocfs2_global_disk_dqinfo)) {
4379e33d69fSJan Kara mlog(ML_ERROR, "Cannot write global quota info structure\n");
4389e33d69fSJan Kara if (size >= 0)
4399e33d69fSJan Kara size = -EIO;
4409e33d69fSJan Kara return size;
4419e33d69fSJan Kara }
4429e33d69fSJan Kara return 0;
4439e33d69fSJan Kara }
4449e33d69fSJan Kara
ocfs2_global_write_info(struct super_block * sb,int type)4459e33d69fSJan Kara int ocfs2_global_write_info(struct super_block *sb, int type)
4469e33d69fSJan Kara {
4479e33d69fSJan Kara int err;
4489a8ae30eSJan Kara struct quota_info *dqopt = sb_dqopt(sb);
4499a8ae30eSJan Kara struct ocfs2_mem_dqinfo *info = dqopt->info[type].dqi_priv;
4509e33d69fSJan Kara
4519a8ae30eSJan Kara down_write(&dqopt->dqio_sem);
4529e33d69fSJan Kara err = ocfs2_qinfo_lock(info, 1);
4539e33d69fSJan Kara if (err < 0)
4549a8ae30eSJan Kara goto out_sem;
4559e33d69fSJan Kara err = __ocfs2_global_write_info(sb, type);
4569e33d69fSJan Kara ocfs2_qinfo_unlock(info, 1);
4579a8ae30eSJan Kara out_sem:
4589a8ae30eSJan Kara up_write(&dqopt->dqio_sem);
4599e33d69fSJan Kara return err;
4609e33d69fSJan Kara }
4619e33d69fSJan Kara
ocfs2_global_qinit_alloc(struct super_block * sb,int type)462b409d7a0SJan Kara static int ocfs2_global_qinit_alloc(struct super_block *sb, int type)
463b409d7a0SJan Kara {
464b409d7a0SJan Kara struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
465b409d7a0SJan Kara
466b409d7a0SJan Kara /*
467b409d7a0SJan Kara * We may need to allocate tree blocks and a leaf block but not the
468b409d7a0SJan Kara * root block
469b409d7a0SJan Kara */
470b409d7a0SJan Kara return oinfo->dqi_gi.dqi_qtree_depth;
471b409d7a0SJan Kara }
472b409d7a0SJan Kara
ocfs2_calc_global_qinit_credits(struct super_block * sb,int type)473b409d7a0SJan Kara static int ocfs2_calc_global_qinit_credits(struct super_block *sb, int type)
474b409d7a0SJan Kara {
475832d09cfSJan Kara /* We modify all the allocated blocks, tree root, info block and
476832d09cfSJan Kara * the inode */
477b409d7a0SJan Kara return (ocfs2_global_qinit_alloc(sb, type) + 2) *
478832d09cfSJan Kara OCFS2_QUOTA_BLOCK_UPDATE_CREDITS + 1;
479b409d7a0SJan Kara }
480b409d7a0SJan Kara
4819e33d69fSJan Kara /* Sync local information about quota modifications with global quota file.
4829e33d69fSJan Kara * Caller must have started the transaction and obtained exclusive lock for
4839e33d69fSJan Kara * global quota file inode */
__ocfs2_sync_dquot(struct dquot * dquot,int freeing)4849e33d69fSJan Kara int __ocfs2_sync_dquot(struct dquot *dquot, int freeing)
4859e33d69fSJan Kara {
4869e33d69fSJan Kara int err, err2;
4879e33d69fSJan Kara struct super_block *sb = dquot->dq_sb;
4884c376dcaSEric W. Biederman int type = dquot->dq_id.type;
4899e33d69fSJan Kara struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
4909e33d69fSJan Kara struct ocfs2_global_disk_dqblk dqblk;
4919e33d69fSJan Kara s64 spacechange, inodechange;
492e008bb61SArnd Bergmann time64_t olditime, oldbtime;
4939e33d69fSJan Kara
4949e33d69fSJan Kara err = sb->s_op->quota_read(sb, type, (char *)&dqblk,
4959e33d69fSJan Kara sizeof(struct ocfs2_global_disk_dqblk),
4969e33d69fSJan Kara dquot->dq_off);
4979e33d69fSJan Kara if (err != sizeof(struct ocfs2_global_disk_dqblk)) {
4989e33d69fSJan Kara if (err >= 0) {
4999e33d69fSJan Kara mlog(ML_ERROR, "Short read from global quota file "
5009e33d69fSJan Kara "(%u read)\n", err);
5019e33d69fSJan Kara err = -EIO;
5029e33d69fSJan Kara }
5039e33d69fSJan Kara goto out;
5049e33d69fSJan Kara }
5059e33d69fSJan Kara
5069e33d69fSJan Kara /* Update space and inode usage. Get also other information from
5079e33d69fSJan Kara * global quota file so that we don't overwrite any changes there.
5089e33d69fSJan Kara * We are */
5097b9ca4c6SJan Kara spin_lock(&dquot->dq_dqb_lock);
5109e33d69fSJan Kara spacechange = dquot->dq_dqb.dqb_curspace -
5119e33d69fSJan Kara OCFS2_DQUOT(dquot)->dq_origspace;
5129e33d69fSJan Kara inodechange = dquot->dq_dqb.dqb_curinodes -
5139e33d69fSJan Kara OCFS2_DQUOT(dquot)->dq_originodes;
5149e33d69fSJan Kara olditime = dquot->dq_dqb.dqb_itime;
5159e33d69fSJan Kara oldbtime = dquot->dq_dqb.dqb_btime;
5169e33d69fSJan Kara ocfs2_global_disk2memdqb(dquot, &dqblk);
5174c376dcaSEric W. Biederman trace_ocfs2_sync_dquot(from_kqid(&init_user_ns, dquot->dq_id),
5184c376dcaSEric W. Biederman dquot->dq_dqb.dqb_curspace,
5191db986a8STao Ma (long long)spacechange,
5201db986a8STao Ma dquot->dq_dqb.dqb_curinodes,
5211db986a8STao Ma (long long)inodechange);
5229e33d69fSJan Kara if (!test_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags))
5239e33d69fSJan Kara dquot->dq_dqb.dqb_curspace += spacechange;
5249e33d69fSJan Kara if (!test_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags))
5259e33d69fSJan Kara dquot->dq_dqb.dqb_curinodes += inodechange;
5269e33d69fSJan Kara /* Set properly space grace time... */
5279e33d69fSJan Kara if (dquot->dq_dqb.dqb_bsoftlimit &&
5289e33d69fSJan Kara dquot->dq_dqb.dqb_curspace > dquot->dq_dqb.dqb_bsoftlimit) {
5299e33d69fSJan Kara if (!test_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags) &&
5309e33d69fSJan Kara oldbtime > 0) {
5319e33d69fSJan Kara if (dquot->dq_dqb.dqb_btime > 0)
5329e33d69fSJan Kara dquot->dq_dqb.dqb_btime =
5339e33d69fSJan Kara min(dquot->dq_dqb.dqb_btime, oldbtime);
5349e33d69fSJan Kara else
5359e33d69fSJan Kara dquot->dq_dqb.dqb_btime = oldbtime;
5369e33d69fSJan Kara }
5379e33d69fSJan Kara } else {
5389e33d69fSJan Kara dquot->dq_dqb.dqb_btime = 0;
5399e33d69fSJan Kara clear_bit(DQ_BLKS_B, &dquot->dq_flags);
5409e33d69fSJan Kara }
5419e33d69fSJan Kara /* Set properly inode grace time... */
5429e33d69fSJan Kara if (dquot->dq_dqb.dqb_isoftlimit &&
5439e33d69fSJan Kara dquot->dq_dqb.dqb_curinodes > dquot->dq_dqb.dqb_isoftlimit) {
5449e33d69fSJan Kara if (!test_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags) &&
5459e33d69fSJan Kara olditime > 0) {
5469e33d69fSJan Kara if (dquot->dq_dqb.dqb_itime > 0)
5479e33d69fSJan Kara dquot->dq_dqb.dqb_itime =
5489e33d69fSJan Kara min(dquot->dq_dqb.dqb_itime, olditime);
5499e33d69fSJan Kara else
5509e33d69fSJan Kara dquot->dq_dqb.dqb_itime = olditime;
5519e33d69fSJan Kara }
5529e33d69fSJan Kara } else {
5539e33d69fSJan Kara dquot->dq_dqb.dqb_itime = 0;
5549e33d69fSJan Kara clear_bit(DQ_INODES_B, &dquot->dq_flags);
5559e33d69fSJan Kara }
5569e33d69fSJan Kara /* All information is properly updated, clear the flags */
5579e33d69fSJan Kara __clear_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
5589e33d69fSJan Kara __clear_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
5599e33d69fSJan Kara __clear_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
5609e33d69fSJan Kara __clear_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
5619e33d69fSJan Kara __clear_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
5629e33d69fSJan Kara __clear_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
5639e33d69fSJan Kara OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace;
5649e33d69fSJan Kara OCFS2_DQUOT(dquot)->dq_originodes = dquot->dq_dqb.dqb_curinodes;
5657b9ca4c6SJan Kara spin_unlock(&dquot->dq_dqb_lock);
5669e33d69fSJan Kara err = ocfs2_qinfo_lock(info, freeing);
5679e33d69fSJan Kara if (err < 0) {
56825985edcSLucas De Marchi mlog(ML_ERROR, "Failed to lock quota info, losing quota write"
5694c376dcaSEric W. Biederman " (type=%d, id=%u)\n", dquot->dq_id.type,
5704c376dcaSEric W. Biederman (unsigned)from_kqid(&init_user_ns, dquot->dq_id));
5719e33d69fSJan Kara goto out;
5729e33d69fSJan Kara }
5739e33d69fSJan Kara if (freeing)
5749e33d69fSJan Kara OCFS2_DQUOT(dquot)->dq_use_count--;
5759e33d69fSJan Kara err = qtree_write_dquot(&info->dqi_gi, dquot);
5769e33d69fSJan Kara if (err < 0)
5779e33d69fSJan Kara goto out_qlock;
5789e33d69fSJan Kara if (freeing && !OCFS2_DQUOT(dquot)->dq_use_count) {
5799e33d69fSJan Kara err = qtree_release_dquot(&info->dqi_gi, dquot);
5809e33d69fSJan Kara if (info_dirty(sb_dqinfo(sb, type))) {
5819e33d69fSJan Kara err2 = __ocfs2_global_write_info(sb, type);
5829e33d69fSJan Kara if (!err)
5839e33d69fSJan Kara err = err2;
5849e33d69fSJan Kara }
5859e33d69fSJan Kara }
5869e33d69fSJan Kara out_qlock:
5879e33d69fSJan Kara ocfs2_qinfo_unlock(info, freeing);
5889e33d69fSJan Kara out:
5899e33d69fSJan Kara if (err < 0)
5909e33d69fSJan Kara mlog_errno(err);
5919e33d69fSJan Kara return err;
5929e33d69fSJan Kara }
5939e33d69fSJan Kara
5949e33d69fSJan Kara /*
595171bf93cSMark Fasheh * Functions for periodic syncing of dquots with global file
596171bf93cSMark Fasheh */
ocfs2_sync_dquot_helper(struct dquot * dquot,unsigned long type)597171bf93cSMark Fasheh static int ocfs2_sync_dquot_helper(struct dquot *dquot, unsigned long type)
598171bf93cSMark Fasheh {
599171bf93cSMark Fasheh handle_t *handle;
600171bf93cSMark Fasheh struct super_block *sb = dquot->dq_sb;
601171bf93cSMark Fasheh struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
602171bf93cSMark Fasheh struct ocfs2_super *osb = OCFS2_SB(sb);
603171bf93cSMark Fasheh int status = 0;
604171bf93cSMark Fasheh
6054c376dcaSEric W. Biederman trace_ocfs2_sync_dquot_helper(from_kqid(&init_user_ns, dquot->dq_id),
6064c376dcaSEric W. Biederman dquot->dq_id.type,
6071db986a8STao Ma type, sb->s_id);
6084c376dcaSEric W. Biederman if (type != dquot->dq_id.type)
609171bf93cSMark Fasheh goto out;
610171bf93cSMark Fasheh status = ocfs2_lock_global_qf(oinfo, 1);
611171bf93cSMark Fasheh if (status < 0)
612171bf93cSMark Fasheh goto out;
613171bf93cSMark Fasheh
614171bf93cSMark Fasheh handle = ocfs2_start_trans(osb, OCFS2_QSYNC_CREDITS);
615171bf93cSMark Fasheh if (IS_ERR(handle)) {
616171bf93cSMark Fasheh status = PTR_ERR(handle);
617171bf93cSMark Fasheh mlog_errno(status);
618171bf93cSMark Fasheh goto out_ilock;
619171bf93cSMark Fasheh }
620bc8230eeSJan Kara down_write(&sb_dqopt(sb)->dqio_sem);
621171bf93cSMark Fasheh status = ocfs2_sync_dquot(dquot);
622171bf93cSMark Fasheh if (status < 0)
623171bf93cSMark Fasheh mlog_errno(status);
624171bf93cSMark Fasheh /* We have to write local structure as well... */
625741e1289SJan Kara status = ocfs2_local_write_dquot(dquot);
626171bf93cSMark Fasheh if (status < 0)
627171bf93cSMark Fasheh mlog_errno(status);
628bc8230eeSJan Kara up_write(&sb_dqopt(sb)->dqio_sem);
629171bf93cSMark Fasheh ocfs2_commit_trans(osb, handle);
630171bf93cSMark Fasheh out_ilock:
631171bf93cSMark Fasheh ocfs2_unlock_global_qf(oinfo, 1);
632171bf93cSMark Fasheh out:
633171bf93cSMark Fasheh return status;
634171bf93cSMark Fasheh }
635171bf93cSMark Fasheh
qsync_work_fn(struct work_struct * work)636171bf93cSMark Fasheh static void qsync_work_fn(struct work_struct *work)
637171bf93cSMark Fasheh {
638171bf93cSMark Fasheh struct ocfs2_mem_dqinfo *oinfo = container_of(work,
639171bf93cSMark Fasheh struct ocfs2_mem_dqinfo,
640171bf93cSMark Fasheh dqi_sync_work.work);
641171bf93cSMark Fasheh struct super_block *sb = oinfo->dqi_gqinode->i_sb;
642171bf93cSMark Fasheh
6432a64f80eSJan Kara /*
6442a64f80eSJan Kara * We have to be careful here not to deadlock on s_umount as umount
6452a64f80eSJan Kara * disabling quotas may be in progress and it waits for this work to
6462a64f80eSJan Kara * complete. If trylock fails, we'll do the sync next time...
6472a64f80eSJan Kara */
6482a64f80eSJan Kara if (down_read_trylock(&sb->s_umount)) {
649171bf93cSMark Fasheh dquot_scan_active(sb, ocfs2_sync_dquot_helper, oinfo->dqi_type);
6502a64f80eSJan Kara up_read(&sb->s_umount);
6512a64f80eSJan Kara }
652316873c9STejun Heo schedule_delayed_work(&oinfo->dqi_sync_work,
6534539f1dfSJan Kara msecs_to_jiffies(oinfo->dqi_syncms));
654171bf93cSMark Fasheh }
655171bf93cSMark Fasheh
656171bf93cSMark Fasheh /*
6579e33d69fSJan Kara * Wrappers for generic quota functions
6589e33d69fSJan Kara */
6599e33d69fSJan Kara
ocfs2_write_dquot(struct dquot * dquot)6609e33d69fSJan Kara static int ocfs2_write_dquot(struct dquot *dquot)
6619e33d69fSJan Kara {
6629e33d69fSJan Kara handle_t *handle;
6639e33d69fSJan Kara struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
6649e33d69fSJan Kara int status = 0;
6659e33d69fSJan Kara
6664c376dcaSEric W. Biederman trace_ocfs2_write_dquot(from_kqid(&init_user_ns, dquot->dq_id),
6674c376dcaSEric W. Biederman dquot->dq_id.type);
6689e33d69fSJan Kara
6699e33d69fSJan Kara handle = ocfs2_start_trans(osb, OCFS2_QWRITE_CREDITS);
6709e33d69fSJan Kara if (IS_ERR(handle)) {
6719e33d69fSJan Kara status = PTR_ERR(handle);
6729e33d69fSJan Kara mlog_errno(status);
6739e33d69fSJan Kara goto out;
6749e33d69fSJan Kara }
675bc8230eeSJan Kara down_write(&sb_dqopt(dquot->dq_sb)->dqio_sem);
676741e1289SJan Kara status = ocfs2_local_write_dquot(dquot);
677bc8230eeSJan Kara up_write(&sb_dqopt(dquot->dq_sb)->dqio_sem);
6789e33d69fSJan Kara ocfs2_commit_trans(osb, handle);
6799e33d69fSJan Kara out:
6809e33d69fSJan Kara return status;
6819e33d69fSJan Kara }
6829e33d69fSJan Kara
ocfs2_calc_qdel_credits(struct super_block * sb,int type)683b409d7a0SJan Kara static int ocfs2_calc_qdel_credits(struct super_block *sb, int type)
6849e33d69fSJan Kara {
685b409d7a0SJan Kara struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
6860584974aSJan Kara /*
6870584974aSJan Kara * We modify tree, leaf block, global info, local chunk header,
6880584974aSJan Kara * global and local inode; OCFS2_QINFO_WRITE_CREDITS already
6890584974aSJan Kara * accounts for inode update
6900584974aSJan Kara */
691b409d7a0SJan Kara return (oinfo->dqi_gi.dqi_qtree_depth + 2) *
692b409d7a0SJan Kara OCFS2_QUOTA_BLOCK_UPDATE_CREDITS +
6930584974aSJan Kara OCFS2_QINFO_WRITE_CREDITS +
6940584974aSJan Kara OCFS2_INODE_UPDATE_CREDITS;
6959e33d69fSJan Kara }
6969e33d69fSJan Kara
ocfs2_drop_dquot_refs(struct work_struct * work)697e3a767b6SJan Kara void ocfs2_drop_dquot_refs(struct work_struct *work)
698e3a767b6SJan Kara {
699e3a767b6SJan Kara struct ocfs2_super *osb = container_of(work, struct ocfs2_super,
700e3a767b6SJan Kara dquot_drop_work);
701e3a767b6SJan Kara struct llist_node *list;
702e3a767b6SJan Kara struct ocfs2_dquot *odquot, *next_odquot;
703e3a767b6SJan Kara
704e3a767b6SJan Kara list = llist_del_all(&osb->dquot_drop_list);
705e3a767b6SJan Kara llist_for_each_entry_safe(odquot, next_odquot, list, list) {
706e3a767b6SJan Kara /* Drop the reference we acquired in ocfs2_dquot_release() */
707e3a767b6SJan Kara dqput(&odquot->dq_dquot);
708e3a767b6SJan Kara }
709e3a767b6SJan Kara }
710e3a767b6SJan Kara
711e3a767b6SJan Kara /*
712e3a767b6SJan Kara * Called when the last reference to dquot is dropped. If we are called from
713e3a767b6SJan Kara * downconvert thread, we cannot do all the handling here because grabbing
714e3a767b6SJan Kara * quota lock could deadlock (the node holding the quota lock could need some
715e3a767b6SJan Kara * other cluster lock to proceed but with blocked downconvert thread we cannot
716e3a767b6SJan Kara * release any lock).
717e3a767b6SJan Kara */
ocfs2_release_dquot(struct dquot * dquot)7189e33d69fSJan Kara static int ocfs2_release_dquot(struct dquot *dquot)
7199e33d69fSJan Kara {
7209e33d69fSJan Kara handle_t *handle;
7219e33d69fSJan Kara struct ocfs2_mem_dqinfo *oinfo =
7224c376dcaSEric W. Biederman sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;
7239e33d69fSJan Kara struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
7249e33d69fSJan Kara int status = 0;
7259e33d69fSJan Kara
7264c376dcaSEric W. Biederman trace_ocfs2_release_dquot(from_kqid(&init_user_ns, dquot->dq_id),
7274c376dcaSEric W. Biederman dquot->dq_id.type);
7289e33d69fSJan Kara
729fb8dd8d7SJan Kara mutex_lock(&dquot->dq_lock);
730fb8dd8d7SJan Kara /* Check whether we are not racing with some other dqget() */
731df4bb5d1SDmitry Monakhov if (dquot_is_busy(dquot))
732fb8dd8d7SJan Kara goto out;
733e3a767b6SJan Kara /* Running from downconvert thread? Postpone quota processing to wq */
734e3a767b6SJan Kara if (current == osb->dc_task) {
735e3a767b6SJan Kara /*
736e3a767b6SJan Kara * Grab our own reference to dquot and queue it for delayed
737e3a767b6SJan Kara * dropping. Quota code rechecks after calling
738e3a767b6SJan Kara * ->release_dquot() and won't free dquot structure.
739e3a767b6SJan Kara */
740e3a767b6SJan Kara dqgrab(dquot);
741e3a767b6SJan Kara /* First entry on list -> queue work */
742e3a767b6SJan Kara if (llist_add(&OCFS2_DQUOT(dquot)->list, &osb->dquot_drop_list))
74335ddf78eSjiangyiwen queue_work(osb->ocfs2_wq, &osb->dquot_drop_work);
744e3a767b6SJan Kara goto out;
745e3a767b6SJan Kara }
7469e33d69fSJan Kara status = ocfs2_lock_global_qf(oinfo, 1);
7479e33d69fSJan Kara if (status < 0)
7489e33d69fSJan Kara goto out;
7499e33d69fSJan Kara handle = ocfs2_start_trans(osb,
7504c376dcaSEric W. Biederman ocfs2_calc_qdel_credits(dquot->dq_sb, dquot->dq_id.type));
7519e33d69fSJan Kara if (IS_ERR(handle)) {
752*3e6e5acfSSu Yue /*
753*3e6e5acfSSu Yue * Mark dquot as inactive to avoid endless cycle in
754*3e6e5acfSSu Yue * quota_release_workfn().
755*3e6e5acfSSu Yue */
756*3e6e5acfSSu Yue clear_bit(DQ_ACTIVE_B, &dquot->dq_flags);
7579e33d69fSJan Kara status = PTR_ERR(handle);
7589e33d69fSJan Kara mlog_errno(status);
7599e33d69fSJan Kara goto out_ilock;
7609e33d69fSJan Kara }
761fb8dd8d7SJan Kara
762fb8dd8d7SJan Kara status = ocfs2_global_release_dquot(dquot);
763fb8dd8d7SJan Kara if (status < 0) {
764fb8dd8d7SJan Kara mlog_errno(status);
765fb8dd8d7SJan Kara goto out_trans;
766fb8dd8d7SJan Kara }
767fb8dd8d7SJan Kara status = ocfs2_local_release_dquot(handle, dquot);
768fb8dd8d7SJan Kara /*
769fb8dd8d7SJan Kara * If we fail here, we cannot do much as global structure is
770fb8dd8d7SJan Kara * already released. So just complain...
771fb8dd8d7SJan Kara */
772fb8dd8d7SJan Kara if (status < 0)
773fb8dd8d7SJan Kara mlog_errno(status);
77415c34a76SJan Kara /*
77515c34a76SJan Kara * Clear dq_off so that we search for the structure in quota file next
77615c34a76SJan Kara * time we acquire it. The structure might be deleted and reallocated
77715c34a76SJan Kara * elsewhere by another node while our dquot structure is on freelist.
77815c34a76SJan Kara */
77915c34a76SJan Kara dquot->dq_off = 0;
780fb8dd8d7SJan Kara clear_bit(DQ_ACTIVE_B, &dquot->dq_flags);
781fb8dd8d7SJan Kara out_trans:
7829e33d69fSJan Kara ocfs2_commit_trans(osb, handle);
7839e33d69fSJan Kara out_ilock:
7849e33d69fSJan Kara ocfs2_unlock_global_qf(oinfo, 1);
7859e33d69fSJan Kara out:
786fb8dd8d7SJan Kara mutex_unlock(&dquot->dq_lock);
787c1e8d35eSTao Ma if (status)
788c1e8d35eSTao Ma mlog_errno(status);
7899e33d69fSJan Kara return status;
7909e33d69fSJan Kara }
7919e33d69fSJan Kara
792fb8dd8d7SJan Kara /*
793fb8dd8d7SJan Kara * Read global dquot structure from disk or create it if it does
794fb8dd8d7SJan Kara * not exist. Also update use count of the global structure and
795fb8dd8d7SJan Kara * create structure in node-local quota file.
796fb8dd8d7SJan Kara */
ocfs2_acquire_dquot(struct dquot * dquot)7979e33d69fSJan Kara static int ocfs2_acquire_dquot(struct dquot *dquot)
7989e33d69fSJan Kara {
799fb8dd8d7SJan Kara int status = 0, err;
800fb8dd8d7SJan Kara int ex = 0;
801fb8dd8d7SJan Kara struct super_block *sb = dquot->dq_sb;
802fb8dd8d7SJan Kara struct ocfs2_super *osb = OCFS2_SB(sb);
8034c376dcaSEric W. Biederman int type = dquot->dq_id.type;
804fb8dd8d7SJan Kara struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
805fb8dd8d7SJan Kara struct inode *gqinode = info->dqi_gqinode;
806fb8dd8d7SJan Kara int need_alloc = ocfs2_global_qinit_alloc(sb, type);
807fb8dd8d7SJan Kara handle_t *handle;
8089e33d69fSJan Kara
8094c376dcaSEric W. Biederman trace_ocfs2_acquire_dquot(from_kqid(&init_user_ns, dquot->dq_id),
8104c376dcaSEric W. Biederman type);
811fb8dd8d7SJan Kara mutex_lock(&dquot->dq_lock);
812fb8dd8d7SJan Kara /*
813fb8dd8d7SJan Kara * We need an exclusive lock, because we're going to update use count
814fb8dd8d7SJan Kara * and instantiate possibly new dquot structure
815fb8dd8d7SJan Kara */
816fb8dd8d7SJan Kara status = ocfs2_lock_global_qf(info, 1);
8179e33d69fSJan Kara if (status < 0)
8189e33d69fSJan Kara goto out;
819fb8dd8d7SJan Kara status = ocfs2_qinfo_lock(info, 0);
820fb8dd8d7SJan Kara if (status < 0)
821fb8dd8d7SJan Kara goto out_dq;
82215c34a76SJan Kara /*
82315c34a76SJan Kara * We always want to read dquot structure from disk because we don't
82415c34a76SJan Kara * know what happened with it while it was on freelist.
82515c34a76SJan Kara */
826fb8dd8d7SJan Kara status = qtree_read_dquot(&info->dqi_gi, dquot);
827fb8dd8d7SJan Kara ocfs2_qinfo_unlock(info, 0);
828fb8dd8d7SJan Kara if (status < 0)
829fb8dd8d7SJan Kara goto out_dq;
830fb8dd8d7SJan Kara
831fb8dd8d7SJan Kara OCFS2_DQUOT(dquot)->dq_use_count++;
832fb8dd8d7SJan Kara OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace;
833fb8dd8d7SJan Kara OCFS2_DQUOT(dquot)->dq_originodes = dquot->dq_dqb.dqb_curinodes;
834fb8dd8d7SJan Kara if (!dquot->dq_off) { /* No real quota entry? */
835fb8dd8d7SJan Kara ex = 1;
836fb8dd8d7SJan Kara /*
837fb8dd8d7SJan Kara * Add blocks to quota file before we start a transaction since
838fb8dd8d7SJan Kara * locking allocators ranks above a transaction start
839fb8dd8d7SJan Kara */
840fb8dd8d7SJan Kara WARN_ON(journal_current_handle());
8415693486bSJoel Becker status = ocfs2_extend_no_holes(gqinode, NULL,
842f17c20ddSJunxiao Bi i_size_read(gqinode) + (need_alloc << sb->s_blocksize_bits),
843f17c20ddSJunxiao Bi i_size_read(gqinode));
844fb8dd8d7SJan Kara if (status < 0)
845fb8dd8d7SJan Kara goto out_dq;
846fb8dd8d7SJan Kara }
847fb8dd8d7SJan Kara
848fb8dd8d7SJan Kara handle = ocfs2_start_trans(osb,
849fb8dd8d7SJan Kara ocfs2_calc_global_qinit_credits(sb, type));
850fb8dd8d7SJan Kara if (IS_ERR(handle)) {
851fb8dd8d7SJan Kara status = PTR_ERR(handle);
852fb8dd8d7SJan Kara goto out_dq;
853fb8dd8d7SJan Kara }
854fb8dd8d7SJan Kara status = ocfs2_qinfo_lock(info, ex);
855fb8dd8d7SJan Kara if (status < 0)
856fb8dd8d7SJan Kara goto out_trans;
857fb8dd8d7SJan Kara status = qtree_write_dquot(&info->dqi_gi, dquot);
858fb8dd8d7SJan Kara if (ex && info_dirty(sb_dqinfo(sb, type))) {
859fb8dd8d7SJan Kara err = __ocfs2_global_write_info(sb, type);
860fb8dd8d7SJan Kara if (!status)
861fb8dd8d7SJan Kara status = err;
862fb8dd8d7SJan Kara }
863fb8dd8d7SJan Kara ocfs2_qinfo_unlock(info, ex);
864fb8dd8d7SJan Kara out_trans:
865fb8dd8d7SJan Kara ocfs2_commit_trans(osb, handle);
866fb8dd8d7SJan Kara out_dq:
867fb8dd8d7SJan Kara ocfs2_unlock_global_qf(info, 1);
868fb8dd8d7SJan Kara if (status < 0)
869fb8dd8d7SJan Kara goto out;
870fb8dd8d7SJan Kara
871fb8dd8d7SJan Kara status = ocfs2_create_local_dquot(dquot);
872fb8dd8d7SJan Kara if (status < 0)
873fb8dd8d7SJan Kara goto out;
874fb8dd8d7SJan Kara set_bit(DQ_ACTIVE_B, &dquot->dq_flags);
8759e33d69fSJan Kara out:
876fb8dd8d7SJan Kara mutex_unlock(&dquot->dq_lock);
877c1e8d35eSTao Ma if (status)
878c1e8d35eSTao Ma mlog_errno(status);
8799e33d69fSJan Kara return status;
8809e33d69fSJan Kara }
8819e33d69fSJan Kara
ocfs2_get_next_id(struct super_block * sb,struct kqid * qid)8825a9530e4SJan Kara static int ocfs2_get_next_id(struct super_block *sb, struct kqid *qid)
8835a9530e4SJan Kara {
8845a9530e4SJan Kara int type = qid->type;
8855a9530e4SJan Kara struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
8865a9530e4SJan Kara int status = 0;
8875a9530e4SJan Kara
8885a9530e4SJan Kara trace_ocfs2_get_next_id(from_kqid(&init_user_ns, *qid), type);
8892e3d203bSDennis Lam if (!sb_has_quota_active(sb, type)) {
8908f9e8f5fSJan Kara status = -ESRCH;
8918f9e8f5fSJan Kara goto out;
8928f9e8f5fSJan Kara }
8935a9530e4SJan Kara status = ocfs2_lock_global_qf(info, 0);
8945a9530e4SJan Kara if (status < 0)
8955a9530e4SJan Kara goto out;
8965a9530e4SJan Kara status = ocfs2_qinfo_lock(info, 0);
8975a9530e4SJan Kara if (status < 0)
8985a9530e4SJan Kara goto out_global;
8995a9530e4SJan Kara status = qtree_get_next_id(&info->dqi_gi, qid);
9005a9530e4SJan Kara ocfs2_qinfo_unlock(info, 0);
9015a9530e4SJan Kara out_global:
9025a9530e4SJan Kara ocfs2_unlock_global_qf(info, 0);
9035a9530e4SJan Kara out:
9048f9e8f5fSJan Kara /*
9058f9e8f5fSJan Kara * Avoid logging ENOENT since it just means there isn't next ID and
9068f9e8f5fSJan Kara * ESRCH which means quota isn't enabled for the filesystem.
9078f9e8f5fSJan Kara */
9088f9e8f5fSJan Kara if (status && status != -ENOENT && status != -ESRCH)
9095a9530e4SJan Kara mlog_errno(status);
9105a9530e4SJan Kara return status;
9115a9530e4SJan Kara }
9125a9530e4SJan Kara
ocfs2_mark_dquot_dirty(struct dquot * dquot)9139e33d69fSJan Kara static int ocfs2_mark_dquot_dirty(struct dquot *dquot)
9149e33d69fSJan Kara {
9159e33d69fSJan Kara unsigned long mask = (1 << (DQ_LASTSET_B + QIF_ILIMITS_B)) |
9169e33d69fSJan Kara (1 << (DQ_LASTSET_B + QIF_BLIMITS_B)) |
9179e33d69fSJan Kara (1 << (DQ_LASTSET_B + QIF_INODES_B)) |
9189e33d69fSJan Kara (1 << (DQ_LASTSET_B + QIF_SPACE_B)) |
9199e33d69fSJan Kara (1 << (DQ_LASTSET_B + QIF_BTIME_B)) |
9209e33d69fSJan Kara (1 << (DQ_LASTSET_B + QIF_ITIME_B));
9219e33d69fSJan Kara int sync = 0;
9229e33d69fSJan Kara int status;
9239e33d69fSJan Kara struct super_block *sb = dquot->dq_sb;
9244c376dcaSEric W. Biederman int type = dquot->dq_id.type;
9259e33d69fSJan Kara struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
9269e33d69fSJan Kara handle_t *handle;
9279e33d69fSJan Kara struct ocfs2_super *osb = OCFS2_SB(sb);
9289e33d69fSJan Kara
9294c376dcaSEric W. Biederman trace_ocfs2_mark_dquot_dirty(from_kqid(&init_user_ns, dquot->dq_id),
9304c376dcaSEric W. Biederman type);
9319e33d69fSJan Kara
9329e33d69fSJan Kara /* In case user set some limits, sync dquot immediately to global
9339e33d69fSJan Kara * quota file so that information propagates quicker */
9347b9ca4c6SJan Kara spin_lock(&dquot->dq_dqb_lock);
9359e33d69fSJan Kara if (dquot->dq_flags & mask)
9369e33d69fSJan Kara sync = 1;
9377b9ca4c6SJan Kara spin_unlock(&dquot->dq_dqb_lock);
938f8afead7SJan Kara /* This is a slight hack but we can't afford getting global quota
939f8afead7SJan Kara * lock if we already have a transaction started. */
940f8afead7SJan Kara if (!sync || journal_current_handle()) {
9419e33d69fSJan Kara status = ocfs2_write_dquot(dquot);
9429e33d69fSJan Kara goto out;
9439e33d69fSJan Kara }
9449e33d69fSJan Kara status = ocfs2_lock_global_qf(oinfo, 1);
9459e33d69fSJan Kara if (status < 0)
9469e33d69fSJan Kara goto out;
9479e33d69fSJan Kara handle = ocfs2_start_trans(osb, OCFS2_QSYNC_CREDITS);
9489e33d69fSJan Kara if (IS_ERR(handle)) {
9499e33d69fSJan Kara status = PTR_ERR(handle);
9509e33d69fSJan Kara mlog_errno(status);
9519e33d69fSJan Kara goto out_ilock;
9529e33d69fSJan Kara }
953bc8230eeSJan Kara down_write(&sb_dqopt(sb)->dqio_sem);
9549e33d69fSJan Kara status = ocfs2_sync_dquot(dquot);
9559e33d69fSJan Kara if (status < 0) {
9569e33d69fSJan Kara mlog_errno(status);
957741e1289SJan Kara goto out_dlock;
9589e33d69fSJan Kara }
9599e33d69fSJan Kara /* Now write updated local dquot structure */
960741e1289SJan Kara status = ocfs2_local_write_dquot(dquot);
961741e1289SJan Kara out_dlock:
962bc8230eeSJan Kara up_write(&sb_dqopt(sb)->dqio_sem);
9639e33d69fSJan Kara ocfs2_commit_trans(osb, handle);
9649e33d69fSJan Kara out_ilock:
9659e33d69fSJan Kara ocfs2_unlock_global_qf(oinfo, 1);
9669e33d69fSJan Kara out:
967c1e8d35eSTao Ma if (status)
968c1e8d35eSTao Ma mlog_errno(status);
9699e33d69fSJan Kara return status;
9709e33d69fSJan Kara }
9719e33d69fSJan Kara
9729e33d69fSJan Kara /* This should happen only after set_dqinfo(). */
ocfs2_write_info(struct super_block * sb,int type)9739e33d69fSJan Kara static int ocfs2_write_info(struct super_block *sb, int type)
9749e33d69fSJan Kara {
9759e33d69fSJan Kara handle_t *handle;
9769e33d69fSJan Kara int status = 0;
9779e33d69fSJan Kara struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
9789e33d69fSJan Kara
9799e33d69fSJan Kara status = ocfs2_lock_global_qf(oinfo, 1);
9809e33d69fSJan Kara if (status < 0)
9819e33d69fSJan Kara goto out;
9829e33d69fSJan Kara handle = ocfs2_start_trans(OCFS2_SB(sb), OCFS2_QINFO_WRITE_CREDITS);
9839e33d69fSJan Kara if (IS_ERR(handle)) {
9849e33d69fSJan Kara status = PTR_ERR(handle);
9859e33d69fSJan Kara mlog_errno(status);
9869e33d69fSJan Kara goto out_ilock;
9879e33d69fSJan Kara }
9889e33d69fSJan Kara status = dquot_commit_info(sb, type);
9899e33d69fSJan Kara ocfs2_commit_trans(OCFS2_SB(sb), handle);
9909e33d69fSJan Kara out_ilock:
9919e33d69fSJan Kara ocfs2_unlock_global_qf(oinfo, 1);
9929e33d69fSJan Kara out:
993c1e8d35eSTao Ma if (status)
994c1e8d35eSTao Ma mlog_errno(status);
9959e33d69fSJan Kara return status;
9969e33d69fSJan Kara }
9979e33d69fSJan Kara
ocfs2_alloc_dquot(struct super_block * sb,int type)9989e33d69fSJan Kara static struct dquot *ocfs2_alloc_dquot(struct super_block *sb, int type)
9999e33d69fSJan Kara {
10009e33d69fSJan Kara struct ocfs2_dquot *dquot =
10019e33d69fSJan Kara kmem_cache_zalloc(ocfs2_dquot_cachep, GFP_NOFS);
10029e33d69fSJan Kara
10039e33d69fSJan Kara if (!dquot)
10049e33d69fSJan Kara return NULL;
10059e33d69fSJan Kara return &dquot->dq_dquot;
10069e33d69fSJan Kara }
10079e33d69fSJan Kara
ocfs2_destroy_dquot(struct dquot * dquot)10089e33d69fSJan Kara static void ocfs2_destroy_dquot(struct dquot *dquot)
10099e33d69fSJan Kara {
10109e33d69fSJan Kara kmem_cache_free(ocfs2_dquot_cachep, dquot);
10119e33d69fSJan Kara }
10129e33d69fSJan Kara
101361e225dcSAlexey Dobriyan const struct dquot_operations ocfs2_quota_operations = {
1014741e1289SJan Kara /* We never make dquot dirty so .write_dquot is never called */
10159e33d69fSJan Kara .acquire_dquot = ocfs2_acquire_dquot,
10169e33d69fSJan Kara .release_dquot = ocfs2_release_dquot,
10179e33d69fSJan Kara .mark_dirty = ocfs2_mark_dquot_dirty,
10189e33d69fSJan Kara .write_info = ocfs2_write_info,
10199e33d69fSJan Kara .alloc_dquot = ocfs2_alloc_dquot,
10209e33d69fSJan Kara .destroy_dquot = ocfs2_destroy_dquot,
10215a9530e4SJan Kara .get_next_id = ocfs2_get_next_id,
10229e33d69fSJan Kara };
1023