Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 May 2026 06:26:24 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Rick Macklem <rick.macklem@gmail.com>
Cc:        FreeBSD CURRENT <freebsd-current@freebsd.org>
Subject:   Re: RFC: what to do about KASSERT() in allocuio()?
Message-ID:  <agVA4PcPtKNrv4aF@kib.kiev.ua>
In-Reply-To: <CAM5tNy6xPuy8gDu71kLVW6GxEXqRU_J4AfN2473mobBWeGygcg@mail.gmail.com>
References:  <CAM5tNy6u4gqb_UOcSboVr7CiZxtqAE8QAjTfbfvdrjh6PZgq0w@mail.gmail.com> <agU3F1iuwluJhctv@kib.kiev.ua> <CAM5tNy6xPuy8gDu71kLVW6GxEXqRU_J4AfN2473mobBWeGygcg@mail.gmail.com>

index | next in thread | previous in thread | raw e-mail

On Wed, May 13, 2026 at 08:00:17PM -0700, Rick Macklem wrote:
> On Wed, May 13, 2026 at 7:50 PM Konstantin Belousov <kostikbel@gmail.com> wrote:
> >
> > On Wed, May 13, 2026 at 05:30:46PM -0700, Rick Macklem wrote:
> > > Hi,
> > >
> > > The following KASSERT() is at the beginning of allocuio():
> > > KASSERT(iovcnt <= UIO_MAXIOV,
> > >     ("Requested %u iovecs exceed UIO_MAXIOV", iovcnt));
> > >
> > > This fails for the NFS server if it is configured for > 1Mbyte I/O
> > > size, since the number of elements (mbufs) for the VOP_READ() > > > exceeds UIO_MAXIOV (1024). This shows up because ZFS
> > > does a cloneuio() call which calls allocuio().
> > >
> > > Since UIO_MAXIOV is used is several places, including setting
> > > the limit for copyinuio() and freebsd32_copyinuio(), I don't think
> > > changing the value of UIO_MAXIOV is an appropriate fix.
> > > (ie. This changes the APIs, etc.)
> > >
> > > Now, since all that the above check does it set a sanity limit
> > > on how big the allocated uio can be, do you think it is
> > > reasonable to change the above KASSERT() to:
> > > KASSERT(iovcnt <= 4096,
> > >     ("Requested %u iovecs exceed 4096", iovcnt));
> > > which would allow a 4Mbyte NFS I/O to work.
> > >
> > > Note that copyinuio() and freebsd32_copyinuio() check the
> > > iov length for < UIO_MAXIOV before calling allocuio(), so
> > > those interfaces are not broken by this.
> >
> > I do not quite understand how changing the assert in allocuio() would
> > change anything?  All callers of the function (copyinuio, cloneuio,
> > and freebsd32_copyinuio) check iovcnt, and I do not see a call to
> > allocuio() from the NFS server.
> >
> > Where specifically does the NFS server fail with too long iovec?
> zfs_freebsd_write()->zfs_write()->zfs_uiocopy()->cloneuio()->allocuio()
> (and zfs_freebsd_write() is ZFS's VOP_WRITE())

I would just remove the assert from allocuio() then.


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?agVA4PcPtKNrv4aF>