Beispiel #1
0
/* Write information header to quota file */
static int v2_write_file_info(struct super_block *sb, int type)
{
    struct v2_disk_dqinfo dinfo;
    struct mem_dqinfo *info = sb_dqinfo(sb, type);
    struct qtree_mem_dqinfo *qinfo = info->dqi_priv;
    ssize_t size;

    spin_lock(&dq_data_lock);
    info->dqi_flags &= ~DQF_INFO_DIRTY;
    dinfo.dqi_bgrace = cpu_to_le32(info->dqi_bgrace);
    dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace);
    dinfo.dqi_flags = cpu_to_le32(info->dqi_flags & DQF_MASK);
    spin_unlock(&dq_data_lock);
    dinfo.dqi_blocks = cpu_to_le32(qinfo->dqi_blocks);
    dinfo.dqi_free_blk = cpu_to_le32(qinfo->dqi_free_blk);
    dinfo.dqi_free_entry = cpu_to_le32(qinfo->dqi_free_entry);
    size = sb->s_op->quota_write(sb, type, (char *)&dinfo,
                                 sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
    if (size != sizeof(struct v2_disk_dqinfo)) {
        printk(KERN_WARNING "Can't write info structure on device %s.\n",
               sb->s_id);
        return -1;
    }
    return 0;
}
Beispiel #2
0
/* Write information header to quota file */
static int v2_write_file_info(struct super_block *sb, int type)
{
	struct v2_disk_dqinfo dinfo;
	struct mem_dqinfo *info = sb_dqinfo(sb, type);
	struct qtree_mem_dqinfo *qinfo = info->dqi_priv;
	ssize_t size;

	spin_lock(&dq_data_lock);
	info->dqi_flags &= ~DQF_INFO_DIRTY;
	dinfo.dqi_bgrace = cpu_to_le32(info->dqi_bgrace);
	dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace);
	/* No flags currently supported */
	dinfo.dqi_flags = cpu_to_le32(0);
	spin_unlock(&dq_data_lock);
	dinfo.dqi_blocks = cpu_to_le32(qinfo->dqi_blocks);
	dinfo.dqi_free_blk = cpu_to_le32(qinfo->dqi_free_blk);
	dinfo.dqi_free_entry = cpu_to_le32(qinfo->dqi_free_entry);
	size = sb->s_op->quota_write(sb, type, (char *)&dinfo,
	       sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
	if (size != sizeof(struct v2_disk_dqinfo)) {
		quota_error(sb, "Can't write info structure");
		return -1;
	}
	return 0;
}
Beispiel #3
0
/* Read information header from quota file */
static int v2_read_file_info(struct super_block *sb, int type)
{
    struct v2_disk_dqinfo dinfo;
    struct v2_disk_dqheader dqhead;
    struct mem_dqinfo *info = sb_dqinfo(sb, type);
    struct qtree_mem_dqinfo *qinfo;
    ssize_t size;
    unsigned int version;

    if (!v2_read_header(sb, type, &dqhead))
        return -1;
    version = le32_to_cpu(dqhead.dqh_version);
    if ((info->dqi_fmt_id == QFMT_VFS_V0 && version != 0) ||
            (info->dqi_fmt_id == QFMT_VFS_V1 && version != 1))
        return -1;

    size = sb->s_op->quota_read(sb, type, (char *)&dinfo,
                                sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
    if (size != sizeof(struct v2_disk_dqinfo)) {
        printk(KERN_WARNING "quota_v2: Can't read info structure on device %s.\n",
               sb->s_id);
        return -1;
    }
    info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);
    if (!info->dqi_priv) {
        printk(KERN_WARNING
               "Not enough memory for quota information structure.\n");
        return -1;
    }
    qinfo = info->dqi_priv;
    if (version == 0) {
        /* limits are stored as unsigned 32-bit data */
        info->dqi_maxblimit = 0xffffffff;
        info->dqi_maxilimit = 0xffffffff;
    } else {
        /* used space is stored as unsigned 64-bit value */
        info->dqi_maxblimit = 0xffffffffffffffffULL;	/* 2^64-1 */
        info->dqi_maxilimit = 0xffffffffffffffffULL;
    }
    info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
    info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
    info->dqi_flags = le32_to_cpu(dinfo.dqi_flags);
    qinfo->dqi_sb = sb;
    qinfo->dqi_type = type;
    qinfo->dqi_blocks = le32_to_cpu(dinfo.dqi_blocks);
    qinfo->dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk);
    qinfo->dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry);
    qinfo->dqi_blocksize_bits = V2_DQBLKSIZE_BITS;
    qinfo->dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS;
    qinfo->dqi_qtree_depth = qtree_depth(qinfo);
    if (version == 0) {
        qinfo->dqi_entry_size = sizeof(struct v2r0_disk_dqblk);
        qinfo->dqi_ops = &v2r0_qtree_ops;
    } else {
        qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk);
        qinfo->dqi_ops = &v2r1_qtree_ops;
    }
    return 0;
}
Beispiel #4
0
static int v2r1_is_id(void *dp, struct dquot *dquot)
{
    struct v2r1_disk_dqblk *d = dp;
    struct qtree_mem_dqinfo *info =
        sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;

    if (qtree_entry_unused(info, dp))
        return 0;
    return le32_to_cpu(d->dqb_id) == dquot->dq_id;
}
Beispiel #5
0
static int v2r1_is_id(void *dp, struct dquot *dquot)
{
	struct v2r1_disk_dqblk *d = dp;
	struct qtree_mem_dqinfo *info =
			sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;

	if (qtree_entry_unused(info, dp))
		return 0;
	return qid_eq(make_kqid(&init_user_ns, dquot->dq_id.type,
				le32_to_cpu(d->dqb_id)),
		      dquot->dq_id);
}
Beispiel #6
0
static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot)
{
    struct v2r1_disk_dqblk *d = dp;
    struct mem_dqblk *m = &dquot->dq_dqb;
    struct qtree_mem_dqinfo *info =
        sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;

    d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit);
    d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit);
    d->dqb_curinodes = cpu_to_le64(m->dqb_curinodes);
    d->dqb_itime = cpu_to_le64(m->dqb_itime);
    d->dqb_bhardlimit = cpu_to_le64(v2_stoqb(m->dqb_bhardlimit));
    d->dqb_bsoftlimit = cpu_to_le64(v2_stoqb(m->dqb_bsoftlimit));
    d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
    d->dqb_btime = cpu_to_le64(m->dqb_btime);
    d->dqb_id = cpu_to_le32(dquot->dq_id);
    if (qtree_entry_unused(info, dp))
        d->dqb_itime = cpu_to_le64(1);
}
Beispiel #7
0
static int v2_free_file_info(struct super_block *sb, int type)
{
    kfree(sb_dqinfo(sb, type)->dqi_priv);
    return 0;
}
Beispiel #8
0
static int v2_release_dquot(struct dquot *dquot)
{
    return qtree_release_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot);
}
Beispiel #9
0
static int v2_write_dquot(struct dquot *dquot)
{
	return qtree_write_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot);
}
Beispiel #10
0
/* Read information header from quota file */
static int v2_read_file_info(struct super_block *sb, int type)
{
	struct v2_disk_dqinfo dinfo;
	struct v2_disk_dqheader dqhead;
	struct mem_dqinfo *info = sb_dqinfo(sb, type);
	struct qtree_mem_dqinfo *qinfo;
	ssize_t size;
	unsigned int version;

	if (!v2_read_header(sb, type, &dqhead))
		return -1;
	version = le32_to_cpu(dqhead.dqh_version);
	if ((info->dqi_fmt_id == QFMT_VFS_V0 && version != 0) ||
	    (info->dqi_fmt_id == QFMT_VFS_V1 && version != 1))
		return -1;

	size = sb->s_op->quota_read(sb, type, (char *)&dinfo,
	       sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
	if (size != sizeof(struct v2_disk_dqinfo)) {
		quota_error(sb, "Can't read info structure");
		return -1;
	}
	info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);
	if (!info->dqi_priv) {
		printk(KERN_WARNING
		       "Not enough memory for quota information structure.\n");
		return -ENOMEM;
	}
	qinfo = info->dqi_priv;
	if (version == 0) {
		/* limits are stored as unsigned 32-bit data */
		info->dqi_max_spc_limit = 0xffffffffLL << QUOTABLOCK_BITS;
		info->dqi_max_ino_limit = 0xffffffff;
	} else {
		/*
		 * Used space is stored as unsigned 64-bit value in bytes but
		 * quota core supports only signed 64-bit values so use that
		 * as a limit
		 */
		info->dqi_max_spc_limit = 0x7fffffffffffffffLL; /* 2^63-1 */
		info->dqi_max_ino_limit = 0x7fffffffffffffffLL;
	}
	info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
	info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
	/* No flags currently supported */
	info->dqi_flags = 0;
	qinfo->dqi_sb = sb;
	qinfo->dqi_type = type;
	qinfo->dqi_blocks = le32_to_cpu(dinfo.dqi_blocks);
	qinfo->dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk);
	qinfo->dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry);
	qinfo->dqi_blocksize_bits = V2_DQBLKSIZE_BITS;
	qinfo->dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS;
	qinfo->dqi_qtree_depth = qtree_depth(qinfo);
	if (version == 0) {
		qinfo->dqi_entry_size = sizeof(struct v2r0_disk_dqblk);
		qinfo->dqi_ops = &v2r0_qtree_ops;
	} else {
		qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk);
		qinfo->dqi_ops = &v2r1_qtree_ops;
	}
	return 0;
}