From 17f49dbede69febf4ee647e54726d35b9c78cf99 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 22 Jul 2016 16:48:38 +0000 Subject: [PATCH 1/3] scst_dlm: Initialize reg->dlm_idx for PR information loaded from disk This patch avoids that the following kernel warning appears while starting SCST after having loaded APTPL PR information: WARNING: scst/src/scst_dlm.c:461 scst_copy_to_dlm() Reported-by: git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6912 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_dlm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scst/src/scst_dlm.c b/scst/src/scst_dlm.c index 5b4f79cf5..9896532e9 100644 --- a/scst/src/scst_dlm.c +++ b/scst/src/scst_dlm.c @@ -1363,9 +1363,15 @@ create_st_wq(const char *fmt, ...) static int scst_pr_dlm_init(struct scst_device *dev, const char *cl_dev_id) { struct scst_pr_dlm_data *pr_dlm; + struct scst_dev_registrant *reg; int res = -ENOMEM; compile_time_size_checks(); + + list_for_each_entry(reg, &dev->dev_registrants_list, + dev_registrants_list_entry) + scst_dlm_pr_init_reg(dev, reg); + pr_dlm = kzalloc(sizeof(*dev->pr_dlm), GFP_KERNEL); if (!pr_dlm) goto out; From e2b03a783656f41125715ab5ec1f53029b5da3b5 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 22 Jul 2016 16:50:31 +0000 Subject: [PATCH 2/3] scst_pres: Modify scst_pr_sync_device_file() function prototype git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6913 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_pres.c | 25 +++++-------------------- scst/src/scst_pres.h | 2 +- scst/src/scst_targ.c | 2 +- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 5ac78d112..1627e792d 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -870,10 +870,8 @@ out: return res; } -static void scst_pr_remove_device_files(struct scst_tgt_dev *tgt_dev) +static void scst_pr_remove_device_files(struct scst_device *dev) { - struct scst_device *dev = tgt_dev->dev; - TRACE_ENTRY(); scst_assert_pr_mutex_held(dev); @@ -888,10 +886,9 @@ static void scst_pr_remove_device_files(struct scst_tgt_dev *tgt_dev) } /* Must be called under dev_pr_mutex */ -void scst_pr_sync_device_file(struct scst_tgt_dev *tgt_dev, struct scst_cmd *cmd) +void scst_pr_sync_device_file(struct scst_device *dev) { int res = 0; - struct scst_device *dev = tgt_dev->dev; struct file *file; mm_segment_t old_fs = get_fs(); loff_t pos = 0; @@ -905,7 +902,7 @@ void scst_pr_sync_device_file(struct scst_tgt_dev *tgt_dev, struct scst_cmd *cmd scst_assert_pr_mutex_held(dev); if ((dev->pr_aptpl == 0) || list_empty(&dev->dev_registrants_list)) { - scst_pr_remove_device_files(tgt_dev); + scst_pr_remove_device_files(dev); goto out; } @@ -1022,21 +1019,9 @@ out_set_fs: set_fs(old_fs); out: - if (res != 0) { + if (res != 0) PRINT_CRIT_ERROR("Unable to save persistent information " - "(target %s, initiator %s, device %s)", - tgt_dev->sess->tgt->tgt_name, - tgt_dev->sess->initiator_name, dev->virt_name); -#if 0 /* - * Looks like it's safer to return SUCCESS and expect operator's - * intervention to be able to save the PR's state next time, than - * to return HARDWARE ERROR and screw up all the interaction with - * the affected initiator. - */ - if (cmd != NULL) - scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_internal_failure)); -#endif - } + "(device %s)", dev->virt_name); TRACE_EXIT_RES(res); return; diff --git a/scst/src/scst_pres.h b/scst/src/scst_pres.h index 94a69f379..81f432964 100644 --- a/scst/src/scst_pres.h +++ b/scst/src/scst_pres.h @@ -148,7 +148,7 @@ void scst_pr_set_holder(struct scst_device *dev, void scst_pr_clear_holder(struct scst_device *dev); #ifndef CONFIG_SCST_PROC -void scst_pr_sync_device_file(struct scst_tgt_dev *tgt_dev, struct scst_cmd *cmd); +void scst_pr_sync_device_file(struct scst_device *dev); #endif #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 214d221e6..507c71b62 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -3167,7 +3167,7 @@ static int scst_persistent_reserve_out_local(struct scst_cmd *cmd) #ifndef CONFIG_SCST_PROC if (cmd->status == SAM_STAT_GOOD) - scst_pr_sync_device_file(tgt_dev, cmd); + scst_pr_sync_device_file(dev); #endif if ((cmd->devt->pr_cmds_notifications) && From 18ccf50b872ff1bc98f7679dd443b49d8caba1c7 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 22 Jul 2016 16:51:07 +0000 Subject: [PATCH 3/3] scst_pres: Save APTPL PR info on both nodes git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6914 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_dlm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scst/src/scst_dlm.c b/scst/src/scst_dlm.c index 9896532e9..65fe76c9f 100644 --- a/scst/src/scst_dlm.c +++ b/scst/src/scst_dlm.c @@ -356,6 +356,10 @@ static int scst_copy_from_dlm(struct scst_device *dev, dlm_lockspace_t *ls, if (reg->lksb.lksb.sb_lkid == 0) scst_pr_remove_registrant(dev, reg); +#ifndef CONFIG_SCST_PROC + scst_pr_sync_device_file(dev); +#endif + scst_pr_write_unlock(dev); res = 0;