Re: [PATCH] ext3: fsid for statvfs

Andrew Morton <[email protected]> Tue, 10 Oct 2006 13:36:36 -0700
Newsgroups gmane.linux.kernel,gmane.comp.file-systems.ext2.devel
Message-ID <[email protected]>
On Tue, 10 Oct 2006 11:32:13 +0300 (EEST)
Pekka J Enberg <[email protected]> wrote:

> From: Pekka Enberg <[email protected]>
> 
> Update ext3_statfs to return an FSID that is a 64 bit XOR of the 128 bit
> filesystem UUID as suggested by Andreas Dilger. See the following Bugzilla
> entry for details:
> 
>   http://bugzilla.kernel.org/show_bug.cgi?id=136
> 
> Cc: Andreas Dilger <[email protected]>
> Cc: Stephen Tweedie <[email protected]>
> Signed-off-by: Pekka Enberg <[email protected]>

Deja vu.  Gosh, has it really been four years?

Combatants cc'ed ;)

> 
>  fs/ext3/super.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> Index: 2.6/fs/ext3/super.c
> ===================================================================
> --- 2.6.orig/fs/ext3/super.c
> +++ 2.6/fs/ext3/super.c
> @@ -2385,6 +2385,7 @@ static int ext3_statfs (struct dentry * 
>  	struct ext3_super_block *es = sbi->s_es;
>  	ext3_fsblk_t overhead;
>  	int i;
> +	u64 fsid;
>  
>  	if (test_opt (sb, MINIX_DF))
>  		overhead = 0;
> @@ -2431,6 +2432,10 @@ static int ext3_statfs (struct dentry * 
>  	buf->f_files = le32_to_cpu(es->s_inodes_count);
>  	buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
>  	buf->f_namelen = EXT3_NAME_LEN;
> +	fsid = le64_to_cpup((void *)es->s_uuid) ^
> +	       le64_to_cpup((void *)es->s_uuid + sizeof(u64));
> +	buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
> +	buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
>  	return 0;
>  }
>  

ext2 and ext4 would need patching too...