[Ocfs2-tools-devel] [Ocfs2-devel] [PATCH 4/9] Write out quota info changes on ocfs2_close()

tristan.ye tristan.ye at oracle.com
Mon Aug 3 22:18:22 PDT 2009


On Mon, 2009-08-03 at 15:23 +0200, Jan Kara wrote:
> We don't write out change of information in quota file header on each change,
> we rather cache it in ocfs2_filesys structure. So write out all the
> information when ocfs2_close() is called.
> 
> Signed-off-by: Jan Kara <jack at suse.cz>
> ---
>  libocfs2/closefs.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/libocfs2/closefs.c b/libocfs2/closefs.c
> index 54411da..290bfd1 100644
> --- a/libocfs2/closefs.c
> +++ b/libocfs2/closefs.c
> @@ -39,6 +39,7 @@ errcode_t ocfs2_flush(ocfs2_filesys *fs)
>  errcode_t ocfs2_close(ocfs2_filesys *fs)
>  {
>  	errcode_t ret;
> +	int type;
>  
>  	if (fs->fs_flags & OCFS2_FLAG_DIRTY) {
>  		ret = ocfs2_flush(fs);
> @@ -46,6 +47,17 @@ errcode_t ocfs2_close(ocfs2_filesys *fs)
>  			return ret;
>  	}
>  
> +	for (type = 0; type < MAXQUOTAS; type++)
> +		if (fs->qinfo[type].flags & OCFS2_QF_INFO_DIRTY) {
> +			ret = ocfs2_write_global_quota_info(fs, type);

Sometimes, some fields of 'fs' may get freed somehow(e.g, such as
tunefs.ocfs2 case) before we call ocfs2_close(), then your
ocfs2_write_global_quota_info() may suffer a segfault disaster somehow
when it refers to 'fs_io' or some other fields.

> +			if (ret)
> +				return ret;
> +			ret = ocfs2_write_cached_inode(fs,
> +						fs->qinfo[type].qi_inode);
> +			if (ret)
> +				return ret;
> +		}
> +
>  	ocfs2_freefs(fs);
>  	return 0;
>  }




More information about the Ocfs2-tools-devel mailing list