1. 28 Sep, 2021 2 commits
    • Kirk McKusick's avatar
      Avoid "consumer not attached in g_io_request" panic when disk lost · 4a365e86
      Kirk McKusick authored
      while using a UFS snapshot.
      The UFS filesystem supports snapshots. Each snapshot is a file whose
      contents are a frozen image of the disk partition on which the filesystem
      resides. Each time an existing block in the filesystem is modified,
      the filesystem checks whether that block was in use at the time that
      the snapshot was taken. If so, and if it has not already been copied,
      a new block is allocated from among the blocks that were not in use
      at the time that the snapshot was taken and placed in the snapshot file
      to replace the entry that has not yet been copied. The previous contents
      of the block are copied to the newly allocated snapshot file block,
      and the write to the original is then allowed to proceed.
      The block allocation is done using the usual UFS_BALLOC() routine
      which allocates the needed block in the snapshot and returns a
      buffer that is set up to write data into the newly allocated block.
      In usual filesystem operation, the contents for the new block is
      copied from user space into the buffer and the buffer is then written
      to the file using bwrite(), bawrite(), or bdwrite(). In the case of a
      snapshot the new block must be filled from the disk block that is about
      to be rewritten. The snapshot routine has a function readblock() that
      it uses to read the `about to be rewritten' disk block.
       * Read the specified block into the given buffer.
      static int
      readblock(snapvp, bp, lbn)
      	struct vnode *snapvp;
      	struct buf *bp;
      	ufs2_daddr_t lbn;
      	struct inode *ip;
      	struct bio *bip;
      	struct fs *fs;
      	ip = VTOI(snapvp);
      	fs = ITOFS(ip);
      	bip = g_alloc_bio();
      	bip->bio_cmd = BIO_READ;
      	bip->bio_offset = dbtob(fsbtodb(fs, blkstofrags(fs, lbn)));
      	bip->bio_data = bp->b_data;
      	bip->bio_length = bp->b_bcount;
      	bip->bio_done = NULL;
      	g_io_request(bip, ITODEVVP(ip)->v_bufobj.bo_private);
      	bp->b_error = biowait(bip, "snaprdb");
      	return (bp->b_error);
      When the underlying disk fails, its GEOM module is removed.
      Subsequent attempts to access it should return the ENXIO error.
      The functionality of checking for the lost disk and returning
      ENXIO is handled by the g_vfs_strategy() routine:
      g_vfs_strategy(struct bufobj *bo, struct buf *bp)
      	struct g_vfs_softc *sc;
      	struct g_consumer *cp;
      	struct bio *bip;
      	cp = bo->bo_private;
      	sc = cp->geom->softc;
      	 * If the provider has orphaned us, just return ENXIO.
      	if (sc->sc_orphaned || sc->sc_enxio_active) {
      		bp->b_error = ENXIO;
      		bp->b_ioflags |= BIO_ERROR;
      	bip = g_alloc_bio();
      	bip->bio_cmd = bp->b_iocmd;
      	bip->bio_offset = bp->b_iooffset;
      	bip->bio_length = bp->b_bcount;
      	bdata2bio(bp, bip);
      	if ((bp->b_flags & B_BARRIER) != 0) {
      		bip->bio_flags |= BIO_ORDERED;
      		bp->b_flags &= ~B_BARRIER;
      	if (bp->b_iocmd == BIO_SPEEDUP)
      		bip->bio_flags |= bp->b_ioflags;
      	bip->bio_done = g_vfs_done;
      	bip->bio_caller2 = bp;
      	g_io_request(bip, cp);
      Only after checking that the device is present does it construct
      the "bio" request and call g_io_request(). When readblock()
      constructs its own "bio" request and calls g_io_request() directly
      it panics with "consumer not attached in g_io_request" when the
      underlying device no longer exists.
      The fix is to have readblock() call g_vfs_strategy() rather than
      constructing its own "bio" request:
       * Read the specified block into the given buffer.
      static int
      readblock(snapvp, bp, lbn)
      	struct vnode *snapvp;
      	struct buf *bp;
      	ufs2_daddr_t lbn;
      	struct inode *ip;
      	struct fs *fs;
      	ip = VTOI(snapvp);
      	fs = ITOFS(ip);
      	bp->b_iocmd = BIO_READ;
      	bp->b_iooffset = dbtob(fsbtodb(fs, blkstofrags(fs, lbn)));
      	bp->b_iodone = bdone;
      	g_vfs_strategy(&ITODEVVP(ip)->v_bufobj, bp);
      	return (bp->b_error);
      Here it uses the buffer that will eventually be written to the disk.
      The g_vfs_strategy() routine uses four parts of the buffer: b_bcount,
      b_iocmd, b_iooffset, and b_data.
      The b_bcount field is already correctly set for the buffer. It is
      safe to set the b_iocmd and b_iooffset fields as they are set
      correctly when the later write is done. The write path will also
      clear the B_DONE flag that our use of the buffer will set. The
      b_iodone callback has to be set to bdone() which will do just
      notification that the I/O is done in bufdone(). The rest of
      bufdone() includes things like processing the softdeps associated
      with the buffer should not be done until the buffer has been
      written. Bufdone() will set b_iodone back to NULL after using it,
      so the full bufdone() processing will be done when the buffer is
      written. The final change from the previous version of readblock()
      is that it used the b_data for the destination of the read while
      g_vfs_strategy() uses the bdata2bio() function to take advantage
      of VMIO when it is available.
      Differential revision: https://reviews.freebsd.org/D32150
      Reviewed by:  kib, chs
      MFC after:    1 week
      Sponsored by: Netflix
    • Kirk McKusick's avatar
      Bring the tags and links entries for amd64 up to date. · 1c8d670c
      Kirk McKusick authored
      MFC after:    1 week
      Sponsored by: Netflix
  2. 27 Sep, 2021 20 commits
    • Bjoern A. Zeeb's avatar
      LinuxKPI: dma-mapping.h unify "mask" and "dma_mask" · 72c89ce9
      Bjoern A. Zeeb authored
      In some places we are using "mask" and others "dma_mask" for the
      same thing.  Harmonize the various places to "dma_mask" as used in
      linux_pci.c.  For the declaration remove the argument names to
      avoid the entire problem.
      This is in preparation for an upcoming change.
      No functional changes intended.
      Sponsored by:	The FreeBSD Foundation
      MFC after:	5 days
    • David Bright's avatar
      ntb_hw_intel: fix xeon NTB gen3 bar disable logic · e3cf7ebc
      David Bright authored
      In NTB gen3 driver, it was supposed to disable NTB bar access by
      default, but due to incorrect register access method, the bar disable
      logic does not work as expected. Those registers should be modified
      through NTB bar0 rather than PCI configuration space.
      Besides, we'd better to protect ourselves from a bad buddy node so
      ingress disable logic should be implemented together.
      Submitted by:   Austin Zhang (austin.zhang@dell.com)
      Reviewers:      markj, mav, vangyzen, dab
      Differential Revision:  https://reviews.freebsd.org/D31736
      Sponsored by:   Dell EMC
      MFC to:      stable/12, stable/13
      MFC after:   1 week
    • Cy Schubert's avatar
      ipfilter: Correct a comment · aa6cfcc8
      Cy Schubert authored
      Correct a comment's grammar and while at it clarify its meaining.
      MFC after:	3 days
    • Cy Schubert's avatar
      ipfilter: Print the correct TCP sequence index number · df38343e
      Cy Schubert authored
      TCP sequence numbers in the FTP proxy are maintained in a two dimensional
      array. The debug message prints the same seq[N] for both. Fix that.
      MFC after:	3 days
    • Bjoern A. Zeeb's avatar
      LinuxKPI: disable device_release_driver() · 93b14194
      Bjoern A. Zeeb authored
      As reported by multiple people testing iwlwifi, device_release_driver()
      can lead to a panic on secondary errors (usually during attach).
      Disable device_release_driver() for the short-term to prevent the panic
      but leave it in place so it can be re-worked and fixed properly for
      the long-term more easily.
      Sponsored by:	The FreeBSD Foundation
      MFC after:	3 days
    • Elliott Mitchell's avatar
      rman: fix overflow in rman_reserve_resource_bound() · bcddaadb
      Elliott Mitchell authored
      If the default range of [0, ~0] is given, then (~0 - 0) + 1 == 0. This
      in turn will cause any allocation of non-zero size to fail. Zero-sized
      allocations are prohibited, so add a KASSERT to this effect.
      History indicates it is part of the original rman code.  This bug may in
      fact be older than some contributors.
      Reviewed by:	mhorne
      MFC after:	1 week
      Differential Revision:	https://reviews.freebsd.org/D30280
    • Greg V's avatar
      pci_host_generic: implement bus_translate_resource (for LinuxKPI) · 0eb901f7
      Greg V authored
      In D21096 BUS_TRANSLATE_RESOURCE was introduced to allow LinuxKPI to get
      physical addresses in pci_resource_start for PowerPC and implemented
      in ofw_pci.
      When the translation was implemented in pci_host_generic in 372c142b,
      this method was not implemented; instead a local static function was
      added for a similar purpose.
      Rename the static function to "_common" and implement the bus function
      as a wrapper around that.  With this a LinuxKPI driver using
      physical addresses correctly finds the configuration registers of
      the GPU.
      This unbreaks amdgpu on NXP Layerscape LX2160A SoC (SolidRun HoneyComb
      LX2K workstation) which has a Translation Offset in ACPI for
      below-4G PCI addresses.
      More info:	https://github.com/freebsd/drm-kmod/issues/84
      Tested by:	dan.kotowski_a9development.com
      Reviewed by:	hselasky
      Differential Revision: https://reviews.freebsd.org/D30986
    • Konstantin Belousov's avatar
      amd64 sendsig: fix context corruption · b1e2f063
      Konstantin Belousov authored
      Drop fpstate only after copying out xfpustate from the thread usermode
      save area. Otherwise a context switch between get_fpcontext(), which now
      returns the pointer directly into user save area, and copyout, would
      cause reinit of the save area, loosing user registers.
      Reported, reviewed, and tested by:	markj
      Sponsored by:	The FreeBSD Foundation
      MFC after:	3 days
      Differential revision:	https://reviews.freebsd.org/D32159
    • Emmanuel Vadot's avatar
      Fix gssd rc.d installation · 860ee179
      Emmanuel Vadot authored
      CONFGROUPS needs to be in CAPS
      Fixes: a30235a4 ("pkgbase: Create a FreeBSD-kerberos package")
      Reported by:	    kp
    • Kevin Bowling's avatar
      e1000: Re-arm link changes · 450c3f8b
      Kevin Bowling authored
      A change to MSI-X link handler was somehow causing issues on
      MSI-based em(4) NICs.
      Revert the change based on user reports and testing.
      PR:		258551
      Reported by:	Franco Fichtner <franco@opnsense.org>, t_uemura@macome.co.jp
      Reviewed by:	markj, Franco Fichtner <franco@opnsense.org>
      Tested by:	t_uemura@macome.co.jp
      MFC after:	1 day
    • Andrew Turner's avatar
      Check cpu_softc is not NULL before dereferencing · 4e50efb1
      Andrew Turner authored
      In the acpi_cpu_postattach SYSINIT function cpu_softc may be NULL, e.g.
      on arm64 when booting from FDT. Check it is not NULL at the start of
      the function so we don't try to dereference a NULL pointer.
      Sponsored by:	The FreeBSD Foundation
    • Yasuhiro Kimura's avatar
      Add myself to calendar.freebsd · 74237127
      Yasuhiro Kimura authored
      It corresponds to the 9th step of the procedure described in section
      7.1 of Committer's Guide.
      Approved by:	meta (mentor)
      Differential Revision:	https://reviews.freebsd.org/D32153
    • Eugene Grosbein's avatar
      syslogd: undo regression after r326573 · 3b4cc56e
      Eugene Grosbein authored
      Restore ability for our syslogd to collect pre-RFC3164 formatted
      messages from remote hosts that was broken with r326573.
      For example, the line from Cisco SCE8000 splitted for readability:
      1130: 03:37:57: %USER-6-PORT_OPERSTATUS_CHANGE_TRAP: CPU#000 trap:link
      down EntityAdminState: 4  EntityAlarmStatus: 32
      Such line was collected and stored before mentioned change
      but silently dropped after that. Now syslogd saves it again.
      Note that parsing of RFC5424 format not changed.
      MFC after:	1 month
    • Yasuhiro Kimura's avatar
      Add myself as ports committer and update mentor/mentee information · 77087b11
      Yasuhiro Kimura authored
      It corresponds to the 5th step of the procedure described in section
      7.1 of Committer's Guide.
      Approved by:	meta (mentor)
      Differential Revision:	https://reviews.freebsd.org/D32151
    • Wojciech Macek's avatar
      ipsec: fix typo part2 · 8deba29c
      Wojciech Macek authored
    • Wojciech Macek's avatar
      ipsec: fix typo in comment · c27214f0
      Wojciech Macek authored
    • Piotr Pawel Stefaniak's avatar
      mount: make libxo support more locale-aware · 260f26f0
      Piotr Pawel Stefaniak authored
      "special", "node", and "mounter" are not guaranteed to be encoded with
      UTF-8. Use the appropriate modifier.
      Reported by:	eugen@
    • Alan Somers's avatar
      fusefs: implement FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT · 7124d2bc
      Alan Somers authored
      For file systems that allow it, fusefs will skip FUSE_OPEN,
      FUSE_RELEASE, FUSE_OPENDIR, and FUSE_RELEASEDIR operations, a minor
      MFC after:	2 weeks
      Reviewed by:	pfg
      Differential Revision: https://reviews.freebsd.org/D32141
    • Alan Somers's avatar
      fusefs: diff reduction in fuse_kernel.h · a3a1ce37
      Alan Somers authored
      Synchronize formatting and documentation in fuse_kernel.h with upstream
      MFC after:	2 weeks
      Reviewed by:	pfg
      Differential Revision:	https://reviews.freebsd.org/D32141
    • Rick Macklem's avatar
      nfscl: Add a check for "has acquired a delegation" to nfscl_removedeleg() · 62c5be4a
      Rick Macklem authored
      Commit 5e5ca4c8 added a flag to a NFSv4 mount point that is set when
      the first delegation is acquired from the NFSv4 server.
      For a common case where delegations are not being issued by the
      NFSv4 server, the nfscl_removedeleg() code acquires the mutex lock for
      open/lock state, finds the delegation list empty, then just unlocks the
      mutex and returns. This patch adds a check of the flag to avoid the
      need to acquire the mutex for this common case.
      This change appears to be performance neutral for a small number
      of opens, but should reduce lock contention for a large number of opens
      for the common case where server is not issuing delegations.
      This commit should not affect the high level semantics of delegation
      MFC after:      2 weeks
  3. 26 Sep, 2021 15 commits
  4. 25 Sep, 2021 3 commits