public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] make tmpfs_statfs more user friendly
@ 2001-02-04 15:37 Christoph Rohland
  2001-02-05  7:05 ` Christoph Rohland
  2001-02-05 18:33 ` Andreas Dilger
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Rohland @ 2001-02-04 15:37 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel, Mathias.Froehlich

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

diff -uNr 2.4.1-tmpfs/mm/shmem.c 2.4.1-tmpfs-fstat/mm/shmem.c
--- 2.4.1-tmpfs/mm/shmem.c	Sun Feb  4 16:08:57 2001
+++ 2.4.1-tmpfs-fstat/mm/shmem.c	Sun Feb  4 16:09:50 2001
@@ -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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] make tmpfs_statfs more user friendly
  2001-02-04 15:37 [patch] make tmpfs_statfs more user friendly Christoph Rohland
@ 2001-02-05  7:05 ` Christoph Rohland
  2001-02-05 18:33 ` Andreas Dilger
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Rohland @ 2001-02-05  7:05 UTC (permalink / raw)
  To: linux-kernel

Christoph Rohland <cr@sap.com> writes:

> 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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] make tmpfs_statfs more user friendly
  2001-02-04 15:37 [patch] make tmpfs_statfs more user friendly Christoph Rohland
  2001-02-05  7:05 ` Christoph Rohland
@ 2001-02-05 18:33 ` Andreas Dilger
  2001-02-05 20:14   ` Christoph Rohland
  1 sibling, 1 reply; 4+ messages in thread
From: Andreas Dilger @ 2001-02-05 18:33 UTC (permalink / raw)
  To: Christoph Rohland; +Cc: Alan Cox, linux-kernel, Mathias.Froehlich

Christoph Rohland writes:
> 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?

> diff -uNr 2.4.1-tmpfs/mm/shmem.c 2.4.1-tmpfs-fstat/mm/shmem.c
> --- 2.4.1-tmpfs/mm/shmem.c	Sun Feb  4 16:08:57 2001
> +++ 2.4.1-tmpfs-fstat/mm/shmem.c	Sun Feb  4 16:09:50 2001
> @@ -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);

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

> +		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
-- 
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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] make tmpfs_statfs more user friendly
  2001-02-05 18:33 ` Andreas Dilger
@ 2001-02-05 20:14   ` Christoph Rohland
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Rohland @ 2001-02-05 20:14 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: Alan Cox, linux-kernel, Mathias.Froehlich

Hi Andreas,

On Mon, 5 Feb 2001, Andreas Dilger wrote:
>> diff -uNr 2.4.1-tmpfs/mm/shmem.c 2.4.1-tmpfs-fstat/mm/shmem.c
>> --- 2.4.1-tmpfs/mm/shmem.c	Sun Feb  4 16:08:57 2001
>> +++ 2.4.1-tmpfs-fstat/mm/shmem.c	Sun Feb  4 16:09:50 2001
>> @@ -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);
> 
> Should f_bavail be reduced by freepages.min or freepages.low?

Is it still used? If yes, good idea.

>> + 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

> 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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-02-05 20:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-02-04 15:37 [patch] make tmpfs_statfs more user friendly Christoph Rohland
2001-02-05  7:05 ` Christoph Rohland
2001-02-05 18:33 ` Andreas Dilger
2001-02-05 20:14   ` Christoph Rohland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox