/*
* Implementation of operations over local quota file
*/
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/quota.h>
#include <linux/quotaops.h>
#include <linux/module.h>
#define MLOG_MASK_PREFIX ML_QUOTA
#include <cluster/masklog.h>
#include "ocfs2_fs.h"
#include "ocfs2.h"
#include "inode.h"
#include "alloc.h"
#include "file.h"
#include "buffer_head_io.h"
#include "journal.h"
#include "sysfile.h"
#include "dlmglue.h"
#include "quota.h"
#include "uptodate.h"
/* Number of local quota structures per block */
static inline unsigned int ol_quota_entries_per_block(struct super_block *sb)
{
return ((sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE) /
sizeof(struct ocfs2_local_disk_dqblk));
}
/* Number of blocks with entries in one chunk */
static inline unsigned int ol_chunk_blocks(struct super_block *sb)
{
return ((sb->s_blocksize - sizeof(struct ocfs2_local_disk_chunk) -
OCFS2_QBLK_RESERVED_SPACE) << 3) /
ol_quota_entries_per_block(sb);
}
/* Number of entries in a chunk bitmap */
static unsigned int ol_chunk_entries(struct super_block *sb)
{
return ol_chunk_blocks(sb) * ol_quota_entries_per_block(sb);
}
/* Offset of the chunk in quota file */
static unsigned int ol_quota_chunk_block(struct super_block *sb, int c)
{
/* 1 block for local quota file info, 1 block per chunk for chunk info */
return 1 + (ol_chunk_blocks(sb) + 1) * c;
}
static unsigned int ol_dqblk_block(struct super_block *sb, int c, int off)
{
int epb = ol_quota_entries_per_block(sb);
return ol_quota_chunk_block(sb, c) + 1 + off / epb;
}
static unsigned int ol_dqblk_block_off(struct super_block *sb, int c, int off)
{
int epb = ol_quota_entries_per_block(sb);
return (off % epb) * sizeof(struct ocfs2_local_disk_dqblk);
}
/* Offset of the dquot structure in the quota file */
static