mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] stat: don't fail if the major number is >= 256
Date: Mon, 11 Apr 2022 16:03:37 +0100	[thread overview]
Message-ID: <YlRDSXQG+ED1Okpp@casper.infradead.org> (raw)
In-Reply-To: <alpine.LRH.2.02.2204111023230.6206@file01.intranet.prod.int.rdu2.redhat.com>

On Mon, Apr 11, 2022 at 10:43:33AM -0400, Mikulas Patocka wrote:
> If you run a program compiled with OpenWatcom for Linux on a filesystem on 
> NVMe, all "stat" syscalls fail with -EOVERFLOW. The reason is that the 
> NVMe driver allocates a device with the major number 259 and it doesn't 
> pass the "old_valid_dev" test.
> 
> This patch removes the tests - it's better to wrap around than to return
> an error. (note that cp_old_stat also doesn't report an error and wraps
> the number around)

Is it better?  You've done a good job arguing why it is for this particular
situation, but if there's a program which compares files by
st_dev+st_ino, it might think two files are identical when they're
actually different and, eg, skip backing up a file because it thinks
it already did it.  That would be a silent failure, which is worse
than this noisy failure.

The real problem is clearly that Linus denied my request for a real
major number for NVMe back in 2012 or whenever it was :-P

> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> 
> ---
>  fs/stat.c |    6 ------
>  1 file changed, 6 deletions(-)
> 
> Index: linux-5.17.2/fs/stat.c
> ===================================================================
> --- linux-5.17.2.orig/fs/stat.c	2022-04-10 21:39:27.000000000 +0200
> +++ linux-5.17.2/fs/stat.c	2022-04-10 21:42:43.000000000 +0200
> @@ -334,7 +334,6 @@ SYSCALL_DEFINE2(fstat, unsigned int, fd,
>  #  define choose_32_64(a,b) b
>  #endif
>  
> -#define valid_dev(x)  choose_32_64(old_valid_dev(x),true)
>  #define encode_dev(x) choose_32_64(old_encode_dev,new_encode_dev)(x)
>  
>  #ifndef INIT_STRUCT_STAT_PADDING
> @@ -345,8 +344,6 @@ static int cp_new_stat(struct kstat *sta
>  {
>  	struct stat tmp;
>  
> -	if (!valid_dev(stat->dev) || !valid_dev(stat->rdev))
> -		return -EOVERFLOW;
>  #if BITS_PER_LONG == 32
>  	if (stat->size > MAX_NON_LFS)
>  		return -EOVERFLOW;
> @@ -644,9 +641,6 @@ static int cp_compat_stat(struct kstat *
>  {
>  	struct compat_stat tmp;
>  
> -	if (!old_valid_dev(stat->dev) || !old_valid_dev(stat->rdev))
> -		return -EOVERFLOW;
> -
>  	memset(&tmp, 0, sizeof(tmp));
>  	tmp.st_dev = old_encode_dev(stat->dev);
>  	tmp.st_ino = stat->ino;
> 

  reply	other threads:[~2022-04-11 15:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11 14:43 Mikulas Patocka
2022-04-11 15:03 ` Matthew Wilcox [this message]
2022-04-11 15:16   ` Christoph Hellwig
2022-04-11 16:30 ` Linus Torvalds
2022-04-11 17:13   ` Mikulas Patocka
2022-04-12  5:37     ` Linus Torvalds
2022-04-12  5:41       ` Christoph Hellwig
2022-04-12  5:47         ` Linus Torvalds
2022-04-12  5:52           ` Christoph Hellwig
2022-04-12  6:49       ` Linus Torvalds
2022-04-12  8:19       ` Andreas Schwab
2022-04-12  9:41       ` [PATCH] stat: fix inconsistency between struct stat and struct compat_stat Mikulas Patocka
2022-04-12 16:30         ` Linus Torvalds
2022-04-12 17:42           ` Mikulas Patocka
2022-04-12 23:25             ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YlRDSXQG+ED1Okpp@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®