Files
scst/scst_local
Yan Burman d7e6569b1a Merged revisions 5667-5670,5672-5686,5698,5700-5722,5724-5737 via svnmerge from
svn+ssh://yanb123@svn.code.sf.net/p/scst/svn/trunk

........
  r5667 | bvassche | 2014-07-08 18:11:58 +0300 (Tue, 08 Jul 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5668 | vlnb | 2014-07-10 04:00:29 +0300 (Thu, 10 Jul 2014) | 3 lines
  
  Make SCST interface compatibility more robust
........
  r5669 | bvassche | 2014-07-10 09:17:57 +0300 (Thu, 10 Jul 2014) | 1 line
  
  scst/Makefile: Create /var/lib/scst/vdev_mode_pages while installing SCST
........
  r5670 | bvassche | 2014-07-10 09:18:58 +0300 (Thu, 10 Jul 2014) | 1 line
  
  scst.spec.in: Create /var/lib/scst/pr and /var/lib/scst/vdev_mode_pages when installing the SCST RPM
........
  r5672 | bvassche | 2014-07-10 15:29:59 +0300 (Thu, 10 Jul 2014) | 2 lines
  
  scripts/rebuild-rhel-kernel-rpm: Move code for downloading a RHEL (clone) RPM into a separate file
........
  r5673 | bvassche | 2014-07-11 09:48:49 +0300 (Fri, 11 Jul 2014) | 1 line
  
  scripts/generate-kernel-patch: Also generate scst-itf-ver.h
........
  r5674 | bvassche | 2014-07-11 10:54:19 +0300 (Fri, 11 Jul 2014) | 1 line
  
  scripts/generate-kernel-patch: Remove trailing whitespace
........
  r5675 | vlnb | 2014-07-12 03:53:46 +0300 (Sat, 12 Jul 2014) | 3 lines
  
  BLOCKIO microoptimization: use per-device biosets
........
  r5676 | bvassche | 2014-07-13 10:15:05 +0300 (Sun, 13 Jul 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5677 | vlnb | 2014-07-16 06:27:20 +0300 (Wed, 16 Jul 2014) | 3 lines
  
  Install scst_itf_ver.h as well
........
  r5678 | bvassche | 2014-07-16 08:35:40 +0300 (Wed, 16 Jul 2014) | 1 line
  
  scst-devel rpm: Include /usr/include/scst/scst_itf_ver.h
........
  r5679 | bvassche | 2014-07-16 11:29:16 +0300 (Wed, 16 Jul 2014) | 6 lines
  
  ib_srpt: Fix Mellanox OFED build
  
  Use the proper include directory when building against Mellanox OFED.
  Do not require to remove /lib/modules/$(KVER)/kernel/drivers/infiniband
  before building ib_srpt.
........
  r5680 | bvassche | 2014-07-18 12:27:41 +0300 (Fri, 18 Jul 2014) | 1 line
  
  srpt/Makefile: Remove a superfluous assignment statement
........
  r5681 | bvassche | 2014-07-18 12:28:22 +0300 (Fri, 18 Jul 2014) | 1 line
  
  srpt/Makefile: SLES + Mellanox OFED build fix
........
  r5682 | bvassche | 2014-07-18 12:30:25 +0300 (Fri, 18 Jul 2014) | 1 line
  
  srpt/README: Fix SLES patch instructions
........
  r5683 | vlnb | 2014-07-19 06:54:33 +0300 (Sat, 19 Jul 2014) | 11 lines
  
  iscsi-scst: Handle data buffers with non-zero offset correctly
  
  Start at the proper offset in the receive buffer if sg[0].offset != 0.
  Return the proper data to the initiator if sg[0].offset != 0.
  
  This patch reworks trunk r5281, "iscsi-scst: fix offset
  calculation", February 13, 2014.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5684 | vlnb | 2014-07-19 07:08:30 +0300 (Sat, 19 Jul 2014) | 10 lines
  
  scst: Clean up scst_process_active_cmd()
  
  Since inside scst_process_active_cmd() cmd->state can only change after
  cmd has been added back to the command list it is safe to perform the
  cmd->state check without holding the command list lock. Hence move the
  perform the cmd->state check without holding the command list lock.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5685 | vlnb | 2014-07-19 07:11:39 +0300 (Sat, 19 Jul 2014) | 7 lines
  
  scst: Introduce scst_set_thr_cpu_mask()
  
  This patch does not change any functionality.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5686 | vlnb | 2014-07-19 07:13:24 +0300 (Sat, 19 Jul 2014) | 8 lines
  
  scst_vdisk: Micro-optimize the zero-copy check
  
  Only evaluate the SCSI command type if virt_dev->zero_copy has been
  set instead of always checking the SCSI command type.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5698 | bvassche | 2014-07-20 11:37:58 +0300 (Sun, 20 Jul 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5700 | vlnb | 2014-07-22 02:04:18 +0300 (Tue, 22 Jul 2014) | 3 lines
  
  Web updates
........
  r5701 | vlnb | 2014-07-22 03:22:06 +0300 (Tue, 22 Jul 2014) | 8 lines
  
  scst: Make scst_cmd_threads.threads_list locking more fine-grained
  
  Introduce a new synchronization object, namely scst_cmd_threads.thr_lock,
  to protect scst_cmd_threads.threads_list.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5702 | vlnb | 2014-07-23 05:00:06 +0300 (Wed, 23 Jul 2014) | 7 lines
  
  Prevent possible collisions between saved PR and mode pages backup files
  
  From now on '.' is illegal character in SCST device names
  
  Reported-by Ken Raeburn <raeburn@permabit.com>
........
  r5703 | vlnb | 2014-07-23 05:49:50 +0300 (Wed, 23 Jul 2014) | 5 lines
  
  Review of host_status handling (pass-through mode)
  
  Inspired by Dave Butler <tears.the@gmail.com> and Bart Van Assche <bvanassche@acm.org>
........
  r5704 | vlnb | 2014-07-26 03:04:51 +0300 (Sat, 26 Jul 2014) | 3 lines
  
  Internal REQUEST SENSE: NO SENSE is also valid sense
........
  r5705 | vlnb | 2014-07-29 02:11:14 +0300 (Tue, 29 Jul 2014) | 3 lines
  
  Print initiator and target in the abort messages
........
  r5706 | vlnb | 2014-07-30 05:27:10 +0300 (Wed, 30 Jul 2014) | 3 lines
  
  Minor logging improvements
........
  r5707 | vlnb | 2014-07-30 05:52:26 +0300 (Wed, 30 Jul 2014) | 3 lines
  
  Follow up for r5704: NO SENSE is also valid sense
........
  r5708 | vlnb | 2014-07-30 05:53:07 +0300 (Wed, 30 Jul 2014) | 3 lines
  
  Minor fix
........
  r5709 | bvassche | 2014-08-06 20:40:30 +0300 (Wed, 06 Aug 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5710 | bvassche | 2014-08-07 10:20:08 +0300 (Thu, 07 Aug 2014) | 1 line
  
  RHEL 7: Add scst_exec_req_fifo and put_page_callback patches
........
  r5711 | bvassche | 2014-08-07 11:12:22 +0300 (Thu, 07 Aug 2014) | 1 line
  
  Rename the two RHEL 7 scst_exec_req_fifo patches
........
  r5712 | bvassche | 2014-08-07 11:38:19 +0300 (Thu, 07 Aug 2014) | 1 line
  
  scripts/rebuild-rhel-kernel-rpm: Add RHEL 7 support
........
  r5713 | bvassche | 2014-08-08 13:37:17 +0300 (Fri, 08 Aug 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5714 | bvassche | 2014-08-09 14:02:19 +0300 (Sat, 09 Aug 2014) | 1 line
  
  scripts/rebuild-rhel-kernel-rpm: Install more prerequisites
........
  r5715 | bvassche | 2014-08-15 10:49:07 +0300 (Fri, 15 Aug 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5716 | vlnb | 2014-08-16 02:44:33 +0300 (Sat, 16 Aug 2014) | 3 lines
  
  Fix blockio bioset for older kernels, which need explicit bio destructors
........
  r5717 | vlnb | 2014-08-20 00:52:31 +0300 (Wed, 20 Aug 2014) | 3 lines
  
  Update for kernels 3.16
........
  r5718 | vlnb | 2014-08-20 05:24:08 +0300 (Wed, 20 Aug 2014) | 12 lines
  
  Fix Coverity warning of q2t_ctio_to_cmd() dead code
  
  Coverity warns that 'handle == Q2T_SKIP_HANDLE' can never occur, because
  code preceding the test has masked out a handle bit that would be
  required for the test to succeed.
  
  Fix that by extending Q2T_SKIP_HANDLE to incorporate
  CTIO_INTERMEDIATE_HANDLE_MARK as well.
  
  Reported-by: Steven J. Magnani <steve@digidescorp.com>
........
  r5719 | bvassche | 2014-08-20 09:55:04 +0300 (Wed, 20 Aug 2014) | 1 line
  
  nightly build: Add kernel 3.16 nightly build infrastructure
........
  r5720 | bvassche | 2014-08-20 09:57:04 +0300 (Wed, 20 Aug 2014) | 1 line
  
  nightly build: Add kernel version 3.16.1
........
  r5721 | vlnb | 2014-08-21 08:17:47 +0300 (Thu, 21 Aug 2014) | 5 lines
  
  Fix incorrect address computation during receive PDUs preparations
  
  Found and fix suggested by Кирилл Тюшев <kirill.tyushev8@gmail.com>
........
  r5722 | vlnb | 2014-08-21 08:18:43 +0300 (Thu, 21 Aug 2014) | 3 lines
  
  Integration of the QLogic git's qla2x00t into the SCST tree
........
  r5724 | bvassche | 2014-08-22 10:19:55 +0300 (Fri, 22 Aug 2014) | 9 lines
  
  Fix a kernel 3.16 checkpatch complaint about trailing semicolons
  
  Avoid that the checkpatch tool included in Linux kernel v3.16 reports the
  following warning:
  
      macros should not use a trailing semicolon
  
  This patch does not change any functionality.
........
  r5725 | bvassche | 2014-08-25 14:36:33 +0300 (Mon, 25 Aug 2014) | 1 line
  
  ib_srpt: Kernel v3.17 build fix
........
  r5726 | bvassche | 2014-08-25 14:41:55 +0300 (Mon, 25 Aug 2014) | 1 line
  
  ib_srpt: Log QPN next to session name
........
  r5727 | bvassche | 2014-08-25 14:46:43 +0300 (Mon, 25 Aug 2014) | 6 lines
  
  ib_srpt: Speed up kernel driver unloading after a cable pull
  
  When unloading the ib_srpt kernel module, instead of waiting until
  all connected queue pairs have left the TimeWait state, destroy
  these queue pairs immediately.
........
  r5728 | bvassche | 2014-08-25 15:50:19 +0300 (Mon, 25 Aug 2014) | 8 lines
  
  ib_srpt: Make the completion vector configurable
  
  Allow a set of completion vectors to be associated with each InfiniBand
  HCA port and allocate the completion vector for each session in a
  round-robin fashion from the per-port set. This helps to spread the
  InfiniBand interrupt workload over multiple CPU's, at least if different
  InfiniBand MSI-X vectors are associated with different CPU's.
........
  r5729 | vlnb | 2014-08-26 06:21:07 +0300 (Tue, 26 Aug 2014) | 7 lines
  
  scst_vdisk: Make vdisk_sup_vpd() easier to extend
  
  This patch doesn't change any functionality.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5730 | vlnb | 2014-08-26 06:44:23 +0300 (Tue, 26 Aug 2014) | 12 lines
  
  scst_vdisk: Make EUI-64 and NAA IDs configurable
  
  Make the SCSI device identification page (83h) EUI-64 and NAA
  IDs configurable. If neither the eui64_id nor the naa_id sysfs
  attribute has been set, export the first eight bytes of the
  t10_dev_id as an EUI-64 ID. If the NAA ID but not the EUI-64 ID
  has been set, report the NAA ID only. If both IDs have been set,
  report both.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5731 | bvassche | 2014-08-26 12:56:54 +0300 (Tue, 26 Aug 2014) | 1 line
  
  scstadmin: Avoid that the Perl interpreter prints a warning message about using an undefined variable on Fedora systems
........
  r5732 | vlnb | 2014-08-27 05:41:40 +0300 (Wed, 27 Aug 2014) | 9 lines
  
  iscsi-scst: Build fix for IPV6=n
  
  Ensure that iscsi-scst builds properly against a kernel with CONFIG_IPV6=n.
  
  Reported by Igor Novgorodov <igor@novg.net> on June 7, 2014.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5733 | vlnb | 2014-08-27 05:42:35 +0300 (Wed, 27 Aug 2014) | 9 lines
  
  scst_pres: Make a few error messages more clear
  
  Make it possible to figure out what went wrong from inspecting the
  system log only by mentioning the incorrect filename in the system
  log.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5734 | vlnb | 2014-08-27 05:43:50 +0300 (Wed, 27 Aug 2014) | 8 lines
  
  scst: Remove set_cpus_allowed() invocations
  
  Since scst.h contains a backport of the definition of set_cpus_allowed_ptr(),
  the set_cpus_allowed() invocations are superfluous. Hence remove these.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5735 | vlnb | 2014-08-27 05:55:28 +0300 (Wed, 27 Aug 2014) | 8 lines
  
  iscsi-scst: Micro-optimize cmnd_prepare_recv_pdu()
  
  Instead of adding sg[idx].offset to addr and immediately subtracting
  sg[idx].offset again, leave out both arithmetic operations.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5736 | vlnb | 2014-08-27 06:00:44 +0300 (Wed, 27 Aug 2014) | 5 lines
  
  scst/include/scst.h: Document on_abort_cmd() further
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5737 | bvassche | 2014-08-27 09:33:02 +0300 (Wed, 27 Aug 2014) | 1 line
  
  scst_vdisk: Build fix for kernel 3.1.x
........


git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/iser@5738 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2014-08-27 13:26:02 +00:00
..

SCST Local ...
Richard Sharpe, 30-Nov-2008

This is the SCST Local driver. Its function is to allow you to access devices
that are exported via SCST directly on the same Linux system that they are
exported from.

No assumptions are made in the code about the device types on the target, so
any device handlers that you load in SCST should be visible, including tapes
and so forth.

You can freely use any sg, sd, st, etc. devices imported from target,
except the following: you can't mount file systems or put swap on them
for all dev handlers, except BLOCKIO and pass-through, because it can
lead to recursive memory allocation deadlock. This is a limitation of
Linux memory/cache manager. See SCST README file for details. For
BLOCKIO and pass-through dev handlers there's no such limitation, so you
can freely mount file systems over them.

To build, simply issue 'make' in the scst_local directory.

Try 'modinfo scst_local' for a listing of module parameters so far.

Here is how I have used it so far:

1. Load up scst:

  modprobe scst
  modprobe scst_vdisk

2. Create a virtual disk (or your own device handler):

  dd if=/dev/zero of=/some/path/vdisk1.img bs=16384 count=1000000
  echo "add_device vm_disk1 filename=/some/path/vdisk1.img" >/sys/kernel/scst_tgt/handlers/vdisk_fileio/mgmt

3. Load the scst_local driver:

  insmod scst_local
  echo "add vm_disk1 0" >/sys/kernel/scst_tgt/targets/scst_local/scst_local_tgt/luns/mgmt

4. Check what you have

   cat /proc/scsi/scsi
  Attached devices:
  Host: scsi0 Channel: 00 Id: 00 Lun: 00
    Vendor: ATA      Model: ST9320320AS      Rev: 0303
    Type:   Direct-Access                    ANSI  SCSI revision: 05
  Host: scsi4 Channel: 00 Id: 00 Lun: 00
    Vendor: TSSTcorp Model: CD/DVDW TS-L632D Rev: TO04
    Type:   CD-ROM                           ANSI  SCSI revision: 05
  Host: scsi7 Channel: 00 Id: 00 Lun: 00
    Vendor: SCST_FIO Model: vm_disk1         Rev:  200
    Type:   Direct-Access                    ANSI  SCSI revision: 04

Or instead of manually "add_device" in (2) and step (3) write a
scstadmin config:

HANDLER vdisk_fileio {
        DEVICE vm_disk1 {
        	filename /some/path/vdisk1.img
        }
}

TARGET_DRIVER scst_local {
	TARGET scst_local_tgt {
		LUN 0 vm_disk1
	}
}

then:

  insmod scst_local
  scstadmin -config conf_file.cfg

More advanced examples:

For (3) you can:

  insmod scst_local add_default_tgt=0
  echo "add_target scst_local_tgt session_name=scst_local_host" >/sys/kernel/scst_tgt/targets/scst_local//mgmt
  echo "add vm_disk1 0" >/sys/kernel/scst_tgt/targets/scst_local/scst_local_tgt/luns/mgmt

Scst_local module's parameter add_default_tgt disables creation of
default target "scst_local_tgt" and session "scst_local_host", so you
needed to create it manually.

There can be any number of targets and sessions created. Each SCST
session corresponds to SCSI host. You can change which LUNs assigned to
each session by using SCST access control. This mode is intended for
user space target drivers (see below).

Alternatively, you can write an scstadmin's config file conf_file.cfg:

HANDLER vdisk_fileio {
        DEVICE vm_disk1 {
        	filename /some/path/vdisk1.img
        }
}

TARGET_DRIVER scst_local {
	TARGET scst_local_tgt {
		session_name scst_local_host

		LUN 0 vm_disk1
	}
}

then:

  insmod scst_local add_default_tgt=0
  scstadmin -config conf_file.cfg

NOTE! Although scstadmin allows to create scst_local's sessions using
"session_name" expression, it doesn't save existing sessions during
writing config file by "write_config" command. If you need this
functionality, feel free to send a request for it in SCST development
mailing list.

5. Have fun.

Some of this was coded while in Santa Clara, some in Bangalore, and some in
Hyderabad. Noe doubt some will be coded on the way back to Santa Clara.

The code still has bugs, so if you encounter any, email me the fixes at:

   realrichardsharpe@gmail.com

I am thinking of renaming this to something more interesting.


Sysfs interface
===============

See SCST's README for a common SCST sysfs description.

Root of this driver is /sys/kernel/scst_tgt/targets/scst_local. It has
the following additional entry:

 - stats - read-only attribute with some statistical information.

Each target subdirectory contains the following additional entries:

 - phys_transport_version - contains and allows to change physical
   transport version descriptor. It determines by which physical
   interface this target will look like. See SPC for more details. By
   default, it is not defined (0).

 - scsi_transport_version - contains and allows to change SCSI
   transport version descriptor. It determines by which SCSI
   transport this target will look like. See SPC for more details. By
   default, it is SAS.

Each session subdirectory contains the following additional entries:

 - transport_id - contains this host's TransportID. This TransportID
   used to identify initiator in Persisten Reservation commands. If you
   change scsi_transport_version for a target, make sure you set for all
   its sessions correct TransportID. See SPC for more details.

 - host - links to the corresponding SCSI host. Using it you can find
   local sg/bsg/sd/etc. devices of this session. For instance, this
   links points out to host12, so you can find your sg devices by:

$ lsscsi -g|grep "\[12:"
[12:0:0:0]   disk    SCST_FIO rd1               200  /dev/sdc  /dev/sg2
[12:0:0:1]   disk    SCST_FIO nullio            200  /dev/sdd  /dev/sg3

They are /dev/sg2 and /dev/sg3.

The following management commands available via /sys/kernel/scst_tgt/targets/scst_local/mgmt:

 - add_target target_name [session_name=sess_name; [session_name=sess_name1;] [...]] -
   creates a target with optionally one or more sessions.

 - del_target target_name - deletes a target.

 - add_session target_name session_name - adds to target target_name
   session (SCSI host) with name session_name.

 - del_session target_name session_name - deletes session session_name
    from target target_name.


Note on performance
===================

Although this driver implemented in the most performance effective way,
including zero-copy passing data between SCSI/block subsystems and SCST,
in many cases it is NOT suited to measure performance as a NULL link.
For example, it is not suited for max IOPS measurements. This is because
for such cases not performance of the link between the target and
initiator is the bottleneck, but CPU or memory speed on the target or
initiator. For scst_local you have both initiator and target on the same
system, which means each your initiator and target are much less
CPU/memory powerful.


User space target drivers
=========================

Scst_local can be used to write full featured SCST target drivers in
user space:

1. For each SCSI target a user space target driver should create an
   scst_local's target using "add_target" command.

2. Then the user space target driver should, if needed, set its SCSI and
   physical transport version descriptors using attributes
   scsi_transport_version and phys_transport_version correspondingly in
   /sys/kernel/scst_tgt/targets/scst_local/target_name directory.

3. For incoming session (I_T nexus) from an initiator the user space
   target driver should create scst_local's session using "add_session"
   command.

4. Then, if needed, the user space target driver should set TransportID
   for this session (I_T nexus) using attribute
   /sys/kernel/scst_tgt/targets/scst_local/target_name/sessions/session_name/transport_id

5. Then the user space target driver should find out sg/bsg devices for
   the LUNs the created session has using link
   /sys/kernel/scst_tgt/targets/scst_local/target_name/sessions/session_name/host
   as described above.

6. Then the user space target driver can start serving the initiator using
   found sg/bsg devices.

For other connected initiators steps 3-6 should be repeated.


Compilation options
===================

There are the following compilation options, that could be commented
in/out in Makefile:

 - CONFIG_SCST_LOCAL_DIRECT_PROCESSING - by default, when this option
   is not defined, scst_local reschedules all commands for processing in
   one of the SCST threads. If this option is defined, scst_local tries
   to not do it, if possible (sometimes queuecommand() called under
   various locks held), but instead process them in the submitter's
   context. This is to increase performance, but as on 2.6.37 and below
   Linux block layer doesn't work with such kind of reentrance, hence
   this option disabled by default. Note! At the moment in
   scst_estimate_context*() returning DIRECT contexts disabled, so this
   option doesn't have any real effect.


Change log
==========

V0.1 24-Sep-2008 (Hyderabad) Initial coding, pretty chatty and messy,
                             but worked.

V0.2 25-Sep-2008 (Hong Kong) Cleaned up the code a lot, reduced the log
			     chatter, fixed a bug where multiple LUNs did not
			     work. Also, added logging control. Tested with
			     five virtual disks. They all came up as /dev/sdb
			     through /dev/sdf and I could dd to them. Also
			     fixed a bug preventing multiple adapters.

V0.3 26-Sep-2008 (Santa Clara) Added back a copyright plus cleaned up some
			       unused functions and structures.

V0.4 5-Oct-2008 (Santa Clara) Changed name to scst_local as suggested, cleaned
			      up some unused variables (made them used) and
			      change allocation to a kmem_cache pool.

V0.5 5-Oct-2008 (Santa Clara) Added mgmt commands to handle dev reset and
			      aborts. Not sure if aborts works. Also corrected
			      the version info and renamed readme to README.

V0.6 7-Oct-2008 (Santa Clara) Removed some redundant code and made some
			      changes suggested by Vladislav.

V0.7 11-Oct-2008 (Santa Clara) Moved into the scst tree. Cleaned up some
			       unused functions, used TRACE macros etc.

V0.9 30-Nov-2008 (Mtn View) Cleaned up an additional problem with symbols not
			    being defined in older version of the kernel. Also
			    fixed some English and cleaned up this doc.

V1.0 10-Sep-2010 (Moscow)   Sysfs management added. Reviewed and cleaned up.

V2.1                        Update for kernels up to 3.0. Cleanups.