a syscall is an exception (a software interrupt); if you
use spin_lock() in your kernel thread you will just be protecting your
data structure; the system call (the exception) has nothing to do with
that structure, until the system call handler is called (the ioctl
routine, in your case); if your ioctl routine uses the same structure
than you should protect it using a spinlock also
please note that when a system call is made, first there is an
analysis of the system call arguments (registers), then a switch to
kernel (supervisor) mode then a search for the proper system call
handler routine; this is the exception (software interrupt) handler; as
long as it doesn't access the protected structure (and it never does,
unless you were mangling with the sys_call_table structure) nothing bad
(
a.k.a. inconsistency due to lack of synchronization) will ever happen
when
the ioctl routine is finally executed, there is no exception context;
you are in kernel mode, in process context; the kernel simply executes
the ioctl routine on behalf of the process that requested it through
the proper system call; the syncrhonization methods that I have
mentioned in the previous mail (spinlock, semaphore, preempt_disable)
will work fine here
you should definitely consult chapter 9 of Linux Kernel
Development 2nd Edition by Robert Love; it presents all the kernel
synchronization methods and their advantages/disadvantages quite clearly