Page MenuHomeFreeBSD

Convert CAM to use sbufs for 'da' arrival announcements
ClosedPublic

Authored by scottl on Feb 14 2017, 10:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 7, 12:19 PM
Unknown Object (File)
Jun 29 2025, 10:19 PM
Unknown Object (File)
May 3 2025, 3:49 PM
Unknown Object (File)
Apr 12 2025, 2:51 AM
Unknown Object (File)
Apr 7 2025, 3:04 PM
Unknown Object (File)
Mar 7 2025, 7:04 PM
Unknown Object (File)
Mar 3 2025, 12:13 AM
Unknown Object (File)
Feb 27 2025, 5:27 AM
Subscribers
None

Details

Reviewers
ken
imp
Group Reviewers
cam
Summary

Add infrastructure so that periphs can use sbufs for device
arrival announcements. Only scsi_da is converted at the moment,
everything else remains working and unchanged. Have not added
device departure infrastructure, nor ATA/SATA infrastructure.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 7465
Build 7627: arc lint + arc unit

Event Timeline

scottl retitled this revision from to Convert CAM to use sbufs for 'da' arrival announcements.
scottl updated this object.
scottl edited the test plan for this revision. (Show Details)
scottl added reviewers: imp, ken.
imp edited edge metadata.

Looks reasonable to my eye.

This revision is now accepted and ready to land.Feb 16 2017, 7:32 AM

So, the question is, should we just have one version of these functions, and use a stack buffer to re-implement in terms of the new sbuf routines, or would we risk stack overflow?

sys/cam/cam_xpt.c
1079

Instead of duplicating xpt_announce_periph() in sbuf form, what do you think about re-implementing it to just call xpt_announce_periph_sbuf() with a static buffer and then printf that?

I guess the question would be how big of a stack buffer we're talking about, and whether that would cause things to blow up in any particular situation.

1144

Same question here.

sys/cam/scsi/scsi_all.c
5476

And I suppose the same question goes here. Should we just implement scsi_print_inquiry() in terms of scsi_print_inquiry_sbuf()?

sys/cam/scsi/scsi_xpt.c
3132

And the same question here. Should we just re-implement in terms of scsi_announce_periph_sbuf()?

sys/cam/cam_xpt.c
1079

This path has had problems in the past with blowing out the stack. Adding more to the stack makes me nervous. We can try your suggestion, and I've done it to a lesser degree in some places. However what I'd really like to do is get everything converted, add fine-grained draining, and then remove the legacy functions. This is just an intermediate step to that goal.

sys/cam/scsi/scsi_all.c
5476

Would there be any side effects in camcontrol and other userland utilities from doing this? I would have to be careful about using sbuf_putbuf() because it doesn't exist in userland (and I'm not sure how it would be implemented there).

This has already landed.

commit 5d01277f596ee9b05b6b19b6a55fe84668ffc100
Author: Scott Long <scottl@FreeBSD.org>
Date:   Wed Apr 19 15:04:52 2017 +0000

  Add infrastructure to the ATA and SCSI transports that supports
  using a driver-supplied sbuf for printing device discovery
  announcements. This helps ensure that messages to the console
  will be properly serialized (through sbuf_putbuf) and not be
  truncated and interleaved with other messages. The
  infrastructure mirrors the existing xpt_announce_periph()
  entry point and is opt-in for now. No content or formatting
  changes are visible to the operator other than the new coherency.

  While here, eliminate the stack usage of the temporary
  announcement buffer in some of the drivers. It's moved to the
  softc for now, but future work will eliminate it entirely by
  making the code flow more linear. Future work will also address
  locking so that the sbufs can be dynamically sized.

  The scsi_da, scs_cd, scsi_ses, and ata_da drivers are converted
  at this point, other drivers can be converted at a later date.
  A tunable+sysctl, kern.cam.announce_nosbuf, exists for testing
  purposes but will be removed later.

  TODO:
  Eliminate all of the code duplication and temporary buffers.  The
  old printf-based methods will be retired, and xpt_announce_periph()
  will just be a wrapper that uses a dynamically sized sbuf.  This
  requires that the register and deregister paths be made malloc-safe,
  which they aren't currently.

  Sponsored by:   Netflix

Notes:
  svn path=/head/; revision=317143