Commit Graph

116 Commits

Author SHA1 Message Date
andvar cb7270a436 s/should't/shouldn't/ and s/mistmatch/mismatch/ in comments. 2024-02-08 19:44:08 +00:00
mlelstv 7f0211635e Use correct status value SCSI_BUSY (0x08) instead of XS_BUSY (7) when running
out of sessions. The bug had no impact as scsipi was only comparing
against SCSI_CHECK (0x02) and SCSI_QUEUE_FULL (0x28).
2023-12-28 15:58:24 +00:00
mlelstv 4ccc61761f Adapt to bignum representation of target.
Fix negotiation for mutual authentication.
Prepare for more CHAP types.
Fix crashes for invalid socket descriptors passed to kernel.
Protect usecount with connection mutex, avoids race on connection close.
Minor cosmetics.
2023-11-25 10:08:27 +00:00
mlelstv 1ec2b09a37 kill_session now uses the session id to avoid stale session pointers.
protect network socket with rwlock to handle recconnects.
always take over socket from iscsid to prevent leaks.
keep a good connection alive.
don't forget child device when config_detach fails.
fix locking when reassigning CCBs.
pducount is protected by lock, no need for atomic.
some code rework, refined debug messages.
2022-09-13 13:09:16 +00:00
pgoyette 9dda5c7f82 Split some common stuff into scsi_subr module. This enables loading
of the iscsi module whether or not there are any scsi things built
into the kernel.

Addresses the iscsi portion of kern/56772
2022-04-14 16:50:26 +00:00
pgoyette 97f8debd62 For device modules that provide both auto-config and /dev/xxx
interfaces, make sure that initialization and destruction
follow the proper sequence.  This is triggered by the recent
changes to the devsw stuff; per riastradh@ the required call
sequence is:

	devsw_attach()
	config_init_component() or config_cf*_attach()
	...
	config_fini_component() or config_cf*_detach()
	devsw_detach()

While here, add a few missing calls to some of the detach
routines.

Testing of these changes has been limited to:
	1. compile without build break
	2. no related test failures from atf
	3. modload/modunload work as well as
	   before.

No functional device testing done, since I don't have any
of these devices.  Let me know of any damage I might cause
here!

XXX Some of the modules affected by this commit are already
XXX broken;  see kern/56772.  This commit does not break
any additional modules (as far as I know).
2022-03-31 19:30:15 +00:00
riastradh adeed0a04b iscsi(4): Fix config_found usage -- needs kernel lock.
Candidate fix for PR kern/56709.
2022-02-13 19:03:25 +00:00
thorpej c7fb772b85 Merge thorpej-cfargs2. 2021-08-07 16:18:40 +00:00
mlelstv 1f5bdd0a0d Provide missing file ops. Before a simple read() would panic the kernel.
No longer fail close().
2021-06-06 10:40:14 +00:00
mlelstv b486bc6b80 Schedule command timeout without connection lock being held to prevent
a deadlock.
2021-06-06 10:39:10 +00:00
thorpej 2685996b0e Merge thorpej-cfargs branch:
Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
  actually needed.
- Don't be explicit about what interface attribute is attaching if
  the device only has one.  (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
  situations, making is visibly easier to see when indirect config is
  in play, and allowing for future change in semantics.  (As of now,
  this is just a wrapper around config_match(), but that is an
  implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance.  This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
2021-04-24 23:36:23 +00:00
mlelstv 0f81aa3085 Stop advertising more openings after limit is reached. 2021-03-07 12:30:03 +00:00
chs b906de5d01 avoid the use of UVM internals in the iscsi ioctl code.
copyin/out are fine in this context.
2020-06-21 23:08:16 +00:00
kamil 9f15ed54af Catch up with the usage of struct vmspace::vm_refcnt
Use the dedicated reference counting routines.

Change the type of struct vmspace::vm_refcnt and struct vm_map::ref_count
to volatile.

Remove the unnecessary vm->vm_map.misc_lock locking in process_domem().

Reviewed by <ad>
2020-05-26 00:50:53 +00:00
jdolecek 75014c5064 make the iscsi attached message aprint_verbose(), no need to show normally 2020-05-13 21:59:45 +00:00
chs 02991323a4 in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
2019-10-01 18:00:07 +00:00
pgoyette 97b627eca5 Many years ago someone created a new __link_set_sysctl_funcs to hold
the list of routines that need to be called for setting up sysctl
variables.  This worked great for all code included in the kernel
itself, but didn't deal with modules that want to create their own
sysctl data.  So, we ended up with a lot of #ifdef _MODULE blocks
so modules could explicitly call their setup functions when loaded
as non-built-in modules.

So today, we complete the task that was started so many years ago.

When modules are loaded, after we've called xxx_modcmd(INIT...) we
check if the module contains its own __link_set_sysctl_funcs, and
if so we call the functions listed.  We add a struct sysctllog member
to the struct module so we can call sysctl_teardown() when the module
gets unloaded.  (The sequence of events ensures that the sysctl stuff
doesn't get created until the rest of the module's init code does any
required memory allocation.)

So, no more need to explicitly call the sysctl setup routines when
built as a loadable module.
2019-08-07 00:38:01 +00:00
mlelstv eea8587cd3 register with pmf to allow suspend. 2019-07-13 17:06:00 +00:00
maya f93d65267a wether -> whether 2019-04-21 11:45:08 +00:00
mlelstv f1a7fa8c8a Replace build option to enable hex encoded bignum parameters with a sysctl. 2019-04-21 11:26:46 +00:00
kamil 894a43424d Fix CVS Id
NFCI
2019-04-11 11:40:58 +00:00
msaitoh 25629ef49d Fix typo in comment (s/numer/number/). 2019-04-01 06:20:40 +00:00
mrg cdf28a3078 fix FALLTRHOUGH spell-o. 2019-02-01 08:33:29 +00:00
mlelstv 40d825b97a interlock isn't taken when cleaning up. 2018-12-07 14:59:19 +00:00
mlelstv 7143608235 Return temporary errors when the session is trying to recover the last
connection. The scsipi layer will retry.
2018-03-04 07:39:45 +00:00
mlelstv 888922af0f Add sanity check. 2018-03-04 07:37:43 +00:00
ozaki-r 7475694f27 Fix typo 2017-12-06 04:29:58 +00:00
christos 8ab41cb9c8 - add a prefix to struct members (but not the ioctl ones because they affect
the API)
- use consistent variable names.
2017-12-03 19:07:10 +00:00
mlelstv 67cf3e04f7 unreference session only for responses to SCSI commands. 2017-12-03 07:24:47 +00:00
mlelstv 8add5d8468 use same lock for ref/deref. 2017-12-03 07:23:45 +00:00
mlelstv 501f6ddfbf add debug messages 2017-12-03 07:23:12 +00:00
christos ea05286d92 add fo_name so we can identify the fileops in a simple way. 2017-11-30 20:25:54 +00:00
mlelstv 0b6b65ff23 Fix session cleanup. 2017-06-24 11:31:26 +00:00
maya e0c33d5694 Remove redundant duplicate assignment.
from clang static analyzer
2017-04-18 17:28:18 +00:00
mlelstv 7442aaf8ef Use correct lock for session wakeup. 2017-02-25 12:03:57 +00:00
mlelstv 61e95c24aa Destroy callouts when cleaning up. 2017-02-05 12:05:46 +00:00
mlelstv 015f574c37 Lock correctly around CV calls.
Fix handling of session termination.
Enable MPSAFE processing for scsipi.
2016-12-25 06:55:28 +00:00
mlelstv d48455317c Work around an issue with MSG_WAITALL that would block for too long by
replacing it with a receive loop.
2016-06-15 04:33:52 +00:00
mlelstv bbe94f43d2 Remove throttling code, instead signal scsipi layer to reduce the openings
and retry the command. Start with a small openings number and let scsipi
request to grow it up to the current send window.

Adjust ccb and pdu counts to avoid ressource shortages. These are still
very ad-hoc numbers, but seem to be sufficient for a Gigabit link.

Use separate condvar for PDU pool and add counter to help debugging.

Revert setting PDU disposition to UNUSED before freeing. free_pdu
uses this as a flag to detect already returned PDUs.

Add reference counter for open commands to defer unmapping a session
that would lead to crashes in scsipi.

Move session cleanup to cleanup thread.

Use get_sernum to retrieve current serial number where possible and
make it check for immediate commands itself.

Adjust debug output.
2016-06-15 04:30:30 +00:00
mlelstv ae0ee83b73 drop unused debug helper routine 2016-06-15 03:51:55 +00:00
mlelstv e27d88e376 Fix field name in response pdu. 2016-06-15 03:40:59 +00:00
mlelstv eafa082213 use correct comparison of serial numbers 2016-06-05 15:04:31 +00:00
mlelstv 35a1d99d03 Don't resume throttled CCBs when connection is terminating, except for
those being actively waited for. Stop unthrottling when reaching MaxCmdSN
again.
2016-06-05 14:00:12 +00:00
mlelstv 3e27116260 Handle freeing of PDU when referencing CCB is freed. 2016-06-05 13:54:28 +00:00
mlelstv 7465018a7b More debug output. Dump pending CCBs when cleaning up. 2016-06-05 13:45:56 +00:00
mlelstv 7b7c8b93ad more debug output 2016-06-05 11:01:39 +00:00
mlelstv 62f45d0b81 acquire session lock when changing throttling queue 2016-06-05 09:21:14 +00:00
mlelstv 6bd66ce750 wrong assertion. 2016-06-05 09:12:48 +00:00
mlelstv c13976ae8f Need session mutex to read serial number. 2016-06-05 09:09:57 +00:00
mlelstv 3f22eb9b95 initialize before check. 2016-06-05 09:03:10 +00:00