Re: add support for \ and \ word delimiters in regcomp
On Mon, Sep 01, 2014 at 12:41:37AM -0400, Ted Unangst wrote: On Mon, Sep 01, 2014 at 14:03, Jonathan Gray wrote: This adds support for using the SVR4/glibc word delimeters in regcomp as an extension to what posix requires. We already have [[::]] and [[::]] as extensions, apparently from 'Henry Spencer's Alpha 3.0 regex release' back in 1993. But now Solaris/Linux/FreeBSD all have the other syntax and sadly lots of uses of grep and sed in what are supposed to be portable projects use it. This diff is from Garrett D'Amore in Illumos via FreeBSD. https://www.illumos.org/issues/516 I have a slight preference for my diff (I think it's clearer than deeper nested switches), but no matter. http://marc.info/?l=openbsd-techm=131094975127745w=2 I'd be fine with that one going in as well. Are there any reasons not to add it? I don't see a portable alternative here as brought up by Mark in that thread, and the only if it's supported on the majority of UNIX-ike operating system comment seems to be true?
Re: Refactoring process-local file descriptor data
On Wed, Sep 03, 2014 at 03:31:50PM -0500, Kent R. Spillner wrote: Need to re-roll for -current? Yep, sorry. I knew the the dup3 changes would break it when I saw them go in but I've been busy with classes and stuff. Here's a new version. This one considerably less tested than previous versions, I just made sure it still built and that build built itself too. Capsicum is still blocking on this patch (or one like it). Any/all feedback welcome. On Thu, Jul 10, 2014 at 04:13:38PM -0400, Jean-Philippe Ouellet wrote: This diff adds another struct between filedesc and file to store process-local per-descriptor information. Currently, the only thing in this struct is the file pointer and some flags, however I have another patch on top of this that adds capsicum capabilities to it. (And another that uses mallocarray(9) where applicable. One thing at a time.) The data is currently stored in one big allocation with all the file *s in front, and all the flags after. When that allocation grows, there are two copies and two zeroings. This is fine when we only have two fields (fd_ofiles and fd_ofileflags), but adding more is ugly. Instead, I propose we have a struct for each file descriptor table entry (filedescent) and put the files, flags, and capabilities in that. The immediate impact is some memory waste due to padding (3 or 7 bytes per file descriptor, depending on the arch), however once capabilities are added it will be negligible. I discussed it with matthew@ and guenther@ and concluded this was the saner way. For what it's worth, FreeBSD and NetBSD have done the same thing. I've been running different versions of this for about a month or so, no issues noticed so far. A similar earlier version was reviewed by matthew@ and guenther@. Index: sys/filedesc.h === RCS file: /cvs/src/sys/sys/filedesc.h,v retrieving revision 1.28 diff -u -p -r1.28 filedesc.h --- sys/filedesc.h 15 May 2014 03:52:25 - 1.28 +++ sys/filedesc.h 7 Sep 2014 19:04:20 - @@ -34,9 +34,6 @@ #include sys/rwlock.h /* - * This structure is used for the management of descriptors. It may be - * shared by multiple processes. - * * A process is initially started out with NDFILE descriptors stored within * this structure, selected to be enough for typical applications based on * the historical limit of 20 open files (and the usage of descriptors by @@ -56,22 +53,33 @@ #define NDHISLOTS(x) (NDREDUCE(NDREDUCE(x))) #define NDLOSLOTS(x) (NDHISLOTS(x) NDENTRYSHIFT) +/* + * File wrapper for per-process per-file data. + */ +struct filedescent { + struct file *fde_file; /* file structure for open file */ + charfde_flags; /* process-local file flags */ +}; + +/* + * This structure is used for the management of descriptors. It may be + * shared by multiple processes. + */ struct filedesc { - struct file **fd_ofiles; /* file structures for open files */ - char*fd_ofileflags; /* per-process open file flags */ + struct filedescent *fd_fdents; /* per-process file wrappers */ struct vnode *fd_cdir; /* current directory */ struct vnode *fd_rdir; /* root directory */ int fd_nfiles; /* number of open files allocated */ int fd_openfd; /* number of files currently open */ u_int *fd_himap; /* each bit points to 32 fds */ u_int *fd_lomap; /* bitmap of free fds */ - int fd_lastfile;/* high-water mark of fd_ofiles */ + int fd_lastfile;/* high-water mark of fd_fdents */ int fd_freefile;/* approx. next free file */ u_short fd_cmask; /* mask for file creation */ u_short fd_refcnt; /* reference count */ struct rwlock fd_lock; /* lock for the file descs; must be */ - /* held when writing to fd_ofiles, */ - /* fd_ofileflags, or fd_{hi,lo}map */ + /* held when writing to fd_fdents */ + /* or fd_{hi,lo}map */ int fd_knlistsize; /* size of knlist */ struct klist *fd_knlist; /* list of attached knotes */ @@ -91,8 +99,7 @@ struct filedesc0 { * These arrays are used when the number of open files is * = NDFILE, and are then pointed to by the pointers above. */ - struct file *fd_dfiles[NDFILE]; - charfd_dfileflags[NDFILE]; + struct filedescent fd_dfdents[NDFILE]; /* * There arrays are used when the number of open files is * = 1024, and are then pointed to by the pointers above. Index: kern/kern_descrip.c
Re: add support for \ and \ word delimiters in regcomp
On Mon, 08 Sep 2014 02:28:42 +1000, Jonathan Gray wrote: I'd be fine with that one going in as well. Are there any reasons not to add it? I don't see a portable alternative here as brought up by Mark in that thread, and the only if it's supported on the majority of UNIX-ike operating system comment seems to be true? My preference is for Ted's patch. I was against this initially but now that it is supported by most modern systems I don't have a problem with it. - todd
mpsafe interrupts for mfi(4)
...and some mpsafety in the scsi_cmd path. this is working well for me, but considering how used it is i would appreciate some extra tests. ok? Index: pci/mfi_pci.c === RCS file: /cvs/src/sys/dev/pci/mfi_pci.c,v retrieving revision 1.28 diff -u -p -r1.28 mfi_pci.c --- pci/mfi_pci.c 14 Aug 2012 04:10:14 - 1.28 +++ pci/mfi_pci.c 8 Sep 2014 04:47:03 - @@ -133,8 +133,8 @@ mfi_pci_attach(struct device *parent, st } printf(: %s\n, pci_intr_string(pa-pa_pc, ih)); - sc-sc_ih = pci_intr_establish(pa-pa_pc, ih, IPL_BIO, mfi_intr, sc, - sc-sc_dev.dv_xname); + sc-sc_ih = pci_intr_establish(pa-pa_pc, ih, IPL_BIO | IPL_MPSAFE, + mfi_intr, sc, sc-sc_dev.dv_xname); if (!sc-sc_ih) { printf(%s: can't establish interrupt\n, DEVNAME(sc)); goto unmap; Index: ic/mfi.c === RCS file: /cvs/src/sys/dev/ic/mfi.c,v retrieving revision 1.155 diff -u -p -r1.155 mfi.c --- ic/mfi.c15 Aug 2014 02:27:02 - 1.155 +++ ic/mfi.c8 Sep 2014 04:47:03 - @@ -199,6 +199,8 @@ mfi_get_ccb(void *cookie) struct mfi_softc*sc = cookie; struct mfi_ccb *ccb; + KERNEL_UNLOCK(); + mtx_enter(sc-sc_ccb_mtx); ccb = SLIST_FIRST(sc-sc_ccb_freeq); if (ccb != NULL) { @@ -208,6 +210,7 @@ mfi_get_ccb(void *cookie) mtx_leave(sc-sc_ccb_mtx); DNPRINTF(MFI_D_CCB, %s: mfi_get_ccb: %p\n, DEVNAME(sc), ccb); + KERNEL_LOCK(); return (ccb); } @@ -220,9 +223,11 @@ mfi_put_ccb(void *cookie, void *io) DNPRINTF(MFI_D_CCB, %s: mfi_put_ccb: %p\n, DEVNAME(sc), ccb); + KERNEL_UNLOCK(); mtx_enter(sc-sc_ccb_mtx); SLIST_INSERT_HEAD(sc-sc_ccb_freeq, ccb, ccb_link); mtx_leave(sc-sc_ccb_mtx); + KERNEL_LOCK(); } void @@ -1108,7 +1113,9 @@ mfi_scsi_xs_done(struct mfi_softc *sc, s break; } + KERNEL_LOCK(); scsi_done(xs); + KERNEL_UNLOCK(); } int @@ -1174,6 +1181,8 @@ mfi_scsi_cmd(struct scsi_xfer *xs) DNPRINTF(MFI_D_CMD, %s: mfi_scsi_cmd opcode: %#x\n, DEVNAME(sc), xs-cmd-opcode); + KERNEL_UNLOCK(); + if (!sc-sc_ld[target].ld_present) { DNPRINTF(MFI_D_CMD, %s: invalid target %d\n, DEVNAME(sc), target); @@ -1236,11 +1245,13 @@ mfi_scsi_cmd(struct scsi_xfer *xs) else mfi_start(sc, ccb); + KERNEL_LOCK(); return; stuffup: xs-error = XS_DRIVER_STUFFUP; complete: + KERNEL_LOCK(); scsi_done(xs); } @@ -2492,6 +2503,8 @@ mfi_pd_scsi_cmd(struct scsi_xfer *xs) struct mfi_pass_frame *pf = ccb-ccb_frame-mfr_pass; struct mfi_pd_link *pl = sc-sc_pd-pd_links[link-target]; + KERNEL_UNLOCK(); + mfi_scrub_ccb(ccb); xs-error = XS_NOERROR; @@ -2532,9 +2545,11 @@ mfi_pd_scsi_cmd(struct scsi_xfer *xs) else mfi_start(sc, ccb); + KERNEL_LOCK(); return; stuffup: xs-error = XS_DRIVER_STUFFUP; + KERNEL_LOCK(); scsi_done(xs); }