On 12/13 12:20, Philip Guenther wrote:
> On Wed, 13 Dec 2017, Jeremy Evans wrote:
> > I think this may be a bug. I'm guessing either:
> >
> > 1) fcntl(fd,F_SETFL, O_NONBLOCK) shouldn't fail, because
> > open("/dev/zero", O_NONBLOCK) doesn't fail; or
>
> Yes.
>
> > After more testing, it appears any fcntl/F_SETFL call on /dev/zero
> > fails, even if you are setting the flags to the same value.
>
> Looks like the MD mmioctl() implementations need to ignore the ioctls that
> are used internally by fcntl(F_SETFL). Something like this untested diff:
Philip,
Thanks for your quick analysis and fix. Your diff was correct, except
missing an include. I've confirmed this diff fixes the issue.
Thanks,
Jeremy
Index: arch/amd64/amd64/mem.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/mem.c,v
retrieving revision 1.32
diff -u -p -r1.32 mem.c
--- arch/amd64/amd64/mem.c 14 Oct 2017 04:44:43 -0000 1.32
+++ arch/amd64/amd64/mem.c 13 Dec 2017 23:09:43 -0000
@@ -45,6 +45,7 @@
#include <sys/param.h>
#include <sys/buf.h>
+#include <sys/filio.h>
#include <sys/systm.h>
#include <sys/uio.h>
#include <sys/ioccom.h>
@@ -237,6 +238,12 @@ mmmmap(dev_t dev, off_t off, int prot)
int
mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
{
+ switch (cmd) {
+ case FIONBIO:
+ case FIOASYNC:
+ /* handled by fd layer */
+ return 0;
+ }
#ifdef MTRR
switch (minor(dev)) {
case 0: