mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs: sysv: Fix sysv_nblocks() returns wrong value
@ 2022-12-09 10:04 Chen Zhongjin
  2022-12-10 19:12 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Zhongjin @ 2022-12-09 10:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: chenzhongjin, hch

sysv_nblocks() returns 'blocks' rather than 'res', which only counting
the number of triple-indirect blocks and causing sysv_getattr() gets a
wrong result.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
---
 fs/sysv/itree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
index d4ec9bb97de9..3b8567564e7e 100644
--- a/fs/sysv/itree.c
+++ b/fs/sysv/itree.c
@@ -438,7 +438,7 @@ static unsigned sysv_nblocks(struct super_block *s, loff_t size)
 		res += blocks;
 		direct = 1;
 	}
-	return blocks;
+	return res;
 }
 
 int sysv_getattr(struct user_namespace *mnt_userns, const struct path *path,
-- 
2.17.1


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

* Re: [PATCH] fs: sysv: Fix sysv_nblocks() returns wrong value
  2022-12-09 10:04 [PATCH] fs: sysv: Fix sysv_nblocks() returns wrong value Chen Zhongjin
@ 2022-12-10 19:12 ` Al Viro
  2022-12-12  8:59   ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2022-12-10 19:12 UTC (permalink / raw)
  To: Chen Zhongjin; +Cc: linux-kernel, hch

On Fri, Dec 09, 2022 at 06:04:48PM +0800, Chen Zhongjin wrote:
> sysv_nblocks() returns 'blocks' rather than 'res', which only counting
> the number of triple-indirect blocks and causing sysv_getattr() gets a
> wrong result.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
> ---
>  fs/sysv/itree.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
> index d4ec9bb97de9..3b8567564e7e 100644
> --- a/fs/sysv/itree.c
> +++ b/fs/sysv/itree.c
> @@ -438,7 +438,7 @@ static unsigned sysv_nblocks(struct super_block *s, loff_t size)
>  		res += blocks;
>  		direct = 1;
>  	}
> -	return blocks;
> +	return res;
>  }
>  
>  int sysv_getattr(struct user_namespace *mnt_userns, const struct path *path,

Argh...

To quote historical tree:
commit 0fcd426de9d02175c9771ea19f972389eeba7688
Author: Andries E. Brouwer <andries.brouwer@cwi.nl>
Date:   Sun Aug 22 00:07:46 2004 -0700

    [PATCH] minix block usage counting fix
    
    In 2.5.18 some minix-specific stuff was moved to the minix subdirectory
    where it belonged.  However, a typo crept in, causing inode disk usage
    to be incorrectly reported.  A few people have complained, but so far
    not sufficiently loudly.
    
    Signed-off-by: Andries Brouwer <Andries.Brouwer@cwi.nl>
    Signed-off-by: Linus Torvalds <torvalds@osdl.org>

diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
index f8e9bd831c90..5a4b51dbfcb3 100644
--- a/fs/minix/itree_common.c
+++ b/fs/minix/itree_common.c
@@ -358,5 +358,5 @@ static inline unsigned nblocks(loff_t size)
                res += blocks;
                direct = 1;
        }
-       return blocks;
+       return res;
 }


This is obviously the sysvfs counterpart, not noticed back then and
not caught in 18 years since then...

Mea culpa - the original bug (both in minixfs and sysvfs) is mine and
I should've thought to look for sysvfs counterpart when minixfs fix
got posted.

Applied.

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

* Re: [PATCH] fs: sysv: Fix sysv_nblocks() returns wrong value
  2022-12-10 19:12 ` Al Viro
@ 2022-12-12  8:59   ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2022-12-12  8:59 UTC (permalink / raw)
  To: Al Viro; +Cc: Chen Zhongjin, linux-kernel, hch

On Sat, Dec 10, 2022 at 07:12:58PM +0000, Al Viro wrote:
> This is obviously the sysvfs counterpart, not noticed back then and
> not caught in 18 years since then...
> 
> Mea culpa - the original bug (both in minixfs and sysvfs) is mine and
> I should've thought to look for sysvfs counterpart when minixfs fix
> got posted.

Btw, I have no way to actually test sysv anymore, so I'm tempted to
orphan it.  Is there anyone actually still using it?  With some
of the upcoming transitions in the folio, buffer_head and co APIs
it might be a good time to drop unmaintained file systems now,
and sysv is a hot candidate.

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

end of thread, other threads:[~2022-12-12  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-09 10:04 [PATCH] fs: sysv: Fix sysv_nblocks() returns wrong value Chen Zhongjin
2022-12-10 19:12 ` Al Viro
2022-12-12  8:59   ` Christoph Hellwig

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

all inboxes | Powered by JetHome®