Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/quota.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/quotaops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/dqblk_v1.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "quotaio_v1.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) MODULE_AUTHOR("Jan Kara");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) MODULE_DESCRIPTION("Old quota format support");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define QUOTABLOCK_BITS 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) static inline qsize_t v1_stoqb(qsize_t space)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	return (space + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static inline qsize_t v1_qbtos(qsize_t blocks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	return blocks << QUOTABLOCK_BITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) static void v1_disk2mem_dqblk(struct mem_dqblk *m, struct v1_disk_dqblk *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	m->dqb_ihardlimit = d->dqb_ihardlimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	m->dqb_isoftlimit = d->dqb_isoftlimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	m->dqb_curinodes = d->dqb_curinodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	m->dqb_bhardlimit = v1_qbtos(d->dqb_bhardlimit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	m->dqb_bsoftlimit = v1_qbtos(d->dqb_bsoftlimit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	m->dqb_curspace = v1_qbtos(d->dqb_curblocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	m->dqb_itime = d->dqb_itime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	m->dqb_btime = d->dqb_btime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static void v1_mem2disk_dqblk(struct v1_disk_dqblk *d, struct mem_dqblk *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	d->dqb_ihardlimit = m->dqb_ihardlimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	d->dqb_isoftlimit = m->dqb_isoftlimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	d->dqb_curinodes = m->dqb_curinodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	d->dqb_bhardlimit = v1_stoqb(m->dqb_bhardlimit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	d->dqb_bsoftlimit = v1_stoqb(m->dqb_bsoftlimit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	d->dqb_curblocks = v1_stoqb(m->dqb_curspace);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	d->dqb_itime = m->dqb_itime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	d->dqb_btime = m->dqb_btime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) static int v1_read_dqblk(struct dquot *dquot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	int type = dquot->dq_id.type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct v1_disk_dqblk dqblk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	if (!dqopt->files[type])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	/* Set structure to 0s in case read fails/is after end of file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	memset(&dqblk, 0, sizeof(struct v1_disk_dqblk));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	dquot->dq_sb->s_op->quota_read(dquot->dq_sb, type, (char *)&dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			sizeof(struct v1_disk_dqblk),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 			v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	v1_disk2mem_dqblk(&dquot->dq_dqb, &dqblk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	if (dquot->dq_dqb.dqb_bhardlimit == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	    dquot->dq_dqb.dqb_bsoftlimit == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	    dquot->dq_dqb.dqb_ihardlimit == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	    dquot->dq_dqb.dqb_isoftlimit == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		set_bit(DQ_FAKE_B, &dquot->dq_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	dqstats_inc(DQST_READS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) static int v1_commit_dqblk(struct dquot *dquot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	short type = dquot->dq_id.type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct v1_disk_dqblk dqblk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if (((type == USRQUOTA) && uid_eq(dquot->dq_id.uid, GLOBAL_ROOT_UID)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	    ((type == GRPQUOTA) && gid_eq(dquot->dq_id.gid, GLOBAL_ROOT_GID))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		dqblk.dqb_btime =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			sb_dqopt(dquot->dq_sb)->info[type].dqi_bgrace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		dqblk.dqb_itime =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			sb_dqopt(dquot->dq_sb)->info[type].dqi_igrace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (sb_dqopt(dquot->dq_sb)->files[type])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			(char *)&dqblk, sizeof(struct v1_disk_dqblk),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	if (ret != sizeof(struct v1_disk_dqblk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		quota_error(dquot->dq_sb, "dquota write failed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		if (ret >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	dqstats_inc(DQST_WRITES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /* Magics of new quota format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define V2_INITQMAGICS {\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	0xd9c01f11,     /* USRQUOTA */\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	0xd9c01927      /* GRPQUOTA */\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* Header of new quota format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct v2_disk_dqheader {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	__le32 dqh_magic;        /* Magic number identifying file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	__le32 dqh_version;      /* File version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static int v1_check_quota_file(struct super_block *sb, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct inode *inode = sb_dqopt(sb)->files[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	ulong blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	size_t off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	struct v2_disk_dqheader dqhead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	ssize_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	loff_t isize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	static const uint quota_magics[] = V2_INITQMAGICS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	isize = i_size_read(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	if (!isize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	blocks = isize >> BLOCK_SIZE_BITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	off = isize & (BLOCK_SIZE - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	if ((blocks % sizeof(struct v1_disk_dqblk) * BLOCK_SIZE + off) %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	    sizeof(struct v1_disk_dqblk))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	/* Doublecheck whether we didn't get file with new format - with old
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	 * quotactl() this could happen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	size = sb->s_op->quota_read(sb, type, (char *)&dqhead,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 				    sizeof(struct v2_disk_dqheader), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	if (size != sizeof(struct v2_disk_dqheader))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		return 1;	/* Probably not new format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		return 1;	/* Definitely not new format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	printk(KERN_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	       "VFS: %s: Refusing to turn on old quota format on given file."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	       " It probably contains newer quota format.\n", sb->s_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)         return 0;		/* Seems like a new format file -> refuse it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static int v1_read_file_info(struct super_block *sb, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	struct quota_info *dqopt = sb_dqopt(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	struct v1_disk_dqblk dqblk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	down_read(&dqopt->dqio_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	ret = sb->s_op->quota_read(sb, type, (char *)&dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 				sizeof(struct v1_disk_dqblk), v1_dqoff(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	if (ret != sizeof(struct v1_disk_dqblk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		if (ret >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 			ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	/* limits are stored as unsigned 32-bit data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	dqopt->info[type].dqi_max_spc_limit = 0xffffffffULL << QUOTABLOCK_BITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	dqopt->info[type].dqi_max_ino_limit = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	dqopt->info[type].dqi_igrace =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			dqblk.dqb_itime ? dqblk.dqb_itime : MAX_IQ_TIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	dqopt->info[type].dqi_bgrace =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 			dqblk.dqb_btime ? dqblk.dqb_btime : MAX_DQ_TIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	up_read(&dqopt->dqio_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static int v1_write_file_info(struct super_block *sb, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	struct quota_info *dqopt = sb_dqopt(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	struct v1_disk_dqblk dqblk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	down_write(&dqopt->dqio_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	ret = sb->s_op->quota_read(sb, type, (char *)&dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 				sizeof(struct v1_disk_dqblk), v1_dqoff(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	if (ret != sizeof(struct v1_disk_dqblk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		if (ret >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 			ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	spin_lock(&dq_data_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	dqopt->info[type].dqi_flags &= ~DQF_INFO_DIRTY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	dqblk.dqb_itime = dqopt->info[type].dqi_igrace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	dqblk.dqb_btime = dqopt->info[type].dqi_bgrace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	spin_unlock(&dq_data_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	ret = sb->s_op->quota_write(sb, type, (char *)&dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	      sizeof(struct v1_disk_dqblk), v1_dqoff(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (ret == sizeof(struct v1_disk_dqblk))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	else if (ret > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	up_write(&dqopt->dqio_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static const struct quota_format_ops v1_format_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	.check_quota_file	= v1_check_quota_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	.read_file_info		= v1_read_file_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	.write_file_info	= v1_write_file_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	.read_dqblk		= v1_read_dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	.commit_dqblk		= v1_commit_dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static struct quota_format_type v1_quota_format = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	.qf_fmt_id	= QFMT_VFS_OLD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	.qf_ops		= &v1_format_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	.qf_owner	= THIS_MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static int __init init_v1_quota_format(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)         return register_quota_format(&v1_quota_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static void __exit exit_v1_quota_format(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)         unregister_quota_format(&v1_quota_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) module_init(init_v1_quota_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) module_exit(exit_v1_quota_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)