mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-14 09:11:27 +00:00
svn+ssh://yanb123@svn.code.sf.net/p/scst/svn/trunk
........
r5322 | vlnb | 2014-03-05 05:27:21 +0200 (Wed, 05 Mar 2014) | 13 lines
scst_vdisk: Make vdisk_nullio size configurable
Keep the default size of vdisk_nullio devices at VDISK_NULLIO_SIZE. Add
a sysfs attribute 'size' which is the size of a vdisk device in
bytes. Make the size of vdisk_nullio devices configurable. Accept
"size" and "size_mb" as creation parameters for vdisk_nullio
devices. Generate a CAPACITY DATA HAS CHANGED unit attention after size
changes. Refuse any attempt to change the size into a number that is
not a multiple of the block size.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5323 | bvassche | 2014-03-06 09:29:00 +0200 (Thu, 06 Mar 2014) | 1 line
scst_vdisk: Avoid that smatch complains about unreachable code
........
r5324 | vlnb | 2014-03-07 06:02:39 +0200 (Fri, 07 Mar 2014) | 27 lines
PERSISTENT RESERVE IN: Suppress a kernel warning for small output buffer sizes
This patch suppresses the following error message and kernel warning:
scst: ***ERROR***: Too big response data len 24 (max 8), limiting it to the max (dev iis)
Call Trace:
[<ffffffff818b1193>] ? dump_stack+0x41/0x56
[<ffffffffa01c1a8f>] ? scst_set_resp_data_len+0x82/0xb1 [scst]
[<ffffffffa01ca80f>] ? scst_pr_read_reservation+0xbf/0xc4 [scst]
[<ffffffffa01b707b>] ? scst_persistent_reserve_in_local+0x140/0x1ce [scst]
[<ffffffffa01b7cee>] ? scst_exec_check_blocking+0x57/0xf1 [scst]
[<ffffffffa01b85f4>] ? scst_process_active_cmd+0x86c/0x136f [scst]
[<ffffffffa01b913c>] ? scst_do_job_active+0x45/0x5b [scst]
[<ffffffffa01b939c>] ? scst_cmd_thread+0x218/0x2b7 [scst]
[<ffffffff8105292a>] ? wake_up_bit+0x23/0x23
[<ffffffffa01b9184>] ? scst_cmd_tasklet+0x32/0x32 [scst]
[<ffffffff81052355>] ? kthread_freezable_should_stop+0x51/0x51
[<ffffffffa01b9184>] ? scst_cmd_tasklet+0x32/0x32 [scst]
[<ffffffff81052400>] ? kthread+0xab/0xb3
[<ffffffff81052355>] ? kthread_freezable_should_stop+0x51/0x51
[<ffffffff818b4e3c>] ? ret_from_fork+0x7c/0xb0
[<ffffffff81052355>] ? kthread_freezable_should_stop+0x51/0x51
Reported-by: Roman Bogdanov <bogdanovr@gmail.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5325 | bvassche | 2014-03-08 15:30:29 +0200 (Sat, 08 Mar 2014) | 1 line
nightly build: Update kernel versions
........
r5326 | vlnb | 2014-03-13 05:50:37 +0200 (Thu, 13 Mar 2014) | 3 lines
Update link to Gentoo HOWTO from Jurie Botha
........
r5329 | vlnb | 2014-03-15 03:38:06 +0200 (Sat, 15 Mar 2014) | 3 lines
Cleanup
........
r5330 | vlnb | 2014-03-15 03:38:37 +0200 (Sat, 15 Mar 2014) | 3 lines
Implement REPORT SUPPORTED TASK MANAGEMENT FUNCTIONS command
........
r5331 | vlnb | 2014-03-15 03:40:57 +0200 (Sat, 15 Mar 2014) | 8 lines
scst_vdisk: Remove an unused parameter from vdisk_fsync*()
The "struct vdisk_cmd_params *p" parameter is neither used by vdisk_fsync(),
vdisk_fsync_blockio() nor by vdisk_fsync_fileio() so remove it.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5332 | vlnb | 2014-03-15 03:42:06 +0200 (Sat, 15 Mar 2014) | 8 lines
vdisk_blockio: Change default vendor name back to "SCST_BIO"
In r5316 the default vendor name for vdisk_blockio devices was changed
into "SCST_FIO". Change this back into "SCST_BIO".
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5333 | vlnb | 2014-03-15 03:44:35 +0200 (Sat, 15 Mar 2014) | 8 lines
vdisk_blockio: Add VERIFY implementation
There is already an implementation of the VERIFY command for vdisk_fileio
devices. Add an implementation for vdisk_blockio devices.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5334 | vlnb | 2014-03-15 04:01:17 +0200 (Sat, 15 Mar 2014) | 8 lines
scst_vdisk: Implement COMPARE AND WRITE
Ensure that COMPARE AND WRITE is executed atomically by serializing
all COMPARE AND WRITE commands per device (SCST_SERIALIZED).
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5335 | vlnb | 2014-03-15 04:09:17 +0200 (Sat, 15 Mar 2014) | 5 lines
Fix URL to SCST website
Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
........
r5336 | vlnb | 2014-03-15 04:13:58 +0200 (Sat, 15 Mar 2014) | 3 lines
Cleanup
........
r5337 | bvassche | 2014-03-15 08:47:26 +0200 (Sat, 15 Mar 2014) | 1 line
scripts/kernel-functions: Kernel 3.13.6 build fix
........
r5338 | bvassche | 2014-03-16 15:38:50 +0200 (Sun, 16 Mar 2014) | 1 line
srpt: Minor buid process terminology change
........
r5339 | bvassche | 2014-03-18 17:35:13 +0200 (Tue, 18 Mar 2014) | 1 line
ib_srpt: Avoid that session logout hangs sporadically
........
r5340 | vlnb | 2014-03-19 06:28:46 +0200 (Wed, 19 Mar 2014) | 8 lines
scst/README: Show how to read SCST sysfs attributes
Make the behavior of SCST sysfs attributes more clear by adding
examples in scst/README of code for reading and writing these attributes.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5344 | bvassche | 2014-03-20 17:13:50 +0200 (Thu, 20 Mar 2014) | 1 line
ib_srpt: Simplify srpt_handle_cmd()
........
r5345 | bvassche | 2014-03-20 17:14:45 +0200 (Thu, 20 Mar 2014) | 5 lines
ib_srpt: Micro-optimize I/O context state manipulation
All ioctx->state manipulations are serialized per command so it is
not necessary to use locking to protect these manipulations.
........
r5346 | bvassche | 2014-03-20 17:15:54 +0200 (Thu, 20 Mar 2014) | 8 lines
ib_srpt: Handle GID change events properly
The mlx4_core driver generates a GID change event after a port has been
changed from IB into Ethernet mode. Avoid that this causes the following
error message to appear in the system log:
ib_srpt: ***ERROR***: received unrecognized IB event 18
........
r5347 | bvassche | 2014-03-20 17:16:27 +0200 (Thu, 20 Mar 2014) | 1 line
ib_srpt/Makefile: Add kerneldoc target
........
r5348 | bvassche | 2014-03-20 17:17:04 +0200 (Thu, 20 Mar 2014) | 1 line
ib_srpt: Fix an error reported by the kerneldoc tool
........
r5349 | bvassche | 2014-03-20 17:18:06 +0200 (Thu, 20 Mar 2014) | 5 lines
ib_srpt: Avoid that cmd_wait_list processing triggers command reordering
Although harmless for SCSI commands with SIMPLE ordering, avoid that commands
received before RTU can get reordered.
........
r5350 | bvassche | 2014-03-20 17:18:38 +0200 (Thu, 20 Mar 2014) | 2 lines
ib_srpt: Micro-optimize SRP_CMD parsing
........
r5351 | bvassche | 2014-03-20 17:19:05 +0200 (Thu, 20 Mar 2014) | 1 line
ib_srpt: Sync information unit memory only once
........
r5352 | bvassche | 2014-03-20 17:19:34 +0200 (Thu, 20 Mar 2014) | 2 lines
ib_srpt: Introduce a temporary variable in srpt_handle_new_iu()
........
r5353 | bvassche | 2014-03-20 17:20:55 +0200 (Thu, 20 Mar 2014) | 2 lines
ib_srpt: Micro-optimize polling
........
r5354 | bvassche | 2014-03-20 17:22:19 +0200 (Thu, 20 Mar 2014) | 5 lines
ib_srpt: Rework multi-channel support
Store initiator and target port ID's once per nexus instead of in each
channel data structure.
........
r5355 | bvassche | 2014-03-20 17:23:16 +0200 (Thu, 20 Mar 2014) | 2 lines
ib_srpt: Simplify channel state management code
........
r5356 | bvassche | 2014-03-20 17:24:18 +0200 (Thu, 20 Mar 2014) | 5 lines
ib_srpt: Defer destroying the QP until the TimeWait state has been left
This is necessary to avoid that a login gets rejected due to reusing a
queue pair number that has not yet been freed by the target side.
........
r5357 | bvassche | 2014-03-20 17:25:34 +0200 (Thu, 20 Mar 2014) | 5 lines
ib_srpt: Rework waiting for last WQE
After having changed the queue pair state into "error", queue an additional
work request instead of waiting for the last WQE event.
........
r5358 | bvassche | 2014-03-20 17:26:48 +0200 (Thu, 20 Mar 2014) | 1 line
srpt/session-management.txt: Document how sessions are managed by the ib_srpt driver
........
r5359 | bvassche | 2014-03-20 18:10:19 +0200 (Thu, 20 Mar 2014) | 1 line
scst_const.h: Make COMPARE_AND_WRITE definition available for kernel versions 3.6..3.11
........
r5360 | vlnb | 2014-03-21 03:58:13 +0200 (Fri, 21 Mar 2014) | 3 lines
In VERIFY commands BYTCHK 1x is not supported (yet)
........
r5361 | bvassche | 2014-03-21 18:29:26 +0200 (Fri, 21 Mar 2014) | 1 line
srpt/Makefile: Avoid that the build process depends on source control tools
........
r5362 | vlnb | 2014-03-22 01:12:42 +0200 (Sat, 22 Mar 2014) | 3 lines
Fix error recovery of internal commands
........
r5363 | bvassche | 2014-03-24 13:53:00 +0200 (Mon, 24 Mar 2014) | 1 line
ib_srpt: Clarify a kernel-doc comment
........
r5364 | bvassche | 2014-03-24 13:55:56 +0200 (Mon, 24 Mar 2014) | 1 line
ib_srpt: Add newline at the end of kernel warning statements
........
r5365 | bvassche | 2014-03-24 13:57:39 +0200 (Mon, 24 Mar 2014) | 5 lines
ib_srpt: Change the severity level of a log message
Make sure that target port state changes get logged even with
debugging disabled.
........
r5366 | bvassche | 2014-03-24 13:59:27 +0200 (Mon, 24 Mar 2014) | 5 lines
ib_srpt: Clean up srpt_destroy_ch_ib()
All callers guarantee that the completion queue is empty so it is
not necessary to invoke ib_poll_cq() from inside this function.
........
r5367 | bvassche | 2014-03-24 14:01:07 +0200 (Mon, 24 Mar 2014) | 5 lines
ib_srpt: Micro-optimize srpt_adjust_srq_wr_avail()
The overhead of atomic_add_return() is lower than that of a
spin_lock() / spin_unlock() pair, hence switch to the former.
........
r5368 | bvassche | 2014-03-24 14:03:09 +0200 (Mon, 24 Mar 2014) | 20 lines
ib_srpt: Fix a kernel warning
Avoid that the following (very rare) kernel warning is reported
when an ib_srpt target port is disabled while I/O is ongoing:
WARNING: CPU: 3 PID: 12259 at srpt/src/ib_srpt.c:3334 srpt_xmit_response+0x165/0x300 [ib_srpt]()
Unexpected command state 6
Call Trace:
[<ffffffff814a15dc>] dump_stack+0x4e/0x7a
[<ffffffff8104bc5d>] warn_slowpath_common+0x7d/0xa0
[<ffffffff8104bccc>] warn_slowpath_fmt+0x4c/0x50
[<ffffffffa0771525>] srpt_xmit_response+0x165/0x300 [ib_srpt]
[<ffffffffa082aacc>] scst_xmit_response+0xbc/0x560 [scst]
[<ffffffffa083123d>] scst_process_active_cmd+0x29d/0x7b0 [scst]
[<ffffffffa0832bd9>] scst_do_job_active+0x89/0x1a0 [scst]
[<ffffffffa0832e4f>] scst_cmd_thread+0x15f/0x350 [scst]
[<ffffffff810766cd>] kthread+0xed/0x110
[<ffffffff814b312c>] ret_from_fork+0x7c/0xb0
---[ end trace 591f7af7d006fc0e ]---
........
r5369 | bvassche | 2014-03-24 14:04:44 +0200 (Mon, 24 Mar 2014) | 5 lines
ib_srpt: Add a kernel warning
Invoking srpt_zerolength_write() before the queue pair has reached
the error state is a bug, so complain loudly if that happens.
........
r5370 | bvassche | 2014-03-24 14:07:43 +0200 (Mon, 24 Mar 2014) | 7 lines
ib_srpt: Avoid waiting for missing error completions
Apparently with mlx4 firmware up to and including 2.30.8000 it is not
guaranteed that for a QP associated with an SRQ error completions are
generated for all pending work requests. Avoid triggering
srpt_pending_cmd_timeout() for missing error completions.
........
r5371 | bvassche | 2014-03-25 18:19:00 +0200 (Tue, 25 Mar 2014) | 1 line
nightly build: Update kernel versions
........
r5382 | vlnb | 2014-03-26 04:31:52 +0200 (Wed, 26 Mar 2014) | 6 lines
Black hole functionality added
Scst_mutex intentially used directly in the sysfs handler, because
comming sysfs improvements will allow that.
........
r5383 | vlnb | 2014-03-26 05:18:03 +0200 (Wed, 26 Mar 2014) | 5 lines
documentation: Document SCST_SERIALIZED and SCST_STRICTLY_SERIALIZED
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5384 | vlnb | 2014-03-26 05:18:36 +0200 (Wed, 26 Mar 2014) | 3 lines
Cleanup
........
r5385 | vlnb | 2014-03-26 05:20:04 +0200 (Wed, 26 Mar 2014) | 9 lines
scst_local: Remove two superfluous tests
The to_scst_lcl_sess() macro is based on container_of() and hence never
returns NULL. Hence remove the two tests that compare the result of that
macro against NULL.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5386 | vlnb | 2014-03-26 05:21:25 +0200 (Wed, 26 Mar 2014) | 7 lines
iscsi-scst: Introduce ARRAY_SIZE()
This patch does not change any functionality.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5387 | vlnb | 2014-03-26 05:22:16 +0200 (Wed, 26 Mar 2014) | 8 lines
scst: Clarify a comment
The comment above scst_nexus_loss() is somewhat confusing so change
it into something that is more clear.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5388 | vlnb | 2014-03-26 05:23:57 +0200 (Wed, 26 Mar 2014) | 9 lines
scst_vdisk: Fix READ CAPACITY(10)
SBC-2 defines the LBA as a 32-bit field that starts at offset 2 and
not as a 64-bit field.
Reported-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5389 | bvassche | 2014-03-26 13:56:13 +0200 (Wed, 26 Mar 2014) | 4 lines
ib_srpt: Clean up srpt_handle_rdma_comp()
This patch does not change any functionality.
........
r5390 | bvassche | 2014-03-26 13:56:59 +0200 (Wed, 26 Mar 2014) | 4 lines
ib_srpt: Clean up srpt_handle_send_err_comp()
This patch does not change any functionality.
........
r5391 | bvassche | 2014-03-26 13:58:25 +0200 (Wed, 26 Mar 2014) | 4 lines
ib_srpt: Clean up srpt_handle_rdma_err_comp()
This patch does not change any functionality.
........
r5392 | bvassche | 2014-03-26 13:59:37 +0200 (Wed, 26 Mar 2014) | 5 lines
ib_srpt: Suppress superfluous error messages
Only complain about a missing completion for I/O contexts that are
in a state where the ib_srpt driver is waiting for the HCA.
........
r5393 | bvassche | 2014-03-26 14:00:43 +0200 (Wed, 26 Mar 2014) | 5 lines
ib_srpt: Make srpt_abort_cmd() state checks more strict
Complain if srpt_abort_cmd() is called for an I/O context that is
being processed by SCST and not by the HCA.
........
r5394 | vlnb | 2014-03-27 00:16:16 +0200 (Thu, 27 Mar 2014) | 3 lines
Cosmetics
........
r5395 | vlnb | 2014-03-27 01:51:36 +0200 (Thu, 27 Mar 2014) | 3 lines
Reimplement dropping of TM requests in a more reliable manner
........
r5396 | vlnb | 2014-03-27 03:57:08 +0200 (Thu, 27 Mar 2014) | 3 lines
Possibility to specify SCSI target device name added
........
r5397 | bvassche | 2014-03-27 10:27:45 +0200 (Thu, 27 Mar 2014) | 6 lines
Fix two checkpatch complaints about whitespace
Avoid that checkpatch reports the following error message:
ERROR: "(foo*)" should be "(foo *)"
........
r5398 | bvassche | 2014-03-27 10:34:27 +0200 (Thu, 27 Mar 2014) | 6 lines
Avoid that checkpatch complains that return is not a function
Avoid that checkpatch reports the following error message:
ERROR: return is not a function, parentheses are not required
........
r5399 | bvassche | 2014-03-27 10:39:53 +0200 (Thu, 27 Mar 2014) | 1 line
scripts/generate-kernel-patch: Fix for kernel versions 3.7, 3.10, 3.12 and 3.13
........
r5400 | vlnb | 2014-03-29 04:07:22 +0300 (Sat, 29 Mar 2014) | 3 lines
Cleanup
........
r5401 | bvassche | 2014-04-01 20:46:36 +0300 (Tue, 01 Apr 2014) | 1 line
vdisk_blockio: Temporarily disable COMPARE AND WRITE support
........
r5402 | bvassche | 2014-04-02 00:05:31 +0300 (Wed, 02 Apr 2014) | 1 line
vdisk_blockio: Fix the (recently enabled) VERIFY command
........
r5403 | bvassche | 2014-04-03 18:58:16 +0300 (Thu, 03 Apr 2014) | 1 line
ib_srpt: RHEL 6.5 build fix
........
r5404 | vlnb | 2014-04-04 03:57:30 +0300 (Fri, 04 Apr 2014) | 3 lines
Fix typo in scst_report_supported_tm_fns() reported by Steve Magnani <steve.magnani@digidescorp.com>
........
r5405 | bvassche | 2014-04-04 07:38:33 +0300 (Fri, 04 Apr 2014) | 1 line
scripts/specialize-patch: Handle numbers surrounded by parentheses properly
........
r5406 | bvassche | 2014-04-04 08:50:52 +0300 (Fri, 04 Apr 2014) | 1 line
scripts/specialize-patch: Rework r5405
........
r5407 | bvassche | 2014-04-04 08:56:25 +0300 (Fri, 04 Apr 2014) | 1 line
nightly build: Update kernel versions
........
git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/iser@5408 d57e44dd-8a1f-0410-8b47-8ef2f437770f
607 lines
18 KiB
Awk
Executable File
607 lines
18 KiB
Awk
Executable File
#!/usr/bin/gawk -f
|
|
|
|
############################################################################
|
|
#
|
|
# Script that removes preprocessor checks on the kernel version. Somewhat
|
|
# related to the v4l-scripts-gentree.pl script.
|
|
#
|
|
# Copyright (C) 2008-2009 Bart Van Assche <bvanassche@acm.org>
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# as published by the Free Software Foundation, version 2
|
|
# of the License.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
############################################################################
|
|
|
|
# Usage:
|
|
# * Specify the kernel version code as follows: -v kernel_version=...
|
|
# * Provide the patch to be processed to stdin.
|
|
#
|
|
# The output of this script will be a patch that is specialized for the
|
|
# specified kernel version.
|
|
|
|
|
|
# Convert a kernel version in the x.y.z format into numeric form, just like
|
|
# the KERNEL_VERSION() macro.
|
|
|
|
function version_code(kver, array) {
|
|
if (!match(kver, "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$", array))
|
|
match(kver, "^([0-9]+)\\.([0-9]+)$", array)
|
|
return 65536*array[1] + 256*array[2] + array[3]
|
|
}
|
|
|
|
|
|
# Evaluate a preprocessor statement via repeated substitutions.
|
|
# Mathematicians call this algorithm 'term rewriting'.
|
|
# Note: the order in which the substitutions appear below is important --
|
|
# it is the same order as the order of operators in C.
|
|
|
|
function evaluate(stmnt, pattern, arg, op, result) {
|
|
|
|
if (debug)
|
|
printf "/* debug specialize-patch: (a) %s */\n", stmnt
|
|
|
|
# Remove C-style comments.
|
|
gsub("[[:blank:]]*\\/\\*[^*]*\\*\\/[[:blank:]]*", "", stmnt)
|
|
|
|
# Remove the spaces before the #-sign.
|
|
gsub("^+[[:blank:]]*#[[:blank:]]*", "+#", stmnt)
|
|
|
|
if (match(stmnt, "^+#ifdef (.*)$", arg))
|
|
{
|
|
stmnt = "+#if defined(" arg[1] ")"
|
|
}
|
|
|
|
if (match(stmnt, "^+#ifndef (.*)$", arg))
|
|
{
|
|
stmnt = "+#if !defined(" arg[1] ")"
|
|
}
|
|
|
|
gsub("LINUX_VERSION_CODE", LINUX_VERSION_CODE, stmnt)
|
|
|
|
pattern="KERNEL_VERSION\\([[:blank:]]*([0-9]+)[[:blank:]]*,[[:blank:]]*([0-9]+)[[:blank:]]*,[[:blank:]]*([0-9]+)[[:blank:]]*\\)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
sub(pattern, op[1] * 65536 + op[2] * 256 + op[3], stmnt)
|
|
}
|
|
|
|
gsub("defined\\(INSIDE_KERNEL_TREE\\)", "1", stmnt)
|
|
|
|
gsub("defined\\(BACKPORT_LINUX_WORKQUEUE_TO_2_6_19\\)", "0", stmnt)
|
|
|
|
gsub("defined\\(CONFIG_SUSE_KERNEL\\)", "0", stmnt)
|
|
|
|
if (RHEL_MAJOR == "")
|
|
{
|
|
gsub("defined\\(RHEL_MAJOR\\)", "0", stmnt)
|
|
gsub("RHEL_MAJOR", "", stmnt)
|
|
}
|
|
else
|
|
{
|
|
gsub("defined\\(RHEL_MAJOR\\)", "1", stmnt)
|
|
gsub("RHEL_MAJOR", RHEL_MAJOR, stmnt)
|
|
}
|
|
|
|
if (RHEL_MINOR == "")
|
|
{
|
|
gsub("defined\\(RHEL_MINOR\\)", "0", stmnt)
|
|
gsub("RHEL_MINOR", "0", stmnt)
|
|
}
|
|
else
|
|
{
|
|
gsub("defined\\(RHEL_MINOR\\)", "1", stmnt)
|
|
gsub("RHEL_MINOR", RHEL_MINOR, stmnt)
|
|
}
|
|
|
|
gsub("defined\\(RHEL_RELEASE_VERSION\\)", "1", stmnt)
|
|
if (RHEL_MAJOR == "" || RHEL_MINOR == "")
|
|
{
|
|
gsub("defined\\(RHEL_RELEASE_CODE\\)", "0", stmnt)
|
|
gsub("RHEL_RELEASE_CODE", "", stmnt)
|
|
gsub("RHEL_RELEASE_VERSION\\([^,)]*,[ ]*[^,)]*\\)", "0", stmnt)
|
|
}
|
|
else
|
|
{
|
|
gsub("defined\\(RHEL_RELEASE_CODE\\)", "1", stmnt)
|
|
gsub("RHEL_RELEASE_CODE", RHEL_MAJOR * 256 + RHEL_MINOR, stmnt)
|
|
stmnt = gensub("RHEL_RELEASE_VERSION\\(([^,)]*),[ ]*([^,)]*)\\)",
|
|
"(\\1) * 256 + (\\2)", "g", stmnt)
|
|
}
|
|
|
|
if (SCSI_EXEC_REQ_FIFO_DEFINED != "")
|
|
{
|
|
gsub("defined[[:blank:]]+SCSI_EXEC_REQ_FIFO_DEFINED",
|
|
SCSI_EXEC_REQ_FIFO_DEFINED, stmnt)
|
|
gsub("defined[[:blank:]]*\\([[:blank:]]*SCSI_EXEC_REQ_FIFO_DEFINED[[:blank:]]*\\)",
|
|
SCSI_EXEC_REQ_FIFO_DEFINED, stmnt)
|
|
}
|
|
|
|
if (SCST_IO_CONTEXT != "")
|
|
{
|
|
gsub("defined[[:blank:]]+SCST_IO_CONTEXT", SCST_IO_CONTEXT, stmnt)
|
|
gsub("defined[[:blank:]]*\\([[:blank:]]*SCST_IO_CONTEXT[[:blank:]]*\\)", SCST_IO_CONTEXT, stmnt)
|
|
}
|
|
|
|
if (generating_upstream_patch_defined)
|
|
{
|
|
gsub("defined[[:blank:]]+GENERATING_UPSTREAM_PATCH", 1, stmnt)
|
|
gsub("defined[[:blank:]]*\\([[:blank:]]*GENERATING_UPSTREAM_PATCH[[:blank:]]*\\)", 1, stmnt)
|
|
}
|
|
|
|
if (config_tcp_zero_copy_transfer_completion_notification_undefined)
|
|
{
|
|
gsub("defined[[:blank:]]+CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION", 0, stmnt)
|
|
gsub("defined[[:blank:]]*\\([[:blank:]]*CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION[[:blank:]]*\\)", 0, stmnt)
|
|
}
|
|
|
|
gsub("defined[[:blank:]]+CONFIG_SCST_PROC", !config_scst_proc_undefined, stmnt)
|
|
gsub("defined[[:blank:]]*\\([[:blank:]]*CONFIG_SCST_PROC[[:blank:]]*\\)", !config_scst_proc_undefined,
|
|
stmnt)
|
|
|
|
if (debug)
|
|
printf "/* debug specialize-patch: (b) %s */\n", stmnt
|
|
|
|
do
|
|
{
|
|
last_stmnt = stmnt
|
|
|
|
pattern = "![[:blank:]]*(-*[0-9]+)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
sub(pattern, op[1] == 0, stmnt)
|
|
}
|
|
|
|
pattern = "![[:blank:]]*\\([[:blank:]]*(-*[0-9]+)[[:blank:]]*\\)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
sub(pattern, op[1] == 0, stmnt)
|
|
}
|
|
|
|
pattern="(-*[0-9]+)[[:blank:]]*(\\*|/)[[:blank:]]*(-*[0-9]+)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
result="error"
|
|
if (op[2] == "*") result = op[1] * op[3]
|
|
else if (op[2] == "/" && op[3] != 0) result = op[1] / op[3]
|
|
sub(pattern, result, stmnt)
|
|
}
|
|
|
|
pattern="(-*[0-9]+)[[:blank:]]*(\\+|-)[[:blank:]]*(-*[0-9]+)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
result="error"
|
|
if (op[2] == "+") result = op[1] + op[3]
|
|
else if (op[2] == "-") result = op[1] - op[3]
|
|
sub(pattern, result, stmnt)
|
|
}
|
|
|
|
pattern="(-*[0-9]+)[[:blank:]]*(<<|>>)[[:blank:]]*(-*[0-9]+)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
result="error"
|
|
if (op[2] == "<<") result = int(op[1] * (2**op[3]))
|
|
else if (op[2] == ">>") result = int(op[1] / (2**op[3]))
|
|
sub(pattern, result, stmnt)
|
|
}
|
|
|
|
pattern="(-*[0-9]+)[[:blank:]]*(<|<=|>|>=|==|!=)[[:blank:]]*(-*[0-9]+)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
result="error"
|
|
if (op[2] == "<" ) result = op[1] < op[3]
|
|
else if (op[2] == "<=") result = op[1] <= op[3]
|
|
else if (op[2] == ">" ) result = op[1] > op[3]
|
|
else if (op[2] == ">=") result = op[1] >= op[3]
|
|
else if (op[2] == "==") result = op[1] == op[3]
|
|
else if (op[2] == "!=") result = op[1] != op[3]
|
|
sub(pattern, result, stmnt)
|
|
}
|
|
|
|
pattern="(-*[0-9]+)[[:blank:]]*\\&\\&[[:blank:]]*\\([[:blank:]]*(-*[0-9]+)[[:blank:]]*\\)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
sub(pattern, (op[1] != 0) && (op[2] != 0), stmnt)
|
|
}
|
|
|
|
pattern="(-*[0-9]+)[[:blank:]]*\\&\\&[[:blank:]]*(-*[0-9]+)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
sub(pattern, (op[1] != 0) && (op[2] != 0), stmnt)
|
|
}
|
|
|
|
pattern="^+#if[[:blank:]]*([01])[[:blank:]]*\\&\\&[[:blank:]]*(!*[[:blank:]]*defined[[:blank:]]*\\([[:blank:]]*[A-Za-z_]*[[:blank:]]*\\))$"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
stmnt = "+#if " (op[1] != 0 ? op[2] : op[1])
|
|
}
|
|
|
|
pattern="^+#if[[:blank:]]*(!*[[:blank:]]*defined[[:blank:]]*\\([[:blank:]]*[A-Za-z_]*[[:blank:]]*\\))\\&\\&[[:blank:]]*([01])[[:blank:]]*$"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
stmnt = "+#if " (op[2] != 0 ? op[1] : op[2])
|
|
}
|
|
|
|
pattern="^+#if[[:blank:]]*(!*[[:blank:]]*[A-Za-z_]*[[:blank:]]*)\\&\\&[[:blank:]]*([01])[[:blank:]]*$"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
stmnt = "+#if " (op[2] != 0 ? op[1] : op[2])
|
|
}
|
|
|
|
pattern="(-*[0-9]+)[[:blank:]]*\\|\\|[[:blank:]]*(-*[0-9]+)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
sub(pattern, (op[1] != 0) || (op[2] != 0), stmnt)
|
|
}
|
|
|
|
pattern="^+#if[[:blank:]]*([01])[[:blank:]]*\\|\\|[[:blank:]]*(!*[[:blank:]]*defined[[:blank:]]*\\([[:blank:]]*[A-Za-z_]*[[:blank:]]*\\))$"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
stmnt = "+#if " (op[1] == 0 ? op[2] : op[1])
|
|
}
|
|
|
|
pattern="\\(([01])[[:blank:]]*\\|\\|[[:blank:]]*(!*[[:blank:]]*defined[[:blank:]]*\\([[:blank:]]*[A-Za-z_]*[[:blank:]]*\\))\\)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
sub(pattern, op[1] == 0 ? op[2] : op[1], stmnt)
|
|
}
|
|
|
|
pattern="\\((-*[0-9]+)\\)"
|
|
while (match(stmnt, pattern, op) != 0)
|
|
{
|
|
sub(pattern, op[1], stmnt)
|
|
}
|
|
|
|
if (debug)
|
|
printf "/* debug specialize-patch: (c) %s -> %s */\n", last_stmnt, stmnt
|
|
|
|
} while (stmnt != last_stmnt)
|
|
|
|
return stmnt
|
|
}
|
|
|
|
|
|
# Evaluate !stmnt
|
|
function invert(stmnt) {
|
|
return evaluate(gensub("^+#if (.*)$", "+#if !(\\1)", "g", stmnt))
|
|
}
|
|
|
|
|
|
# Handle #if or #elif
|
|
|
|
function handle_if(evaluated)
|
|
{
|
|
# Only act on preprocessor conditional expressions with regard to the Linux
|
|
# kernel version, and do not interpret other expressions.
|
|
if ($0 ~ "LINUX_VERSION_CODE" \
|
|
|| $0 ~ "INSIDE_KERNEL_TREE" \
|
|
|| $0 ~ "CONFIG_SCST_PROC" \
|
|
|| $0 ~ "RHEL_MAJOR" \
|
|
|| $0 ~ "RHEL_MINOR" \
|
|
|| $0 ~ "RHEL_RELEASE_CODE" \
|
|
|| generating_upstream_patch_defined \
|
|
&& $0 ~ "GENERATING_UPSTREAM_PATCH" \
|
|
|| $0 ~ "CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION" \
|
|
|| ($0 ~ "CONFIG_SCST_PROC" && config_scst_proc_undefined) \
|
|
|| ($0 ~ "SCSI_EXEC_REQ_FIFO_DEFINED" && SCSI_EXEC_REQ_FIFO_DEFINED!="") \
|
|
|| ($0 ~ "SCST_IO_CONTEXT" && SCST_IO_CONTEXT != ""))
|
|
{
|
|
}
|
|
else
|
|
{
|
|
evaluated = "+#if undecided"
|
|
}
|
|
|
|
if (debug)
|
|
printf "/* debug specialize-patch: (d) %s -> %s */\n", $0, evaluated
|
|
|
|
if (evaluated ~ "^+#if")
|
|
{
|
|
if_stmnt[if_nesting_level] = evaluated
|
|
any_section_output[if_nesting_level] = 0
|
|
decision[if_nesting_level] = evaluated
|
|
inv_decision[if_nesting_level] = evaluate(sprintf("+#if !%s", substr(evaluated, 6)))
|
|
if (debug)
|
|
printf "/* debug specialize-patch: (f) %s / %s */\n", \
|
|
decision[if_nesting_level], inv_decision[if_nesting_level]
|
|
}
|
|
else
|
|
{
|
|
sub("^+#elif ",
|
|
sprintf("+#if %s \\&\\& ", substr(inv_decision[if_nesting_level], 6)),
|
|
evaluated)
|
|
if (debug)
|
|
printf "/* debug specialize-patch: (e) %s */\n", evaluated
|
|
evaluated = evaluate(evaluated)
|
|
decision[if_nesting_level] = evaluated
|
|
inv_decision[if_nesting_level] \
|
|
= evaluate(sprintf("+#if %s && !%s", \
|
|
substr(inv_decision[if_nesting_level], 6), \
|
|
substr(evaluated, 6)))
|
|
if (debug)
|
|
printf "/* debug specialize-patch: (f) %s / %s */\n", \
|
|
decision[if_nesting_level], inv_decision[if_nesting_level]
|
|
}
|
|
matching_if = if_stmnt[if_nesting_level]
|
|
return evaluated
|
|
}
|
|
|
|
|
|
# Decide whether or not to print the preprocessor statement $0.
|
|
|
|
function process_preprocessor_statement(evaluated, condition) {
|
|
evaluated = evaluate($0)
|
|
condition = 1
|
|
ei = evaluated_if_stmnt[if_nesting_level];
|
|
if (evaluated ~ "^+#if")
|
|
{
|
|
if_nesting_level++
|
|
evaluated_if_stmnt[if_nesting_level] = evaluated
|
|
evaluated = handle_if(evaluated)
|
|
}
|
|
else if (evaluated ~ "^+#elif")
|
|
{
|
|
evaluated = handle_if(evaluated)
|
|
}
|
|
else if (evaluated ~ "^+#else")
|
|
{
|
|
matching_if = if_stmnt[if_nesting_level]
|
|
decision[if_nesting_level] = inv_decision[if_nesting_level]
|
|
}
|
|
else if (evaluated ~ "^+#endif")
|
|
{
|
|
matching_if = if_stmnt[if_nesting_level]
|
|
if_nesting_level--
|
|
}
|
|
else
|
|
{
|
|
condition = 0
|
|
}
|
|
if (condition)
|
|
{
|
|
output = 1
|
|
for (i = if_nesting_level; i >= 0; i--) {
|
|
if (debug)
|
|
printf "/* debug specialize-patch: (g1) %s: decision[%d] = %s */\n", \
|
|
evaluated, i, decision[i]
|
|
output = output && decision[i] != "+#if 0" && decision[i] != "+#elif 0"
|
|
}
|
|
if (output)
|
|
any_section_output[if_nesting_level] = 1
|
|
if (debug)
|
|
printf "/* debug specialize-patch: (g2) %s: output = %d */\n", \
|
|
evaluated, output
|
|
}
|
|
if (evaluated ~ "^+#define SCSI_EXEC_REQ_FIFO_DEFINED$" \
|
|
&& SCSI_EXEC_REQ_FIFO_DEFINED != "" \
|
|
|| evaluated ~ "^+#define SCST_IO_CONTEXT$" \
|
|
&& SCST_IO_CONTEXT != "" \
|
|
|| (evaluated ~ "^+#define CONFIG_SCST_PROC$" \
|
|
&& config_scst_proc_undefined))
|
|
{
|
|
discard = 1
|
|
delete_next_blank_line = 1
|
|
}
|
|
else if (output && (!condition \
|
|
|| condition && matching_if !~ "^+#if [01]" \
|
|
&& matching_if !~ "^+#elif [01]"))
|
|
{
|
|
if (evaluated == "+#if undecided" \
|
|
|| (evaluated !~ "^+#if" \
|
|
&& evaluated !~ "^+#elif" \
|
|
&& evaluated !~ "^+#endif"))
|
|
{
|
|
for (i = 0; i < input_line_count; i++)
|
|
line[lines++] = input_line[i]
|
|
} else {
|
|
# If the statement being processed is an #else or #endif that is not a
|
|
# header file include guard and if that statement has a trailing comment,
|
|
# replace that comment by the partially evaluated matching #if expression.
|
|
if (evaluated ~ "^+#else" || evaluated ~ "^+#endif") {
|
|
if ($0 ~ "\\*/") {
|
|
if ($0 ~ "_H_* \\*/$") {
|
|
evaluated = $0
|
|
} else {
|
|
if (ei ~ "^+#if ")
|
|
ei = substr(ei, 6)
|
|
else if (ei ~ "^+#ifdef")
|
|
ei = substr(ei, 9)
|
|
evaluated = sprintf("%s /* %s */",
|
|
$0 ~ " " ? substr($0, 1, index($0, " ")) : $0,
|
|
ei);
|
|
if (match(evaluated, "([^/ ]*) */\\* defined\\(([^()]*)\\) \\*/",
|
|
arg))
|
|
{
|
|
evaluated = sprintf("%s /* %s */", arg[1], arg[2])
|
|
}
|
|
}
|
|
} else {
|
|
evaluated = $0
|
|
}
|
|
if (debug)
|
|
printf "/* debug specialize-patch: (h) %s */\n", evaluated
|
|
}
|
|
line[lines++] = evaluated
|
|
lines_less_added += input_line_count - 1
|
|
}
|
|
}
|
|
else
|
|
{
|
|
discard = 1
|
|
if (lines >= 1 && line[lines - 1] == "+")
|
|
delete_next_blank_line = 1
|
|
}
|
|
}
|
|
|
|
function reset_hunk_state_variables() {
|
|
lines = 0
|
|
lines_less_added = 0
|
|
lines_less_deleted = 0
|
|
output = 1
|
|
if_nesting_level = -1
|
|
delete_next_blank_line = 0
|
|
h[0] = ""
|
|
}
|
|
|
|
function dump_lines() {
|
|
# Detect empty hunks
|
|
first_modif = -1
|
|
for (i = 0; i < lines; i++)
|
|
{
|
|
if (line[i] ~ "^[+-]")
|
|
{
|
|
first_modif = i
|
|
break
|
|
}
|
|
}
|
|
|
|
# Dump line[] as a hunk, but only if the hunk is not empty.
|
|
if (first_modif >= 0)
|
|
{
|
|
if (h[0] != "")
|
|
printf "@@ -%d,%d +%d,%d @@%s\n",h[1],h[2]-lines_less_deleted,h[3],h[4]-lines_less_added,h[5]
|
|
for (i = 0; i < lines; i++)
|
|
print line[i]
|
|
}
|
|
}
|
|
|
|
BEGIN {
|
|
# Verify arguments.
|
|
if (kernel_version == "")
|
|
{
|
|
printf "Error: kernel_version was not specified.\n"
|
|
exit 1
|
|
}
|
|
LINUX_VERSION_CODE = version_code(kernel_version)
|
|
if (LINUX_VERSION_CODE < 2*65536 || LINUX_VERSION_CODE > 4*65536)
|
|
{
|
|
printf "Error: kernel version (%s) is out of range.\n", kernel_version
|
|
exit 1
|
|
}
|
|
if (blank_deleted_code != 0 && blank_deleted_code != 1)
|
|
blank_deleted_code = 0
|
|
if (generating_upstream_patch_defined != 0 && generating_upstream_patch_defined != 1)
|
|
generating_upstream_patch_defined = 0
|
|
if (config_tcp_zero_copy_transfer_completion_notification_undefined != 0 && config_tcp_zero_copy_transfer_completion_notification_undefined != 1)
|
|
config_tcp_zero_copy_transfer_completion_notification_undefined = 0
|
|
if (config_scst_proc_undefined != 0 && config_scst_proc_undefined != 1)
|
|
config_scst_proc_undefined = 0
|
|
|
|
# Variable initialization.
|
|
is_c_source = 0
|
|
reset_hunk_state_variables()
|
|
}
|
|
|
|
|
|
{
|
|
if (match($0, "^diff[ \t]+[^ \t]+[ \t]+[^ \t]+[ \t]+([^ \t]+)$", filename) \
|
|
|| match($0, "^\\+\\+\\+[ \t]+([^ \t]+)[ \t]+", filename))
|
|
{
|
|
# Start of new file.
|
|
dump_lines()
|
|
reset_hunk_state_variables()
|
|
is_c_source = match(filename[1], "\\.[ch]$") != 0
|
|
}
|
|
|
|
if (!is_c_source)
|
|
{
|
|
print
|
|
next
|
|
}
|
|
|
|
if (!config_scst_proc_undefined)
|
|
{
|
|
gsub("^+/\\* #define CONFIG_SCST_PROC \\*/$", "+#define CONFIG_SCST_PROC")
|
|
}
|
|
else
|
|
{
|
|
gsub("^+/\\* #define CONFIG_SCST_PROC \\*/$", "+")
|
|
}
|
|
input_line[0] = $0
|
|
input_line_count = 1
|
|
# Join continued lines before processing these.
|
|
while (match($0, "\\\\$"))
|
|
{
|
|
previous_line = $0
|
|
sub("[ \t]*\\\\$", "", previous_line)
|
|
getline
|
|
input_line[input_line_count++] = $0
|
|
sub("^+[ \t]*", "", $0)
|
|
$0 = previous_line " " $0
|
|
}
|
|
|
|
discard = 0
|
|
# If the line currently being processed is a hunk header, print all lines
|
|
# that were stored in the array line[] since the last hunk header was read.
|
|
if (match($0, "^@@ -([0-9]*),([0-9]*) \\+([0-9]*),([0-9]*) @@(.*)$"))
|
|
{
|
|
/* print h[1], h[2], h[3], h[4], h[5] */
|
|
dump_lines()
|
|
reset_hunk_state_variables()
|
|
match($0, "^@@ -([0-9]*),([0-9]*) \\+([0-9]*),([0-9]*) @@(.*)$", h)
|
|
}
|
|
else if (delete_next_blank_line && match($0, "^+$"))
|
|
{
|
|
discard = 1
|
|
delete_next_blank_line = 0
|
|
}
|
|
else
|
|
{
|
|
delete_next_blank_line = 0
|
|
if (match($0, "^+ *#"))
|
|
{
|
|
process_preprocessor_statement()
|
|
}
|
|
else if (output)
|
|
{
|
|
# Store the lines that were just read.
|
|
for (i = 0; i < input_line_count; i++)
|
|
line[lines++] = input_line[i]
|
|
# Convert double blank lines into a single blank line.
|
|
if (line[lines-1] == "+")
|
|
delete_next_blank_line = 1
|
|
}
|
|
else
|
|
{
|
|
discard = 1
|
|
if (lines >= 1 && line[lines-1] == "+")
|
|
delete_next_blank_line = 1
|
|
}
|
|
}
|
|
if (discard)
|
|
{
|
|
for (i = 0; i < input_line_count; i++)
|
|
{
|
|
if (blank_deleted_code)
|
|
{
|
|
if (input_line[i] ~ "^+")
|
|
line[lines++] = "+"
|
|
else
|
|
line[lines++] = input_line[i]
|
|
}
|
|
else
|
|
{
|
|
if (input_line[i] ~ "^+")
|
|
lines_less_added++
|
|
else if (input_line[i] ~ "^-")
|
|
lines_less_deleted++
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
END {
|
|
# Dump processed contents of the last read hunk.
|
|
dump_lines()
|
|
}
|
|
|
|
# Local variables:
|
|
# indent-tabs-mode: nil
|
|
# c-basic-offset: 2
|
|
# End:
|