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@xxxxxxxxxx> > > --- > 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; >