NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/54335: rewrite ufs_readdir using ufs_blkatoff



>Number:         54335
>Category:       kern
>Synopsis:       rewrite ufs_readdir using ufs_blkatoff
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 01 01:40:00 +0000 2019
>Originator:     David A. Holland
>Release:        NetBSD 8.99.49 (20190630)
>Organization:
>Environment:
System: irrelevant
Architecture: x86_64
Machine: amd64
>Description:

ufs_readdir() currently uses a (potentially large) transfer buffer as
a staging area for reading on-disk struct directs and shipping the
data to userspace as dirents.

This results in an extra bulk copy that can easily be avoided by going
straight from buffers to userspace. In ffs directory entries cannot
span blocks (or even directory blocks, which are usually smaller than
fs-level blocks) so there is nothing to be gained by looking at more
than one block of the directory at a time.

ufs_blkatoff provides the right interface for this (most of the other
directory I/O uses ufs_blkatoff already) -- use it in a loop to read
blocks of size ump->um_dirblksiz, and scan over the struct directs in
each of these, copying to userspace incrementally until the user's
buffer space runs out. This will simplify the current loop code a fair
amount -- though note that the logic to start at the beginning of a
block and iterate through to skip to a given start offset will still
be needed, because you can't count on the input offset to not point to
the middle of an entry. Also it'll allow handling some of the corner
cases, like too-small user buffers, more systematically.

>How-To-Repeat:

Code reading.

>Fix:

As above.

(This is an entry off my todo list, which I'm putting in gnats in the
hopes that maybe someone else will take it up.)



Home | Main Index | Thread Index | Old Index