Skip to contentSkip to conversation

stat64 for over 2TB file returned invalid st_blocks

DISCUSSION Takashi Sato 6 participants 17 messages Dec 6, 2005 – Dec 10, 2005 VFS

lore
Share & tools
lore
#0 lore raw

Hi,

Quoted 17 lines
Quoted 12 lines
Quoted 11 lines
Quoted 4 lines

2. Change the type of architecture dependent stat64.st_blocks in include/asm/asm-*/stat.h from unsigned long to unsigned long long. I tried modifying only stat64 of 32bit architecture (include/asm-i386/stat.h).

This changes the API, but the structure does suggest that the 4-byte pad should be used for the high-order bytes of st_blocks, so that's not really a problem. A correct fix would replace __pad4 with st_blocks_high (or something like that) and ensure that the high-order word was stored there. Your proposed fix would only be correct on little-endian hardware, as Jörn pointed out.

Quoted 4 lines

Thank you for your advice. I'll research for glibc and consider how to implement.
By the way I think, as Avi Kivity said, it's always little-endian on i386, is it correct?

Quoted 5 lines

That's true. The patch does fix i386 without any bad side-effects. A generic fix that would fix all architectures would be a little more complicated, since the size of st_blocks varies. 32-bit big-endian would have to explicitly copy the high and low words. (The first time I looked at this, I ignored the fact that the change was in asm-i386.)

I realized some 32-bit big-endian architectures such as sh and m68k have a padding before 32-bit st_blocks, though mips and ppc have 64-bit st_blocks.

- asm-sh
#if defined(__BIG_ENDIAN__)

        unsigned long   __pad4;         /* Future possible st_blocks hi bits */
        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
#else /* Must be little */
        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
        unsigned long   __pad4;         /* Future possible st_blocks hi bits */

#endif

- asm-m68k

        unsigned long   __pad4;         /* future possible st_blocks high bits */
        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */

So I updated the patch. Any feedback and comments are welcome.

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/asm-i386/stat.h linux-2.6.15-rc5-blocks/include/asm-i386/stat.h

include/asm-i386/stat.h +1 -2
@@ -58,8 +58,7 @@ struct stat64 {
 	long long	st_size;
 	unsigned long	st_blksize;
 
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
-	unsigned long	__pad4;		/* future possible st_blocks high bits */
+	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
 
 	unsigned long	st_atime;
 	unsigned long	st_atime_nsec;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/asm-m68k/stat.h linux-2.6.15-rc5-blocks/include/asm-m68k/stat.h

include/asm-m68k/stat.h +1 -2
@@ -60,8 +60,7 @@ struct stat64 {
 	long long	st_size;
 	unsigned long	st_blksize;
 
-	unsigned long	__pad4;		/* future possible st_blocks high bits */
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
+	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
 
 	unsigned long	st_atime;
 	unsigned long	st_atime_nsec;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/asm-sh/stat.h linux-2.6.15-rc5-blocks/include/asm-sh/stat.h

include/asm-sh/stat.h +1 -7
@@ -60,13 +60,7 @@ struct stat64 {
 	long long	st_size;
 	unsigned long	st_blksize;
 
-#if defined(__BIG_ENDIAN__)
-	unsigned long	__pad4;		/* Future possible st_blocks hi bits */
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
-#else /* Must be little */
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
-	unsigned long	__pad4;		/* Future possible st_blocks hi bits */
-#endif
+	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
 
 	unsigned long	st_atime;
 	unsigned long	st_atime_nsec;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/linux/fs.h linux-2.6.15-rc5-blocks/include/linux/fs.h

include/linux/fs.h +1 -1
@@ -450,7 +450,7 @@ struct inode {
 	unsigned int		i_blkbits;
 	unsigned long		i_blksize;
 	unsigned long		i_version;
-	unsigned long		i_blocks;
+	unsigned long long	i_blocks;
 	unsigned short          i_bytes;
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	struct semaphore	i_sem;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/linux/stat.h linux-2.6.15-rc5-blocks/include/linux/stat.h

include/linux/stat.h +1 -1
@@ -69,7 +69,7 @@ struct kstat {
 	struct timespec	mtime;
 	struct timespec	ctime;
 	unsigned long	blksize;
-	unsigned long	blocks;
+	unsigned long long	blocks;
 };
 
 #endif

-- Takashi Sato

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw
Quoted 11 lines · Takashi Sato

I realized some 32-bit big-endian architectures such as sh and m68k have a padding before 32-bit st_blocks, though mips and ppc have 64-bit st_blocks.

- asm-sh
#if defined(__BIG_ENDIAN__)

        unsigned long   __pad4;         /* Future possible st_blocks hi bits */
        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
#else /* Must be little */
        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
        unsigned long   __pad4;         /* Future possible st_blocks hi bits */
Quoted 7 lines

#endif

- asm-m68k

        unsigned long   __pad4;         /* future possible st_blocks high bits */
        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */

So I updated the patch. Any feedback and comments are welcome.

I think it looks good. The only issue I have is that I agree with Andreas that i_blocks should be of type sector_t. I find the case of accessing very large files over nfs with CONFIG_LBD disabled to be very unlikely.

Quoted 78 lines

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/asm-i386/stat.h linux-2.6.15-rc5-blocks/include/asm-i386/stat.h

include/asm-i386/stat.h +1 -2
@@ -58,8 +58,7 @@ struct stat64 {
 	long long	st_size;
 	unsigned long	st_blksize;
 
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
-	unsigned long	__pad4;		/* future possible st_blocks high bits */
+	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
 
 	unsigned long	st_atime;
 	unsigned long	st_atime_nsec;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/asm-m68k/stat.h linux-2.6.15-rc5-blocks/include/asm-m68k/stat.h

include/asm-m68k/stat.h +1 -2
@@ -60,8 +60,7 @@ struct stat64 {
 	long long	st_size;
 	unsigned long	st_blksize;
 
-	unsigned long	__pad4;		/* future possible st_blocks high bits */
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
+	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
 
 	unsigned long	st_atime;
 	unsigned long	st_atime_nsec;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/asm-sh/stat.h linux-2.6.15-rc5-blocks/include/asm-sh/stat.h

include/asm-sh/stat.h +1 -7
@@ -60,13 +60,7 @@ struct stat64 {
 	long long	st_size;
 	unsigned long	st_blksize;
 
-#if defined(__BIG_ENDIAN__)
-	unsigned long	__pad4;		/* Future possible st_blocks hi bits */
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
-#else /* Must be little */
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
-	unsigned long	__pad4;		/* Future possible st_blocks hi bits */
-#endif
+	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
 
 	unsigned long	st_atime;
 	unsigned long	st_atime_nsec;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/linux/fs.h linux-2.6.15-rc5-blocks/include/linux/fs.h

include/linux/fs.h +1 -1
@@ -450,7 +450,7 @@ struct inode {
 	unsigned int		i_blkbits;
 	unsigned long		i_blksize;
 	unsigned long		i_version;
-	unsigned long		i_blocks;
+	unsigned long long	i_blocks;
 	unsigned short          i_bytes;
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	struct semaphore	i_sem;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/linux/stat.h linux-2.6.15-rc5-blocks/include/linux/stat.h

include/linux/stat.h +1 -2
@@ -69,7 +69,7 @@ struct kstat {
 	struct timespec	mtime;
 	struct timespec	ctime;
 	unsigned long	blksize;
-	unsigned long	blocks;
+	unsigned long long	blocks;
 };
 
 #endif
 
-- Takashi Sato
Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
#2 lore raw
Quoted 18 lines · Dave Kleikamp
Quoted 17 lines · Takashi Sato

I realized some 32-bit big-endian architectures such as sh and m68k have a padding before 32-bit st_blocks, though mips and ppc have 64-bit st_blocks.

- asm-sh
#if defined(__BIG_ENDIAN__)

        unsigned long   __pad4;         /* Future possible st_blocks hi bits */
        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
#else /* Must be little */
        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
        unsigned long   __pad4;         /* Future possible st_blocks hi bits */

#endif

- asm-m68k

        unsigned long   __pad4;         /* future possible st_blocks high bits */
        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
Quoted 6 lines
Quoted 1 line

So I updated the patch. Any feedback and comments are welcome.

I think it looks good. The only issue I have is that I agree with Andreas that i_blocks should be of type sector_t. I find the case of accessing very large files over nfs with CONFIG_LBD disabled to be very unlikely.

NO! sector_t is a block-device specific type. It does not belong in the generic inode.

Cheers,
Trond

#3 lore raw
Quoted 11 lines · Trond Myklebust
Quoted 7 lines · Dave Kleikamp
Quoted 1 line · Takashi Sato

So I updated the patch. Any feedback and comments are welcome.

I think it looks good. The only issue I have is that I agree with Andreas that i_blocks should be of type sector_t. I find the case of accessing very large files over nfs with CONFIG_LBD disabled to be very unlikely.

NO! sector_t is a block-device specific type. It does not belong in the generic inode.

OK. I withdraw my objection. The patch looks good to me.

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
#4 lore raw
In reply to Trond Myklebust
Quoted 8 lines · Trond Myklebust
Quoted 4 lines · Dave Kleikamp

I think it looks good. The only issue I have is that I agree with Andreas that i_blocks should be of type sector_t. I find the case of accessing very large files over nfs with CONFIG_LBD disabled to be very unlikely.

NO! sector_t is a block-device specific type. It does not belong in the generic inode.

sector_t would imply "units of 512-byte sectors", and this is exactly what i_blocks is actually measuring, so I don't really understand your objection.

If you have objection to the use of sector_t, it could be some other type that is defined virtually identically as CONFIG_LBD sector_t, except that it might be desirable to allow it to be configured separately for network filesystems that have large files. I'm sure the embedded linux folks wouldn't be thrilled at an extra 4 bytes in every inode and 64-bit math if they don't really use it.

Even in HPC very few users have many-TB files, and Lustre is one of the few filesystems that can actually do this today. We of course would enable this option for our kernels, but I don't want to force it upon everyone.

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.

#5 lore raw
Quoted 7 lines · Andreas Dilger
Quoted 6 lines · Trond Myklebust
Quoted 4 lines · Dave Kleikamp

I think it looks good. The only issue I have is that I agree with Andreas that i_blocks should be of type sector_t. I find the case of accessing very large files over nfs with CONFIG_LBD disabled to be very unlikely.

Quoted 6 lines
Quoted 2 lines

NO! sector_t is a block-device specific type. It does not belong in the generic inode.

sector_t would imply "units of 512-byte sectors", and this is exactly what i_blocks is actually measuring, so I don't really understand your objection.

Strictly speaking, sector_t is a block offset that happens to be in "units of 1<<inode->i_blkbits bytes". It is not a count of the number of blocks in a file.

Quoted 6 lines

If you have objection to the use of sector_t, it could be some other type that is defined virtually identically as CONFIG_LBD sector_t, except that it might be desirable to allow it to be configured separately for network filesystems that have large files. I'm sure the embedded linux folks wouldn't be thrilled at an extra 4 bytes in every inode and 64-bit math if they don't really use it.

That would be fine.

Cheers,
Trond

#6 lore raw
In reply to Andreas Dilger

Hi,

Quoted 20 lines
Quoted 8 lines · Dave Kleikamp
Quoted 4 lines

I think it looks good. The only issue I have is that I agree with Andreas that i_blocks should be of type sector_t. I find the case of accessing very large files over nfs with CONFIG_LBD disabled to be very unlikely.

NO! sector_t is a block-device specific type. It does not belong in the generic inode.

sector_t would imply "units of 512-byte sectors", and this is exactly what i_blocks is actually measuring, so I don't really understand your objection.

If you have objection to the use of sector_t, it could be some other type that is defined virtually identically as CONFIG_LBD sector_t, except that it might be desirable to allow it to be configured separately for network filesystems that have large files. I'm sure the embedded linux folks wouldn't be thrilled at an extra 4 bytes in every inode and 64-bit math if they don't really use it.

Quoted 4 lines

Even in HPC very few users have many-TB files, and Lustre is one of the few filesystems that can actually do this today. We of course would enable this option for our kernels, but I don't want to force it upon everyone.

On my previous mail, I said that CONFIG_LBD should not determine whether large single files is enabled. But after further consideration, on such a small system that CONFIG_LBD is disabled, using large filesystem over network seems to be very rare. So I think that the type of i_blocks should be sector_t.

Below shows the updated patch.

This patch fixes st_blocks of >2TB file on 32-bit linux.
- inode.i_blocks
changes to sector_t whose size depends on CONFIG_LBD.
- kstat.blocks
changes to `unsigned long long'.
- stat64.st_blocks
changes to `unsigned long long' on i386, m68k and sh.

Any feedback and comments are welcome.

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/asm-i386/stat.h linux-2.6.15-rc5-blocks/include/asm-i386/stat.h

include/asm-i386/stat.h +1 -2
@@ -58,8 +58,7 @@ struct stat64 {
 	long long	st_size;
 	unsigned long	st_blksize;
 
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
-	unsigned long	__pad4;		/* future possible st_blocks high bits */
+	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
 
 	unsigned long	st_atime;
 	unsigned long	st_atime_nsec;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/asm-m68k/stat.h linux-2.6.15-rc5-blocks/include/asm-m68k/stat.h

include/asm-m68k/stat.h +1 -2
@@ -60,8 +60,7 @@ struct stat64 {
 	long long	st_size;
 	unsigned long	st_blksize;
 
-	unsigned long	__pad4;		/* future possible st_blocks high bits */
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
+	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
 
 	unsigned long	st_atime;
 	unsigned long	st_atime_nsec;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/asm-sh/stat.h linux-2.6.15-rc5-blocks/include/asm-sh/stat.h

include/asm-sh/stat.h +1 -7
@@ -60,13 +60,7 @@ struct stat64 {
 	long long	st_size;
 	unsigned long	st_blksize;
 
-#if defined(__BIG_ENDIAN__)
-	unsigned long	__pad4;		/* Future possible st_blocks hi bits */
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
-#else /* Must be little */
-	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
-	unsigned long	__pad4;		/* Future possible st_blocks hi bits */
-#endif
+	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
 
 	unsigned long	st_atime;
 	unsigned long	st_atime_nsec;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/linux/fs.h linux-2.6.15-rc5-blocks/include/linux/fs.h

include/linux/fs.h +1 -1
@@ -450,7 +450,7 @@ struct inode {
 	unsigned int		i_blkbits;
 	unsigned long		i_blksize;
 	unsigned long		i_version;
-	unsigned long		i_blocks;
+	sector_t		i_blocks;
 	unsigned short          i_bytes;
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	struct semaphore	i_sem;

diff -uprN -X linux-2.6.15-rc5.org/Documentation/dontdiff linux-2.6.15-rc5.org/include/linux/stat.h linux-2.6.15-rc5-blocks/include/linux/stat.h

include/linux/stat.h +1 -1
@@ -69,7 +69,7 @@ struct kstat {
 	struct timespec	mtime;
 	struct timespec	ctime;
 	unsigned long	blksize;
-	unsigned long	blocks;
+	unsigned long long	blocks;
 };
 
 #endif

-- Takashi Sato

#7 lore raw
Quoted 5 lines · Takashi Sato

On my previous mail, I said that CONFIG_LBD should not determine whether large single files is enabled. But after further consideration, on such a small system that CONFIG_LBD is disabled, using large filesystem over network seems to be very rare. So I think that the type of i_blocks should be sector_t.

???? Where do you get this misinformation from?

Cheers,
Trond

#8 lore raw
Quoted 9 lines · Trond Myklebust
Quoted 5 lines · Takashi Sato

On my previous mail, I said that CONFIG_LBD should not determine whether large single files is enabled. But after further consideration, on such a small system that CONFIG_LBD is disabled, using large filesystem over network seems to be very rare. So I think that the type of i_blocks should be sector_t.

???? Where do you get this misinformation from?

Without some kind of counter-example, I would tend to agree with Takashi. In what scenerio would someone build a kernel with CONFIG_LBD disabled, yet would be needing to access files > 2TB across the network?

Shaggy

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
#9 lore raw
Quoted 9 lines · Dave Kleikamp
Quoted 8 lines · Trond Myklebust
Quoted 5 lines · Takashi Sato

On my previous mail, I said that CONFIG_LBD should not determine whether large single files is enabled. But after further consideration, on such a small system that CONFIG_LBD is disabled, using large filesystem over network seems to be very rare. So I think that the type of i_blocks should be sector_t.

Quoted 5 lines
Quoted 1 line

???? Where do you get this misinformation from?

Without some kind of counter-example, I would tend to agree with Takashi. In what scenerio would someone build a kernel with CONFIG_LBD disabled, yet would be needing to access files > 2TB across the network?

The word "filesystem" confused me. In my experience > 2TB filesystems tend to be the norm for NFS shared systems these days, and so the fact that 'struct kstatfs' uses sector_t irks me.
Access to > TB files is not unheard of in HPC circles (particularly in the case of simulations), but these files tend to be pretty sparse, so the block counts are not necessarily that large.

My point stands, though. whether or not sector_t may indeed be the right size as far as i_block is concerned, a quick grep through (fs|block)/*.c shows you that as a type, it is anything but a count of the number of blocks in a file.

If you really want a variable size type here, then the right thing to do is to define a __kernel_blkcnt_t or some such thing, and hide the configuration knob for it somewhere in the arch-specific Kconfigs.

Cheers,
Trond

#10 lore raw
Quoted 3 lines · Trond Myklebust

If you really want a variable size type here, then the right thing to do is to define a __kernel_blkcnt_t or some such thing, and hide the configuration knob for it somewhere in the arch-specific Kconfigs.

Takashi's patch does improve on what currently exists. Maybe someone can create a separate patch to replace sector_t with blkcnt_t where it makes sense.

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
#11 lore raw
Quoted 8 lines · Dave Kleikamp
Quoted 3 lines · Trond Myklebust

If you really want a variable size type here, then the right thing to do is to define a __kernel_blkcnt_t or some such thing, and hide the configuration knob for it somewhere in the arch-specific Kconfigs.

Takashi's patch does improve on what currently exists. Maybe someone can create a separate patch to replace sector_t with blkcnt_t where it makes sense.

I can't see that it makes sense to replace sector_t with blkcnt_t in the case of kstatfs. The only place where it may make sense is i_block, since that grows the size of the inode on embedded systems.

Here is a patch to fix the former.

Cheers,
Trond

VFS: Convert abuses of sector_t

The type "sector_t" is heavily tied in to the block layer interface as an offset/handle to a block, and is subject to a supposedly block-specific configuration option: CONFIG_LBD. Despite this, it is used in struct kstatfs to save a couple of bytes on the stack whenever we call the filesystems' ->statfs().

One consequence is that networked filesystems may break if CONFIG_LBD is not set, since it is quite common to have multi-TB remote filesystems.

The following patch just converts struct kstatfs to use the standard type u64.

---

 include/linux/statfs.h |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
include/linux/statfs.h +5 -5
index ad83a2b..b34cc82 100644
@@ -8,11 +8,11 @@
 struct kstatfs {
 	long f_type;
 	long f_bsize;
-	sector_t f_blocks;
-	sector_t f_bfree;
-	sector_t f_bavail;
-	sector_t f_files;
-	sector_t f_ffree;
+	u64 f_blocks;
+	u64 f_bfree;
+	u64 f_bavail;
+	u64 f_files;
+	u64 f_ffree;
 	__kernel_fsid_t f_fsid;
 	long f_namelen;
 	long f_frsize;
#12 lore raw
In reply to Dave Kleikamp

Hi,

Quoted 8 lines · Trond Myklebust
Quoted 3 lines

If you really want a variable size type here, then the right thing to do is to define a __kernel_blkcnt_t or some such thing, and hide the configuration knob for it somewhere in the arch-specific Kconfigs.

Takashi's patch does improve on what currently exists. Maybe someone can create a separate patch to replace sector_t with blkcnt_t where it makes sense.

I prefer sector_t for i_blocks rather than newly defined blkcnt_t. The reasons are:

- Both i_blocks and common sector_t are for on-disk 512-byte unit. In this point of view, they have the same character.

- If we created the type blkcnt_t newly, the patch would have to touch a lot of files as follows, like sector_t does.

       block/Kconfig, asm-i386/types.h, asm-x86_64/types.h,
       asm-ppc/types.h, asm-s390/types.h, asm-sh/types.h,
       asm-h8300/types.h, asm-mips/types.h

It will be simple if we use sector_t for i_blocks.

Also, I cannot imagine the situation that > 2TB files are used over network with CONFIG_LBD disabled kernel. Is there such a thing realistically?

-- Takashi Sato

#13 lore raw
Quoted 5 lines · Takashi Sato

I prefer sector_t for i_blocks rather than newly defined blkcnt_t. The reasons are:

- Both i_blocks and common sector_t are for on-disk 512-byte unit. In this point of view, they have the same character.

One is a count of the number of blocks used by a file, and exists only in order to help filesystems cache this value. The other is a handle to a block. How is that the same?

Quoted 6 lines

- If we created the type blkcnt_t newly, the patch would have to

    touch a lot of files as follows, like sector_t does.
        block/Kconfig, asm-i386/types.h, asm-x86_64/types.h,
        asm-ppc/types.h, asm-s390/types.h, asm-sh/types.h,
        asm-h8300/types.h, asm-mips/types.h
    It will be simple if we use sector_t for i_blocks.

That is not a particularly good reason.

Quoted 3 lines

Also, I cannot imagine the situation that > 2TB files are used over network with CONFIG_LBD disabled kernel. Is there such a thing realistically?

Apart from this and the kstat wart, there is no reason to set CONFIG_LBD for a networked filesystem. Why would you want to buy a > 2TB local disk on an HPC cluster node if you already have a server?

I suppose we can make NFS use a private field instead, and just set i_blocks to 0, but that's unnecessarily wasteful too.

Cheers,
Trond

#14 lore raw
Quoted 25 lines · Trond Myklebust
Quoted 5 lines · Takashi Sato

I prefer sector_t for i_blocks rather than newly defined blkcnt_t. The reasons are:

- Both i_blocks and common sector_t are for on-disk 512-byte unit. In this point of view, they have the same character.

One is a count of the number of blocks used by a file, and exists only in order to help filesystems cache this value. The other is a handle to a block. How is that the same?

Quoted 6 lines

- If we created the type blkcnt_t newly, the patch would have to

    touch a lot of files as follows, like sector_t does.
        block/Kconfig, asm-i386/types.h, asm-x86_64/types.h,
        asm-ppc/types.h, asm-s390/types.h, asm-sh/types.h,
        asm-h8300/types.h, asm-mips/types.h
    It will be simple if we use sector_t for i_blocks.

That is not a particularly good reason.

Quoted 3 lines

Also, I cannot imagine the situation that > 2TB files are used over network with CONFIG_LBD disabled kernel. Is there such a thing realistically?

Quoted 6 lines

Apart from this and the kstat wart, there is no reason to set CONFIG_LBD for a networked filesystem. Why would you want to buy a > 2TB local disk on an HPC cluster node if you already have a server?

I suppose we can make NFS use a private field instead, and just set i_blocks to 0, but that's unnecessarily wasteful too.

And it breaks applications, too (e.g. du will then report all your files to be zero size)...

Best regards,

Anton

Signature · 4 lines
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
#15 lore raw
Quoted 2 lines · Anton Altaparmakov

And it breaks applications, too (e.g. du will then report all your files to be zero size)...

That's not a problem. We have our own ->getattr() method, so we can set stat->blocks to the correct value. The only real side effect is therefore that we waste space in the inode.

Cheers,
Trond

#16 lore raw
In reply to Trond Myklebust

Hi,

Quoted 9 lines
Quoted 5 lines

I prefer sector_t for i_blocks rather than newly defined blkcnt_t. The reasons are:

- Both i_blocks and common sector_t are for on-disk 512-byte unit. In this point of view, they have the same character.

One is a count of the number of blocks used by a file, and exists only in order to help filesystems cache this value. The other is a handle to a block. How is that the same?

Both i_blocks and sector_t handle on-disk blocks in a certain unit.

But their relation seems to be similar to the relation between off_t and size_t of POSIX. So adding blkcnt_t makes sense too. I'll think of this point further.

By the way, I think there is a kind of confusions on sector_t. Its unit is 512 bytes on block/ and driver/ tree, but it is filesystem block on fs/ tree. Does anyone think the latter should be fsblock_t or something?

Quoted 7 lines
Quoted 6 lines

- If we created the type blkcnt_t newly, the patch would have to

    touch a lot of files as follows, like sector_t does.
        block/Kconfig, asm-i386/types.h, asm-x86_64/types.h,
        asm-ppc/types.h, asm-s390/types.h, asm-sh/types.h,
        asm-h8300/types.h, asm-mips/types.h
    It will be simple if we use sector_t for i_blocks.
Quoted 5 lines

That is not a particularly good reason.

Quoted 3 lines

Also, I cannot imagine the situation that > 2TB files are used over network with CONFIG_LBD disabled kernel. Is there such a thing realistically?

CONFIG_LBD is enabled not only on HPC but on all major distribution for server and desktop. The only exception is embedded system, isn't it?

Quoted 6 lines

Apart from this and the kstat wart, there is no reason to set CONFIG_LBD for a networked filesystem. Why would you want to buy a > 2TB local disk on an HPC cluster node if you already have a server?

I suppose we can make NFS use a private field instead, and just set i_blocks to 0, but that's unnecessarily wasteful too.

I think your suggestion is effective only for the problem of stat64, but other problems would be left on code which handles inode.i_blocks. For example, ioctl with FIOQSIZE command returns the size of file's data calculated from inode.i_blocks. If inode.i_blocks is 0, ioctl with FIOQSIZE always returns 0 even if the file data exists.

-- Takashi Sato