FS poll(2)/select(2) behavior with kqfilter handlers

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FS poll(2)/select(2) behavior with kqfilter handlers

Martin Pieuchot
FS poll handlers always return true kqueue handlers are different.  So
the diff below introduces a new NOTE_IMM hint to be able to match the
existing poll(2)/select(2) behavior.

This hint is obviously kernel-only.  This is related to the NFS poller
discussion so I'm bringing the diff now in order to move forward.

Comments, oks?

Index: sys/event.h
===================================================================
RCS file: /cvs/src/sys/sys/event.h,v
retrieving revision 1.38
diff -u -p -r1.38 event.h
--- sys/event.h 25 May 2020 15:54:10 -0000 1.38
+++ sys/event.h 31 May 2020 08:34:38 -0000
@@ -128,6 +128,10 @@ struct klist {
 };
 
 #ifdef _KERNEL
+/*
+ * data/hint flags for EVFILT_{READ|WRITE}, not shared with userspace
+ */
+#define NOTE_IMM 0x1000 /* Immediate read event */
 
 #define EVFILT_MARKER 0xf /* placemarker for tailq */
 
Index: isofs/cd9660/cd9660_vnops.c
===================================================================
RCS file: /cvs/src/sys/isofs/cd9660/cd9660_vnops.c,v
retrieving revision 1.83
diff -u -p -r1.83 cd9660_vnops.c
--- isofs/cd9660/cd9660_vnops.c 7 Apr 2020 13:27:51 -0000 1.83
+++ isofs/cd9660/cd9660_vnops.c 31 May 2020 08:34:38 -0000
@@ -1036,6 +1036,9 @@ filt_cd9660read(struct knote *kn, long h
  return (1);
  }
 
+ if (kn->kn_sfflags & NOTE_IMM)
+ return (1);
+
  return (kn->kn_data != 0);
 }
 
Index: miscfs/fuse/fuse_vnops.c
===================================================================
RCS file: /cvs/src/sys/miscfs/fuse/fuse_vnops.c,v
retrieving revision 1.59
diff -u -p -r1.59 fuse_vnops.c
--- miscfs/fuse/fuse_vnops.c 7 Apr 2020 13:27:51 -0000 1.59
+++ miscfs/fuse/fuse_vnops.c 31 May 2020 08:34:38 -0000
@@ -188,6 +188,9 @@ filt_fusefsread(struct knote *kn, long h
  return (1);
  }
 
+ if (kn->kn_sfflags & NOTE_IMM)
+ return (1);
+
  return (kn->kn_data != 0);
 }
 
Index: msdosfs/msdosfs_vnops.c
===================================================================
RCS file: /cvs/src/sys/msdosfs/msdosfs_vnops.c,v
retrieving revision 1.132
diff -u -p -r1.132 msdosfs_vnops.c
--- msdosfs/msdosfs_vnops.c 7 Apr 2020 13:27:52 -0000 1.132
+++ msdosfs/msdosfs_vnops.c 31 May 2020 08:34:38 -0000
@@ -2013,6 +2013,10 @@ filt_msdosfsread(struct knote *kn, long
  kn->kn_fflags |= NOTE_EOF;
  return (1);
  }
+
+ if (kn->kn_sfflags & NOTE_IMM)
+ return (1);
+
  return (kn->kn_data != 0);
 }
 
Index: nfs/nfs_kq.c
===================================================================
RCS file: /cvs/src/sys/nfs/nfs_kq.c,v
retrieving revision 1.30
diff -u -p -r1.30 nfs_kq.c
--- nfs/nfs_kq.c 7 Apr 2020 13:27:52 -0000 1.30
+++ nfs/nfs_kq.c 31 May 2020 08:36:21 -0000
@@ -234,6 +234,10 @@ filt_nfsread(struct knote *kn, long hint
  kn->kn_fflags |= NOTE_EOF;
  return (1);
  }
+
+ if (kn->kn_sfflags & NOTE_IMM)
+ return (1);
+
         return (kn->kn_data != 0);
 }
 
Index: tmpfs/tmpfs_vnops.c
===================================================================
RCS file: /cvs/src/sys/tmpfs/tmpfs_vnops.c,v
retrieving revision 1.40
diff -u -p -r1.40 tmpfs_vnops.c
--- tmpfs/tmpfs_vnops.c 7 Apr 2020 13:27:52 -0000 1.40
+++ tmpfs/tmpfs_vnops.c 31 May 2020 08:34:38 -0000
@@ -2665,6 +2665,9 @@ filt_tmpfsread(struct knote *kn, long hi
  return (1);
  }
 
+ if (kn->kn_sfflags & NOTE_IMM)
+ return (1);
+
  return (kn->kn_data != 0);
 }
 
Index: ufs/ufs/ufs_vnops.c
===================================================================
RCS file: /cvs/src/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.150
diff -u -p -r1.150 ufs_vnops.c
--- ufs/ufs/ufs_vnops.c 7 Apr 2020 13:27:52 -0000 1.150
+++ ufs/ufs/ufs_vnops.c 31 May 2020 08:34:38 -0000
@@ -1973,6 +1973,9 @@ filt_ufsread(struct knote *kn, long hint
  return (1);
  }
 
+ if (kn->kn_sfflags & NOTE_IMM)
+ return (1);
+
  return (kn->kn_data != 0);
 }