* Re: [PATCH] floppy: reintroduce O_NDELAY fix
2021-01-21 10:25 ` Jiri Kosina
@ 2021-01-21 13:28 ` kernel test robot
2021-01-21 14:44 ` [PATCH RESEND] floppy: fix open(O_ACCMODE) for ioctl-only open Jiri Kosina
2021-01-21 14:45 ` [PATCH RESEND] floppy: fix open(O_ACCMODE) for ioctl-only open Denis Efremov
2 siblings, 0 replies; 33+ messages in thread
From: kernel test robot @ 2021-01-21 13:28 UTC (permalink / raw)
To: Jiri Kosina, Denis Efremov
Cc: kbuild-all, Jens Axboe, linux-kernel, linux-block, Wim Osterholt
[-- Attachment #1: Type: text/plain, Size: 6802 bytes --]
Hi Jiri,
I love your patch! Yet something to improve:
[auto build test ERROR on block/for-next]
[also build test ERROR on linux/master linus/master v5.11-rc4 next-20210121]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jiri-Kosina/floppy-reintroduce-O_NDELAY-fix/20210121-182951
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: sparc64-randconfig-r033-20210121 (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/605da67173ab7c362845b2f74c2914bfcec6db2e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jiri-Kosina/floppy-reintroduce-O_NDELAY-fix/20210121-182951
git checkout 605da67173ab7c362845b2f74c2914bfcec6db2e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sparc64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from arch/sparc/include/asm/floppy.h:5,
from drivers/block/floppy.c:251:
arch/sparc/include/asm/floppy_64.h:200:13: warning: no previous prototype for 'sparc_floppy_irq' [-Wmissing-prototypes]
200 | irqreturn_t sparc_floppy_irq(int irq, void *dev_cookie)
| ^~~~~~~~~~~~~~~~
In file included from arch/sparc/include/asm/floppy.h:5,
from drivers/block/floppy.c:251:
arch/sparc/include/asm/floppy_64.h:437:6: warning: no previous prototype for 'sun_pci_fd_dma_callback' [-Wmissing-prototypes]
437 | void sun_pci_fd_dma_callback(struct ebus_dma_info *p, int event, void *cookie)
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/block/floppy.c: In function 'floppy_open':
>> drivers/block/floppy.c:4125:3: error: 'UDRS' undeclared (first use in this function)
4125 | UDRS->last_checked = 0;
| ^~~~
drivers/block/floppy.c:4125:3: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/block/floppy.c:4127:3: error: implicit declaration of function 'check_disk_change'; did you mean 'bdev_disk_changed'? [-Werror=implicit-function-declaration]
4127 | check_disk_change(bdev);
| ^~~~~~~~~~~~~~~~~
| bdev_disk_changed
cc1: some warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for COMPAT_BINFMT_ELF
Depends on COMPAT && BINFMT_ELF
Selected by
- COMPAT && SPARC64
WARNING: unmet direct dependencies detected for FRAME_POINTER
Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS || MCOUNT
Selected by
- LOCKDEP && DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT && !MIPS && !PPC && !ARM && !S390 && !MICROBLAZE && !ARC && !X86
vim +/UDRS +4125 drivers/block/floppy.c
4052
4053 /*
4054 * floppy_open check for aliasing (/dev/fd0 can be the same as
4055 * /dev/PS0 etc), and disallows simultaneous access to the same
4056 * drive with different device numbers.
4057 */
4058 static int floppy_open(struct block_device *bdev, fmode_t mode)
4059 {
4060 int drive = (long)bdev->bd_disk->private_data;
4061 int old_dev, new_dev;
4062 int try;
4063 int res = -EBUSY;
4064 char *tmp;
4065
4066 mutex_lock(&floppy_mutex);
4067 mutex_lock(&open_lock);
4068 old_dev = drive_state[drive].fd_device;
4069 if (opened_bdev[drive] && opened_bdev[drive] != bdev)
4070 goto out2;
4071
4072 if (!drive_state[drive].fd_ref && (drive_params[drive].flags & FD_BROKEN_DCL)) {
4073 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags);
4074 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags);
4075 }
4076
4077 drive_state[drive].fd_ref++;
4078
4079 opened_bdev[drive] = bdev;
4080
4081 res = -ENXIO;
4082
4083 if (!floppy_track_buffer) {
4084 /* if opening an ED drive, reserve a big buffer,
4085 * else reserve a small one */
4086 if ((drive_params[drive].cmos == 6) || (drive_params[drive].cmos == 5))
4087 try = 64; /* Only 48 actually useful */
4088 else
4089 try = 32; /* Only 24 actually useful */
4090
4091 tmp = (char *)fd_dma_mem_alloc(1024 * try);
4092 if (!tmp && !floppy_track_buffer) {
4093 try >>= 1; /* buffer only one side */
4094 INFBOUND(try, 16);
4095 tmp = (char *)fd_dma_mem_alloc(1024 * try);
4096 }
4097 if (!tmp && !floppy_track_buffer)
4098 fallback_on_nodma_alloc(&tmp, 2048 * try);
4099 if (!tmp && !floppy_track_buffer) {
4100 DPRINT("Unable to allocate DMA memory\n");
4101 goto out;
4102 }
4103 if (floppy_track_buffer) {
4104 if (tmp)
4105 fd_dma_mem_free((unsigned long)tmp, try * 1024);
4106 } else {
4107 buffer_min = buffer_max = -1;
4108 floppy_track_buffer = tmp;
4109 max_buffer_sectors = try;
4110 }
4111 }
4112
4113 new_dev = MINOR(bdev->bd_dev);
4114 drive_state[drive].fd_device = new_dev;
4115 set_capacity(disks[drive][ITYPE(new_dev)], floppy_sizes[new_dev]);
4116 if (old_dev != -1 && old_dev != new_dev) {
4117 if (buffer_drive == drive)
4118 buffer_track = -1;
4119 }
4120
4121 if (fdc_state[FDC(drive)].rawcmd == 1)
4122 fdc_state[FDC(drive)].rawcmd = 2;
4123
4124 if (mode & (FMODE_READ|FMODE_WRITE)) {
> 4125 UDRS->last_checked = 0;
4126 clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags);
> 4127 check_disk_change(bdev);
4128 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
4129 goto out;
4130 if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
4131 goto out;
4132 }
4133
4134 res = -EROFS;
4135
4136 if ((mode & FMODE_WRITE) &&
4137 !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
4138 goto out;
4139
4140 mutex_unlock(&open_lock);
4141 mutex_unlock(&floppy_mutex);
4142 return 0;
4143 out:
4144 drive_state[drive].fd_ref--;
4145
4146 if (!drive_state[drive].fd_ref)
4147 opened_bdev[drive] = NULL;
4148 out2:
4149 mutex_unlock(&open_lock);
4150 mutex_unlock(&floppy_mutex);
4151 return res;
4152 }
4153
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 25754 bytes --]
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH] floppy: reintroduce O_NDELAY fix
@ 2021-01-21 13:28 ` kernel test robot
0 siblings, 0 replies; 33+ messages in thread
From: kernel test robot @ 2021-01-21 13:28 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 6973 bytes --]
Hi Jiri,
I love your patch! Yet something to improve:
[auto build test ERROR on block/for-next]
[also build test ERROR on linux/master linus/master v5.11-rc4 next-20210121]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jiri-Kosina/floppy-reintroduce-O_NDELAY-fix/20210121-182951
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: sparc64-randconfig-r033-20210121 (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/605da67173ab7c362845b2f74c2914bfcec6db2e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jiri-Kosina/floppy-reintroduce-O_NDELAY-fix/20210121-182951
git checkout 605da67173ab7c362845b2f74c2914bfcec6db2e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sparc64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from arch/sparc/include/asm/floppy.h:5,
from drivers/block/floppy.c:251:
arch/sparc/include/asm/floppy_64.h:200:13: warning: no previous prototype for 'sparc_floppy_irq' [-Wmissing-prototypes]
200 | irqreturn_t sparc_floppy_irq(int irq, void *dev_cookie)
| ^~~~~~~~~~~~~~~~
In file included from arch/sparc/include/asm/floppy.h:5,
from drivers/block/floppy.c:251:
arch/sparc/include/asm/floppy_64.h:437:6: warning: no previous prototype for 'sun_pci_fd_dma_callback' [-Wmissing-prototypes]
437 | void sun_pci_fd_dma_callback(struct ebus_dma_info *p, int event, void *cookie)
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/block/floppy.c: In function 'floppy_open':
>> drivers/block/floppy.c:4125:3: error: 'UDRS' undeclared (first use in this function)
4125 | UDRS->last_checked = 0;
| ^~~~
drivers/block/floppy.c:4125:3: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/block/floppy.c:4127:3: error: implicit declaration of function 'check_disk_change'; did you mean 'bdev_disk_changed'? [-Werror=implicit-function-declaration]
4127 | check_disk_change(bdev);
| ^~~~~~~~~~~~~~~~~
| bdev_disk_changed
cc1: some warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for COMPAT_BINFMT_ELF
Depends on COMPAT && BINFMT_ELF
Selected by
- COMPAT && SPARC64
WARNING: unmet direct dependencies detected for FRAME_POINTER
Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS || MCOUNT
Selected by
- LOCKDEP && DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT && !MIPS && !PPC && !ARM && !S390 && !MICROBLAZE && !ARC && !X86
vim +/UDRS +4125 drivers/block/floppy.c
4052
4053 /*
4054 * floppy_open check for aliasing (/dev/fd0 can be the same as
4055 * /dev/PS0 etc), and disallows simultaneous access to the same
4056 * drive with different device numbers.
4057 */
4058 static int floppy_open(struct block_device *bdev, fmode_t mode)
4059 {
4060 int drive = (long)bdev->bd_disk->private_data;
4061 int old_dev, new_dev;
4062 int try;
4063 int res = -EBUSY;
4064 char *tmp;
4065
4066 mutex_lock(&floppy_mutex);
4067 mutex_lock(&open_lock);
4068 old_dev = drive_state[drive].fd_device;
4069 if (opened_bdev[drive] && opened_bdev[drive] != bdev)
4070 goto out2;
4071
4072 if (!drive_state[drive].fd_ref && (drive_params[drive].flags & FD_BROKEN_DCL)) {
4073 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags);
4074 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags);
4075 }
4076
4077 drive_state[drive].fd_ref++;
4078
4079 opened_bdev[drive] = bdev;
4080
4081 res = -ENXIO;
4082
4083 if (!floppy_track_buffer) {
4084 /* if opening an ED drive, reserve a big buffer,
4085 * else reserve a small one */
4086 if ((drive_params[drive].cmos == 6) || (drive_params[drive].cmos == 5))
4087 try = 64; /* Only 48 actually useful */
4088 else
4089 try = 32; /* Only 24 actually useful */
4090
4091 tmp = (char *)fd_dma_mem_alloc(1024 * try);
4092 if (!tmp && !floppy_track_buffer) {
4093 try >>= 1; /* buffer only one side */
4094 INFBOUND(try, 16);
4095 tmp = (char *)fd_dma_mem_alloc(1024 * try);
4096 }
4097 if (!tmp && !floppy_track_buffer)
4098 fallback_on_nodma_alloc(&tmp, 2048 * try);
4099 if (!tmp && !floppy_track_buffer) {
4100 DPRINT("Unable to allocate DMA memory\n");
4101 goto out;
4102 }
4103 if (floppy_track_buffer) {
4104 if (tmp)
4105 fd_dma_mem_free((unsigned long)tmp, try * 1024);
4106 } else {
4107 buffer_min = buffer_max = -1;
4108 floppy_track_buffer = tmp;
4109 max_buffer_sectors = try;
4110 }
4111 }
4112
4113 new_dev = MINOR(bdev->bd_dev);
4114 drive_state[drive].fd_device = new_dev;
4115 set_capacity(disks[drive][ITYPE(new_dev)], floppy_sizes[new_dev]);
4116 if (old_dev != -1 && old_dev != new_dev) {
4117 if (buffer_drive == drive)
4118 buffer_track = -1;
4119 }
4120
4121 if (fdc_state[FDC(drive)].rawcmd == 1)
4122 fdc_state[FDC(drive)].rawcmd = 2;
4123
4124 if (mode & (FMODE_READ|FMODE_WRITE)) {
> 4125 UDRS->last_checked = 0;
4126 clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags);
> 4127 check_disk_change(bdev);
4128 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
4129 goto out;
4130 if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
4131 goto out;
4132 }
4133
4134 res = -EROFS;
4135
4136 if ((mode & FMODE_WRITE) &&
4137 !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
4138 goto out;
4139
4140 mutex_unlock(&open_lock);
4141 mutex_unlock(&floppy_mutex);
4142 return 0;
4143 out:
4144 drive_state[drive].fd_ref--;
4145
4146 if (!drive_state[drive].fd_ref)
4147 opened_bdev[drive] = NULL;
4148 out2:
4149 mutex_unlock(&open_lock);
4150 mutex_unlock(&floppy_mutex);
4151 return res;
4152 }
4153
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 25754 bytes --]
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH RESEND] floppy: fix open(O_ACCMODE) for ioctl-only open
2021-01-21 10:25 ` Jiri Kosina
2021-01-21 13:28 ` kernel test robot
@ 2021-01-21 14:44 ` Jiri Kosina
2021-01-21 15:02 ` Denis Efremov
2021-01-21 14:45 ` [PATCH RESEND] floppy: fix open(O_ACCMODE) for ioctl-only open Denis Efremov
2 siblings, 1 reply; 33+ messages in thread
From: Jiri Kosina @ 2021-01-21 14:44 UTC (permalink / raw)
To: Denis Efremov; +Cc: Jens Axboe, linux-kernel, linux-block, Wim Osterholt
On Thu, 21 Jan 2021, Jiri Kosina wrote:
> I am currently waiting for confirmation by the original reporter that the
> patch below fixes the issue.
... a now a patch that actually compiles :) (made a mistake when
forward-porting from the older kernel on which this has been reported).
From: Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH v2] floppy: reintroduce O_NDELAY fix
Originally fixed in 09954bad4 ("floppy: refactor open() flags handling")
then reverted for unknown reason in f2791e7eadf437 instead of taking
the open(O_ACCMODE) for ioctl-only open fix, which had the changelog below
====
Commit 09954bad4 ("floppy: refactor open() flags handling"), as a
side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that
this is being used setfdprm userspace for ioctl-only open().
Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE)
modes, while still keeping the original O_NDELAY bug fixed.
Cc: stable@vger.kernel.org # v4.5+
Reported-by: Wim Osterholt <wim@djo.tudelft.nl>
Tested-by: Wim Osterholt <wim@djo.tudelft.nl>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
=====
Fixes: 09954bad4 ("floppy: refactor open() flags handling")
Fixes: f2791e7ead ("Revert "floppy: refactor open() flags handling"")
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
v1 -> v2: fix build issue due to bad forward-port
drivers/block/floppy.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index dfe1dfc901cc..f9e839c8c5aa 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4121,23 +4121,23 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
if (fdc_state[FDC(drive)].rawcmd == 1)
fdc_state[FDC(drive)].rawcmd = 2;
- if (!(mode & FMODE_NDELAY)) {
- if (mode & (FMODE_READ|FMODE_WRITE)) {
- drive_state[drive].last_checked = 0;
- clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
- &drive_state[drive].flags);
- if (bdev_check_media_change(bdev))
- floppy_revalidate(bdev->bd_disk);
- if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
- goto out;
- if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
- goto out;
- }
- res = -EROFS;
- if ((mode & FMODE_WRITE) &&
- !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
+ if (mode & (FMODE_READ|FMODE_WRITE)) {
+ UDRS->last_checked = 0;
+ clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags);
+ if (bdev_check_media_change(bdev))
+ floppy_revalidate(bdev->bd_disk);
+ if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
+ goto out;
+ if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
goto out;
}
+
+ res = -EROFS;
+
+ if ((mode & FMODE_WRITE) &&
+ !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
+ goto out;
+
mutex_unlock(&open_lock);
mutex_unlock(&floppy_mutex);
return 0;
--
Jiri Kosina
SUSE Labs
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCH RESEND] floppy: fix open(O_ACCMODE) for ioctl-only open
2021-01-21 14:44 ` [PATCH RESEND] floppy: fix open(O_ACCMODE) for ioctl-only open Jiri Kosina
@ 2021-01-21 15:02 ` Denis Efremov
2021-01-21 15:05 ` Jiri Kosina
0 siblings, 1 reply; 33+ messages in thread
From: Denis Efremov @ 2021-01-21 15:02 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Jens Axboe, linux-kernel, linux-block, Wim Osterholt
On 1/21/21 5:44 PM, Jiri Kosina wrote:
> On Thu, 21 Jan 2021, Jiri Kosina wrote:
>
>> I am currently waiting for confirmation by the original reporter that the
>> patch below fixes the issue.
>
> ... a now a patch that actually compiles :) (made a mistake when
> forward-porting from the older kernel on which this has been reported).
Oh, sorry for the last message (forgot to check the inbox before hitting
the send button). I'll test the patch. A couple of nitpicks below.
>
> From: Jiri Kosina <jkosina@suse.cz>
> Subject: [PATCH v2] floppy: reintroduce O_NDELAY fix
>
> Originally fixed in 09954bad4 ("floppy: refactor open() flags handling")
> then reverted for unknown reason in f2791e7eadf437 instead of taking
> the open(O_ACCMODE) for ioctl-only open fix, which had the changelog below
>
> ====
> Commit 09954bad4 ("floppy: refactor open() flags handling"), as a
> side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that
> this is being used setfdprm userspace for ioctl-only open().
>
> Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE)
> modes, while still keeping the original O_NDELAY bug fixed.
>
> Cc: stable@vger.kernel.org # v4.5+
Are you sure that it's not worth to backport it to LTS v4.4?
Because f2791e7ead is just a revert and 09954bad4 is not
presented in v4.4 I'm not sure what fixes tag is better to
use in this case.
> Reported-by: Wim Osterholt <wim@djo.tudelft.nl>
> Tested-by: Wim Osterholt <wim@djo.tudelft.nl>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> =====
>
> Fixes: 09954bad4 ("floppy: refactor open() flags handling")
> Fixes: f2791e7ead ("Revert "floppy: refactor open() flags handling"")
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> ---
>
> v1 -> v2: fix build issue due to bad forward-port
>
> drivers/block/floppy.c | 30 +++++++++++++++---------------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index dfe1dfc901cc..f9e839c8c5aa 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -4121,23 +4121,23 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
> if (fdc_state[FDC(drive)].rawcmd == 1)
> fdc_state[FDC(drive)].rawcmd = 2;
>
> - if (!(mode & FMODE_NDELAY)) {
> - if (mode & (FMODE_READ|FMODE_WRITE)) {
> - drive_state[drive].last_checked = 0;
> - clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
> - &drive_state[drive].flags);
> - if (bdev_check_media_change(bdev))
> - floppy_revalidate(bdev->bd_disk);
> - if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
> - goto out;
> - if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
> - goto out;
> - }
> - res = -EROFS;
> - if ((mode & FMODE_WRITE) &&
> - !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
> + if (mode & (FMODE_READ|FMODE_WRITE)) {
> + UDRS->last_checked = 0;
UDRS will still break the compilation here.
> + clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags);
> + if (bdev_check_media_change(bdev))
> + floppy_revalidate(bdev->bd_disk);
> + if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
> + goto out;
> + if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
> goto out;
> }
> +
> + res = -EROFS;
> +
> + if ((mode & FMODE_WRITE) &&
> + !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
> + goto out;
> +
> mutex_unlock(&open_lock);
> mutex_unlock(&floppy_mutex);
> return 0;
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH RESEND] floppy: fix open(O_ACCMODE) for ioctl-only open
2021-01-21 15:02 ` Denis Efremov
@ 2021-01-21 15:05 ` Jiri Kosina
2021-01-22 11:13 ` [PATCH] floppy: reintroduce O_NDELAY fix Jiri Kosina
0 siblings, 1 reply; 33+ messages in thread
From: Jiri Kosina @ 2021-01-21 15:05 UTC (permalink / raw)
To: Denis Efremov; +Cc: Jens Axboe, linux-kernel, linux-block, Wim Osterholt
On Thu, 21 Jan 2021, Denis Efremov wrote:
> > From: Jiri Kosina <jkosina@suse.cz>
> > Subject: [PATCH v2] floppy: reintroduce O_NDELAY fix
> >
> > Originally fixed in 09954bad4 ("floppy: refactor open() flags handling")
> > then reverted for unknown reason in f2791e7eadf437 instead of taking
> > the open(O_ACCMODE) for ioctl-only open fix, which had the changelog below
> >
> > ====
> > Commit 09954bad4 ("floppy: refactor open() flags handling"), as a
> > side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that
> > this is being used setfdprm userspace for ioctl-only open().
> >
> > Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE)
> > modes, while still keeping the original O_NDELAY bug fixed.
> >
> > Cc: stable@vger.kernel.org # v4.5+
>
> Are you sure that it's not worth to backport it to LTS v4.4? Because
> f2791e7ead is just a revert and 09954bad4 is not presented in v4.4 I'm
> not sure what fixes tag is better to use in this case.
You are right; I'll drop the '4.5+' indicator and will backport it once/if
it hits Linus' tree.
> > + if (mode & (FMODE_READ|FMODE_WRITE)) {
> > + UDRS->last_checked = 0;
>
> UDRS will still break the compilation here.
Doh, forgot to refresh before sending, sorry for the noise.
I'll send the final version once I get confirmation from the reporter that
it's fixing the issue properly, add his Reported-by: etc.
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH] floppy: reintroduce O_NDELAY fix
2021-01-21 15:05 ` Jiri Kosina
@ 2021-01-22 11:13 ` Jiri Kosina
2021-01-26 8:21 ` Denis Efremov
0 siblings, 1 reply; 33+ messages in thread
From: Jiri Kosina @ 2021-01-22 11:13 UTC (permalink / raw)
To: Denis Efremov, Jens Axboe
Cc: linux-kernel, linux-block, Wim Osterholt, Kurt Garloff
From: Jiri Kosina <jkosina@suse.cz>
This issue was originally fixed in 09954bad4 ("floppy: refactor open()
flags handling").
The fix as a side-effect, however, introduce issue for open(O_ACCMODE)
that is being used for ioctl-only open. I wrote a fix for that, but
instead of it being merged, full revert of 09954bad4 was performed,
re-introducing the O_NDELAY / O_NONBLOCK issue, and it strikes again.
This is a forward-port of the original fix to current codebase; the
original submission had the changelog below:
====
Commit 09954bad4 ("floppy: refactor open() flags handling"), as a
side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that
this is being used setfdprm userspace for ioctl-only open().
Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE)
modes, while still keeping the original O_NDELAY bug fixed.
Cc: stable@vger.kernel.org
Reported-by: Wim Osterholt <wim@djo.tudelft.nl>
Tested-by: Wim Osterholt <wim@djo.tudelft.nl>
Reported-and-tested-by: Kurt Garloff <kurt@garloff.de>
Fixes: 09954bad4 ("floppy: refactor open() flags handling")
Fixes: f2791e7ead ("Revert "floppy: refactor open() flags handling"")
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
drivers/block/floppy.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index dfe1dfc901cc..0b71292d9d5a 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4121,23 +4121,23 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
if (fdc_state[FDC(drive)].rawcmd == 1)
fdc_state[FDC(drive)].rawcmd = 2;
- if (!(mode & FMODE_NDELAY)) {
- if (mode & (FMODE_READ|FMODE_WRITE)) {
- drive_state[drive].last_checked = 0;
- clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
- &drive_state[drive].flags);
- if (bdev_check_media_change(bdev))
- floppy_revalidate(bdev->bd_disk);
- if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
- goto out;
- if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
- goto out;
- }
- res = -EROFS;
- if ((mode & FMODE_WRITE) &&
- !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
+ if (mode & (FMODE_READ|FMODE_WRITE)) {
+ drive_state[drive].last_checked = 0;
+ clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags);
+ if (bdev_check_media_change(bdev))
+ floppy_revalidate(bdev->bd_disk);
+ if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
+ goto out;
+ if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
goto out;
}
+
+ res = -EROFS;
+
+ if ((mode & FMODE_WRITE) &&
+ !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
+ goto out;
+
mutex_unlock(&open_lock);
mutex_unlock(&floppy_mutex);
return 0;
--
Jiri Kosina
SUSE Labs
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCH] floppy: reintroduce O_NDELAY fix
2021-01-22 11:13 ` [PATCH] floppy: reintroduce O_NDELAY fix Jiri Kosina
@ 2021-01-26 8:21 ` Denis Efremov
2021-01-26 9:31 ` Kurt Garloff
2021-02-04 9:24 ` Jiri Kosina
0 siblings, 2 replies; 33+ messages in thread
From: Denis Efremov @ 2021-01-26 8:21 UTC (permalink / raw)
To: Jiri Kosina, Jens Axboe
Cc: linux-kernel, linux-block, Wim Osterholt, Kurt Garloff
On 1/22/21 2:13 PM, Jiri Kosina wrote:
> From: Jiri Kosina <jkosina@suse.cz>
>
> This issue was originally fixed in 09954bad4 ("floppy: refactor open()
> flags handling").
>
> The fix as a side-effect, however, introduce issue for open(O_ACCMODE)
> that is being used for ioctl-only open. I wrote a fix for that, but
> instead of it being merged, full revert of 09954bad4 was performed,
> re-introducing the O_NDELAY / O_NONBLOCK issue, and it strikes again.
>
> This is a forward-port of the original fix to current codebase; the
> original submission had the changelog below:
>
> ====
> Commit 09954bad4 ("floppy: refactor open() flags handling"), as a
> side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that
> this is being used setfdprm userspace for ioctl-only open().
>
> Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE)
> modes, while still keeping the original O_NDELAY bug fixed.
>
> Cc: stable@vger.kernel.org
> Reported-by: Wim Osterholt <wim@djo.tudelft.nl>
> Tested-by: Wim Osterholt <wim@djo.tudelft.nl>
> Reported-and-tested-by: Kurt Garloff <kurt@garloff.de>
> Fixes: 09954bad4 ("floppy: refactor open() flags handling")
> Fixes: f2791e7ead ("Revert "floppy: refactor open() flags handling"")
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Applied. I'll send it to Jens soon with a couple of cleanup patches.
https://github.com/evdenis/linux-floppy/commit/e32f6163c47efbdbad06258560aa00d1c7e5b699
Thanks,
Denis
> ---
> drivers/block/floppy.c | 30 +++++++++++++++---------------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index dfe1dfc901cc..0b71292d9d5a 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -4121,23 +4121,23 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
> if (fdc_state[FDC(drive)].rawcmd == 1)
> fdc_state[FDC(drive)].rawcmd = 2;
>
> - if (!(mode & FMODE_NDELAY)) {
> - if (mode & (FMODE_READ|FMODE_WRITE)) {
> - drive_state[drive].last_checked = 0;
> - clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
> - &drive_state[drive].flags);
> - if (bdev_check_media_change(bdev))
> - floppy_revalidate(bdev->bd_disk);
> - if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
> - goto out;
> - if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
> - goto out;
> - }
> - res = -EROFS;
> - if ((mode & FMODE_WRITE) &&
> - !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
> + if (mode & (FMODE_READ|FMODE_WRITE)) {
> + drive_state[drive].last_checked = 0;
> + clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags);
> + if (bdev_check_media_change(bdev))
> + floppy_revalidate(bdev->bd_disk);
> + if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
> + goto out;
> + if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
> goto out;
> }
> +
> + res = -EROFS;
> +
> + if ((mode & FMODE_WRITE) &&
> + !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
> + goto out;
> +
> mutex_unlock(&open_lock);
> mutex_unlock(&floppy_mutex);
> return 0;
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH] floppy: reintroduce O_NDELAY fix
2021-01-26 8:21 ` Denis Efremov
@ 2021-01-26 9:31 ` Kurt Garloff
2021-01-26 9:59 ` Denis Efremov
2021-02-04 9:24 ` Jiri Kosina
1 sibling, 1 reply; 33+ messages in thread
From: Kurt Garloff @ 2021-01-26 9:31 UTC (permalink / raw)
To: Denis Efremov, Jiri Kosina, Jens Axboe
Cc: linux-kernel, linux-block, Wim Osterholt
Hi Denis, Jiri, Jens,
Am 26.01.21 um 09:21 schrieb Denis Efremov:
> On 1/22/21 2:13 PM, Jiri Kosina wrote:
>> From: Jiri Kosina <jkosina@suse.cz>
>>
>> This issue was originally fixed in 09954bad4 ("floppy: refactor open()
>> flags handling").
>>
>> The fix as a side-effect, however, introduce issue for open(O_ACCMODE)
>> that is being used for ioctl-only open. I wrote a fix for that, but
>> instead of it being merged, full revert of 09954bad4 was performed,
>> re-introducing the O_NDELAY / O_NONBLOCK issue, and it strikes again.
>>
>> This is a forward-port of the original fix to current codebase; the
>> original submission had the changelog below:
>>
>> ====
>> Commit 09954bad4 ("floppy: refactor open() flags handling"), as a
>> side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that
>> this is being used setfdprm userspace for ioctl-only open().
>>
>> Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE)
>> modes, while still keeping the original O_NDELAY bug fixed.
>>
>> Cc: stable@vger.kernel.org
>> Reported-by: Wim Osterholt <wim@djo.tudelft.nl>
>> Tested-by: Wim Osterholt <wim@djo.tudelft.nl>
>> Reported-and-tested-by: Kurt Garloff <kurt@garloff.de>
>> Fixes: 09954bad4 ("floppy: refactor open() flags handling")
>> Fixes: f2791e7ead ("Revert "floppy: refactor open() flags handling"")
>> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> Applied. I'll send it to Jens soon with a couple of cleanup patches.
>
> https://github.com/evdenis/linux-floppy/commit/e32f6163c47efbdbad06258560aa00d1c7e5b699
Great, thanks.
Due to libblkid (rightfully) using O_NONBLOCK these days when probing
devices, the floppy driver does spit loads of
[ 9.533513] floppy0: disk absent or changed during operation
[ 9.534989] blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[ 9.537206] Buffer I/O error on dev fd0, logical block 0, async page read
[ 9.546837] floppy0: disk absent or changed during operation
[ 9.548389] blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 1
and fails a mount prior to being opened without O_NONBLOCK at least once.
(Reproduction is easy with qemu-kvm.)
The patch addresses it and I would suggest it to also be backported and
applied to the active stable kernel trees.
Thanks,
--
Kurt Garloff <kurt@garloff.de>, Cologne, Germany
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH] floppy: reintroduce O_NDELAY fix
2021-01-26 9:31 ` Kurt Garloff
@ 2021-01-26 9:59 ` Denis Efremov
0 siblings, 0 replies; 33+ messages in thread
From: Denis Efremov @ 2021-01-26 9:59 UTC (permalink / raw)
To: Kurt Garloff, Jiri Kosina, Jens Axboe
Cc: linux-kernel, linux-block, Wim Osterholt
On 1/26/21 12:31 PM, Kurt Garloff wrote:
> Hi Denis, Jiri, Jens,
>
> Am 26.01.21 um 09:21 schrieb Denis Efremov:
>> On 1/22/21 2:13 PM, Jiri Kosina wrote:
>>> From: Jiri Kosina <jkosina@suse.cz>
>>>
>>> This issue was originally fixed in 09954bad4 ("floppy: refactor open()
>>> flags handling").
>>>
>>> The fix as a side-effect, however, introduce issue for open(O_ACCMODE)
>>> that is being used for ioctl-only open. I wrote a fix for that, but
>>> instead of it being merged, full revert of 09954bad4 was performed,
>>> re-introducing the O_NDELAY / O_NONBLOCK issue, and it strikes again.
>>>
>>> This is a forward-port of the original fix to current codebase; the
>>> original submission had the changelog below:
>>>
>>> ====
>>> Commit 09954bad4 ("floppy: refactor open() flags handling"), as a
>>> side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that
>>> this is being used setfdprm userspace for ioctl-only open().
>>>
>>> Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE)
>>> modes, while still keeping the original O_NDELAY bug fixed.
>>>
>>> Cc: stable@vger.kernel.org
>>> Reported-by: Wim Osterholt <wim@djo.tudelft.nl>
>>> Tested-by: Wim Osterholt <wim@djo.tudelft.nl>
>>> Reported-and-tested-by: Kurt Garloff <kurt@garloff.de>
>>> Fixes: 09954bad4 ("floppy: refactor open() flags handling")
>>> Fixes: f2791e7ead ("Revert "floppy: refactor open() flags handling"")
>>> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
>> Applied. I'll send it to Jens soon with a couple of cleanup patches.
>>
>> https://github.com/evdenis/linux-floppy/commit/e32f6163c47efbdbad06258560aa00d1c7e5b699
>
> Great, thanks.
>
> Due to libblkid (rightfully) using O_NONBLOCK these days when probing
> devices, the floppy driver does spit loads of
> [ 9.533513] floppy0: disk absent or changed during operation
> [ 9.534989] blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
> [ 9.537206] Buffer I/O error on dev fd0, logical block 0, async page read
> [ 9.546837] floppy0: disk absent or changed during operation
> [ 9.548389] blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 1
> and fails a mount prior to being opened without O_NONBLOCK at least once.
> (Reproduction is easy with qemu-kvm.)
>
> The patch addresses it and I would suggest it to also be backported and
> applied to the active stable kernel trees.
Yes, it will be backported to all stable trees including v4.4
Thanks,
Denis
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH] floppy: reintroduce O_NDELAY fix
2021-01-26 8:21 ` Denis Efremov
2021-01-26 9:31 ` Kurt Garloff
@ 2021-02-04 9:24 ` Jiri Kosina
2021-02-04 10:18 ` Denis Efremov
1 sibling, 1 reply; 33+ messages in thread
From: Jiri Kosina @ 2021-02-04 9:24 UTC (permalink / raw)
To: Denis Efremov
Cc: Jens Axboe, linux-kernel, linux-block, Wim Osterholt, Kurt Garloff
On Tue, 26 Jan 2021, Denis Efremov wrote:
> Applied. I'll send it to Jens soon with a couple of cleanup patches.
>
> https://github.com/evdenis/linux-floppy/commit/e32f6163c47efbdbad06258560aa00d1c7e5b699
Denis,
I don't see this fix in Jens' tree yet. Is there any problem with the
patch?
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH] floppy: reintroduce O_NDELAY fix
2021-02-04 9:24 ` Jiri Kosina
@ 2021-02-04 10:18 ` Denis Efremov
0 siblings, 0 replies; 33+ messages in thread
From: Denis Efremov @ 2021-02-04 10:18 UTC (permalink / raw)
To: Jiri Kosina
Cc: Jens Axboe, linux-kernel, linux-block, Wim Osterholt, Kurt Garloff
On 2/4/21 12:24 PM, Jiri Kosina wrote:
> On Tue, 26 Jan 2021, Denis Efremov wrote:
>
>> Applied. I'll send it to Jens soon with a couple of cleanup patches.
>>
>> https://github.com/evdenis/linux-floppy/commit/e32f6163c47efbdbad06258560aa00d1c7e5b699
>
> Denis,
>
> I don't see this fix in Jens' tree yet. Is there any problem with the
> patch?
Hi, sorry for the delay. I've just send the pull request to Jens.
I tested the patch and stressed the driver with syzkaller.
Everything look good with the patch to me. Thanks!
Denis
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH RESEND] floppy: fix open(O_ACCMODE) for ioctl-only open
2021-01-21 10:25 ` Jiri Kosina
2021-01-21 13:28 ` kernel test robot
2021-01-21 14:44 ` [PATCH RESEND] floppy: fix open(O_ACCMODE) for ioctl-only open Jiri Kosina
@ 2021-01-21 14:45 ` Denis Efremov
2 siblings, 0 replies; 33+ messages in thread
From: Denis Efremov @ 2021-01-21 14:45 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Jens Axboe, linux-kernel, linux-block, Wim Osterholt
On 1/21/21 1:25 PM, Jiri Kosina wrote:
> On Thu, 21 Jan 2021, Denis Efremov wrote:
>
>> I think it's hard to recall the exact reasons after so many years.
>
> Yeah, I guess so :)
>
>> I'll send a patch today based on this one.
>
> I am currently waiting for confirmation by the original reporter that the
> patch below fixes the issue.
>
>
>
> From: Jiri Kosina <jkosina@suse.cz>
> Subject: [PATCH] floppy: reintroduce O_NDELAY fix
>
> Originally fixed in 09954bad4 ("floppy: refactor open() flags handling")
> then reverted for unknown reason in f2791e7eadf437 instead of taking
> the open(O_ACCMODE) for ioctl-only open fix, which had the changelog below
>
> ====
> Commit 09954bad4 ("floppy: refactor open() flags handling"), as a
> side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that
> this is being used setfdprm userspace for ioctl-only open().
>
> Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE)
> modes, while still keeping the original O_NDELAY bug fixed.
>
> Cc: stable@vger.kernel.org # v4.5+
> Reported-by: Wim Osterholt <wim@djo.tudelft.nl>
> Tested-by: Wim Osterholt <wim@djo.tudelft.nl>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> =====
>
> Fixes: 09954bad4 ("floppy: refactor open() flags handling")
> Fixes: f2791e7ead ("Revert "floppy: refactor open() flags handling"")
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> ---
> drivers/block/floppy.c | 29 ++++++++++++++---------------
> 1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index dfe1dfc901cc..bda9417aa0a8 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -4121,23 +4121,22 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
> if (fdc_state[FDC(drive)].rawcmd == 1)
> fdc_state[FDC(drive)].rawcmd = 2;
>
> - if (!(mode & FMODE_NDELAY)) {
> - if (mode & (FMODE_READ|FMODE_WRITE)) {
> - drive_state[drive].last_checked = 0;
> - clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
> - &drive_state[drive].flags);
> - if (bdev_check_media_change(bdev))
> - floppy_revalidate(bdev->bd_disk);
> - if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
> - goto out;
> - if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
> - goto out;
> - }
> - res = -EROFS;
> - if ((mode & FMODE_WRITE) &&
> - !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
> + if (mode & (FMODE_READ|FMODE_WRITE)) {
As the bot points out this was refactored a bit in:
8d9d34e25a37 ("floppy: cleanup: expand macro UDRS")
4a6f3d480edc ("floppy: use bdev_check_media_change")
Should be something like:
+ drive_state[drive].last_checked = 0;
+ clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
+ &drive_state[drive].flags);
+ if (bdev_check_media_change(bdev))
+ floppy_revalidate(bdev->bd_disk);
> + if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
> + goto out;
> + if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
> goto out;
> }
> +
> + res = -EROFS;
> +
> + if ((mode & FMODE_WRITE) &&
> + !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
> + goto out;
> +
> mutex_unlock(&open_lock);
> mutex_unlock(&floppy_mutex);
> return 0;
>
^ permalink raw reply [flat|nested] 33+ messages in thread