All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tao Ma <tao.ma@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 3/8] Implement quota functions to libocfs2
Date: Tue, 28 Jul 2009 15:55:30 +0800	[thread overview]
Message-ID: <4A6EAEF2.10705@oracle.com> (raw)
In-Reply-To: <1248717216-26617-4-git-send-email-jack@suse.cz>

Hi Jan,

Jan Kara wrote:
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  include/ocfs2/ocfs2.h     |   80 +++
>  libocfs2/Makefile         |    1 +
>  libocfs2/feature_string.c |   18 +
>  libocfs2/ocfs2_err.et     |    6 +
>  libocfs2/quota.c          | 1208 +++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 1313 insertions(+), 0 deletions(-)
>  create mode 100644 libocfs2/quota.c
> 
> diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
> index ac16823..7f136ca 100644
> --- a/include/ocfs2/ocfs2.h
> +++ b/include/ocfs2/ocfs2.h
> @@ -125,16 +125,36 @@
>  #define OCFS2_CHB_WAITING	2
>  #define OCFS2_CHB_COMPLETE	3
>  
> +/* Flags for global quotafile info */
> +#define OCFS2_QF_INFO_DIRTY 1
> +/* Should be power of two */
> +#define DEFAULT_QUOTA_HASH_SIZE 8192
> +#define MAX_QUOTA_HASH_SIZE (1<<21)	/* 16 MB on 64-bit arch*/
16MB is 1<<24?
> +errcode_t ocfs2_init_local_quota_file(ocfs2_filesys *fs, int type,
> +				      uint64_t blkno)
> +{
> +	ocfs2_cached_inode *ci = NULL;
> +	struct ocfs2_dinode *di;
> +	struct ocfs2_disk_dqheader *header;
> +	struct ocfs2_local_disk_dqinfo *info;
> +	unsigned int magics[] = OCFS2_LOCAL_QMAGICS;
> +	int versions[] = OCFS2_LOCAL_QVERSIONS;
> +	char *buf = NULL;
> +	unsigned int written;
> +	errcode_t err;
> +
> +	err = ocfs2_read_cached_inode(fs, blkno, &ci);
> +	if (err)
> +		goto out;
> +
> +	if (!(ci->ci_inode->i_flags & OCFS2_VALID_FL) ||
> +	    !(ci->ci_inode->i_flags & OCFS2_SYSTEM_FL) ||
> +	    !(ci->ci_inode->i_flags & OCFS2_QUOTA_FL)) {
> +		err = OCFS2_ET_INTERNAL_FAILURE;
> +		goto out;
> +	}
> +	di = ci->ci_inode;
> +
> +	/* We need at least two blocks */
> +	err = ocfs2_cached_inode_extend_allocation(ci, (2 * fs->fs_blocksize +
> +			fs->fs_clustersize - 1) / fs->fs_clustersize);
> +	if (err)
> +		goto out;
> +	di->i_size = 2 * fs->fs_blocksize;
> +	di->i_mtime = time(NULL);
> +	err = ocfs2_write_inode(fs, blkno, (char *)di);
> +	if (err)
> +		goto out;
> +
> +	err = ocfs2_malloc_blocks(fs->fs_io, fs->fs_blocksize * 2, &buf);
> +	if (err)
> +		goto out;
> +	memset(buf, 0, 2 * fs->fs_blocksize);
> +
> +	header = (struct ocfs2_disk_dqheader *)buf;
> +	header->dqh_magic = magics[type];
> +	header->dqh_version = versions[type];
> +	ocfs2_swap_quota_header(header);
> +
> +	info = (struct ocfs2_local_disk_dqinfo *)(buf + OCFS2_LOCAL_INFO_OFF);
> +	info->dqi_chunks = 1;
> +	info->dqi_blocks = 2;
I see hardcoded "2" so many times in this function while in 
ocfs2_init_global_quota_file you define "int blocks = 2", so I just 
wonder if we can change it somehow like that function?
> +	info->dqi_flags = OLQF_CLEAN;
> +	ocfs2_swap_quota_local_info(info);
> +
> +	/* There are no free chunks because there are no blocks allocated for
> +	 * them yet. So chunk header is all-zero and needs no initialization */
> +	ocfs2_checksum_quota_block(fs, buf);
> +	ocfs2_checksum_quota_block(fs, buf + fs->fs_blocksize);
> +	err = ocfs2_file_write(ci, buf, 2 * fs->fs_blocksize, 0, &written);
> +	if (!err && written != 2 * fs->fs_blocksize) {
> +		err = OCFS2_ET_INTERNAL_FAILURE;
> +		goto out;
> +	}
and here in ocfs2_init_global_quota_file you use write_blk which will 
calculate ocfs2_checksum_quota_block. So we can use that function also here?

Regards,
Tao

  reply	other threads:[~2009-07-28  7:55 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-27 17:53 [Ocfs2-devel] [PATCH 0/8] Quota support for ocfs2-tools Jan Kara
2009-07-27 17:53 ` [Ocfs2-devel] [PATCH 1/8] Update ocfs2_fs.h to contain all necessary quota structures and constants Jan Kara
2009-07-28 21:45   ` Joel Becker
2009-07-29  9:42     ` Jan Kara
2009-07-29 18:19       ` Joel Becker
2009-07-30 16:57         ` Jan Kara
2009-07-27 17:53 ` [Ocfs2-devel] [PATCH 2/8] Provide ocfs2_cached_inode_extend_allocation() Jan Kara
2009-07-28 21:47   ` Joel Becker
2009-07-29  9:46     ` Jan Kara
2009-07-27 17:53 ` [Ocfs2-devel] [PATCH 3/8] Implement quota functions to libocfs2 Jan Kara
2009-07-28  7:55   ` Tao Ma [this message]
2009-07-28  8:40     ` Jan Kara
2009-07-28  8:43       ` Tao Ma
2009-07-28 10:08         ` Jan Kara
2009-07-28 22:52           ` Joel Becker
2009-07-29  9:57             ` Jan Kara
2009-07-27 17:53 ` [Ocfs2-devel] [PATCH 4/8] Write out quota info changes on ocfs2_close() Jan Kara
2009-07-28 22:53   ` Joel Becker
2009-07-29  9:58     ` Jan Kara
2009-07-27 17:53 ` [Ocfs2-devel] [PATCH 5/8] Quota support for fsck.ocfs2 Jan Kara
2009-07-28 23:05   ` Joel Becker
2009-07-29 10:07     ` Jan Kara
2009-07-29 14:28       ` Tao Ma
2009-07-29 18:22       ` Joel Becker
2009-07-27 17:53 ` [Ocfs2-devel] [PATCH 6/8] Quota support for mkfs.ocfs2 Jan Kara
2009-07-28  8:11   ` Tao Ma
2009-07-28  8:43     ` Jan Kara
2009-07-28 10:09       ` Jan Kara
2009-07-28 23:07         ` Joel Becker
2009-07-27 17:53 ` [Ocfs2-devel] [PATCH 7/8] Add quota support to tunefs.ocfs2 Jan Kara
2009-07-29  1:04   ` Joel Becker
2009-07-27 17:53 ` [Ocfs2-devel] [PATCH 8/8] Change headers to reflect that quota is now fully supported Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A6EAEF2.10705@oracle.com \
    --to=tao.ma@oracle.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.