scst: RHEL 5 build fix

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6659 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2015-11-10 19:18:39 +00:00
parent b600a06550
commit 9b65d8b809
9 changed files with 173 additions and 3 deletions

View File

@@ -187,6 +187,15 @@ static inline bool cpumask_equal(const cpumask_t *src1p,
}
#endif
/* <linux/dlm.h> */
/* See also commit 0f8e0d9a317406612700426fad3efab0b7bbc467 */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)
enum {
DLM_LSFL_NEWEXCL = 0
};
#endif
/* <linux/fs.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) && \
@@ -283,6 +292,16 @@ static inline int __must_check kstrtol(const char *s, unsigned int base,
}
#endif
/* <linux/kmod.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
enum umh_wait {
UMH_NO_WAIT = -1, /* don't wait at all */
UMH_WAIT_EXEC = 0, /* wait for the exec, but not the process */
UMH_WAIT_PROC = 1, /* wait for the process to complete */
};
#endif
/* <linux/list.h> */
#ifndef __list_for_each

View File

@@ -1971,7 +1971,11 @@ struct scst_session {
*/
struct list_head sess_cm_list_id_list;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct work_struct sess_cm_list_id_cleanup_work;
#else
struct delayed_work sess_cm_list_id_cleanup_work;
#endif
/* sysfs release completion */
struct completion *sess_kobj_release_cmpl;

View File

@@ -63,7 +63,11 @@ struct scst_event_entry {
int *pqueued_events_cnt;
union {
struct work_struct scst_event_queue_work;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct work_struct event_timeout_work;
#else
struct delayed_work event_timeout_work;
#endif
};
struct scst_event event;

View File

@@ -179,7 +179,11 @@ typedef void (*scst_cm_retry_fn_t)(struct scst_cmd *cmd);
struct scst_cm_retry {
struct scst_cmd *cm_retry_cmd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct work_struct cm_retry_work;
#else
struct delayed_work cm_retry_work;
#endif
scst_cm_retry_fn_t cm_retry_fn;
};
@@ -1980,10 +1984,16 @@ out_unlock_free:
goto out;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
void sess_cm_list_id_cleanup_work_fn(void *p)
{
struct scst_session *sess = p;
#else
void sess_cm_list_id_cleanup_work_fn(struct work_struct *work)
{
struct scst_session *sess = container_of(work,
struct scst_session, sess_cm_list_id_cleanup_work.work);
#endif
struct scst_cm_list_id *l, *t;
unsigned long cur_time = jiffies;
unsigned long flags;

View File

@@ -1077,10 +1077,16 @@ static void scst_dlm_pre_bast(void *bastarg, int mode)
queue_work(pr_dlm->from_wq, &pr_dlm->pre_upd_work);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_pre_join_work(void *p)
{
struct scst_pr_dlm_data *pr_dlm = p;
#else
static void scst_pre_join_work(struct work_struct *work)
{
struct scst_pr_dlm_data *pr_dlm = container_of(work,
struct scst_pr_dlm_data, pre_join_work);
#endif
dlm_lockspace_t *ls;
mutex_lock(&pr_dlm->ls_mutex);
@@ -1094,10 +1100,16 @@ static void scst_pre_join_work(struct work_struct *work)
mutex_unlock(&pr_dlm->ls_mutex);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_pre_upd_work(void *p)
{
struct scst_pr_dlm_data *pr_dlm = p;
#else
static void scst_pre_upd_work(struct work_struct *work)
{
struct scst_pr_dlm_data *pr_dlm = container_of(work,
struct scst_pr_dlm_data, pre_upd_work);
#endif
dlm_lockspace_t *ls;
mutex_lock(&pr_dlm->ls_mutex);
@@ -1128,10 +1140,16 @@ static void scst_dlm_post_bast(void *bastarg, int mode)
* Note: the node that has invoked scst_trigger_lvb_update() holds PR_LOCK
* in EX mode and waits until this function has finished.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_copy_to_dlm_work(void *p)
{
struct scst_pr_dlm_data *pr_dlm = p;
#else
static void scst_copy_to_dlm_work(struct work_struct *work)
{
struct scst_pr_dlm_data *pr_dlm = container_of(work,
struct scst_pr_dlm_data, copy_to_dlm_work);
#endif
struct scst_device *dev = pr_dlm->dev;
dlm_lockspace_t *ls;
int res;
@@ -1195,10 +1213,16 @@ unlock_ls:
* scst_pr_init_tgt_dev() and scst_pr_clear_tgt_dev() in scst_pres.c protect
* these manipulations by locking the PR data structures for writing.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_copy_from_dlm_work(void *p)
{
struct scst_pr_dlm_data *pr_dlm = p;
#else
static void scst_copy_from_dlm_work(struct work_struct *work)
{
struct scst_pr_dlm_data *pr_dlm = container_of(work,
struct scst_pr_dlm_data, copy_from_dlm_work);
#endif
struct scst_device *dev = pr_dlm->dev;
dlm_lockspace_t *ls;
int res = -ENOENT;
@@ -1250,10 +1274,16 @@ static void scst_dlm_post_ast(void *astarg)
}
/* Tell other nodes to refresh their local state from the lock value blocks. */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_reread_lvb_work(void *p)
{
struct scst_pr_dlm_data *pr_dlm = p;
#else
static void scst_reread_lvb_work(struct work_struct *work)
{
struct scst_pr_dlm_data *pr_dlm = container_of(work,
struct scst_pr_dlm_data, reread_lvb_work);
#endif
dlm_lockspace_t *ls;
struct scst_lksb pr_lksb;
int res;
@@ -1275,10 +1305,16 @@ unlock_ls:
}
/* Tell other nodes to update the DLM lock value blocks. */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_lvb_upd_work(void *p)
{
struct scst_pr_dlm_data *pr_dlm = p;
#else
static void scst_lvb_upd_work(struct work_struct *work)
{
struct scst_pr_dlm_data *pr_dlm = container_of(work,
struct scst_pr_dlm_data, lvb_upd_work);
#endif
dlm_lockspace_t *ls;
struct scst_lksb lksb;
int res;
@@ -1332,12 +1368,21 @@ static int scst_pr_dlm_init(struct scst_device *dev, const char *cl_dev_id)
mutex_init(&pr_dlm->ls_cr_mutex);
mutex_init(&pr_dlm->ls_mutex);
pr_dlm->data_lksb.lksb.sb_lvbptr = pr_dlm->lvb;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&pr_dlm->pre_join_work, scst_pre_join_work, pr_dlm);
INIT_WORK(&pr_dlm->pre_upd_work, scst_pre_upd_work, pr_dlm);
INIT_WORK(&pr_dlm->copy_from_dlm_work, scst_copy_from_dlm_work, pr_dlm);
INIT_WORK(&pr_dlm->copy_to_dlm_work, scst_copy_to_dlm_work, pr_dlm);
INIT_WORK(&pr_dlm->lvb_upd_work, scst_lvb_upd_work, pr_dlm);
INIT_WORK(&pr_dlm->reread_lvb_work, scst_reread_lvb_work, pr_dlm);
#else
INIT_WORK(&pr_dlm->pre_join_work, scst_pre_join_work);
INIT_WORK(&pr_dlm->pre_upd_work, scst_pre_upd_work);
INIT_WORK(&pr_dlm->copy_from_dlm_work, scst_copy_from_dlm_work);
INIT_WORK(&pr_dlm->copy_to_dlm_work, scst_copy_to_dlm_work);
INIT_WORK(&pr_dlm->lvb_upd_work, scst_lvb_upd_work);
INIT_WORK(&pr_dlm->reread_lvb_work, scst_reread_lvb_work);
#endif
pr_dlm->latest_lscr_attempt = jiffies - 100 * HZ;
res = -ENOMEM;

View File

@@ -88,10 +88,16 @@ out:
return res;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_event_timeout_fn(void *p)
{
struct scst_event_entry *event_entry = p;
#else
static void scst_event_timeout_fn(struct work_struct *work)
{
struct scst_event_entry *event_entry = container_of(work,
struct scst_event_entry, event_timeout_work.work);
#endif
TRACE_ENTRY();
@@ -198,8 +204,14 @@ static void __scst_event_queue(struct scst_event_entry *event_entry)
break;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&new_event_entry->event_timeout_work,
scst_event_timeout_fn,
new_event_entry);
#else
INIT_DELAYED_WORK(&new_event_entry->event_timeout_work,
scst_event_timeout_fn);
#endif
if (new_event_entry->event_notify_fn != NULL) {
new_event_entry->event.event_id = atomic_inc_return(&base_event_id);
if (new_event_entry->event_timeout == 0)
@@ -245,10 +257,16 @@ done:
return;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_event_queue_work_fn(void *p)
{
struct scst_event_entry *e = p;
#else
static void scst_event_queue_work_fn(struct work_struct *work)
{
struct scst_event_entry *e = container_of(work,
struct scst_event_entry, scst_event_queue_work);
#endif
TRACE_ENTRY();
@@ -264,7 +282,11 @@ void scst_event_queue(uint32_t event_code, const char *issuer_name,
{
TRACE_ENTRY();
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&e->scst_event_queue_work, scst_event_queue_work_fn, e);
#else
INIT_WORK(&e->scst_event_queue_work, scst_event_queue_work_fn);
#endif
TRACE_DBG("Scheduling event entry %p", e);
@@ -1042,7 +1064,11 @@ static const struct file_operations scst_event_fops = {
int scst_event_init(void)
{
int res = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 21)
struct class_device *class_member;
#else
struct device *dev;
#endif
TRACE_ENTRY();
@@ -1060,6 +1086,15 @@ int scst_event_init(void)
goto out_class;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 21)
class_member = class_device_create(scst_event_sysfs_class, NULL,
MKDEV(scst_event_major, 0), NULL,
SCST_EVENT_NAME);
if (IS_ERR(class_member)) {
res = PTR_ERR(class_member);
goto out_chrdev;
}
#else
dev = device_create(scst_event_sysfs_class, NULL,
MKDEV(scst_event_major, 0),
NULL,
@@ -1068,6 +1103,7 @@ int scst_event_init(void)
res = PTR_ERR(dev);
goto out_chrdev;
}
#endif
#ifdef CONFIG_EVENTS_WAIT_TEST
sysfs_create_file(kernel_kobj, &event_wait_test_attr.attr);

View File

@@ -74,7 +74,11 @@
static DEFINE_SPINLOCK(scst_global_stpg_list_lock);
static LIST_HEAD(scst_global_stpg_list);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_put_acg_work(void *p);
#else
static void scst_put_acg_work(struct work_struct *work);
#endif
static void scst_del_acn(struct scst_acn *acn);
static void scst_free_acn(struct scst_acn *acn, bool reassign);
@@ -4119,7 +4123,11 @@ static void scst_init_order_data(struct scst_order_data *order_data)
return;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_ext_blocking_done_fn(void *p);
#else
static void scst_ext_blocking_done_fn(struct work_struct *work);
#endif
static int scst_dif_none(struct scst_cmd *cmd);
#ifdef CONFIG_SCST_DIF_INJECT_CORRUPTED_TAGS
@@ -4154,7 +4162,11 @@ int scst_alloc_device(gfp_t gfp_mask, struct scst_device **out_dev)
INIT_LIST_HEAD(&dev->dev_tgt_dev_list);
INIT_LIST_HEAD(&dev->dev_acg_dev_list);
INIT_LIST_HEAD(&dev->ext_blockers_list);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&dev->ext_blockers_work, scst_ext_blocking_done_fn, dev);
#else
INIT_WORK(&dev->ext_blockers_work, scst_ext_blocking_done_fn);
#endif
dev->dev_double_ua_possible = 1;
dev->queue_alg = SCST_QUEUE_ALG_1_UNRESTRICTED_REORDER;
@@ -4633,13 +4645,19 @@ struct scst_acg_put_work {
struct scst_acg *acg;
};
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_put_acg_work(void *p)
{
struct scst_acg_put_work *put_work = p;
#else
static void scst_put_acg_work(struct work_struct *work)
{
struct scst_acg_put_work *put_work =
container_of(work, typeof(*put_work), work);
#endif
struct scst_acg *acg = put_work->acg;
kfree(work);
kfree(put_work);
kref_put(&acg->acg_kref, scst_release_acg);
}
@@ -4653,7 +4671,11 @@ void scst_put_acg(struct scst_acg *acg)
return;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&put_work->work, scst_put_acg_work, put_work);
#else
INIT_WORK(&put_work->work, scst_put_acg_work);
#endif
put_work->acg = acg;
/*
@@ -6714,11 +6736,13 @@ struct scst_session *scst_alloc_session(struct scst_tgt *tgt, gfp_t gfp_mask,
INIT_LIST_HEAD(&sess->init_deferred_cmd_list);
INIT_LIST_HEAD(&sess->init_deferred_mcmd_list);
INIT_LIST_HEAD(&sess->sess_cm_list_id_list);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
INIT_DELAYED_WORK(&sess->sess_cm_list_id_cleanup_work,
sess_cm_list_id_cleanup_work_fn);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))
INIT_DELAYED_WORK(&sess->hw_pending_work, scst_hw_pending_work_fn);
#else
INIT_WORK(&sess->sess_cm_list_id_cleanup_work,
sess_cm_list_id_cleanup_work_fn, sess);
INIT_WORK(&sess->hw_pending_work, scst_hw_pending_work_fn, sess);
#endif
@@ -14113,10 +14137,16 @@ void __scst_ext_blocking_done(struct scst_device *dev)
return;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_ext_blocking_done_fn(void *p)
{
struct scst_device *dev = p;
#else
static void scst_ext_blocking_done_fn(struct work_struct *work)
{
struct scst_device *dev = container_of(work, struct scst_device,
ext_blockers_work);
#endif
TRACE_ENTRY();

View File

@@ -406,7 +406,10 @@ static inline int scst_dlm_new_lockspace(const char *name, int namelen,
uint32_t flags,
int lvblen)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
return dlm_new_lockspace((char *)name, namelen, lockspace, flags,
lvblen);
#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
return dlm_new_lockspace(name, namelen, lockspace, flags, lvblen);
#else
return dlm_new_lockspace(name, NULL, flags, lvblen, NULL, NULL, NULL,
@@ -858,7 +861,11 @@ void scst_cm_free_descriptors(struct scst_cmd *cmd);
int scst_cm_ext_copy_exec(struct scst_cmd *cmd);
int scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
void sess_cm_list_id_cleanup_work_fn(void *p);
#else
void sess_cm_list_id_cleanup_work_fn(struct work_struct *work);
#endif
void scst_cm_free_pending_list_ids(struct scst_session *sess);
bool scst_cm_check_block_all_devs(struct scst_cmd *cmd);

View File

@@ -397,14 +397,24 @@ out:
struct scst_alua_retry {
struct scst_cmd *alua_retry_cmd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct work_struct alua_retry_work;
#else
struct delayed_work alua_retry_work;
#endif
};
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_alua_transitioning_work_fn(void *p)
{
struct scst_alua_retry *retry = p;
#else
static void scst_alua_transitioning_work_fn(struct work_struct *work)
{
struct scst_alua_retry *retry =
container_of(work, struct scst_alua_retry,
alua_retry_work.work);
#endif
struct scst_cmd *cmd = retry->alua_retry_cmd;
TRACE_ENTRY();
@@ -469,8 +479,13 @@ static int scst_tg_accept_transitioning(struct scst_cmd *cmd)
/* No get is needed, because cmd is sync here */
retry->alua_retry_cmd = cmd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&retry->alua_retry_work,
scst_alua_transitioning_work_fn, retry);
#else
INIT_DELAYED_WORK(&retry->alua_retry_work,
scst_alua_transitioning_work_fn);
#endif
cmd->already_transitioning = 1;
schedule_delayed_work(&retry->alua_retry_work, HZ/2);
res = SCST_ALUA_CHECK_DELAYED;