All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tristan <tristan.ye@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 4/5] Convert disabling of sparse feature to use new code in libocfs2
Date: Fri, 16 Oct 2009 16:16:54 +0800	[thread overview]
Message-ID: <4AD82BF6.4030802@oracle.com> (raw)
In-Reply-To: <1255543739-23844-5-git-send-email-jack@suse.cz>

Jan Kara wrote:
> Make code handling update of quota information when disabling
> sparse feature use new generic code in libocfs2.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  tunefs.ocfs2/feature_sparse_files.c |  100 ++++++----------------------------
>  1 files changed, 18 insertions(+), 82 deletions(-)
>
> diff --git a/tunefs.ocfs2/feature_sparse_files.c b/tunefs.ocfs2/feature_sparse_files.c
> index d4dff34..4f8c0db 100644
> --- a/tunefs.ocfs2/feature_sparse_files.c
> +++ b/tunefs.ocfs2/feature_sparse_files.c
> @@ -448,8 +448,6 @@ static errcode_t fill_sparse_files(ocfs2_filesys *fs,
>  	struct list_head *pos;
>  	struct sparse_file *file;
>  	struct tools_progress *prog;
>   

> -	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
>   
Please don't remove this variable though it will not be used in this 
patch anymore, your following patch(patch5) however will use this 
structure again, see:

[PATCH 5/5] Don't account space used for system files when disabling 
sparse feature

-		if (di->i_clusters != file->old_clusters) {
+		if (di->i_clusters != file->old_clusters && 
+		    (!(di->i_flags & OCFS2_SYSTEM_FL) ||
+		    file->blkno == super->s_root_blkno)) {


> -	int has_usrquota, has_grpquota;
>  	ocfs2_quota_hash *usrhash = NULL, *grphash = NULL;
>  
>  	prog = tools_progress_start("Filling holes", "filling",
> @@ -459,32 +457,14 @@ static errcode_t fill_sparse_files(ocfs2_filesys *fs,
>  		goto out;
>  	}
>  
> -	has_usrquota = OCFS2_HAS_RO_COMPAT_FEATURE(super,
> -					OCFS2_FEATURE_RO_COMPAT_USRQUOTA);
> -	has_grpquota = OCFS2_HAS_RO_COMPAT_FEATURE(super,
> -					OCFS2_FEATURE_RO_COMPAT_GRPQUOTA);
> -	if (has_usrquota) {
> -		ret = ocfs2_init_fs_quota_info(fs, USRQUOTA);
> -		if (ret)
> -			goto out;
> -		ret = ocfs2_read_global_quota_info(fs, USRQUOTA);
> -		if (ret)
> -			goto out;
> -		ret = ocfs2_new_quota_hash(&usrhash);
> -		if (ret)
> -			goto out;
> -	}
> -	if (has_grpquota) {
> -		ret = ocfs2_init_fs_quota_info(fs, GRPQUOTA);
> -		if (ret)
> -			goto out;
> -		ret = ocfs2_read_global_quota_info(fs, GRPQUOTA);
> -		if (ret)
> -			goto out;
> -		ret = ocfs2_new_quota_hash(&grphash);
> -		if (ret)
> -			goto out;
> -	}
> +
> +	ret = ocfs2_load_fs_quota_info(fs);
> +	if (ret)
> +		goto out;
> +
> +	ret = ocfs2_init_quota_change(fs, &usrhash, &grphash);
> +	if (ret)
> +		goto out;
>  
>  	ret = ocfs2_malloc_block(fs->fs_io, &buf);
>  	if (ret)
> @@ -497,7 +477,7 @@ static errcode_t fill_sparse_files(ocfs2_filesys *fs,
>  		if (ret)
>  			break;
>  
> -		if (!file->truncate && !has_usrquota && !has_grpquota)
> +		if (!file->truncate && !usrhash && !grphash)
>  			continue;
>  
>  		ret = ocfs2_read_inode(fs, file->blkno, buf);
> @@ -511,7 +491,6 @@ static errcode_t fill_sparse_files(ocfs2_filesys *fs,
>  		}
>  		if (di->i_clusters != file->old_clusters) {
>  			long long change;
> -			ocfs2_cached_dquot *udquot = NULL, *gdquot = NULL;
>  
>  			if (di->i_clusters > file->old_clusters) {
>  				change = ocfs2_clusters_to_bytes(fs,
> @@ -521,64 +500,21 @@ static errcode_t fill_sparse_files(ocfs2_filesys *fs,
>  					file->old_clusters - di->i_clusters);
>  			}
>  
> -			if (has_usrquota) {
> -				ret = ocfs2_find_quota_hash(usrhash, di->i_uid,
> -							    &udquot);
> -				if (ret)
> -					break;
> -				if (!udquot) {
> -					ret = ocfs2_read_dquot(fs, USRQUOTA,
> -							       di->i_uid,
> -							       &udquot);
> -					if (ret)
> -						break;
> -					ret = ocfs2_insert_quota_hash(usrhash,
> -								      udquot);
> -					if (ret)
> -						break;
> -				}
> -				udquot->d_ddquot.dqb_curspace += change;
> -			}
> -			if (has_grpquota) {
> -				ret = ocfs2_find_quota_hash(grphash, di->i_gid,
> -							    &gdquot);
> -				if (ret)
> -					break;
> -				if (!gdquot) {
> -					ret = ocfs2_read_dquot(fs, GRPQUOTA,
> -							       di->i_gid,
> -							       &gdquot);
> -					if (ret)
> -						break;
> -					ret = ocfs2_insert_quota_hash(grphash,
> -								      gdquot);
> -					if (ret)
> -						break;
> -				}
> -				gdquot->d_ddquot.dqb_curspace += change;
> -			}
> +			ret = ocfs2_apply_quota_change(fs, usrhash, grphash,
> +						       di->i_uid, di->i_gid,
> +						       change, 0);
> +			if (ret)
> +				break;
>  		}
>  	}
>  
>  	ocfs2_free(&buf);
>  
>  out:
> -	if (usrhash) {
> -		err = ocfs2_write_release_dquots(fs, USRQUOTA, usrhash);
> -		if (!ret)
> -			ret = err;
> -		err = ocfs2_free_quota_hash(usrhash);
> -		if (!ret)
> -			ret = err;
> -	}
> -	if (grphash) {
> -		err = ocfs2_write_release_dquots(fs, GRPQUOTA, grphash);
> -		if (!ret)
> -			ret = err;
> -		err = ocfs2_free_quota_hash(grphash);
> -		if (!ret)
> -			ret = err;
> -	}
> +	err = ocfs2_finish_quota_change(fs, usrhash, grphash);
> +	if (!ret)
> +		ret = err;
> +
>  	if (prog)
>  		tools_progress_stop(prog);
>  
>   

  reply	other threads:[~2009-10-16  8:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14 18:08 [Ocfs2-devel] [PATCH 0/5] Quota support for disabling inline-data feature (v2) and a fix Jan Kara
2009-10-14 18:08 ` [Ocfs2-devel] [PATCH 1/5] Do not reinitialize already initialized quota info Jan Kara
2009-10-14 18:08 ` [Ocfs2-devel] [PATCH 2/5] Implement support for quota changes in libocfs2 Jan Kara
2009-10-20  6:49   ` Tristan
2009-10-20  8:26     ` Jan Kara
2009-10-14 18:08 ` [Ocfs2-devel] [PATCH 3/5] Quota support for disabling inline-data feature Jan Kara
2009-10-20 19:08   ` Joel Becker
2009-10-14 18:08 ` [Ocfs2-devel] [PATCH 4/5] Convert disabling of sparse feature to use new code in libocfs2 Jan Kara
2009-10-16  8:16   ` Tristan [this message]
2009-10-19  6:55     ` Jan Kara
2009-10-14 18:08 ` [Ocfs2-devel] [PATCH 5/5] Don't account space used for system files when disabling sparse feature Jan Kara
2009-10-14 20:04 ` [Ocfs2-devel] [PATCH 0/5] Quota support for disabling inline-data feature (v2) and a fix Joel Becker
2009-10-15 10:34   ` Jan Kara
2009-10-19  7:06 ` Tristan

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=4AD82BF6.4030802@oracle.com \
    --to=tristan.ye@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.