Page MenuHomeFreeBSD

Fix an uninitialized variable reference in xpt_async.
ClosedPublic

Authored by asomers on Apr 14 2015, 3:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 5, 1:16 AM
Unknown Object (File)
Nov 24 2024, 4:30 PM
Unknown Object (File)
Oct 28 2024, 10:30 AM
Unknown Object (File)
Oct 4 2024, 11:22 PM
Unknown Object (File)
Sep 30 2024, 10:05 AM
Unknown Object (File)
Sep 20 2024, 4:18 PM
Unknown Object (File)
Sep 17 2024, 11:27 PM
Unknown Object (File)
Aug 21 2024, 10:39 PM
Subscribers

Details

Summary

Initialize async_arg_ptr in xpt_async when called with async_code
AC_ADVINFO_CHANGED.

Test Plan

The only way I know of to call xpt_async with AC_ADVINFO_CHANGED is when the
ses(4) driver sets the physical path of a device. And since that only happens
when a device is inserted (or a SES device changes its configuration, which
never happens on my hardware), symptoms will only be visible if the enc_daemon
thread is running slow. Otherwise it will set the physical path before the
device finishes creating all of its devnodes on startup. And the only way I
know to slow down enc_daemon is to attach a large number of devices at the same
time.

For example, without this patch, attaching 95 disks at once resulted in all of
them getting physical path device nodes for their da devices, but only two
got physical path device nodes for their pass devices.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

asomers retitled this revision from to Fix an uninitialized variable reference in xpt_async..
asomers updated this object.
asomers edited the test plan for this revision. (Show Details)
asomers added reviewers: mav, ken.
mav edited edge metadata.

Hmm. Not sure how could I miss that, looks like a wrong copy/paste. Instead of async_arg_size assignment there should probably be async_arg_ptr assignment. I am not sure that assigning both as in your patch is very useful.

This revision is now accepted and ready to land.Apr 14 2015, 3:37 PM
imp added a reviewer: imp.

This looks good to my eye. Not sure how it could have worked before.

In D2290#4, @mav wrote:

Hmm. Not sure how could I miss that, looks like a wrong copy/paste. Instead of async_arg_size assignment there should probably be async_arg_ptr assignment. I am not sure that assigning both as in your patch is very useful.

async_arg_size gets referenced by xpt_async_process, so it's still worthwhile to assign it.

In D2290#7, @imp wrote:

This looks good to my eye. Not sure how it could have worked before.

Before it only worked due to timing. Normally, ses(4) finishes setting the physical path before the device finishes arriving. For example, passregister enqueues a pass_add_physpath taskqueue. When ses(4) sets the physical path, it attempts to enqueue another pass_add_physpath via xpt_async. But if ses(4) is fast enough, then the first pass_add_physpath won't have fired yet, and it won't matter that xpt_async is broken.

asomers updated this revision to Diff 4824.

Closed by commit rS281531 (authored by @asomers).

In D2290#10, @asomers wrote:
In D2290#4, @mav wrote:

Hmm. Not sure how could I miss that, looks like a wrong copy/paste. Instead of async_arg_size assignment there should probably be async_arg_ptr assignment. I am not sure that assigning both as in your patch is very useful.

async_arg_size gets referenced by xpt_async_process, so it's still worthwhile to assign it.

It is assigned to zero few lines before that point. Assigning it to -1 after that is irrelevant.

In D2290#15, @mav wrote:
In D2290#10, @asomers wrote:
In D2290#4, @mav wrote:

Hmm. Not sure how could I miss that, looks like a wrong copy/paste. Instead of async_arg_size assignment there should probably be async_arg_ptr assignment. I am not sure that assigning both as in your patch is very useful.

async_arg_size gets referenced by xpt_async_process, so it's still worthwhile to assign it.

It is assigned to zero few lines before that point. Assigning it to -1 after that is irrelevant.

The outcome is irrelevant today, but will it always be irrelevant? I prefer to program defensively. async_arg_size has a meaning, and later code checks it, so I prefer that its value be accurate.