Page MenuHomeFreeBSD

Make fsck(8) use pread(2)
ClosedPublic

Authored by trasz on Oct 16 2018, 3:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 14 2024, 2:51 PM
Unknown Object (File)
Apr 29 2024, 10:29 AM
Unknown Object (File)
Mar 7 2024, 5:10 PM
Unknown Object (File)
Jan 1 2024, 5:08 AM
Unknown Object (File)
Dec 22 2023, 9:45 PM
Unknown Object (File)
Dec 18 2023, 6:54 AM
Unknown Object (File)
Nov 28 2023, 4:53 PM
Unknown Object (File)
Oct 14 2023, 12:03 AM
Subscribers

Details

Summary

Make fsck(8) use pread(2). This cuts the number of syscalls by half.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This change looks fine to me.

This revision is now accepted and ready to land.Oct 16 2018, 6:51 PM
sbin/fsck_ffs/fsutil.c
612 ↗(On Diff #49223)

Are callers depend on the specific file position after the call ?

618 ↗(On Diff #49223)

Why did not you converted these uses ?

In answer to kib:

The callers do not depend on the seek offset being set after the call.

The other three places in fsutil.c that do lseek followed by read/write (error followup in blread and blwrite along with blzero) should also be changed to use pread/pwrite.

The reason I hadn't changed the other instances is that while trivial, they are somewhat harder to test, and I've been bitten by trivial changes to rarely excercised branches in the past.

I prefer not to do things halfway. Either we use lseek/read or we use pread. Having it half & half is just crappy coding style. It is possible to write some tests that will exercise the error cases, so if you want to make this change, then I would like you to do it completely.

This revision now requires changes to proceed.Oct 19 2018, 2:39 AM

Use pread/pwrite also in error cases.

kib added inline comments.
sbin/fsck_ffs/fsutil.c
573 ↗(On Diff #51187)

It would be _very_ useful to print errno, in the followup commit.

618 ↗(On Diff #51187)

Perhaps trailing ',' should be fixed, in the follow-up commit.

This now looks good to me. I concur with kib's followup comments.

This revision is now accepted and ready to land.Nov 29 2018, 12:33 AM
This revision was automatically updated to reflect the committed changes.
trasz added inline comments.
sbin/fsck_ffs/fsutil.c
573 ↗(On Diff #51187)

Thanks for suggestion; see https://reviews.freebsd.org/D18570. It adds errno reporting to the normal path, in the other 'if' branch.