From 3732ee39f8a3adf81d3fcea26b380246170c62a0 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 26 Aug 2015 23:34:36 +0000 Subject: [PATCH] scst: Introduce scst_pr_init() and scst_pr_cleanup() git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6485 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 10 +++------- scst/src/scst_pres.c | 19 +++++++++++++++++++ scst/src/scst_priv.h | 3 +++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 2aa492311..f61269d22 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -3964,13 +3964,7 @@ int scst_alloc_device(gfp_t gfp_mask, struct scst_device **out_dev) dev->dev_double_ua_possible = 1; dev->queue_alg = SCST_QUEUE_ALG_1_UNRESTRICTED_REORDER; - mutex_init(&dev->dev_pr_mutex); - dev->pr_generation = 0; - dev->pr_is_set = 0; - dev->pr_holder = NULL; - dev->pr_scope = SCOPE_LU; - dev->pr_type = TYPE_UNSPECIFIED; - INIT_LIST_HEAD(&dev->dev_registrants_list); + scst_pr_init(dev); BUILD_BUG_ON(SCST_DIF_NO_CHECK_APP_TAG != 0); dev->dev_dif_static_app_tag = SCST_DIF_NO_CHECK_APP_TAG; @@ -4003,6 +3997,8 @@ void scst_free_device(struct scst_device *dev) scst_deinit_threads(&dev->dev_cmd_threads); + scst_pr_cleanup(dev); + kfree(dev->virt_name); kmem_cache_free(scst_dev_cachep, dev); diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 7e86b6861..56ed68cef 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -1150,6 +1150,25 @@ out: return res; } +/* Initialize the PR members in *dev. */ +int scst_pr_init(struct scst_device *dev) +{ + mutex_init(&dev->dev_pr_mutex); + dev->pr_generation = 0; + dev->pr_is_set = 0; + dev->pr_holder = NULL; + dev->pr_scope = SCOPE_LU; + dev->pr_type = TYPE_UNSPECIFIED; + INIT_LIST_HEAD(&dev->dev_registrants_list); + + return 0; +} + +/* Free the resources allocated by scst_pr_init(). */ +void scst_pr_cleanup(struct scst_device *dev) +{ +} + /* Must be called under dev_pr_mutex or before dev is on the device list. */ int scst_pr_init_dev(struct scst_device *dev) { diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 50f815ec0..78c7e84f6 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -772,6 +772,9 @@ void scst_unthrottle_cmd(struct scst_cmd *cmd); int scst_do_internal_parsing(struct scst_cmd *cmd); int scst_parse_descriptors(struct scst_cmd *cmd); +int scst_pr_init(struct scst_device *dev); +void scst_pr_cleanup(struct scst_device *dev); + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) void scst_vfs_unlink_and_put(struct nameidata *nd); #else