Skip to contentSkip to conversation

make tmpfs_statfs more user friendly

PATCH In review Christoph Rohland 2 participants 4 messages Feb 4, 2001 – Feb 5, 2001

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make tmpfs_statfs more user friendly

Hi Alan,

The following patch make shmem_statfs report some sensible size estimates in the case that the user does not give a size limit.

This should make it more error prone when used as /tmp

Greetings
Christoph

mm/shmem.c +11 -4
diff -uNr 2.4.1-tmpfs/mm/shmem.c 2.4.1-tmpfs-fstat/mm/shmem.c
@@ -696,13 +696,20 @@
 	buf->f_type = TMPFS_MAGIC;
 	buf->f_bsize = PAGE_CACHE_SIZE;
 	spin_lock (&sb->u.shmem_sb.stat_lock);
-	if (sb->u.shmem_sb.max_blocks != ULONG_MAX || 
-	    sb->u.shmem_sb.max_inodes != ULONG_MAX) {
+	if (sb->u.shmem_sb.max_blocks == ULONG_MAX) {
+		/*
+		 * This is only a guestimate and not honoured.
+		 * We need it to make some programs happy which like to
+		 * test the free space of a file system.
+		 */
+		buf->f_bavail = buf->f_bfree = nr_free_pages() + nr_swap_pages + atomic_read(&buffermem_pages);
+		buf->f_blocks = buf->f_bfree + ULONG_MAX - sb->u.shmem_sb.free_blocks;
+	} else {
 		buf->f_blocks = sb->u.shmem_sb.max_blocks;
 		buf->f_bavail = buf->f_bfree = sb->u.shmem_sb.free_blocks;
-		buf->f_files = sb->u.shmem_sb.max_inodes;
-		buf->f_ffree = sb->u.shmem_sb.free_inodes;
 	}
+	buf->f_files = sb->u.shmem_sb.max_inodes;
+	buf->f_ffree = sb->u.shmem_sb.free_inodes;
 	spin_unlock (&sb->u.shmem_sb.stat_lock);
 	buf->f_namelen = 255;
 	return 0;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 4 lines · Christoph Rohland

The following patch make shmem_statfs report some sensible size estimates in the case that the user does not give a size limit.

This should make it more error prone when used as /tmp

                      ^^^^

Oh well, Lars pointed out that I was apparently in outer space when typing this mail ;-)

So: s/more/less/

Christoph

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
In reply to Christoph Rohland
Quoted 4 lines · Christoph Rohland

The following patch make shmem_statfs report some sensible size estimates in the case that the user does not give a size limit.

This should make it more error prone when used as /tmp

                      ^^^^ less?
Quoted 6 lines

diff -uNr 2.4.1-tmpfs/mm/shmem.c 2.4.1-tmpfs-fstat/mm/shmem.c

mm/shmem.c +0 -0
@@ -696,13 +696,20 @@
 	buf->f_type = TMPFS_MAGIC;
 	buf->f_bsize = PAGE_CACHE_SIZE;

mm/shmem.c line 705

Quoted 10 lines
mm/shmem.c +7 -2
 	spin_lock (&sb->u.shmem_sb.stat_lock);
-	if (sb->u.shmem_sb.max_blocks != ULONG_MAX || 
-	    sb->u.shmem_sb.max_inodes != ULONG_MAX) {
+	if (sb->u.shmem_sb.max_blocks == ULONG_MAX) {
+		/*
+		 * This is only a guestimate and not honoured.
+		 * We need it to make some programs happy which like to
+		 * test the free space of a file system.
+		 */
+		buf->f_bavail = buf->f_bfree = nr_free_pages() + nr_swap_pages + atomic_read(&buffermem_pages);

Should f_bavail be reduced by freepages.min or freepages.low?

mm/shmem.c line 706

Quoted 1 line
mm/shmem.c +1 -0
+		buf->f_blocks = buf->f_bfree + ULONG_MAX - sb->u.shmem_sb.free_blocks;

It's not really clear what you are trying to calculate here... Since f_blocks is a long, adding ULONG_MAX == subtracting 1. Maybe it should just hold the total amount of VM in the system, (i.e. totalram_pages)?

Cheers, Andreas

Signature · 7 lines
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#3 lore raw

Hi Andreas,

Quoted 10 lines · Andreas Dilger
Quoted 10 lines

diff -uNr 2.4.1-tmpfs/mm/shmem.c 2.4.1-tmpfs-fstat/mm/shmem.c

mm/shmem.c +1 -2
@@ -696,13 +696,20 @@
 	buf->f_type = TMPFS_MAGIC;
 	buf->f_bsize = PAGE_CACHE_SIZE;
 	spin_lock (&sb->u.shmem_sb.stat_lock);
-	if (sb->u.shmem_sb.max_blocks != ULONG_MAX || 
-	    sb->u.shmem_sb.max_inodes != ULONG_MAX) {
+	if (sb->u.shmem_sb.max_blocks == ULONG_MAX) {
Quoted 8 lines

mm/shmem.c line 705

Quoted 6 lines
mm/shmem.c +6 -0
+		/*
+		 * This is only a guestimate and not honoured.
+		 * We need it to make some programs happy which like to
+		 * test the free space of a file system.
+		 */
+		buf->f_bavail = buf->f_bfree = nr_free_pages() + nr_swap_pages + atomic_read(&buffermem_pages);

Should f_bavail be reduced by freepages.min or freepages.low?

Is it still used? If yes, good idea.

Quoted 3 lines

mm/shmem.c line 706

Quoted 1 line
mm/shmem.c +1 -0
+ buf->f_blocks = buf->f_bfree + ULONG_MAX - sb->u.shmem_sb.free_blocks;

It's not really clear what you are trying to calculate here...

(ULONG_MAX - sb->u.shmem_sb.free_blocks) is the number of occupied blocks by this instance. So the size of the instance should be clearly buf->f_bfree + ULONG_MAX - sb->u.shmem_sb.free_blocks

Quoted 3 lines

Since f_blocks is a long, adding ULONG_MAX == subtracting 1. Maybe it should just hold the total amount of VM in the system, (i.e. totalram_pages)?

Nope, see above

Greetings
Christoph

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/