You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(19) |
Nov
(18) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(14) |
Feb
(14) |
Mar
(3) |
Apr
(10) |
May
(10) |
Jun
(17) |
Jul
(15) |
Aug
(24) |
Sep
(24) |
Oct
(11) |
Nov
(13) |
Dec
(15) |
2008 |
Jan
(10) |
Feb
(46) |
Mar
(20) |
Apr
(42) |
May
(44) |
Jun
(22) |
Jul
(59) |
Aug
(8) |
Sep
(15) |
Oct
(52) |
Nov
(30) |
Dec
(38) |
2009 |
Jan
(27) |
Feb
(27) |
Mar
(47) |
Apr
(85) |
May
(74) |
Jun
(41) |
Jul
(70) |
Aug
(64) |
Sep
(97) |
Oct
(147) |
Nov
(67) |
Dec
(48) |
2010 |
Jan
(68) |
Feb
(33) |
Mar
(53) |
Apr
(98) |
May
(55) |
Jun
(71) |
Jul
(99) |
Aug
(132) |
Sep
(291) |
Oct
(220) |
Nov
(344) |
Dec
(300) |
2011 |
Jan
(57) |
Feb
(25) |
Mar
(59) |
Apr
(104) |
May
(60) |
Jun
(155) |
Jul
(143) |
Aug
(43) |
Sep
(53) |
Oct
(20) |
Nov
(35) |
Dec
(103) |
2012 |
Jan
(62) |
Feb
(43) |
Mar
(29) |
Apr
(80) |
May
(75) |
Jun
(61) |
Jul
(52) |
Aug
(58) |
Sep
(33) |
Oct
(32) |
Nov
(69) |
Dec
(37) |
2013 |
Jan
(77) |
Feb
(28) |
Mar
(52) |
Apr
(18) |
May
(37) |
Jun
(21) |
Jul
(22) |
Aug
(55) |
Sep
(29) |
Oct
(74) |
Nov
(50) |
Dec
(44) |
2014 |
Jan
(77) |
Feb
(62) |
Mar
(81) |
Apr
(99) |
May
(59) |
Jun
(95) |
Jul
(55) |
Aug
(34) |
Sep
(78) |
Oct
(33) |
Nov
(48) |
Dec
(51) |
2015 |
Jan
(56) |
Feb
(120) |
Mar
(37) |
Apr
(15) |
May
(22) |
Jun
(196) |
Jul
(54) |
Aug
(33) |
Sep
(32) |
Oct
(42) |
Nov
(149) |
Dec
(61) |
2016 |
Jan
(15) |
Feb
(26) |
Mar
(37) |
Apr
(27) |
May
(14) |
Jun
(11) |
Jul
(13) |
Aug
(64) |
Sep
(2) |
Oct
(36) |
Nov
(18) |
Dec
(46) |
2017 |
Jan
(6) |
Feb
(1) |
Mar
(2) |
Apr
(50) |
May
(42) |
Jun
(11) |
Jul
(4) |
Aug
(12) |
Sep
(11) |
Oct
(21) |
Nov
(15) |
Dec
(42) |
2018 |
Jan
(33) |
Feb
(27) |
Mar
(20) |
Apr
(5) |
May
(4) |
Jun
(1) |
Jul
(42) |
Aug
(29) |
Sep
(11) |
Oct
(40) |
Nov
(312) |
Dec
(18) |
2019 |
Jan
(44) |
Feb
(98) |
Mar
(125) |
Apr
(160) |
May
(123) |
Jun
(33) |
Jul
(56) |
Aug
(81) |
Sep
(24) |
Oct
(23) |
Nov
(52) |
Dec
(86) |
2020 |
Jan
(6) |
Feb
(17) |
Mar
(62) |
Apr
(21) |
May
(118) |
Jun
(42) |
Jul
(52) |
Aug
(62) |
Sep
(20) |
Oct
(5) |
Nov
(23) |
Dec
(111) |
2021 |
Jan
(31) |
Feb
(8) |
Mar
(26) |
Apr
(13) |
May
(54) |
Jun
(31) |
Jul
(17) |
Aug
(10) |
Sep
(83) |
Oct
(8) |
Nov
(21) |
Dec
(33) |
2022 |
Jan
(67) |
Feb
(11) |
Mar
(4) |
Apr
(46) |
May
(12) |
Jun
(17) |
Jul
(19) |
Aug
(7) |
Sep
(53) |
Oct
(14) |
Nov
(29) |
Dec
(22) |
2023 |
Jan
(20) |
Feb
(4) |
Mar
(37) |
Apr
(25) |
May
(15) |
Jun
(20) |
Jul
(38) |
Aug
(1) |
Sep
(1) |
Oct
(34) |
Nov
|
Dec
(8) |
2024 |
Jan
(15) |
Feb
(10) |
Mar
|
Apr
(4) |
May
(23) |
Jun
|
Jul
(8) |
Aug
(2) |
Sep
(18) |
Oct
(1) |
Nov
(18) |
Dec
(15) |
2025 |
Jan
(5) |
Feb
(1) |
Mar
(7) |
Apr
(4) |
May
(18) |
Jun
(7) |
Jul
|
Aug
(17) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
From: Gleb C. <lna...@ya...> - 2025-09-23 09:49:30
|
Commit: c38b254 GitHub URL: https://github.com/SCST-project/scst/commit/c38b254c7a33c4654ef3fb1e062ce05c30cca876 Author: Gleb Chesnokov Date: 2025-09-23T12:49:00+03:00 Log Message: ----------- scst_mem: Fix multiple checkpatch warnings This patch does not change any functionality. Modified Paths: -------------- scst/src/scst_mem.c | 497 +++++++-------- 1 file changed, 219 insertions(+), 278 deletions(-) =================================================================== diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 537b90c..a97ef84 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -116,7 +116,7 @@ void scst_sgv_pool_use_norm(struct scst_tgt_dev *tgt_dev) void scst_sgv_pool_use_norm_clust(struct scst_tgt_dev *tgt_dev) { - TRACE_MEM("%s", "Use clustering"); + TRACE_MEM("Use clustering"); tgt_dev->tgt_dev_gfp_mask = __GFP_NOWARN; if (!scst_force_global_sgv_pool) tgt_dev->pools = sgv_norm_clust_pool_per_cpu; @@ -127,7 +127,7 @@ void scst_sgv_pool_use_norm_clust(struct scst_tgt_dev *tgt_dev) void scst_sgv_pool_use_dma(struct scst_tgt_dev *tgt_dev) { - TRACE_MEM("%s", "Use ISA DMA memory"); + TRACE_MEM("Use ISA DMA memory"); tgt_dev->tgt_dev_gfp_mask = __GFP_NOWARN | GFP_DMA; if (!scst_force_global_sgv_pool) tgt_dev->pools = sgv_dma_pool_per_cpu; @@ -148,8 +148,7 @@ static void sgv_dtor_and_free(struct sgv_pool_obj *obj) obj->sg_count, obj->allocator_priv); } if (obj->sg_entries != obj->sg_entries_data) { - if (obj->trans_tbl != - (struct trans_tbl_ent *)obj->sg_entries_data) { + if (obj->trans_tbl != (struct trans_tbl_ent *)obj->sg_entries_data) { /* kfree() handles NULL parameter */ kfree(obj->trans_tbl); obj->trans_tbl = NULL; @@ -158,7 +157,6 @@ static void sgv_dtor_and_free(struct sgv_pool_obj *obj) } kmem_cache_free(pool->caches[obj->cache_num], obj); - return; } /* Must be called under sgv_pool_lock held */ @@ -175,7 +173,7 @@ static void __sgv_purge_from_cache(struct sgv_pool_obj *obj) struct sgv_pool *pool = obj->owner_pool; TRACE_MEM("Purging sgv obj %p from pool %p (new cached_entries %d)", - obj, pool, pool->cached_entries-1); + obj, pool, pool->cached_entries - 1); list_del(&obj->sorted_recycling_list_entry); list_del(&obj->recycling_list_entry); @@ -186,19 +184,16 @@ static void __sgv_purge_from_cache(struct sgv_pool_obj *obj) #ifndef CONFIG_SCST_NO_TOTAL_MEM_CHECKS atomic_sub(pages, &sgv_pages_total); #endif - - return; } /* Must be called under sgv_pool_lock held */ static bool sgv_purge_from_cache(struct sgv_pool_obj *obj, int min_interval, - unsigned long cur_time) + unsigned long cur_time) { EXTRACHECKS_BUG_ON(min_interval < 0); - TRACE_MEM("Checking if sgv obj %p should be purged (cur time %ld, " - "obj time %ld, time to purge %ld)", obj, cur_time, - obj->time_stamp, obj->time_stamp + min_interval); + TRACE_MEM("Checking if sgv obj %p should be purged (cur time %ld, obj time %ld, time to purge %ld)", + obj, cur_time, obj->time_stamp, obj->time_stamp + min_interval); if (time_after_eq(cur_time, (obj->time_stamp + min_interval))) { __sgv_purge_from_cache(obj); @@ -208,15 +203,15 @@ static bool sgv_purge_from_cache(struct sgv_pool_obj *obj, int min_interval, } /* No locks */ -static int sgv_shrink_pool(struct sgv_pool *pool, int nr, int min_interval, - unsigned long cur_time, int *out_freed) +static int sgv_shrink_pool(struct sgv_pool *pool, int nr, int min_interval, unsigned long cur_time, + int *out_freed) { int freed = 0; TRACE_ENTRY(); TRACE_MEM("Trying to shrink pool %p (nr %d, min_interval %d)", - pool, nr, min_interval); + pool, nr, min_interval); if (pool->purge_interval < 0) { TRACE_MEM("Not shrinkable pool %p, skipping", pool); @@ -231,9 +226,9 @@ static int sgv_shrink_pool(struct sgv_pool *pool, int nr, int min_interval, #else (atomic_read(&sgv_pages_total) > sgv_lo_wmk)) { #endif - struct sgv_pool_obj *obj = list_first_entry( - &pool->sorted_recycling_list, - struct sgv_pool_obj, sorted_recycling_list_entry); + struct sgv_pool_obj *obj = list_first_entry(&pool->sorted_recycling_list, + struct sgv_pool_obj, + sorted_recycling_list_entry); if (sgv_purge_from_cache(obj, min_interval, cur_time)) { int pages = obj->pages; @@ -241,19 +236,20 @@ static int sgv_shrink_pool(struct sgv_pool *pool, int nr, int min_interval, freed += pages; nr -= pages; - TRACE_MEM("%d pages purged from pool %p (nr left %d, " - "total freed %d)", pages, pool, nr, freed); + TRACE_MEM("%d pages purged from pool %p (nr left %d, total freed %d)", + pages, pool, nr, freed); spin_unlock_bh(&pool->sgv_pool_lock); sgv_dtor_and_free(obj); spin_lock_bh(&pool->sgv_pool_lock); - } else + } else { break; + } - if ((nr <= 0) || (freed >= MAX_PAGES_PER_POOL)) { + if (nr <= 0 || freed >= MAX_PAGES_PER_POOL) { if (freed >= MAX_PAGES_PER_POOL) - TRACE_MEM("%d pages purged from pool %p, " - "leaving", freed, pool); + TRACE_MEM("%d pages purged from pool %p, leaving", + freed, pool); break; } } @@ -276,8 +272,8 @@ static int __sgv_shrink(int nr, int min_interval, int *out_freed) TRACE_ENTRY(); - TRACE_MEM("Trying to shrink %d pages from all sgv pools " - "(min_interval %d)", nr, min_interval); + TRACE_MEM("Trying to shrink %d pages from all sgv pools (min_interval %d)", + nr, min_interval); while (prev_nr > nr && nr > 0) { prev_nr = nr; @@ -321,14 +317,12 @@ static unsigned long __sgv_can_be_shrunk(void) } #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0) -static unsigned long sgv_can_be_shrunk(struct shrinker *shrinker, - struct shrink_control *sc) +static unsigned long sgv_can_be_shrunk(struct shrinker *shrinker, struct shrink_control *sc) { return __sgv_can_be_shrunk(); } -static unsigned long sgv_scan_shrink(struct shrinker *shrinker, - struct shrink_control *sc) +static unsigned long sgv_scan_shrink(struct shrinker *shrinker, struct shrink_control *sc) { int freed = 0; @@ -351,8 +345,9 @@ static int sgv_shrink(struct shrinker *shrinker, struct shrink_control *sc) if (nr > 0) { nr = __sgv_shrink(nr, SGV_MIN_SHRINK_INTERVAL, &freed); TRACE_MEM("Left %d", nr); - } else + } else { nr = __sgv_can_be_shrunk(); + } TRACE_EXIT_RES(nr); return nr; @@ -374,9 +369,9 @@ static void sgv_purge_work_fn(struct work_struct *work) pool->purge_work_scheduled = false; while (!list_empty(&pool->sorted_recycling_list)) { - struct sgv_pool_obj *obj = list_first_entry( - &pool->sorted_recycling_list, - struct sgv_pool_obj, sorted_recycling_list_entry); + struct sgv_pool_obj *obj = list_first_entry(&pool->sorted_recycling_list, + struct sgv_pool_obj, + sorted_recycling_list_entry); if (sgv_purge_from_cache(obj, pool->purge_interval, cur_time)) { spin_unlock_bh(&pool->sgv_pool_lock); @@ -388,11 +383,9 @@ static void sgv_purge_work_fn(struct work_struct *work) * too often. In the worst case we have shrinker * to reclaim buffers more quickly. */ - TRACE_MEM("Rescheduling purge work for pool %p (delay " - "%d HZ/%d sec)", pool, pool->purge_interval, - pool->purge_interval/HZ); - schedule_delayed_work(&pool->sgv_purge_work, - pool->purge_interval); + TRACE_MEM("Rescheduling purge work for pool %p (delay %d HZ/%d sec)", + pool, pool->purge_interval, pool->purge_interval / HZ); + schedule_delayed_work(&pool->sgv_purge_work, pool->purge_interval); pool->purge_work_scheduled = true; break; } @@ -403,7 +396,6 @@ static void sgv_purge_work_fn(struct work_struct *work) TRACE_MEM("Leaving purge work for pool %p", pool); TRACE_EXIT(); - return; } static int sgv_check_full_clustering(struct scatterlist *sg, int cur, int hint) @@ -419,7 +411,7 @@ static int sgv_check_full_clustering(struct scatterlist *sg, int cur, int hint) #if 0 TRACE_MEM("pfn_cur %ld, pfn_cur_next %ld, len_cur %d, full_page_cur %d", - pfn_cur, pfn_cur_next, len_cur, full_page_cur); + pfn_cur, pfn_cur_next, len_cur, full_page_cur); #endif /* check the hint first */ @@ -428,10 +420,10 @@ static int sgv_check_full_clustering(struct scatterlist *sg, int cur, int hint) pfn_next = pfn + (sg[i].length >> PAGE_SHIFT); full_page = (sg[i].length & (PAGE_SIZE - 1)) == 0; - if ((pfn == pfn_cur_next) && full_page_cur) + if (pfn == pfn_cur_next && full_page_cur) goto out_head; - if ((pfn_next == pfn_cur) && full_page) + if (pfn_next == pfn_cur && full_page) goto out_tail; } @@ -441,10 +433,10 @@ static int sgv_check_full_clustering(struct scatterlist *sg, int cur, int hint) pfn_next = pfn + (sg[i].length >> PAGE_SHIFT); full_page = (sg[i].length & (PAGE_SIZE - 1)) == 0; - if ((pfn == pfn_cur_next) && full_page_cur) + if (pfn == pfn_cur_next && full_page_cur) goto out_head; - if ((pfn_next == pfn_cur) && full_page) + if (pfn_next == pfn_cur && full_page) goto out_tail; } @@ -478,27 +470,26 @@ static int sgv_check_tail_clustering(struct scatterlist *sg, int cur, int hint) #ifdef SCST_HIGHMEM if (page >= highmem_start_page) { - TRACE_MEM("%s", "HIGHMEM page allocated, no clustering") + TRACE_MEM("HIGHMEM page allocated, no clustering") goto out; } #endif #if 0 TRACE_MEM("pfn_cur %ld, pfn_cur_next %ld, len_cur %d, full_page_cur %d", - pfn_cur, pfn_cur_next, len_cur, full_page_cur); + pfn_cur, pfn_cur_next, len_cur, full_page_cur); #endif if (cur == 0) goto out; prev = cur - 1; - pfn_prev = page_to_pfn(sg_page(&sg[prev])) + - (sg[prev].length >> PAGE_SHIFT); + pfn_prev = page_to_pfn(sg_page(&sg[prev])) + (sg[prev].length >> PAGE_SHIFT); full_page = (sg[prev].length & (PAGE_SIZE - 1)) == 0; - if ((pfn_prev == pfn_cur) && full_page) { + if (pfn_prev == pfn_cur && full_page) { TRACE_MEM("SG segment %d will be tail merged with segment %d", - cur, prev); + cur, prev); sg[prev].length += len_cur; sg_clear(&sg[cur]); res = prev; @@ -508,8 +499,7 @@ out: return res; } -static void sgv_free_sys_sg_entries(struct scatterlist *sg, int sg_count, - void *priv) +static void sgv_free_sys_sg_entries(struct scatterlist *sg, int sg_count, void *priv) { int i; @@ -521,13 +511,13 @@ static void sgv_free_sys_sg_entries(struct scatterlist *sg, int sg_count, int pages = PAGE_ALIGN(len) >> PAGE_SHIFT; TRACE_MEM("page %lx, len %d, pages %d", - (unsigned long)p, len, pages); + (unsigned long)p, len, pages); while (pages > 0) { int order = 0; TRACE_MEM("free_pages(): order %d, page %lx", - order, (unsigned long)p); + order, (unsigned long)p); __free_pages(p, order); @@ -537,24 +527,22 @@ static void sgv_free_sys_sg_entries(struct scatterlist *sg, int sg_count, } } -static struct page *sgv_alloc_sys_pages(struct scatterlist *sg, - gfp_t gfp_mask, void *priv) +static struct page *sgv_alloc_sys_pages(struct scatterlist *sg, gfp_t gfp_mask, void *priv) { struct page *page = alloc_pages(gfp_mask, 0); sg_set_page(sg, page, PAGE_SIZE, 0); TRACE_MEM("page=%p, sg=%p, priv=%p", page, sg, priv); - if (page == NULL) { - TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of " - "sg page failed"); - } + if (!page) + TRACE(TRACE_OUT_OF_MEM, "Allocation of sg page failed"); + return page; } -static int sgv_alloc_sg_entries(struct scatterlist *sg, int pages, - gfp_t gfp_mask, enum sgv_clustering_types clustering_type, - struct trans_tbl_ent *trans_tbl, - const struct sgv_pool_alloc_fns *alloc_fns, void *priv) +static int sgv_alloc_sg_entries(struct scatterlist *sg, int pages, gfp_t gfp_mask, + enum sgv_clustering_types clustering_type, + struct trans_tbl_ent *trans_tbl, + const struct sgv_pool_alloc_fns *alloc_fns, void *priv) { int sg_count = 0; int pg, i, j; @@ -570,16 +558,16 @@ static int sgv_alloc_sg_entries(struct scatterlist *sg, int pages, #endif for (pg = 0; pg < pages; pg++) { - void *rc; + void *ret; + #ifdef CONFIG_SCST_DEBUG_OOM if (((gfp_mask & __GFP_NOFAIL) != __GFP_NOFAIL) && ((scst_random() % 10000) == 55)) - rc = NULL; + ret = NULL; else #endif - rc = alloc_fns->alloc_pages_fn(&sg[sg_count], gfp_mask, - priv); - if (rc == NULL) + ret = alloc_fns->alloc_pages_fn(&sg[sg_count], gfp_mask, priv); + if (!ret) goto out_no_mem; /* @@ -598,20 +586,20 @@ static int sgv_alloc_sg_entries(struct scatterlist *sg, int pages, if (merged == -1) sg_count++; - TRACE_MEM("pg=%d, merged=%d, sg_count=%d", pg, merged, - sg_count); + TRACE_MEM("pg=%d, merged=%d, sg_count=%d", + pg, merged, sg_count); } - if ((clustering_type != sgv_no_clustering) && (trans_tbl != NULL)) { + if (clustering_type != sgv_no_clustering && trans_tbl) { pg = 0; for (i = 0; i < pages; i++) { int n = PAGE_ALIGN(sg[i].length) >> PAGE_SHIFT; trans_tbl[i].pg_count = pg; for (j = 0; j < n; j++) - trans_tbl[pg++].sg_num = i+1; - TRACE_MEM("i=%d, n=%d, pg_count=%d", i, n, - trans_tbl[i].pg_count); + trans_tbl[pg++].sg_num = i + 1; + TRACE_MEM("i=%d, n=%d, pg_count=%d", + i, n, trans_tbl[i].pg_count); } } @@ -625,8 +613,7 @@ out_no_mem: goto out; } -static int sgv_alloc_arrays(struct sgv_pool_obj *obj, - int pages_to_alloc, gfp_t gfp_mask) +static int sgv_alloc_arrays(struct sgv_pool_obj *obj, int pages_to_alloc, gfp_t gfp_mask) { int sz, tsz = 0; int res = 0; @@ -636,9 +623,9 @@ static int sgv_alloc_arrays(struct sgv_pool_obj *obj, sz = pages_to_alloc * sizeof(obj->sg_entries[0]); obj->sg_entries = kmalloc(sz, gfp_mask); - if (unlikely(obj->sg_entries == NULL)) { - TRACE(TRACE_OUT_OF_MEM, "Allocation of sgv_pool_obj " - "SG vector failed (size %d)", sz); + if (unlikely(!obj->sg_entries)) { + TRACE(TRACE_OUT_OF_MEM, + "Allocation of sgv_pool_obj SG vector failed (size %d)", sz); res = -ENOMEM; goto out; } @@ -647,8 +634,7 @@ static int sgv_alloc_arrays(struct sgv_pool_obj *obj, if (sgv_pool_clustered(obj->owner_pool)) { if (pages_to_alloc <= sgv_max_trans_pages) { - obj->trans_tbl = - (struct trans_tbl_ent *)obj->sg_entries_data; + obj->trans_tbl = (struct trans_tbl_ent *)obj->sg_entries_data; /* * No need to clear trans_tbl, if needed, it will be * fully rewritten in sgv_alloc_sg_entries() @@ -656,18 +642,17 @@ static int sgv_alloc_arrays(struct sgv_pool_obj *obj, } else { tsz = pages_to_alloc * sizeof(obj->trans_tbl[0]); obj->trans_tbl = kzalloc(tsz, gfp_mask); - if (unlikely(obj->trans_tbl == NULL)) { - TRACE(TRACE_OUT_OF_MEM, "Allocation of " - "trans_tbl failed (size %d)", tsz); + if (unlikely(!obj->trans_tbl)) { + TRACE(TRACE_OUT_OF_MEM, + "Allocation of trans_tbl failed (size %d)", tsz); res = -ENOMEM; goto out_free; } } } - TRACE_MEM("pages_to_alloc %d, sz %d, tsz %d, obj %p, sg_entries %p, " - "trans_tbl %p", pages_to_alloc, sz, tsz, obj, obj->sg_entries, - obj->trans_tbl); + TRACE_MEM("pages_to_alloc %d, sz %d, tsz %d, obj %p, sg_entries %p, trans_tbl %p", + pages_to_alloc, sz, tsz, obj, obj->sg_entries, obj->trans_tbl); out: TRACE_EXIT_RES(res); @@ -679,8 +664,8 @@ out_free: goto out; } -static struct sgv_pool_obj *sgv_get_obj(struct sgv_pool *pool, int cache_num, - int pages, gfp_t gfp_mask, bool get_new) +static struct sgv_pool_obj *sgv_get_obj(struct sgv_pool *pool, int cache_num, int pages, + gfp_t gfp_mask, bool get_new) { struct sgv_pool_obj *obj; @@ -693,7 +678,7 @@ static struct sgv_pool_obj *sgv_get_obj(struct sgv_pool *pool, int cache_num, if (likely(!list_empty(&pool->recycling_lists[cache_num]))) { obj = list_first_entry(&pool->recycling_lists[cache_num], - struct sgv_pool_obj, recycling_list_entry); + struct sgv_pool_obj, recycling_list_entry); list_del(&obj->sorted_recycling_list_entry); list_del(&obj->recycling_list_entry); @@ -710,11 +695,10 @@ get_new: spin_unlock_bh(&pool->sgv_pool_lock); - TRACE_MEM("New cached entries %d (pool %p)", pool->cached_entries, - pool); + TRACE_MEM("New cached entries %d (pool %p)", + pool->cached_entries, pool); - obj = kmem_cache_alloc(pool->caches[cache_num], - gfp_mask & ~(__GFP_HIGHMEM|GFP_DMA)); + obj = kmem_cache_alloc(pool->caches[cache_num], gfp_mask & ~(__GFP_HIGHMEM | GFP_DMA)); if (likely(obj)) { memset(obj, 0, sizeof(*obj)); obj->cache_num = cache_num; @@ -739,30 +723,30 @@ static void sgv_put_obj(struct sgv_pool_obj *obj) spin_lock_bh(&pool->sgv_pool_lock); - TRACE_MEM("sgv %p, cache num %d, pages %d, sg_count %d", obj, - obj->cache_num, pages, obj->sg_count); + TRACE_MEM("sgv %p, cache num %d, pages %d, sg_count %d", + obj, obj->cache_num, pages, obj->sg_count); if (sgv_pool_clustered(pool)) { /* Make objects with less entries more preferred */ __list_for_each(entry, list) { - struct sgv_pool_obj *tmp = list_entry(entry, - struct sgv_pool_obj, recycling_list_entry); + struct sgv_pool_obj *tmp = list_entry(entry, struct sgv_pool_obj, + recycling_list_entry); TRACE_MEM("tmp %p, cache num %d, pages %d, sg_count %d", - tmp, tmp->cache_num, tmp->pages, tmp->sg_count); + tmp, tmp->cache_num, tmp->pages, tmp->sg_count); if (obj->sg_count <= tmp->sg_count) break; } entry = entry->prev; - } else + } else { entry = list; + } TRACE_MEM("Adding in %p (list %p)", entry, list); list_add(&obj->recycling_list_entry, entry); - list_add_tail(&obj->sorted_recycling_list_entry, - &pool->sorted_recycling_list); + list_add_tail(&obj->sorted_recycling_list_entry, &pool->sorted_recycling_list); obj->time_stamp = jiffies; @@ -771,12 +755,10 @@ static void sgv_put_obj(struct sgv_pool_obj *obj) if (!pool->purge_work_scheduled) { TRACE_MEM("Scheduling purge work for pool %p", pool); pool->purge_work_scheduled = true; - schedule_delayed_work(&pool->sgv_purge_work, - pool->purge_interval); + schedule_delayed_work(&pool->sgv_purge_work, pool->purge_interval); } spin_unlock_bh(&pool->sgv_pool_lock); - return; } /* No locks */ @@ -796,13 +778,9 @@ static int sgv_hiwmk_check(int pages_to_alloc) pages = __sgv_shrink(pages, 0, &freed); if (pages > 0) { - TRACE(TRACE_OUT_OF_MEM, "Requested amount of " - "memory (%d pages) for being executed " - "commands together with the already " - "allocated memory exceeds the allowed " - "maximum %d. Should you increase " - "scst_max_cmd_mem?", pages_to_alloc, - sgv_hi_wmk); + TRACE(TRACE_OUT_OF_MEM, + "Requested amount of memory (%d pages) for being executed commands together with the already allocated memory exceeds the allowed maximum %d. Should you increase scst_max_cmd_mem?", + pages_to_alloc, sgv_hi_wmk); atomic_inc(&sgv_releases_on_hiwmk_failed); res = -ENOMEM; goto out_unlock; @@ -812,8 +790,8 @@ static int sgv_hiwmk_check(int pages_to_alloc) atomic_add(pages_to_alloc, &sgv_pages_total); out_unlock: - TRACE_MEM("pages_to_alloc %d, new total %d", pages_to_alloc, - atomic_read(&sgv_pages_total)); + TRACE_MEM("pages_to_alloc %d, new total %d", + pages_to_alloc, atomic_read(&sgv_pages_total)); #endif return res; } @@ -823,10 +801,9 @@ static void sgv_hiwmk_uncheck(int pages) { #ifndef CONFIG_SCST_NO_TOTAL_MEM_CHECKS atomic_sub(pages, &sgv_pages_total); - TRACE_MEM("pages %d, new total %d", pages, - atomic_read(&sgv_pages_total)); + TRACE_MEM("pages %d, new total %d", + pages, atomic_read(&sgv_pages_total)); #endif - return; } /* No locks */ @@ -837,18 +814,15 @@ static bool sgv_check_allowed_mem(struct scst_mem_lim *mem_lim, int pages) alloced = atomic_add_return(pages, &mem_lim->alloced_pages); if (unlikely(alloced > mem_lim->max_allowed_pages)) { - TRACE(TRACE_OUT_OF_MEM, "Requested amount of memory " - "(%d pages) for being executed commands on a device " - "together with the already allocated memory exceeds " - "the allowed maximum %d. Should you increase " - "scst_max_dev_cmd_mem?", pages, - mem_lim->max_allowed_pages); + TRACE(TRACE_OUT_OF_MEM, + "Requested amount of memory (%d pages) for being executed commands on a device together with the already allocated memory exceeds the allowed maximum %d. Should you increase scst_max_dev_cmd_mem?", + pages, mem_lim->max_allowed_pages); atomic_sub(pages, &mem_lim->alloced_pages); res = false; } - TRACE_MEM("mem_lim %p, pages %d, res %d, new alloced %d", mem_lim, - pages, res, atomic_read(&mem_lim->alloced_pages)); + TRACE_MEM("mem_lim %p, pages %d, res %d, new alloced %d", + mem_lim, pages, res, atomic_read(&mem_lim->alloced_pages)); return res; } @@ -858,9 +832,8 @@ static void sgv_uncheck_allowed_mem(struct scst_mem_lim *mem_lim, int pages) { atomic_sub(pages, &mem_lim->alloced_pages); - TRACE_MEM("mem_lim %p, pages %d, new alloced %d", mem_lim, - pages, atomic_read(&mem_lim->alloced_pages)); - return; + TRACE_MEM("mem_lim %p, pages %d, new alloced %d", + mem_lim, pages, atomic_read(&mem_lim->alloced_pages)); } /** @@ -878,9 +851,9 @@ static void sgv_uncheck_allowed_mem(struct scst_mem_lim *mem_lim, int pages) * Allocate an SG vector from the SGV pool and returns pointer to it or * NULL in case of any error. See the SGV pool documentation for more details. */ -struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size, - gfp_t gfp_mask, int flags, int *count, - struct sgv_pool_obj **sgv, struct scst_mem_lim *mem_lim, void *priv) +struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size, gfp_t gfp_mask, + int flags, int *count, struct sgv_pool_obj **sgv, + struct scst_mem_lim *mem_lim, void *priv) { struct sgv_pool_obj *obj; int cache_num, pages, cnt; @@ -907,11 +880,10 @@ struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size, pages_to_alloc = max(pool->single_alloc_pages, pages); } - TRACE_MEM("size=%d, pages=%d, pages_to_alloc=%d, cache num=%d, " - "flags=%x, no_cached=%d, *sgv=%p", size, pages, - pages_to_alloc, cache_num, flags, no_cached, *sgv); + TRACE_MEM("size=%d, pages=%d, pages_to_alloc=%d, cache num=%d, flags=%x, no_cached=%d, *sgv=%p", + size, pages, pages_to_alloc, cache_num, flags, no_cached, *sgv); - if (*sgv != NULL) { + if (*sgv) { obj = *sgv; TRACE_MEM("Supplied obj %p, cache num %d", obj, obj->cache_num); @@ -931,10 +903,10 @@ struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size, allowed_mem_checked = true; obj = sgv_get_obj(pool, cache_num, pages_to_alloc, gfp_mask, - flags & SGV_POOL_ALLOC_GET_NEW); - if (unlikely(obj == NULL)) { - TRACE(TRACE_OUT_OF_MEM, "Allocation of " - "sgv_pool_obj failed (size %d)", size); + flags & SGV_POOL_ALLOC_GET_NEW); + if (unlikely(!obj)) { + TRACE(TRACE_OUT_OF_MEM, + "Allocation of sgv_pool_obj failed (size %d)", size); goto out_fail; } @@ -962,8 +934,8 @@ struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size, sg_init_table(obj->sg_entries, pages_to_alloc); TRACE_MEM("sg_entries %p", obj->sg_entries); if (sgv_pool_clustered(pool)) { - obj->trans_tbl = (struct trans_tbl_ent *) - (obj->sg_entries + pages_to_alloc); + obj->trans_tbl = + (struct trans_tbl_ent *)(obj->sg_entries + pages_to_alloc); TRACE_MEM("trans_tbl %p", obj->trans_tbl); /* * No need to clear trans_tbl, if needed, it @@ -972,8 +944,7 @@ struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size, */ } } else { - if (unlikely(sgv_alloc_arrays(obj, pages_to_alloc, - gfp_mask) != 0)) + if (unlikely(sgv_alloc_arrays(obj, pages_to_alloc, gfp_mask) != 0)) goto out_fail_free; } @@ -1001,9 +972,9 @@ struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size, sz = sizeof(*obj) + pages * sizeof(obj->sg_entries[0]); obj = kmalloc(sz, gfp_mask); - if (unlikely(obj == NULL)) { - TRACE(TRACE_OUT_OF_MEM, "Allocation of " - "sgv_pool_obj failed (size %d)", size); + if (unlikely(!obj)) { + TRACE(TRACE_OUT_OF_MEM, + "Allocation of sgv_pool_obj failed (size %d)", size); goto out_fail; } memset(obj, 0, sizeof(*obj)); @@ -1024,32 +995,26 @@ struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size, TRACE_MEM("Big or no_cached obj %p (size %d)", obj, sz); } - obj->sg_count = sgv_alloc_sg_entries(obj->sg_entries, - pages_to_alloc, gfp_mask, pool->clustering_type, - obj->trans_tbl, &pool->alloc_fns, priv); + obj->sg_count = sgv_alloc_sg_entries(obj->sg_entries, pages_to_alloc, gfp_mask, + pool->clustering_type, obj->trans_tbl, + &pool->alloc_fns, priv); if (unlikely(obj->sg_count <= 0)) { obj->sg_count = 0; - if ((flags & SGV_POOL_RETURN_OBJ_ON_ALLOC_FAIL) && - (cache_num >= 0)) + if ((flags & SGV_POOL_RETURN_OBJ_ON_ALLOC_FAIL) && cache_num >= 0) goto out_return1; else goto out_fail_free_sg_entries; } if (cache_num >= 0) { - atomic_add(pages_to_alloc - obj->sg_count, - &pool->cache_acc[cache_num].merged); + atomic_add(pages_to_alloc - obj->sg_count, &pool->cache_acc[cache_num].merged); } else { if (no_cached) { - atomic_add(pages_to_alloc, - &pool->other_pages); - atomic_add(pages_to_alloc - obj->sg_count, - &pool->other_merged); + atomic_add(pages_to_alloc, &pool->other_pages); + atomic_add(pages_to_alloc - obj->sg_count, &pool->other_merged); } else { - atomic_add(pages_to_alloc, - &pool->big_pages); - atomic_add(pages_to_alloc - obj->sg_count, - &pool->big_merged); + atomic_add(pages_to_alloc, &pool->big_pages); + atomic_add(pages_to_alloc - obj->sg_count, &pool->big_merged); } } @@ -1059,10 +1024,10 @@ success: atomic_inc(&pool->cache_acc[cache_num].total_alloc); if (sgv_pool_clustered(pool)) - cnt = obj->trans_tbl[pages-1].sg_num; + cnt = obj->trans_tbl[pages - 1].sg_num; else cnt = pages; - sg = cnt-1; + sg = cnt - 1; obj->orig_sg = sg; obj->orig_length = obj->sg_entries[sg].length; if (sgv_pool_clustered(pool)) { @@ -1081,12 +1046,12 @@ success: res = obj->sg_entries; *sgv = obj; - obj->sg_entries[cnt-1].length -= PAGE_ALIGN(size) - size; - sg_mark_end(&obj->sg_entries[cnt-1]); + obj->sg_entries[cnt - 1].length -= PAGE_ALIGN(size) - size; + sg_mark_end(&obj->sg_entries[cnt - 1]); - TRACE_MEM("obj=%p, sg_entries %p (size=%d, pages=%d, sg_count=%d, " - "count=%d, last_len=%d)", obj, obj->sg_entries, size, pages, - obj->sg_count, *count, obj->sg_entries[obj->orig_sg].length); + TRACE_MEM("obj=%p, sg_entries %p (size=%d, pages=%d, sg_count=%d, count=%d, last_len=%d)", + obj, obj->sg_entries, size, pages, obj->sg_count, *count, + obj->sg_entries[obj->orig_sg].length); out: TRACE_EXIT_HRES(res); @@ -1107,8 +1072,7 @@ out_return2: out_fail_free_sg_entries: if (obj->sg_entries != obj->sg_entries_data) { - if (obj->trans_tbl != - (struct trans_tbl_ent *)obj->sg_entries_data) { + if (obj->trans_tbl != (struct trans_tbl_ent *)obj->sg_entries_data) { /* kfree() handles NULL parameter */ kfree(obj->trans_tbl); obj->trans_tbl = NULL; @@ -1124,14 +1088,15 @@ out_fail_free: spin_unlock_bh(&pool->sgv_pool_lock); kmem_cache_free(pool->caches[obj->cache_num], obj); - } else + } else { kfree(obj); + } out_fail: res = NULL; *count = 0; *sgv = NULL; - TRACE_MEM("%s", "Allocation failed"); + TRACE_MEM("Allocation failed"); out_uncheck: if (hiwmk_checked) @@ -1166,9 +1131,8 @@ void sgv_pool_free(struct sgv_pool_obj *obj, struct scst_mem_lim *mem_lim) { int pages = (obj->sg_count != 0) ? obj->pages : 0; - TRACE_MEM("Freeing obj %p, cache num %d, pages %d, sg_entries %p, " - "sg_count %d, allocator_priv %p", obj, obj->cache_num, pages, - obj->sg_entries, obj->sg_count, obj->allocator_priv); + TRACE_MEM("Freeing obj %p, cache num %d, pages %d, sg_entries %p, sg_count %d, allocator_priv %p", + obj, obj->cache_num, pages, obj->sg_entries, obj->sg_count, obj->allocator_priv); /* * Enable it if you are investigating a data corruption and want to make @@ -1193,10 +1157,8 @@ void sgv_pool_free(struct sgv_pool_obj *obj, struct scst_mem_lim *mem_lim) while (pages > 0) { if (page_count(p) != 1) { - PRINT_WARNING("Freeing page %p with " - "additional owners (_count %d). " - "Data corruption possible!", - p, page_count(p)); + PRINT_WARNING("Freeing page %p with additional owners (_count %d). Data corruption possible!", + p, page_count(p)); WARN_ON(1); } pages--; @@ -1211,14 +1173,13 @@ void sgv_pool_free(struct sgv_pool_obj *obj, struct scst_mem_lim *mem_lim) sg_unmark_end(&obj->sg_entries[obj->orig_sg]); sgv_put_obj(obj); } else { - obj->owner_pool->alloc_fns.free_pages_fn(obj->sg_entries, - obj->sg_count, obj->allocator_priv); + obj->owner_pool->alloc_fns.free_pages_fn(obj->sg_entries, obj->sg_count, + obj->allocator_priv); kfree(obj); sgv_hiwmk_uncheck(pages); } sgv_uncheck_allowed_mem(mem_lim, pages); - return; } EXPORT_SYMBOL_GPL(sgv_pool_free); @@ -1265,9 +1226,9 @@ struct scatterlist *scst_alloc_sg(int size, gfp_t gfp_mask, int *count) } res = kmalloc_array(pages, sizeof(*res), gfp_mask); - if (res == NULL) { - TRACE(TRACE_OUT_OF_MEM, "Unable to allocate sg for %d pages", - pages); + if (!res) { + TRACE(TRACE_OUT_OF_MEM, + "Unable to allocate sg for %d pages", pages); goto out_uncheck; } @@ -1278,12 +1239,12 @@ struct scatterlist *scst_alloc_sg(int size, gfp_t gfp_mask, int *count) * scst_free_sg() to figure out how many pages are in the SG vector. * So, let's always don't use clustering. */ - cnt = sgv_alloc_sg_entries(res, pages, gfp_mask, sgv_no_clustering, - NULL, &sys_alloc_fns, NULL); + cnt = sgv_alloc_sg_entries(res, pages, gfp_mask, sgv_no_clustering, NULL, &sys_alloc_fns, + NULL); if (cnt <= 0) goto out_free; - res[cnt-1].length -= PAGE_ALIGN(size) - size; + res[cnt - 1].length -= PAGE_ALIGN(size) - size; *count = cnt; @@ -1317,13 +1278,11 @@ void scst_free_sg(struct scatterlist *sg, int count) sgv_free_sys_sg_entries(sg, count, NULL); kfree(sg); - return; } EXPORT_SYMBOL_GPL(scst_free_sg); /* Must be called under sgv_pools_mutex */ -static void sgv_pool_init_cache(struct sgv_pool *pool, int cache_num, - bool per_cpu) +static void sgv_pool_init_cache(struct sgv_pool *pool, int cache_num, bool per_cpu) { int size; int pages; @@ -1339,18 +1298,17 @@ static void sgv_pool_init_cache(struct sgv_pool *pool, int cache_num, pages = pool->single_alloc_pages; if (pages <= sgv_max_local_pages) { - size = sizeof(*obj) + pages * - (sizeof(obj->sg_entries[0]) + - ((pool->clustering_type != sgv_no_clustering) ? - sizeof(obj->trans_tbl[0]) : 0)); + size = sizeof(*obj) + pages * (sizeof(obj->sg_entries[0]) + + ((pool->clustering_type != sgv_no_clustering) ? + sizeof(obj->trans_tbl[0]) : 0)); } else if (pages <= sgv_max_trans_pages) { /* * sg_entries is allocated outside object, * but trans_tbl is still embedded. */ size = sizeof(*obj) + pages * - (((pool->clustering_type != sgv_no_clustering) ? - sizeof(obj->trans_tbl[0]) : 0)); + ((pool->clustering_type != sgv_no_clustering) ? + sizeof(obj->trans_tbl[0]) : 0); } else { size = sizeof(*obj); /* both sgv and trans_tbl are kmalloc'ed() */ @@ -1358,20 +1316,17 @@ static void sgv_pool_init_cache(struct sgv_pool *pool, int cache_num, TRACE_MEM("pages=%d, size=%d (per cpu %d)", pages, size, per_cpu); - scnprintf(pool->cache_names[cache_num], - sizeof(pool->cache_names[cache_num]), - "%s-%uK", pool->name, (pages << PAGE_SHIFT) >> 10); - pool->caches[cache_num] = kmem_cache_create( - pool->cache_names[cache_num], size, - 0, per_cpu ? SCST_SLAB_FLAGS : - (SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN), NULL); - return; + scnprintf(pool->cache_names[cache_num], sizeof(pool->cache_names[cache_num]), + "%s-%uK", pool->name, (pages << PAGE_SHIFT) >> 10); + pool->caches[cache_num] = kmem_cache_create(pool->cache_names[cache_num], size, 0, + per_cpu ? SCST_SLAB_FLAGS : + (SCST_SLAB_FLAGS | SLAB_HWCACHE_ALIGN), NULL); } /* Must be called under sgv_pools_mutex */ static int sgv_pool_init(struct sgv_pool *pool, const char *name, - enum sgv_clustering_types clustering_type, int single_alloc_pages, - int purge_interval, bool per_cpu) + enum sgv_clustering_types clustering_type, int single_alloc_pages, + int purge_interval, bool per_cpu) { int res = -ENOMEM; int i; @@ -1380,7 +1335,7 @@ static int sgv_pool_init(struct sgv_pool *pool, const char *name, if (single_alloc_pages < 0) { PRINT_ERROR("Wrong single_alloc_pages value %d", - single_alloc_pages); + single_alloc_pages); res = -EINVAL; goto out; } @@ -1402,8 +1357,9 @@ static int sgv_pool_init(struct sgv_pool *pool, const char *name, /* Let's pretend that it's always scheduled */ pool->purge_work_scheduled = 1; } - } else + } else { pool->purge_interval = SGV_DEFAULT_PURGE_INTERVAL; + } if (single_alloc_pages == 0) { pool->max_caches = SGV_POOL_ELEMENTS; pool->max_cached_pages = 1 << (SGV_POOL_ELEMENTS - 1); @@ -1414,20 +1370,18 @@ static int sgv_pool_init(struct sgv_pool *pool, const char *name, pool->alloc_fns.alloc_pages_fn = sgv_alloc_sys_pages; pool->alloc_fns.free_pages_fn = sgv_free_sys_sg_entries; - TRACE_MEM("name %s, sizeof(*obj)=%zd, clustering_type=%d, " - "single_alloc_pages=%d, max_caches=%d, max_cached_pages=%d", - name, sizeof(struct sgv_pool_obj), clustering_type, - single_alloc_pages, pool->max_caches, pool->max_cached_pages); + TRACE_MEM("name %s, sizeof(*obj)=%zd, clustering_type=%d, single_alloc_pages=%d, max_caches=%d, max_cached_pages=%d", + name, sizeof(struct sgv_pool_obj), clustering_type, single_alloc_pages, + pool->max_caches, pool->max_cached_pages); - strscpy(pool->name, name, sizeof(pool->name)-1); + strscpy(pool->name, name, sizeof(pool->name) - 1); pool->owner_mm = current->mm; for (i = 0; i < pool->max_caches; i++) { sgv_pool_init_cache(pool, i, per_cpu); - if (pool->caches[i] == NULL) { - PRINT_ERROR("Allocation of sgv_pool " - "cache %s(%d) failed", name, i); + if (!pool->caches[i]) { + PRINT_ERROR("Allocation of sgv_pool cache %s(%d) failed", name, i); goto out_free; } } @@ -1479,8 +1433,7 @@ static void sgv_evaluate_local_max_pages(void) sgv_max_trans_pages = space4sgv_ttbl / sizeof(struct trans_tbl_ent); TRACE_MEM("sgv_max_local_pages %d, sgv_max_trans_pages %d", - sgv_max_local_pages, sgv_max_trans_pages); - return; + sgv_max_local_pages, sgv_max_trans_pages); } /* @@ -1500,8 +1453,8 @@ void sgv_pool_flush(struct sgv_pool *pool) spin_lock_bh(&pool->sgv_pool_lock); while (!list_empty(&pool->recycling_lists[i])) { - obj = list_first_entry(&pool->recycling_lists[i], - struct sgv_pool_obj, recycling_list_entry); + obj = list_first_entry(&pool->recycling_lists[i], struct sgv_pool_obj, + recycling_list_entry); __sgv_purge_from_cache(obj); @@ -1516,7 +1469,6 @@ void sgv_pool_flush(struct sgv_pool *pool) } TRACE_EXIT(); - return; } EXPORT_SYMBOL_GPL(sgv_pool_flush); @@ -1552,7 +1504,6 @@ static void sgv_pool_destroy(struct sgv_pool *pool) out: TRACE_EXIT(); - return; } /** @@ -1566,12 +1517,11 @@ out: * See the SGV pool documentation for more details. */ void sgv_pool_set_allocator(struct sgv_pool *pool, - struct page *(*alloc_pages_fn)(struct scatterlist *, gfp_t, void *), - void (*free_pages_fn)(struct scatterlist *, int, void *)) + struct page *(*alloc_pages_fn)(struct scatterlist *, gfp_t, void *), + void (*free_pages_fn)(struct scatterlist *, int, void *)) { pool->alloc_fns.alloc_pages_fn = alloc_pages_fn; pool->alloc_fns.free_pages_fn = free_pages_fn; - return; } EXPORT_SYMBOL_GPL(sgv_pool_set_allocator); @@ -1601,19 +1551,17 @@ EXPORT_SYMBOL_GPL(sgv_pool_set_allocator); * Description: * Returns the resulting SGV pool or NULL in case of any error. */ -struct sgv_pool *sgv_pool_create_node(const char *name, - enum sgv_clustering_types clustering_type, - int single_alloc_pages, bool shared, int purge_interval, int nodeid) +struct sgv_pool *sgv_pool_create_node(const char *name, enum sgv_clustering_types clustering_type, + int single_alloc_pages, bool shared, int purge_interval, + int nodeid) { struct sgv_pool *pool, *tp; int rc; TRACE_ENTRY(); - TRACE_MEM("Creating pool %s (clustering_type %d, " - "single_alloc_pages %d, shared %d, purge_interval %d, " - "nodeid %d)", name, clustering_type, single_alloc_pages, - shared, purge_interval, nodeid); + TRACE_MEM("Creating pool %s (clustering_type %d, single_alloc_pages %d, shared %d, purge_interval %d, nodeid %d)", + name, clustering_type, single_alloc_pages, shared, purge_interval, nodeid); /* * __sgv_shrink() takes sgv_pools_mutex, so we have to play tricks to @@ -1621,9 +1569,9 @@ struct sgv_pool *sgv_pool_create_node(const char *name, */ pool = kmem_cache_alloc_node(sgv_pool_cachep, GFP_KERNEL, nodeid); - if (pool == NULL) { + if (!pool) { PRINT_ERROR("Allocation of sgv_pool failed (size %zd)", - sizeof(*pool)); + sizeof(*pool)); goto out; } memset(pool, 0, sizeof(*pool)); @@ -1634,9 +1582,8 @@ struct sgv_pool *sgv_pool_create_node(const char *name, if (strcmp(tp->name, name) == 0) { if (shared) { if (tp->owner_mm != current->mm) { - PRINT_ERROR("Attempt of a shared use " - "of SGV pool %s with " - "different MM", name); + PRINT_ERROR("Attempt of a shared use of SGV pool %s with different MM", + name); goto out_free; } sgv_pool_get(tp); @@ -1650,8 +1597,8 @@ struct sgv_pool *sgv_pool_create_node(const char *name, } tp = NULL; - rc = sgv_pool_init(pool, name, clustering_type, single_alloc_pages, - purge_interval, nodeid != NUMA_NO_NODE); + rc = sgv_pool_init(pool, name, clustering_type, single_alloc_pages, purge_interval, + nodeid != NUMA_NO_NODE); if (rc != 0) goto out_free; @@ -1659,7 +1606,7 @@ out_unlock: mutex_unlock(&sgv_pools_mutex); out: - TRACE_EXIT_RES(pool != NULL); + TRACE_EXIT_HRES(pool); return pool; out_free: @@ -1678,8 +1625,7 @@ void sgv_pool_get(struct sgv_pool *pool) { atomic_inc(&pool->sgv_pool_ref); TRACE_MEM("Incrementing sgv pool %p ref (new value %d)", - pool, atomic_read(&pool->sgv_pool_ref)); - return; + pool, atomic_read(&pool->sgv_pool_ref)); } EXPORT_SYMBOL_GPL(sgv_pool_get); @@ -1692,10 +1638,9 @@ EXPORT_SYMBOL_GPL(sgv_pool_get); void sgv_pool_put(struct sgv_pool *pool) { TRACE_MEM("Decrementing sgv pool %p ref (new value %d)", - pool, atomic_read(&pool->sgv_pool_ref)-1); + pool, atomic_read(&pool->sgv_pool_ref) - 1); if (atomic_dec_and_test(&pool->sgv_pool_ref)) sgv_pool_destroy(pool); - return; } EXPORT_SYMBOL_GPL(sgv_pool_put); @@ -1714,7 +1659,6 @@ void sgv_pool_del(struct sgv_pool *pool) sgv_pool_put(pool); TRACE_EXIT(); - return; } EXPORT_SYMBOL_GPL(sgv_pool_del); @@ -1760,8 +1704,8 @@ int __init scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmar TRACE_ENTRY(); - sgv_pool_cachep = KMEM_CACHE(sgv_pool, SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN); - if (sgv_pool_cachep == NULL) + sgv_pool_cachep = KMEM_CACHE(sgv_pool, SCST_SLAB_FLAGS | SLAB_HWCACHE_ALIGN); + if (!sgv_pool_cachep) goto out_err; sgv_hi_wmk = mem_hwmark; @@ -1770,17 +1714,15 @@ int __init scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmar sgv_evaluate_local_max_pages(); sgv_norm_pool_main = sgv_pool_create("sgv", sgv_no_clustering, 0, false, 0); - if (sgv_norm_pool_main == NULL) + if (!sgv_norm_pool_main) goto out_free_pool; - sgv_norm_clust_pool_main = sgv_pool_create("sgv-clust", - sgv_full_clustering, 0, false, 0); - if (sgv_norm_clust_pool_main == NULL) + sgv_norm_clust_pool_main = sgv_pool_create("sgv-clust", sgv_full_clustering, 0, false, 0); + if (!sgv_norm_clust_pool_main) goto out_free_norm; - sgv_dma_pool_main = sgv_pool_create("sgv-dma", sgv_no_clustering, 0, - false, 0); - if (sgv_dma_pool_main == NULL) + sgv_dma_pool_main = sgv_pool_create("sgv-dma", sgv_no_clustering, 0, false, 0); + if (!sgv_dma_pool_main) goto out_free_clust; /* @@ -1803,9 +1745,9 @@ int __init scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmar if (!cpu_online(i)) continue; scnprintf(name, sizeof(name), "sgv-%d", i); - sgv_norm_pool_per_cpu[i] = sgv_pool_create_node(name, - sgv_no_clustering, 0, false, 0, cpu_to_node(i)); - if (sgv_norm_pool_per_cpu[i] == NULL) + sgv_norm_pool_per_cpu[i] = sgv_pool_create_node(name, sgv_no_clustering, 0, false, + 0, cpu_to_node(i)); + if (!sgv_norm_pool_per_cpu[i]) goto out_free_per_cpu_norm; } @@ -1815,9 +1757,9 @@ int __init scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmar if (!cpu_online(i)) continue; scnprintf(name, sizeof(name), "sgv-clust-%d", i); - sgv_norm_clust_pool_per_cpu[i] = sgv_pool_create_node(name, - sgv_full_clustering, 0, false, 0, cpu_to_node(i)); - if (sgv_norm_clust_pool_per_cpu[i] == NULL) + sgv_norm_clust_pool_per_cpu[i] = sgv_pool_create_node(name, sgv_full_clustering, 0, + false, 0, cpu_to_node(i)); + if (!sgv_norm_clust_pool_per_cpu[i]) goto out_free_per_cpu_clust; } @@ -1827,9 +1769,9 @@ int __init scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmar if (!cpu_online(i)) continue; scnprintf(name, sizeof(name), "sgv-dma-%d", i); - sgv_dma_pool_per_cpu[i] = sgv_pool_create_node(name, - sgv_no_clustering, 0, false, 0, cpu_to_node(i)); - if (sgv_dma_pool_per_cpu[i] == NULL) + sgv_dma_pool_per_cpu[i] = sgv_pool_create_node(name, sgv_no_clustering, 0, false, + 0, cpu_to_node(i)); + if (!sgv_dma_pool_per_cpu[i]) goto out_free_per_cpu_dma; } @@ -1901,7 +1843,6 @@ void scst_sgv_pools_deinit(void) kmem_cache_destroy(sgv_pool_cachep); TRACE_EXIT(); - return; } static ssize_t sgv_sysfs_stat_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -1963,8 +1904,8 @@ static ssize_t sgv_sysfs_stat_show(struct kobject *kobj, struct kobj_attribute * return ret; } -static ssize_t sgv_sysfs_stat_reset(struct kobject *kobj, - struct kobj_attribute *attr, const char *buf, size_t count) +static ssize_t sgv_sysfs_stat_reset(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) { struct sgv_pool *pool; int i; @@ -2026,8 +1967,8 @@ static ssize_t sgv_sysfs_global_stat_show(struct kobject *kobj, struct kobj_attr return ret; } -static ssize_t sgv_sysfs_global_stat_reset(struct kobject *kobj, - struct kobj_attribute *attr, const char *buf, size_t count) +static ssize_t sgv_sysfs_global_stat_reset(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) { TRACE_ENTRY(); @@ -2037,20 +1978,20 @@ static ssize_t sgv_sysfs_global_stat_reset(struct kobject *kobj, atomic_set(&sgv_other_total_alloc, 0); #endif - PRINT_INFO("%s", "Global SGV pool statistics reset"); + PRINT_INFO("Global SGV pool statistics reset"); TRACE_EXIT_RES(count); return count; } static struct kobj_attribute sgv_stat_attr = - __ATTR(stats, S_IRUGO | S_IWUSR, sgv_sysfs_stat_show, - sgv_sysfs_stat_reset); + __ATTR(stats, 0644, sgv_sysfs_stat_show, sgv_sysfs_stat_reset); static struct attribute *sgv_pool_attrs[] = { &sgv_stat_attr.attr, NULL, }; + #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) ATTRIBUTE_GROUPS(sgv_pool); #endif @@ -2062,11 +2003,10 @@ static void sgv_kobj_release(struct kobject *kobj) TRACE_ENTRY(); pool = container_of(kobj, struct sgv_pool, sgv_kobj); - if (pool->sgv_kobj_release_cmpl != NULL) + if (pool->sgv_kobj_release_cmpl) complete_all(pool->sgv_kobj_release_cmpl); TRACE_EXIT(); - return; } static struct kobj_type sgv_pool_ktype = { @@ -2114,13 +2054,14 @@ static void scst_sgv_sysfs_del(struct sgv_pool *pool) } static struct kobj_attribute sgv_global_stat_attr = - __ATTR(global_stats, S_IRUGO | S_IWUSR, sgv_sysfs_global_stat_show, - sgv_sysfs_global_stat_reset); + __ATTR(global_stats, 0644, + sgv_sysfs_global_stat_show, sgv_sysfs_global_stat_reset); static struct attribute *sgv_def_attrs[] = { &sgv_global_stat_attr.attr, NULL, }; + #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) ATTRIBUTE_GROUPS(sgv_def); #endif |
From: Gleb C. <lna...@ya...> - 2025-09-23 08:43:58
|
Commit: 6e787cb GitHub URL: https://github.com/SCST-project/scst/commit/6e787cbefd8817a5a0bd441cb38cda9445d9eedf Author: Gleb Chesnokov Date: 2025-09-23T11:41:48+03:00 Log Message: ----------- scst_pres: Fix multiple checkpatch warnings This patch does not change any functionality. Modified Paths: -------------- scst/src/scst_pres.c | 884 ++++++--------- 1 file changed, 371 insertions(+), 513 deletions(-) =================================================================== diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index cfff018..a10be41 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -73,12 +73,11 @@ #endif #if defined(CONFIG_LOCKDEP) -#define scst_assert_pr_mutex_held(dev) \ - do { \ - if (dev->dev_list_entry.next && \ - !list_empty(&dev->dev_list_entry)) \ - lockdep_assert_held(&dev->dev_pr_mutex); \ - } while (0) +#define scst_assert_pr_mutex_held(dev) \ +do { \ + if ((dev)->dev_list_entry.next && !list_empty(&(dev)->dev_list_entry)) \ + lockdep_assert_held(&(dev)->dev_pr_mutex); \ +} while (0) #else static inline void scst_assert_pr_mutex_held(struct scst_device *dev) { @@ -87,7 +86,7 @@ static inline void scst_assert_pr_mutex_held(struct scst_device *dev) uint32_t scst_tid_size(const uint8_t *tid) { - sBUG_ON(tid == NULL); + sBUG_ON(!tid); if ((tid[0] & 0x0f) == SCSI_TRANSPORTID_PROTOCOLID_ISCSI) return get_unaligned_be16(&tid[2]) + 4; @@ -114,11 +113,11 @@ bool tid_equal(const uint8_t *tid_a, const uint8_t *tid_b) { int len; - if (tid_a == NULL || tid_b == NULL) + if (!tid_a || !tid_b) return false; if ((tid_a[0] & 0x0f) != (tid_b[0] & 0x0f)) { - TRACE_DBG("%s", "Different protocol IDs"); + TRACE_DBG("Different protocol IDs"); return false; } @@ -132,37 +131,41 @@ bool tid_equal(const uint8_t *tid_a, const uint8_t *tid_b) tid_a += 4; tid_b += 4; - if (tid_a_fmt == 0x00) + if (tid_a_fmt == 0x00) { tid_a_len = strnlen(tid_a, tid_a_max); - else if (tid_a_fmt == 0x40) { + } else if (tid_a_fmt == 0x40) { if (tid_a_fmt != tid_b_fmt) { uint8_t *p = strnchr(tid_a, tid_a_max, ','); - if (p == NULL) + if (!p) goto out_error; tid_a_len = p - tid_a; sBUG_ON(tid_a_len > tid_a_max); - } else + } else { tid_a_len = strnlen(tid_a, tid_a_max); - } else + } + } else { goto out_error; + } - if (tid_b_fmt == 0x00) + if (tid_b_fmt == 0x00) { tid_b_len = strnlen(tid_b, tid_b_max); - else if (tid_b_fmt == 0x40) { + } else if (tid_b_fmt == 0x40) { if (tid_a_fmt != tid_b_fmt) { uint8_t *p = strnchr(tid_b, tid_b_max, ','); - if (p == NULL) + if (!p) goto out_error; tid_b_len = p - tid_b; sBUG_ON(tid_b_len > tid_b_max); - } else + } else { tid_b_len = strnlen(tid_b, tid_b_max); - } else + } + } else { goto out_error; + } if (tid_a_len != tid_b_len) return false; @@ -181,13 +184,13 @@ bool tid_equal(const uint8_t *tid_a, const uint8_t *tid_b) return memcmp(tid_a, tid_b, len) == 0; out_error: - PRINT_ERROR("%s", "Invalid initiator port transport id"); + PRINT_ERROR("Invalid initiator port transport id"); return false; } /* Must be called under dev_pr_mutex */ -void scst_pr_set_holder(struct scst_device *dev, - struct scst_dev_registrant *holder, uint8_t scope, uint8_t type) +void scst_pr_set_holder(struct scst_device *dev, struct scst_dev_registrant *holder, uint8_t scope, + uint8_t type) { scst_assert_pr_mutex_held(dev); @@ -200,8 +203,7 @@ void scst_pr_set_holder(struct scst_device *dev, } /* Must be called under dev_pr_mutex */ -static bool scst_pr_is_holder(struct scst_device *dev, - struct scst_dev_registrant *reg) +static bool scst_pr_is_holder(struct scst_device *dev, struct scst_dev_registrant *reg) { bool res = false; @@ -213,9 +215,9 @@ static bool scst_pr_is_holder(struct scst_device *dev, goto out; if (dev->pr_type == TYPE_EXCLUSIVE_ACCESS_ALL_REG || - dev->pr_type == TYPE_WRITE_EXCLUSIVE_ALL_REG) { - res = (reg != NULL); - } else + dev->pr_type == TYPE_WRITE_EXCLUSIVE_ALL_REG) + res = reg; + else res = (dev->pr_holder == reg); out: @@ -234,55 +236,46 @@ void scst_pr_dump_prs(struct scst_device *dev, bool force) #if defined(CONFIG_SCST_DEBUG) if ((trace_flag & TRACE_PRES) == 0) #endif - goto out; + return; } PRINT_INFO("Persistent reservations for device %s:", dev->virt_name); - if (list_empty(&dev->dev_registrants_list)) - PRINT_INFO("%s", " No registrants"); - else { + if (list_empty(&dev->dev_registrants_list)) { + PRINT_INFO(" No registrants"); + } else { struct scst_dev_registrant *reg; int i = 0; - list_for_each_entry(reg, &dev->dev_registrants_list, - dev_registrants_list_entry) { - PRINT_INFO(" [%d] registrant %s/%d, key %016llx " - "(reg %p, tgt_dev %p)", i++, - debug_transport_id_to_initiator_name( - reg->transport_id), - reg->rel_tgt_id, be64_to_cpu(reg->key), reg, - reg->tgt_dev); + list_for_each_entry(reg, &dev->dev_registrants_list, dev_registrants_list_entry) { + PRINT_INFO(" [%d] registrant %s/%d, key %016llx (reg %p, tgt_dev %p)", + i++, debug_transport_id_to_initiator_name(reg->transport_id), + reg->rel_tgt_id, be64_to_cpu(reg->key), reg, reg->tgt_dev); } } if (dev->pr_is_set) { struct scst_dev_registrant *holder = dev->pr_holder; - if (holder != NULL) - PRINT_INFO("Reservation holder is %s/%d (key %016llx, " - "scope %x, type %x, reg %p, tgt_dev %p)", - debug_transport_id_to_initiator_name( - holder->transport_id), - holder->rel_tgt_id, be64_to_cpu(holder->key), - dev->pr_scope, dev->pr_type, holder, - holder->tgt_dev); + if (holder) + PRINT_INFO("Reservation holder is %s/%d (key %016llx, scope %x, type %x, reg %p, tgt_dev %p)", + debug_transport_id_to_initiator_name(holder->transport_id), + holder->rel_tgt_id, be64_to_cpu(holder->key), + dev->pr_scope, dev->pr_type, holder, holder->tgt_dev); else - PRINT_INFO("All registrants are reservation holders " - "(scope %x, type %x)", dev->pr_scope, - dev->pr_type); - } else - PRINT_INFO("%s", "Not reserved"); - -out: - return; + PRINT_INFO("All registrants are reservation holders (scope %x, type %x)", + dev->pr_scope, dev->pr_type); + } else { + PRINT_INFO("Not reserved"); + } } #endif /* defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) */ /* dev_pr_mutex must be locked */ static void scst_pr_find_registrants_list_all(struct scst_device *dev, - struct scst_dev_registrant *exclude_reg, struct list_head *list) + struct scst_dev_registrant *exclude_reg, + struct list_head *list) { struct scst_dev_registrant *reg; @@ -290,27 +283,24 @@ static void scst_pr_find_registrants_list_all(struct scst_device *dev, scst_assert_pr_mutex_held(dev); - TRACE_PR("Finding all registered records for device '%s' " - "with exclude reg key %016llx", - dev->virt_name, be64_to_cpu(exclude_reg->key)); + TRACE_PR("Finding all registered records for device '%s' with exclude reg key %016llx", + dev->virt_name, be64_to_cpu(exclude_reg->key)); - list_for_each_entry(reg, &dev->dev_registrants_list, - dev_registrants_list_entry) { + list_for_each_entry(reg, &dev->dev_registrants_list, dev_registrants_list_entry) { if (reg == exclude_reg) continue; TRACE_PR("Adding registrant %s/%d (%p) to find list (key %016llx)", - debug_transport_id_to_initiator_name(reg->transport_id), - reg->rel_tgt_id, reg, be64_to_cpu(reg->key)); + debug_transport_id_to_initiator_name(reg->transport_id), + reg->rel_tgt_id, reg, be64_to_cpu(reg->key)); list_add_tail(®->aux_list_entry, list); } TRACE_EXIT(); - return; } /* dev_pr_mutex must be locked */ -static void scst_pr_find_registrants_list_key(struct scst_device *dev, - __be64 key, struct list_head *list) +static void scst_pr_find_registrants_list_key(struct scst_device *dev, __be64 key, + struct list_head *list) { struct scst_dev_registrant *reg; @@ -319,29 +309,23 @@ static void scst_pr_find_registrants_list_key(struct scst_device *dev, scst_assert_pr_mutex_held(dev); TRACE_PR("Finding registrants for device '%s' with key %016llx", - dev->virt_name, be64_to_cpu(key)); + dev->virt_name, be64_to_cpu(key)); - list_for_each_entry(reg, &dev->dev_registrants_list, - dev_registrants_list_entry) { + list_for_each_entry(reg, &dev->dev_registrants_list, dev_registrants_list_entry) { if (reg->key == key) { - TRACE_PR("Adding registrant %s/%d (%p) to the find " - "list (key %016llx)", - debug_transport_id_to_initiator_name( - reg->transport_id), - reg->rel_tgt_id, reg->tgt_dev, - be64_to_cpu(key)); + TRACE_PR("Adding registrant %s/%d (%p) to the find list (key %016llx)", + debug_transport_id_to_initiator_name(reg->transport_id), + reg->rel_tgt_id, reg->tgt_dev, be64_to_cpu(key)); list_add_tail(®->aux_list_entry, list); } } TRACE_EXIT(); - return; } /* dev_pr_mutex must be locked */ -struct scst_dev_registrant *scst_pr_find_reg( - struct scst_device *dev, const uint8_t *transport_id, - const uint16_t rel_tgt_id) +struct scst_dev_registrant *scst_pr_find_reg(struct scst_device *dev, const uint8_t *transport_id, + const uint16_t rel_tgt_id) { struct scst_dev_registrant *reg, *res = NULL; @@ -349,10 +333,8 @@ struct scst_dev_registrant *scst_pr_find_reg( scst_assert_pr_mutex_held(dev); - list_for_each_entry(reg, &dev->dev_registrants_list, - dev_registrants_list_entry) { - if ((reg->rel_tgt_id == rel_tgt_id) && - tid_equal(reg->transport_id, transport_id)) { + list_for_each_entry(reg, &dev->dev_registrants_list, dev_registrants_list_entry) { + if (reg->rel_tgt_id == rel_tgt_id && tid_equal(reg->transport_id, transport_id)) { res = reg; break; } @@ -378,7 +360,6 @@ static void scst_pr_clear_reservation(struct scst_device *dev) dev->pr_holder = NULL; TRACE_EXIT(); - return; } /* Must be called under dev_pr_mutex */ @@ -394,20 +375,20 @@ void scst_pr_clear_holder(struct scst_device *dev) dev->pr_type == TYPE_EXCLUSIVE_ACCESS_ALL_REG) { if (list_empty(&dev->dev_registrants_list)) scst_pr_clear_reservation(dev); - } else + } else { scst_pr_clear_reservation(dev); + } dev->pr_holder = NULL; TRACE_EXIT(); - return; } /* Must be called under dev_pr_mutex */ -struct scst_dev_registrant *scst_pr_add_registrant( - struct scst_device *dev, const uint8_t *transport_id, - const uint16_t rel_tgt_id, __be64 key, - bool dev_lock_locked) +struct scst_dev_registrant *scst_pr_add_registrant(struct scst_device *dev, + const uint8_t *transport_id, + const uint16_t rel_tgt_id, __be64 key, + bool dev_lock_locked) { struct scst_dev_registrant *reg; struct scst_tgt_dev *t; @@ -417,21 +398,20 @@ struct scst_dev_registrant *scst_pr_add_registrant( scst_assert_pr_mutex_held(dev); - sBUG_ON(dev == NULL); - sBUG_ON(transport_id == NULL); + sBUG_ON(!dev); + sBUG_ON(!transport_id); TRACE_PR("Registering %s/%d (dev %s)", - debug_transport_id_to_initiator_name(transport_id), - rel_tgt_id, dev->virt_name); + debug_transport_id_to_initiator_name(transport_id), rel_tgt_id, dev->virt_name); reg = scst_pr_find_reg(dev, transport_id, rel_tgt_id); - if (reg != NULL) { + if (reg) { /* * It might happen when a target driver would make >1 session * from the same initiator to the same target. */ - PRINT_ERROR("Registrant %p/%d (dev %s) already exists!", reg, - rel_tgt_id, dev->virt_name); + PRINT_ERROR("Registrant %p/%d (dev %s) already exists!", + reg, rel_tgt_id, dev->virt_name); PRINT_BUFFER("TransportID", transport_id, 24); WARN_ON(1); reg = NULL; @@ -439,18 +419,16 @@ struct scst_dev_registrant *scst_pr_add_registrant( } reg = kzalloc(sizeof(*reg), gfp_flags); - if (reg == NULL) { - PRINT_ERROR("%s", "Unable to allocate registration record"); + if (!reg) { + PRINT_ERROR("Unable to allocate registration record"); goto out; } dev->cl_ops->pr_init_reg(dev, reg); - reg->transport_id = kmemdup(transport_id, scst_tid_size(transport_id), - gfp_flags); - if (reg->transport_id == NULL) { - PRINT_ERROR("%s", "Unable to allocate initiator port " - "transport id"); + reg->transport_id = kmemdup(transport_id, scst_tid_size(transport_id), gfp_flags); + if (!reg->transport_id) { + PRINT_ERROR("Unable to allocate initiator port transport id"); goto out_free; } @@ -467,8 +445,7 @@ struct scst_dev_registrant *scst_pr_add_registrant( #endif list_for_each_entry(t, &dev->dev_tgt_dev_list, dev_tgt_dev_list_entry) { if (tid_equal(t->sess->transport_id, transport_id) && - (t->sess->tgt->rel_tgt_id == rel_tgt_id) && - (t->registrant == NULL)) { + t->sess->tgt->rel_tgt_id == rel_tgt_id && !t->registrant) { /* * We must assign here, because t can die * immediately after we release dev_lock. @@ -484,11 +461,10 @@ struct scst_dev_registrant *scst_pr_add_registrant( spin_unlock_bh(&dev->dev_lock); #endif - list_add_tail(®->dev_registrants_list_entry, - &dev->dev_registrants_list); + list_add_tail(®->dev_registrants_list_entry, &dev->dev_registrants_list); - TRACE_PR("Reg %p registered (dev %s, tgt_dev %p)", reg, - dev->virt_name, reg->tgt_dev); + TRACE_PR("Reg %p registered (dev %s, tgt_dev %p)", + reg, dev->virt_name, reg->tgt_dev); out: TRACE_EXIT_HRES(reg); @@ -501,17 +477,15 @@ out_free: } /* Must be called under dev_pr_mutex */ -void scst_pr_remove_registrant(struct scst_device *dev, - struct scst_dev_registrant *reg) +void scst_pr_remove_registrant(struct scst_device *dev, struct scst_dev_registrant *reg) { TRACE_ENTRY(); scst_assert_pr_mutex_held(dev); - TRACE_PR("Removing registrant %s/%d (reg %p, tgt_dev %p, key %016llx, " - "dev %s)", debug_transport_id_to_initiator_name(reg->transport_id), - reg->rel_tgt_id, reg, reg->tgt_dev, be64_to_cpu(reg->key), - dev->virt_name); + TRACE_PR("Removing registrant %s/%d (reg %p, tgt_dev %p, key %016llx, dev %s)", + debug_transport_id_to_initiator_name(reg->transport_id), reg->rel_tgt_id, + reg, reg->tgt_dev, be64_to_cpu(reg->key), dev->virt_name); list_del(®->dev_registrants_list_entry); @@ -527,7 +501,6 @@ void scst_pr_remove_registrant(struct scst_device *dev, kfree(reg); TRACE_EXIT(); - return; } static void scst_pr_remove_registrants(struct scst_device *dev) @@ -535,15 +508,13 @@ static void scst_pr_remove_registrants(struct scst_device *dev) struct scst_dev_registrant *reg, *tmp_reg; list_for_each_entry_safe(reg, tmp_reg, &dev->dev_registrants_list, - dev_registrants_list_entry) { + dev_registrants_list_entry) scst_pr_remove_registrant(dev, reg); - } } /* Must be called under dev_pr_mutex */ -void scst_pr_send_ua_reg(struct scst_device *dev, - struct scst_dev_registrant *reg, - int key, int asc, int ascq) +void scst_pr_send_ua_reg(struct scst_device *dev, struct scst_dev_registrant *reg, + int key, int asc, int ascq) { static uint8_t ua[SCST_STANDARD_SENSE_LEN]; @@ -553,10 +524,9 @@ void scst_pr_send_ua_reg(struct scst_device *dev, scst_set_sense(ua, sizeof(ua), dev->d_sense, key, asc, ascq); - TRACE_PR("Queueing UA [%x %x %x]: registrant %s/%d (%p), tgt_dev %p, " - "key %016llx", ua[2], ua[12], ua[13], - debug_transport_id_to_initiator_name(reg->transport_id), - reg->rel_tgt_id, reg, reg->tgt_dev, be64_to_cpu(reg->key)); + TRACE_PR("Queueing UA [%x %x %x]: registrant %s/%d (%p), tgt_dev %p, key %016llx", + ua[2], ua[12], ua[13], debug_transport_id_to_initiator_name(reg->transport_id), + reg->rel_tgt_id, reg, reg->tgt_dev, be64_to_cpu(reg->key)); if (reg->tgt_dev) scst_check_set_UA(reg->tgt_dev, ua, sizeof(ua), 0); @@ -564,13 +534,11 @@ void scst_pr_send_ua_reg(struct scst_device *dev, dev->cl_ops->pr_reg_queue_rem_ua(dev, reg, key, asc, ascq); TRACE_EXIT(); - return; } /* Must be called under dev_pr_mutex */ -static void scst_pr_send_ua_all(struct scst_device *dev, - struct scst_dev_registrant *exclude_reg, - int key, int asc, int ascq) +static void scst_pr_send_ua_all(struct scst_device *dev, struct scst_dev_registrant *exclude_reg, + int key, int asc, int ascq) { struct scst_dev_registrant *reg; @@ -578,19 +546,17 @@ static void scst_pr_send_ua_all(struct scst_device *dev, scst_assert_pr_mutex_held(dev); - list_for_each_entry(reg, &dev->dev_registrants_list, - dev_registrants_list_entry) { + list_for_each_entry(reg, &dev->dev_registrants_list, dev_registrants_list_entry) { if (reg != exclude_reg) scst_pr_send_ua_reg(dev, reg, key, asc, ascq); } TRACE_EXIT(); - return; } /* Must be called under dev_pr_mutex */ -static void scst_pr_abort_reg(struct scst_device *dev, - struct scst_cmd *pr_cmd, struct scst_dev_registrant *reg) +static void scst_pr_abort_reg(struct scst_device *dev, struct scst_cmd *pr_cmd, + struct scst_dev_registrant *reg) { struct scst_session *sess; __be64 packed_lun; @@ -600,44 +566,40 @@ static void scst_pr_abort_reg(struct scst_device *dev, scst_assert_pr_mutex_held(dev); - if (reg->tgt_dev == NULL) { + if (!reg->tgt_dev) { TRACE_PR("Registrant %s/%d (%p, key 0x%016llx) has no session", - debug_transport_id_to_initiator_name(reg->transport_id), - reg->rel_tgt_id, reg, be64_to_cpu(reg->key)); + debug_transport_id_to_initiator_name(reg->transport_id), + reg->rel_tgt_id, reg, be64_to_cpu(reg->key)); goto out; } sess = reg->tgt_dev->sess; - TRACE_PR("Aborting %d commands for %s/%d (reg %p, key 0x%016llx, " - "tgt_dev %p, sess %p)", - atomic_read(®->tgt_dev->tgt_dev_cmd_count), - debug_transport_id_to_initiator_name(reg->transport_id), - reg->rel_tgt_id, reg, be64_to_cpu(reg->key), reg->tgt_dev, - sess); + TRACE_PR("Aborting %d commands for %s/%d (reg %p, key 0x%016llx, tgt_dev %p, sess %p)", + atomic_read(®->tgt_dev->tgt_dev_cmd_count), + debug_transport_id_to_initiator_name(reg->transport_id), + reg->rel_tgt_id, reg, be64_to_cpu(reg->key), reg->tgt_dev, sess); packed_lun = scst_pack_lun(reg->tgt_dev->lun, sess->acg->addr_method); - rc = scst_rx_mgmt_fn_lun(sess, SCST_PR_ABORT_ALL, - &packed_lun, sizeof(packed_lun), SCST_NON_ATOMIC, - pr_cmd); + rc = scst_rx_mgmt_fn_lun(sess, SCST_PR_ABORT_ALL, &packed_lun, sizeof(packed_lun), + SCST_NON_ATOMIC, pr_cmd); if (rc != 0) { /* * There's nothing more we can do here... Hopefully, it would * never happen. */ PRINT_ERROR("SCST_PR_ABORT_ALL failed %d (sess %p)", - rc, sess); + rc, sess); goto out; } - if ((reg->tgt_dev != pr_cmd->tgt_dev) && !dev->tas) { + if (reg->tgt_dev != pr_cmd->tgt_dev && !dev->tas) { uint8_t sense_buffer[SCST_STANDARD_SENSE_LEN]; int sl; - sl = scst_set_sense(sense_buffer, sizeof(sense_buffer), - dev->d_sense, - SCST_LOAD_SENSE(scst_sense_cleared_by_another_ini_UA)); + sl = scst_set_sense(sense_buffer, sizeof(sense_buffer), dev->d_sense, + SCST_LOAD_SENSE(scst_sense_cleared_by_another_ini_UA)); /* * Potentially, setting UA here, when the aborted commands are * still running, can lead to a situation that one of them could @@ -654,13 +616,10 @@ static void scst_pr_abort_reg(struct scst_device *dev, out: TRACE_EXIT(); - return; } - /* Called under scst_mutex */ -static int scst_pr_do_load_device_file(struct scst_device *dev, - const char *file_name) +static int scst_pr_do_load_device_file(struct scst_device *dev, const char *file_name) { int res = 0, rc; struct file *file = NULL; @@ -693,24 +652,24 @@ static int scst_pr_do_load_device_file(struct scst_device *dev, } /* Let's limit the file size by some reasonable number */ - if ((file_size == 0) || (file_size >= 15*1024*1024)) { + if (file_size == 0 || (file_size >= 15 * 1024 * 1024)) { PRINT_ERROR("Invalid PR file size %d", (int)file_size); res = -EINVAL; goto out_close; } buf = vmalloc(file_size); - if (buf == NULL) { + if (!buf) { res = -ENOMEM; - PRINT_ERROR("%s", "Unable to allocate buffer"); + PRINT_ERROR("Unable to allocate buffer"); goto out_close; } pos = 0; rc = kernel_read(file, buf, file_size, &pos); if (rc != file_size) { - PRINT_ERROR("Unable to read file '%s' - error %d", file_name, - rc); + PRINT_ERROR("Unable to read file '%s' - error %d", + file_name, rc); res = rc; goto out_close; } @@ -734,8 +693,8 @@ static int scst_pr_do_load_device_file(struct scst_device *dev, sign = get_unaligned((uint64_t *)&buf[pos]); if (sign != SCST_PR_FILE_SIGN) { res = -EINVAL; - PRINT_ERROR("Invalid persistent file signature %016llx " - "(expected %016llx)", sign, SCST_PR_FILE_SIGN); + PRINT_ERROR("Invalid persistent file signature %016llx (expected %016llx)", + sign, SCST_PR_FILE_SIGN); goto out_close; } pos += sizeof(sign); @@ -743,8 +702,8 @@ static int scst_pr_do_load_device_file(struct scst_device *dev, version = get_unaligned((uint64_t *)&buf[pos]); if (version != SCST_PR_FILE_VERSION) { res = -EINVAL; - PRINT_ERROR("Invalid persistent file version %016llx " - "(expected %016llx)", version, SCST_PR_FILE_VERSION); + PRINT_ERROR("Invalid persistent file version %016llx (expected %016llx)", + version, SCST_PR_FILE_VERSION); goto out_close; } pos += sizeof(version); @@ -760,9 +719,8 @@ static int scst_pr_do_load_device_file(struct scst_device *dev, if (data_size > file_size) { res = -EINVAL; - PRINT_ERROR("Invalid file '%s' - size mismatch have " - "%lld expected %lld", file_name, file_size, - data_size); + PRINT_ERROR("Invalid file '%s' - size mismatch have %lld expected %lld", + file_name, file_size, data_size); goto out_close; } } @@ -798,7 +756,7 @@ static int scst_pr_do_load_device_file(struct scst_device *dev, pos += sizeof(rel_tgt_id); reg = scst_pr_add_registrant(dev, tid, rel_tgt_id, key, false); - if (reg == NULL) { + if (!reg) { res = -ENOMEM; goto out_close; } @@ -811,8 +769,7 @@ out_close: filp_close(file, NULL); out: - if (buf != NULL) - vfree(buf); + vfree(buf); TRACE_EXIT_RES(res); return res; @@ -826,7 +783,7 @@ static int scst_pr_load_device_file(struct scst_device *dev) scst_assert_pr_mutex_held(dev); - if (dev->pr_file_name == NULL || dev->pr_file_name1 == NULL) { + if (!dev->pr_file_name || !dev->pr_file_name1) { PRINT_ERROR("Invalid file paths for '%s'", dev->virt_name); res = -EINVAL; goto out; @@ -835,7 +792,7 @@ static int scst_pr_load_device_file(struct scst_device *dev) res = scst_pr_do_load_device_file(dev, dev->pr_file_name); if (res == 0) goto out_dump; - else if (res == -ENOMEM) + if (res == -ENOMEM) goto out; rc = res; @@ -867,7 +824,6 @@ static void scst_pr_remove_device_files(struct scst_device *dev) scst_remove_file(dev->pr_file_name1); TRACE_EXIT(); - return; } /* Must be called under dev_pr_mutex */ @@ -885,7 +841,7 @@ void scst_pr_sync_device_file(struct scst_device *dev) scst_assert_pr_mutex_held(dev); - if ((dev->pr_aptpl == 0) || list_empty(&dev->dev_registrants_list)) { + if (dev->pr_aptpl == 0 || list_empty(&dev->dev_registrants_list)) { scst_pr_remove_device_files(dev); goto out; } @@ -896,7 +852,7 @@ void scst_pr_sync_device_file(struct scst_device *dev) if (IS_ERR(file)) { res = PTR_ERR(file); PRINT_ERROR("Unable to (re)create PR file '%s' - error %d", - dev->pr_file_name, res); + dev->pr_file_name, res); goto out; } @@ -996,8 +952,8 @@ void scst_pr_sync_device_file(struct scst_device *dev) out: if (res != 0) { - PRINT_CRIT_ERROR("Unable to save persistent information " - "(device %s)", dev->virt_name); + PRINT_CRIT_ERROR("Unable to save persistent information (device %s)", + dev->virt_name); /* * It's safer to not return any error to the initiator and expect * operator's intervention to be able to save the PR's state next @@ -1023,12 +979,11 @@ write_error_close: scst_vfs_unlink_and_put(&path); else TRACE_PR("Unable to lookup '%s' - error %d", - dev->pr_file_name, rc); + dev->pr_file_name, rc); } goto out; } - /** * scst_pr_set_file_name - set name of file in which to save PR information * @dev: SCST device. @@ -1090,8 +1045,9 @@ int scst_pr_set_file_name(struct scst_device *dev, char **prev, *prev = dev->pr_file_name; dev->pr_file_name = pr_file_name; pr_file_name = NULL; - } else + } else { swap(dev->pr_file_name, pr_file_name); + } swap(dev->pr_file_name1, bkp); res = 0; @@ -1187,7 +1143,6 @@ void scst_pr_clear_dev(struct scst_device *dev) kfree(dev->pr_file_name1); TRACE_EXIT(); - return; } /* Called under scst_mutex */ @@ -1201,16 +1156,16 @@ int scst_pr_init_tgt_dev(struct scst_tgt_dev *tgt_dev) TRACE_ENTRY(); - if (tgt_dev->sess->transport_id == NULL) + if (!tgt_dev->sess->transport_id) goto out; scst_pr_write_lock(dev); reg = scst_pr_find_reg(dev, transport_id, rel_tgt_id); - if ((reg != NULL) && (reg->tgt_dev == NULL)) { + if (reg && !reg->tgt_dev) { TRACE_PR("Assigning reg %s/%d (%p) to tgt_dev %p (dev %s)", - debug_transport_id_to_initiator_name(transport_id), - rel_tgt_id, reg, tgt_dev, dev->virt_name); + debug_transport_id_to_initiator_name(transport_id), + rel_tgt_id, reg, tgt_dev, dev->virt_name); tgt_dev->registrant = reg; reg->tgt_dev = tgt_dev; } @@ -1239,17 +1194,14 @@ void scst_pr_clear_tgt_dev(struct scst_tgt_dev *tgt_dev) reg->tgt_dev = NULL; /* Just in case, actually. It should never happen. */ - list_for_each_entry(t, &dev->dev_tgt_dev_list, - dev_tgt_dev_list_entry) { + list_for_each_entry(t, &dev->dev_tgt_dev_list, dev_tgt_dev_list_entry) { if (t == tgt_dev) continue; - if ((t->sess->tgt->rel_tgt_id == reg->rel_tgt_id) && + if (t->sess->tgt->rel_tgt_id == reg->rel_tgt_id && tid_equal(t->sess->transport_id, reg->transport_id)) { - TRACE_PR("Reassigning reg %s/%d (%p) to tgt_dev " - "%p (being cleared tgt_dev %p)", - debug_transport_id_to_initiator_name( - reg->transport_id), - reg->rel_tgt_id, reg, t, tgt_dev); + TRACE_PR("Reassigning reg %s/%d (%p) to tgt_dev %p (being cleared tgt_dev %p)", + debug_transport_id_to_initiator_name(reg->transport_id), + reg->rel_tgt_id, reg, t, tgt_dev); t->registrant = reg; reg->tgt_dev = t; break; @@ -1260,13 +1212,12 @@ void scst_pr_clear_tgt_dev(struct scst_tgt_dev *tgt_dev) scst_pr_write_unlock(dev); TRACE_EXIT(); - return; } /* Called with dev_pr_mutex locked. Might also be called under scst_mutex2. */ -static int scst_pr_register_with_spec_i_pt(struct scst_cmd *cmd, - const uint16_t rel_tgt_id, uint8_t *buffer, int buffer_size, - struct list_head *rollback_list) +static int scst_pr_register_with_spec_i_pt(struct scst_cmd *cmd, const uint16_t rel_tgt_id, + uint8_t *buffer, int buffer_size, + struct list_head *rollback_list) { int res = 0; int offset; @@ -1281,10 +1232,9 @@ static int scst_pr_register_with_spec_i_pt(struct scst_cmd *cmd, ext_size = get_unaligned_be32(&buffer[24]); if ((ext_size + 28) > buffer_size) { - TRACE_PR("Invalid buffer size %d (max %d)", buffer_size, - ext_size + 28); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); + TRACE_PR("Invalid buffer size %d (max %d)", + buffer_size, ext_size + 28); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); res = -EINVAL; goto out; } @@ -1296,7 +1246,7 @@ static int scst_pr_register_with_spec_i_pt(struct scst_cmd *cmd, if (offset + tid_size > ext_size) { TRACE_PR("Invalid transport_id size %d (max %d)", - tid_size, ext_size - offset); + tid_size, ext_size - offset); scst_set_invalid_field_in_parm_list(cmd, 24, 0); res = -EINVAL; goto out; @@ -1310,73 +1260,66 @@ static int scst_pr_register_with_spec_i_pt(struct scst_cmd *cmd, uint8_t *transport_id = &buffer[28 + offset]; struct scst_tgt_dev *t; - TRACE_PR("rel_tgt_id %d, transport_id %s", rel_tgt_id, - debug_transport_id_to_initiator_name(transport_id)); + TRACE_PR("rel_tgt_id %d, transport_id %s", + rel_tgt_id, debug_transport_id_to_initiator_name(transport_id)); if ((transport_id[0] & 0x0f) == SCSI_TRANSPORTID_PROTOCOLID_ISCSI && (transport_id[0] & 0xc0) == 0) { - TRACE_PR("Wildcard iSCSI TransportID %s", - &transport_id[4]); + TRACE_PR("Wildcard iSCSI TransportID %s", &transport_id[4]); /* * We can't use scst_mutex here because the caller * already holds dev_pr_mutex. */ spin_lock_bh(&dev->dev_lock); - list_for_each_entry(t, &dev->dev_tgt_dev_list, - dev_tgt_dev_list_entry) { + list_for_each_entry(t, &dev->dev_tgt_dev_list, dev_tgt_dev_list_entry) { /* * We must go over all matching tgt_devs and * register them on the requested rel_tgt_id */ - if (!tid_equal(t->sess->transport_id, - transport_id)) + if (!tid_equal(t->sess->transport_id, transport_id)) continue; - reg = scst_pr_find_reg(dev, - t->sess->transport_id, rel_tgt_id); - if (reg == NULL) { - reg = scst_pr_add_registrant(dev, - t->sess->transport_id, - rel_tgt_id, action_key, true); - if (reg == NULL) { + reg = scst_pr_find_reg(dev, t->sess->transport_id, rel_tgt_id); + if (!reg) { + reg = scst_pr_add_registrant(dev, t->sess->transport_id, + rel_tgt_id, action_key, true); + if (!reg) { spin_unlock_bh(&dev->dev_lock); scst_set_busy(cmd); res = -ENOMEM; goto out; } } else if (reg->key != action_key) { - TRACE_PR("Changing key of reg %p " - "(tgt_dev %p)", reg, t); + TRACE_PR("Changing key of reg %p (tgt_dev %p)", reg, t); reg->rollback_key = reg->key; reg->key = action_key; - } else + } else { continue; + } - list_add_tail(®->aux_list_entry, - rollback_list); + list_add_tail(®->aux_list_entry, rollback_list); } spin_unlock_bh(&dev->dev_lock); } else { reg = scst_pr_find_reg(dev, transport_id, rel_tgt_id); - if (reg != NULL) { + if (reg) { if (reg->key == action_key) goto next; TRACE_PR("Changing key of reg %p (tgt_dev %p)", - reg, reg->tgt_dev); + reg, reg->tgt_dev); reg->rollback_key = reg->key; reg->key = action_key; } else { - reg = scst_pr_add_registrant(dev, transport_id, - rel_tgt_id, action_key, false); - if (reg == NULL) { + reg = scst_pr_add_registrant(dev, transport_id, rel_tgt_id, + action_key, false); + if (!reg) { scst_set_busy(cmd); res = -ENOMEM; goto out; } } - list_add_tail(®->aux_list_entry, - rollback_list); + list_add_tail(®->aux_list_entry, rollback_list); } next: offset += scst_tid_size(transport_id); @@ -1386,8 +1329,7 @@ out: } /* Called with dev_pr_mutex locked, no IRQ */ -static void scst_pr_unregister(struct scst_device *dev, - struct scst_dev_registrant *reg) +static void scst_pr_unregister(struct scst_device *dev, struct scst_dev_registrant *reg) { bool is_holder; uint8_t pr_type; @@ -1409,18 +1351,16 @@ static void scst_pr_unregister(struct scst_device *dev, case TYPE_WRITE_EXCLUSIVE_REGONLY: case TYPE_EXCLUSIVE_ACCESS_REGONLY: scst_pr_send_ua_all(dev, NULL, - SCST_LOAD_SENSE(scst_sense_reservation_released)); + SCST_LOAD_SENSE(scst_sense_reservation_released)); break; } } TRACE_EXIT(); - return; } /* Called with dev_pr_mutex locked, no IRQ */ -static void scst_pr_unregister_all_tg_pt(struct scst_device *dev, - const uint8_t *transport_id) +static void scst_pr_unregister_all_tg_pt(struct scst_device *dev, const uint8_t *transport_id) { struct scst_tgt_template *tgtt; uint8_t proto_id = transport_id[0] & 0x0f; @@ -1438,7 +1378,7 @@ static void scst_pr_unregister_all_tg_pt(struct scst_device *dev, list_for_each_entry(tgtt, &scst_template_list, scst_template_list_entry) { struct scst_tgt *tgt; - if (tgtt->get_initiator_port_transport_id == NULL) + if (!tgtt->get_initiator_port_transport_id) continue; list_for_each_entry(tgt, &tgtt->tgt_list, tgt_list_entry) { @@ -1447,9 +1387,8 @@ static void scst_pr_unregister_all_tg_pt(struct scst_device *dev, if (tgtt->get_initiator_port_transport_id(tgt, NULL, NULL) != proto_id) continue; - reg = scst_pr_find_reg(dev, transport_id, - tgt->rel_tgt_id); - if (reg == NULL) + reg = scst_pr_find_reg(dev, transport_id, tgt->rel_tgt_id); + if (!reg) continue; scst_pr_unregister(dev, reg); @@ -1459,13 +1398,12 @@ static void scst_pr_unregister_all_tg_pt(struct scst_device *dev, mutex_unlock(&scst_mutex2); TRACE_EXIT(); - return; } /* Called with dev_pr_mutex locked. Might also be called under scst_mutex2. */ -static int scst_pr_register_on_tgt_id(struct scst_cmd *cmd, - const uint16_t rel_tgt_id, uint8_t *buffer, int buffer_size, - bool spec_i_pt, struct list_head *rollback_list) +static int scst_pr_register_on_tgt_id(struct scst_cmd *cmd, const uint16_t rel_tgt_id, + uint8_t *buffer, int buffer_size, bool spec_i_pt, + struct list_head *rollback_list) { int res; @@ -1476,23 +1414,23 @@ static int scst_pr_register_on_tgt_id(struct scst_cmd *cmd, TRACE_PR("rel_tgt_id %d, spec_i_pt %d", rel_tgt_id, spec_i_pt); if (spec_i_pt) { - res = scst_pr_register_with_spec_i_pt(cmd, rel_tgt_id, buffer, - buffer_size, rollback_list); + res = scst_pr_register_with_spec_i_pt(cmd, rel_tgt_id, buffer, buffer_size, + rollback_list); if (res != 0) goto out; } /* tgt_dev can be among TIDs for scst_pr_register_with_spec_i_pt() */ - if (scst_pr_find_reg(cmd->dev, cmd->sess->transport_id, rel_tgt_id) == NULL) { + if (!scst_pr_find_reg(cmd->dev, cmd->sess->transport_id, rel_tgt_id)) { __be64 action_key; struct scst_dev_registrant *reg; action_key = get_unaligned((__be64 *)&buffer[8]); - reg = scst_pr_add_registrant(cmd->dev, cmd->sess->transport_id, - rel_tgt_id, action_key, false); - if (reg == NULL) { + reg = scst_pr_add_registrant(cmd->dev, cmd->sess->transport_id, rel_tgt_id, + action_key, false); + if (!reg) { res = -ENOMEM; scst_set_busy(cmd); goto out; @@ -1509,8 +1447,8 @@ out: } /* Add registrants for remote ports. Called with dev_pr_mutex locked, no IRQ. */ -static int scst_register_remote_ports(struct scst_cmd *cmd, uint8_t *buffer, - int buffer_size, bool spec_i_pt, struct list_head *rollback_list) +static int scst_register_remote_ports(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size, + bool spec_i_pt, struct list_head *rollback_list) { struct scst_dev_group *dg; struct scst_target_group *tg; @@ -1546,8 +1484,8 @@ out_unlock: } /* Register all target ports. Called with dev_pr_mutex locked, no IRQ. */ -static int scst_pr_register_all_tg_pt(struct scst_cmd *cmd, uint8_t *buffer, - int buffer_size, bool spec_i_pt, struct list_head *rollback_list) +static int scst_pr_register_all_tg_pt(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size, + bool spec_i_pt, struct list_head *rollback_list) { int res = 0; struct scst_tgt_template *tgtt; @@ -1566,7 +1504,7 @@ static int scst_pr_register_all_tg_pt(struct scst_cmd *cmd, uint8_t *buffer, list_for_each_entry(tgtt, &scst_template_list, scst_template_list_entry) { struct scst_tgt *tgt; - if (tgtt->get_initiator_port_transport_id == NULL) + if (!tgtt->get_initiator_port_transport_id) continue; TRACE_PR("tgtt %s, spec_i_pt %d", tgtt->name, spec_i_pt); @@ -1577,14 +1515,14 @@ static int scst_pr_register_all_tg_pt(struct scst_cmd *cmd, uint8_t *buffer, if (tgt->rel_tgt_id == 0) continue; if (tgt->tgt_forward_dst) { - TRACE_PR("ALL_TG_PT: skipping forwarding " - "target %s", tgt->tgt_name); + TRACE_PR("ALL_TG_PT: skipping forwarding target %s", + tgt->tgt_name); continue; } - TRACE_PR("tgt %s, rel_tgt_id %d", tgt->tgt_name, - tgt->rel_tgt_id); - res = scst_pr_register_on_tgt_id(cmd, tgt->rel_tgt_id, - buffer, buffer_size, spec_i_pt, rollback_list); + TRACE_PR("tgt %s, rel_tgt_id %d", + tgt->tgt_name, tgt->rel_tgt_id); + res = scst_pr_register_on_tgt_id(cmd, tgt->rel_tgt_id, buffer, buffer_size, + spec_i_pt, rollback_list); if (res != 0) goto out_unlock; } @@ -1601,8 +1539,8 @@ out_unlock: } /* Called with dev_pr_mutex locked, no IRQ */ -static int __scst_pr_register(struct scst_cmd *cmd, uint8_t *buffer, - int buffer_size, bool spec_i_pt, bool all_tg_pt) +static int __scst_pr_register(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size, + bool spec_i_pt, bool all_tg_pt) { int res; struct scst_dev_registrant *reg, *treg; @@ -1613,21 +1551,19 @@ static int __scst_pr_register(struct scst_cmd *cmd, uint8_t *buffer, scst_assert_pr_mutex_held(cmd->dev); if (all_tg_pt) { - res = scst_pr_register_all_tg_pt(cmd, buffer, buffer_size, - spec_i_pt, &rollback_list); + res = scst_pr_register_all_tg_pt(cmd, buffer, buffer_size, spec_i_pt, + &rollback_list); if (res != 0) goto out_rollback; } else { - res = scst_pr_register_on_tgt_id(cmd, - cmd->sess->tgt->rel_tgt_id, buffer, buffer_size, - spec_i_pt, &rollback_list); + res = scst_pr_register_on_tgt_id(cmd, cmd->sess->tgt->rel_tgt_id, buffer, + buffer_size, spec_i_pt, &rollback_list); if (res != 0) goto out_rollback; } - list_for_each_entry(reg, &rollback_list, aux_list_entry) { + list_for_each_entry(reg, &rollback_list, aux_list_entry) reg->rollback_key = 0; - } out: TRACE_EXIT_RES(res); @@ -1636,9 +1572,9 @@ out: out_rollback: list_for_each_entry_safe(reg, treg, &rollback_list, aux_list_entry) { list_del(®->aux_list_entry); - if (reg->rollback_key == 0) + if (reg->rollback_key == 0) { scst_pr_remove_registrant(cmd->dev, reg); - else { + } else { reg->key = reg->rollback_key; reg->rollback_key = 0; } @@ -1668,58 +1604,54 @@ void scst_pr_register(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) if (spec_i_pt == 0 && buffer_size != 24) { TRACE_PR("Invalid buffer size %d", buffer_size); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); goto out; } - reg = tgt_dev->registrant; - TRACE_PR("Register: initiator %s/%d (%p), key %0llx, action_key %0llx " - "(tgt_dev %p)", - debug_transport_id_to_initiator_name(sess->transport_id), - sess->tgt->rel_tgt_id, reg, be64_to_cpu(key), - be64_to_cpu(action_key), tgt_dev); + TRACE_PR("Register: initiator %s/%d (%p), key %0llx, action_key %0llx (tgt_dev %p)", + debug_transport_id_to_initiator_name(sess->transport_id), + sess->tgt->rel_tgt_id, reg, be64_to_cpu(key), + be64_to_cpu(action_key), tgt_dev); - if (reg == NULL) { + if (!reg) { TRACE_PR("tgt_dev %p is not registered yet - registering", - tgt_dev); + tgt_dev); if (key) { - TRACE_PR("%s", "Key must be zero on new registration"); + TRACE_PR("Key must be zero on new registration"); scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; } if (action_key) { - int rc = __scst_pr_register(cmd, buffer, buffer_size, - spec_i_pt, all_tg_pt); + int rc = __scst_pr_register(cmd, buffer, buffer_size, spec_i_pt, + all_tg_pt); if (rc != 0) goto out; - } else - TRACE_PR("%s", "Doing nothing - action_key is zero"); + } else { + TRACE_PR("Doing nothing - action_key is zero"); + } } else { if (reg->key != key) { - TRACE_PR("tgt_dev %p already registered - reservation " - "key %0llx mismatch", tgt_dev, - be64_to_cpu(reg->key)); - scst_set_cmd_error_status(cmd, - SAM_STAT_RESERVATION_CONFLICT); + TRACE_PR("tgt_dev %p already registered - reservation key %0llx mismatch", + tgt_dev, be64_to_cpu(reg->key)); + scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; } if (spec_i_pt) { - TRACE_PR("%s", "spec_i_pt must be zero in this case"); + TRACE_PR("spec_i_pt must be zero in this case"); scst_set_invalid_field_in_parm_list(cmd, 20, - SCST_INVAL_FIELD_BIT_OFFS_VALID | 3); + SCST_INVAL_FIELD_BIT_OFFS_VALID | 3); goto out; } if (action_key == 0) { if (all_tg_pt) - scst_pr_unregister_all_tg_pt(dev, - sess->transport_id); + scst_pr_unregister_all_tg_pt(dev, sess->transport_id); else scst_pr_unregister(dev, reg); - } else + } else { reg->key = action_key; + } } dev->pr_generation++; @@ -1730,12 +1662,10 @@ void scst_pr_register(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) out: TRACE_EXIT(); - return; } /* Called with dev_pr_mutex locked, no IRQ */ -void scst_pr_register_and_ignore(struct scst_cmd *cmd, uint8_t *buffer, - int buffer_size) +void scst_pr_register_and_ignore(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) { int aptpl, all_tg_pt; __be64 action_key; @@ -1754,39 +1684,35 @@ void scst_pr_register_and_ignore(struct scst_cmd *cmd, uint8_t *buffer, if (buffer_size != 24) { TRACE_PR("Invalid buffer size %d", buffer_size); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); goto out; } - reg = tgt_dev->registrant; - TRACE_PR("Register and ignore: initiator %s/%d (%p), action_key " - "%016llx (tgt_dev %p)", - debug_transport_id_to_initiator_name(sess->transport_id), - sess->tgt->rel_tgt_id, reg, be64_to_cpu(action_key), - tgt_dev); + TRACE_PR("Register and ignore: initiator %s/%d (%p), action_key %016llx (tgt_dev %p)", + debug_transport_id_to_initiator_name(sess->transport_id), + sess->tgt->rel_tgt_id, reg, be64_to_cpu(action_key), tgt_dev); - if (reg == NULL) { - TRACE_PR("Tgt_dev %p is not registered yet - trying to " - "register", tgt_dev); + if (!reg) { + TRACE_PR("Tgt_dev %p is not registered yet - trying to register", tgt_dev); if (action_key) { - int rc = __scst_pr_register(cmd, buffer, buffer_size, - false, all_tg_pt); + int rc = __scst_pr_register(cmd, buffer, buffer_size, false, all_tg_pt); + if (rc != 0) goto out; - } else - TRACE_PR("%s", "Doing nothing, action_key is zero"); + } else { + TRACE_PR("Doing nothing, action_key is zero"); + } } else { if (action_key == 0) { if (all_tg_pt) - scst_pr_unregister_all_tg_pt(dev, - sess->transport_id); + scst_pr_unregister_all_tg_pt(dev, sess->transport_id); else scst_pr_unregister(dev, reg); - } else + } else { reg->key = action_key; + } } dev->pr_generation++; @@ -1797,12 +1723,10 @@ void scst_pr_register_and_ignore(struct scst_cmd *cmd, uint8_t *buffer, out: TRACE_EXIT(); - return; } /* Called with dev_pr_mutex locked, no IRQ */ -void scst_pr_register_and_move(struct scst_cmd *cmd, uint8_t *buffer, - int buffer_size) +void scst_pr_register_and_move(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) { int aptpl; int unreg; @@ -1826,17 +1750,15 @@ void scst_pr_register_and_move(struct scst_cmd *cmd, uint8_t *buffer, unreg = (buffer[17] >> 1) & 0x01; tid_buffer_size = get_unaligned_be32(&buffer[20]); - if ((tid_buffer_size + 24) > buffer_size) { TRACE_PR("Invalid buffer size %d (%d)", - buffer_size, tid_buffer_size + 24); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_invalid_field_in_parm_list)); + buffer_size, tid_buffer_size + 24); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_field_in_parm_list)); goto out; } if (tid_buffer_size < 24) { - TRACE_PR("%s", "Transport id buffer too small"); + TRACE_PR("Transport id buffer too small"); scst_set_invalid_field_in_parm_list(cmd, 20, 0); goto out; } @@ -1844,19 +1766,17 @@ void scst_pr_register_and_move(struct scst_cmd *cmd, uint8_t *buffer, reg = tgt_dev->registrant; /* We already checked reg is not NULL */ if (reg->key != key) { - TRACE_PR("Registrant's %s/%d (%p) key %016llx mismatch with " - "%016llx (tgt_dev %p)", - debug_transport_id_to_initiator_name(reg->transport_id), - reg->rel_tgt_id, reg, be64_to_cpu(reg->key), - be64_to_cpu(key), tgt_dev); + TRACE_PR("Registrant's %s/%d (%p) key %016llx mismatch with %016llx (tgt_dev %p)", + debug_transport_id_to_initiator_name(reg->transport_id), + reg->rel_tgt_id, reg, be64_to_cpu(reg->key), + be64_to_cpu(key), tgt_dev); scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; } if (!dev->pr_is_set) { - TRACE_PR("%s", "There must be a PR"); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_invalid_field_in_cdb)); + TRACE_PR("There must be a PR"); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_field_in_cdb)); goto out; } @@ -1866,14 +1786,14 @@ void scst_pr_register_and_move(struct scst_cmd *cmd, uint8_t *buffer, */ if (!scst_pr_is_holder(dev, reg)) { TRACE_PR("Registrant %s/%d (%p) is not a holder (tgt_dev %p)", - debug_transport_id_to_initiator_name(reg->transport_id), - reg->rel_tgt_id, reg, tgt_dev); + debug_transport_id_to_initiator_name(reg->transport_id), + reg->rel_tgt_id, reg, tgt_dev); scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; } if (action_key == 0) { - TRACE_PR("%s", "Action key must be non-zero"); + TRACE_PR("Action key must be non-zero"); scst_set_invalid_field_in_cdb(cmd, 8, 0); goto out; } @@ -1884,39 +1804,37 @@ void scst_pr_register_and_move(struct scst_cmd *cmd, uint8_t *buffer, if ((scst_tid_size(transport_id_move) + 24) > buffer_size) { TRACE_PR("Invalid buffer size %d (%d)", - buffer_size, scst_tid_size(transport_id_move) + 24); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_invalid_field_in_parm_list)); + buffer_size, scst_tid_size(transport_id_move) + 24); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_field_in_parm_list)); goto out; } if (!tid_secure(transport_id_move, buffer_size - 24)) { TRACE_PR("Transport ID length %d exceeds buffer size %d", scst_tid_size(transport_id_move), buffer_size - 24); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_invalid_field_in_parm_list)); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_field_in_parm_list)); goto out; } if (dev->pr_type == TYPE_WRITE_EXCLUSIVE_ALL_REG || dev->pr_type == TYPE_EXCLUSIVE_ACCESS_ALL_REG) { - TRACE_PR("Unable to finish operation due to wrong reservation " - "type %02x", dev->pr_type); + TRACE_PR("Unable to finish operation due to wrong reservation type %02x", + dev->pr_type); scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; } if (tid_equal(transport_id, transport_id_move)) { - TRACE_PR("%s", "Equal transport id's"); + TRACE_PR("Equal transport id's"); scst_set_invalid_field_in_parm_list(cmd, 24, 0); goto out; } reg_move = scst_pr_find_reg(dev, transport_id_move, rel_tgt_id_move); - if (reg_move == NULL) { - reg_move = scst_pr_add_registrant(dev, transport_id_move, - rel_tgt_id_move, action_key, false); - if (reg_move == NULL) { + if (!reg_move) { + reg_move = scst_pr_add_registrant(dev, transport_id_move, rel_tgt_id_move, + action_key, false); + if (!reg_move) { scst_set_busy(cmd); goto out; } @@ -1925,13 +1843,11 @@ void scst_pr_register_and_move(struct scst_cmd *cmd, uint8_t *buffer, reg_move->key = action_key; } - TRACE_PR("Register and move: from initiator %s/%d (%p, tgt_dev %p) to " - "initiator %s/%d (%p, tgt_dev %p), key %016llx (unreg %d)", - debug_transport_id_to_initiator_name(reg->transport_id), - reg->rel_tgt_id, reg, reg->tgt_dev, - debug_transport_id_to_initiator_name(transport_id_move), - rel_tgt_id_move, reg_move, reg_move->tgt_dev, - be64_to_cpu(action_key), unreg); + TRACE_PR("Register and move: from initiator %s/%d (%p, tgt_dev %p) to initiator %s/%d (%p, tgt_dev %p), key %016llx (unreg %d)", + debug_transport_id_to_initiator_name(reg->transport_id), + reg->rel_tgt_id, reg, reg->tgt_dev, + debug_transport_id_to_initiator_name(transport_id_move), + rel_tgt_id_move, reg_move, reg_move->tgt_dev, be64_to_cpu(action_key), unreg); /* Move the holder */ scst_pr_set_holder(dev, reg_move, dev->pr_scope, dev->pr_type); @@ -1947,7 +1863,6 @@ void scst_pr_register_and_move(struct scst_cmd *cmd, uint8_t *buffer, out: TRACE_EXIT(); - return; } /* Called with dev_pr_mutex locked, no IRQ */ @@ -1969,65 +1884,56 @@ void scst_pr_reserve(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) if (buffer_size != 24) { TRACE_PR("Invalid buffer size %d", buffer_size); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); goto out; } if (!scst_pr_type_valid(type)) { TRACE_PR("Invalid reservation type %d", type); - scst_set_invalid_field_in_cdb(cmd, 2, - SCST_INVAL_FIELD_BIT_OFFS_VALID | 0); + scst_set_invalid_field_in_cdb(cmd, 2, SCST_INVAL_FIELD_BIT_OFFS_VALID | 0); goto out; } if (scope != SCOPE_LU) { TRACE_PR("Invalid reservation scope %d", scope); - scst_set_invalid_field_in_cdb(cmd, 2, - SCST_INVAL_FIELD_BIT_OFFS_VALID | 4); + scst_set_invalid_field_in_cdb(cmd, 2, SCST_INVAL_FIELD_BIT_OFFS_VALID | 4); goto out; } reg = tgt_dev->registrant; - TRACE_PR("Reserve: initiator %s/%d (%p), key %016llx, scope %d, " - "type %d (tgt_dev %p)", - debug_transport_id_to_initiator_name(cmd->sess->transport_id), - cmd->sess->tgt->rel_tgt_id, reg, be64_to_cpu(key), scope, - type, tgt_dev); + TRACE_PR("Reserve: initiator %s/%d (%p), key %016llx, scope %d, type %d (tgt_dev %p)", + debug_transport_id_to_initiator_name(cmd->sess->transport_id), + cmd->sess->tgt->rel_tgt_id, reg, be64_to_cpu(key), scope, type, tgt_dev); /* We already checked reg is not NULL */ if (reg->key != key) { TRACE_PR("Registrant's %p key %016llx mismatch with %016llx", - reg, be64_to_cpu(reg->key), be64_to_cpu(key)); + reg, be64_to_cpu(reg->key), be64_to_cpu(key)); scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; } - if (!dev->pr_is_set) + if (!dev->pr_is_set) { scst_pr_set_holder(dev, reg, scope, type); - else { + } else { if (!scst_pr_is_holder(dev, reg)) { /* * This check also required by table "PERSISTENT * RESERVE OUT service actions that are allowed in the * presence of various reservations". */ - TRACE_PR("Only holder can override - reg %p is not a " - "holder", reg); - scst_set_cmd_error_status(cmd, - SAM_STAT_RESERVATION_CONFLICT); + TRACE_PR("Only holder can override - reg %p is not a holder", reg); + scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; } else { if (dev->pr_scope != scope || dev->pr_type != type) { - TRACE_PR("Error overriding scope or type for " - "reg %p", reg); - scst_set_cmd_error_status(cmd, - SAM_STAT_RESERVATION_CONFLICT); + TRACE_PR("Error overriding scope or type for reg %p", reg); + scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; - } else - TRACE_PR("Do nothing: reservation of reg %p " - "is the same", reg); + } else { + TRACE_PR("Do nothing: reservation of reg %p is the same", reg); + } } } @@ -2035,7 +1941,6 @@ void scst_pr_reserve(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) out: TRACE_EXIT(); - return; } /* Called with dev_pr_mutex locked, no IRQ */ @@ -2058,28 +1963,25 @@ void scst_pr_release(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) if (buffer_size != 24) { TRACE_PR("Invalid buffer size %d", buffer_size); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); goto out; } if (!dev->pr_is_set) { - TRACE_PR("%s", "There is no PR - do nothing"); + TRACE_PR("There is no PR - do nothing"); goto out; } reg = tgt_dev->registrant; - TRACE_PR("Release: initiator %s/%d (%p), key %016llx, scope %d, type " - "%d (tgt_dev %p)", debug_transport_id_to_initiator_name( - cmd->sess->transport_id), - cmd->sess->tgt->rel_tgt_id, reg, be64_to_cpu(key), scope, - type, tgt_dev); + TRACE_PR("Release: initiator %s/%d (%p), key %016llx, scope %d, type %d (tgt_dev %p)", + debug_transport_id_to_initiator_name(cmd->sess->transport_id), + cmd->sess->tgt->rel_tgt_id, reg, be64_to_cpu(key), scope, type, tgt_dev); /* We already checked reg is not NULL */ if (reg->key != key) { TRACE_PR("Registrant's %p key %016llx mismatch with %016llx", - reg, be64_to_cpu(reg->key), be64_to_cpu(key)); + reg, be64_to_cpu(reg->key), be64_to_cpu(key)); scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; } @@ -2090,10 +1992,8 @@ void scst_pr_release(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) } if (dev->pr_scope != scope || dev->pr_type != type) { - TRACE_PR("%s", "Released scope or type do not match with " - "holder"); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_invalid_release)); + TRACE_PR("Released scope or type do not match with holder"); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_release)); goto out; } @@ -2106,15 +2006,13 @@ void scst_pr_release(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) case TYPE_EXCLUSIVE_ACCESS_REGONLY: case TYPE_WRITE_EXCLUSIVE_ALL_REG: case TYPE_EXCLUSIVE_ACCESS_ALL_REG: - scst_pr_send_ua_all(dev, reg, - SCST_LOAD_SENSE(scst_sense_reservation_released)); + scst_pr_send_ua_all(dev, reg, SCST_LOAD_SENSE(scst_sense_reservation_released)); } scst_pr_dump_prs(dev, false); out: TRACE_EXIT(); - return; } /* Called with dev_pr_mutex locked, no IRQ */ @@ -2133,32 +2031,28 @@ void scst_pr_clear(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) if (buffer_size != 24) { TRACE_PR("Invalid buffer size %d", buffer_size); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); goto out; } reg = tgt_dev->registrant; TRACE_PR("Clear: initiator %s/%d (%p), key %016llx (tgt_dev %p)", - debug_transport_id_to_initiator_name(cmd->sess->transport_id), - cmd->sess->tgt->rel_tgt_id, reg, be64_to_cpu(key), tgt_dev); + debug_transport_id_to_initiator_name(cmd->sess->transport_id), + cmd->sess->tgt->rel_tgt_id, reg, be64_to_cpu(key), tgt_dev); /* We already checked reg is not NULL */ if (reg->key != key) { TRACE_PR("Registrant's %p key %016llx mismatch with %016llx", - reg, be64_to_cpu(reg->key), be64_to_cpu(key)); + reg, be64_to_cpu(reg->key), be64_to_cpu(key)); scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; } - scst_pr_send_ua_all(dev, reg, - SCST_LOAD_SENSE(scst_sense_reservation_preempted)); + scst_pr_send_ua_all(dev, reg, SCST_LOAD_SENSE(scst_sense_reservation_preempted)); - list_for_each_entry_safe(r, t, &dev->dev_registrants_list, - dev_registrants_list_entry) { + list_for_each_entry_safe(r, t, &dev->dev_registrants_list, dev_registrants_list_entry) scst_pr_remove_registrant(dev, r); - } dev->pr_generation++; @@ -2166,11 +2060,9 @@ void scst_pr_clear(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) out: TRACE_EXIT(); - return; } -static void scst_pr_do_preempt(struct scst_cmd *cmd, uint8_t *buffer, - int buffer_size, bool abort) +static void scst_pr_do_preempt(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size, bool abort) { __be64 key, action_key; int scope, type; @@ -2185,8 +2077,7 @@ static void scst_pr_do_preempt(struct scst_cmd *cmd, uint8_t *buffer, if (buffer_size != 24) { TRACE_PR("Invalid buffer size %d", buffer_size); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_parameter_list_length_invalid)); goto out; } @@ -2197,39 +2088,36 @@ static void scst_pr_do_preempt(struct scst_cmd *cmd, uint8_t *buffer, if (!scst_pr_type_valid(type)) { TRACE_PR("Invalid reservation type %d", type); - scst_set_invalid_field_in_cdb(cmd, 1, - SCST_INVAL_FIELD_BIT_OFFS_VALID | 0); + scst_set_invalid_field_in_cdb(cmd, 1, SCST_INVAL_FIELD_BIT_OFFS_VALID | 0); goto out; } reg = tgt_dev->registrant; - TRACE_PR("Preempt%s: initiator %s/%d (%p), key %016llx, action_key " - "%016llx, scope %x type %x (tgt_dev %p)", - abort ? " and abort" : "", - debug_transport_id_to_initiator_name(cmd->sess->transport_id), - cmd->sess->tgt->rel_tgt_id, reg, be64_to_cpu(key), - be64_to_cpu(action_key), scope, type, tgt_dev); + TRACE_PR("Preempt%s: initiator %s/%d (%p), key %016llx, action_key %016llx, scope %x type %x (tgt_dev %p)", + abort ? " and abort" : "", + debug_transport_id_to_initiator_name(cmd->sess->transport_id), + cmd->sess->tgt->rel_tgt_id, reg, be64_to_cpu(key), + be64_to_cpu(action_key), scope, type, tgt_dev); /* We already checked reg is not NULL */ if (reg->key != key) { TRACE_PR("Registrant's %p key %016llx mismatch with %016llx", - reg, be64_to_cpu(reg->key), be64_to_cpu(key)); + reg, be64_to_cpu(reg->key), be64_to_cpu(key)); scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT); goto out; } if (!dev->pr_is_set) { - scst_pr_find_registrants_list_key(dev, action_key, - &preempt_list); + scst_pr_find_registrants_list_key(dev, action_key, &preempt_list); if (list_empty(&preempt_list)) goto out_error; list_for_each_entry_safe(r, rt, &preempt_list, aux_list_entry) { if (abort) scst_pr_abort_reg(dev, cmd, r); if (r != reg) { - scst_pr_send_ua_reg(dev, r, SCST_LOAD_SENSE( - scst_sense_registrations_preempted)); + scst_pr_send_ua_reg(dev, r, + SCST_LOAD_SENSE(scst_sense_registrations_preempted)); scst_pr_remove_registrant(dev, r); } } @@ -2239,32 +2127,26 @@ static void scst_pr_do_preempt(struct scst_cmd *cmd, uint8_t *buffer, if (dev->pr_type == TYPE_WRITE_EXCLUSIVE_ALL_REG || dev->pr_type == TYPE_EXCLUSIVE_ACCESS_ALL_REG) { if (action_key == 0) { - scst_pr_find_registrants_list_all(dev, reg, - &preempt_list); - list_for_each_entry_safe(r, rt, &preempt_list, - aux_list_entry) { + scst_pr_find_registrants_list_all(dev, reg, &preempt_list); + list_for_each_entry_safe(r, rt, &preempt_list, aux_list_entry) { sBUG_ON(r == reg); if (abort) scst_pr_abort_reg(dev, cmd, r); scst_pr_send_ua_reg(dev, r, - SCST_LOAD_SENSE( - scst_sense_registrations_preempted)); + SCST_LOAD_SENSE(scst_sense_registrations_preempted)); scst_pr_remove_registrant(dev, r); } scst_pr_set_holder(dev, reg, scope, type); } else { - scst_pr_find_registrants_list_key(dev, action_key, - &preempt_list); + scst_pr_find_registrants_list_key(dev, action_key, &preempt_list); if (list_empty(&preempt_list)) goto out_error; - list_for_each_entry_safe(r, rt, &preempt_list, - aux_list_entry) { + list_for_each_entry_safe(r, rt, &preempt_list, aux_list_entry) { if (abort) scst_pr_abort_reg(dev, cmd, r); if (r != reg) { scst_pr_send_ua_reg(dev, r, - SCST_LOAD_SENSE( - scst_sense_registrations_preempted)); + SCST_LOAD_SENSE(scst_sense_registrations_preempted)); scst_pr_remove_registrant(dev, r); } } @@ -2277,33 +2159,29 @@ static void scst_pr_do_preempt(struct scst_cmd *cmd, uint8_t *buffer, scst_set_invalid_field_in_parm_list(cmd, 8, 0); goto out; } else { - scst_pr_find_registrants_list_key(dev, action_key, - &preempt_list); + scst_pr_find_registrants_list_key(dev, action_key, &preempt_list); if (list_empty(&preempt_list)) goto out_error; - list_for_each_entry_safe(r, rt, &preempt_list, - aux_list_entry) { + list_for_each_entry_safe(r, rt, &preempt_list, aux_list_entry) { if (abort) scst_pr_abort_reg(dev, cmd, r); if (r != reg) scst_pr_send_ua_reg(dev, r, - SCST_LOAD_SENSE( - scst_sense_registrations_preem... [truncated message content] |
From: Gleb C. <lna...@ya...> - 2025-09-09 09:21:54
|
Commit: 5072f0c GitHub URL: https://github.com/SCST-project/scst/commit/5072f0ce5819fca7139f999c4bccd0b5cbe2a208 Author: Gleb Chesnokov Date: 2025-09-09T12:21:23+03:00 Log Message: ----------- scst_copy_mgr: Fix multiple checkpatch warnings This patch does not change any functionality. Modified Paths: -------------- scst/src/scst_copy_mgr.c | 791 +++++++-------- 1 file changed, 352 insertions(+), 439 deletions(-) =================================================================== diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index 38e08a2..fc217fa 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -21,21 +21,21 @@ #undef DEFAULT_SYMBOL_NAMESPACE #define DEFAULT_SYMBOL_NAMESPACE SCST_NAMESPACE -#define SCST_CM_NAME "copy_manager" -#define SCST_CM_TGT_NAME (SCST_CM_NAME "_tgt") -#define SCST_CM_SESS_NAME (SCST_CM_NAME "_sess") +#define SCST_CM_NAME "copy_manager" +#define SCST_CM_TGT_NAME (SCST_CM_NAME "_tgt") +#define SCST_CM_SESS_NAME (SCST_CM_NAME "_sess") -#define SCST_CM_TID_SIZE 24 -#define SCST_CM_TID_ID "COPY_MGR" +#define SCST_CM_TID_SIZE 24 +#define SCST_CM_TID_ID "COPY_MGR" -#define SCST_CM_RETRIES_WAIT HZ -#define SCST_CM_MAX_RETRIES_TIME (30*HZ) -#define SCST_CM_ID_KEEP_TIME (5*HZ) +#define SCST_CM_RETRIES_WAIT HZ +#define SCST_CM_MAX_RETRIES_TIME (30 * HZ) +#define SCST_CM_ID_KEEP_TIME (5 * HZ) -#define SCST_CM_MAX_EACH_IO_SIZE (512*1024) +#define SCST_CM_MAX_EACH_IO_SIZE (512 * 1024) /* Too big value is not too good for the blocking machinery */ -#define SCST_CM_MAX_TGT_DESCR_CNT 5 +#define SCST_CM_MAX_TGT_DESCR_CNT 5 #define SCST_CM_MAX_SEG_DESCR_CNT \ (((PAGE_SIZE * 2) - sizeof(struct scst_cm_ec_cmd_priv)) / \ @@ -201,15 +201,14 @@ static void scst_cm_retry_work_fn(struct work_struct *work) kfree(retry); TRACE_EXIT(); - return; } /* * Checks if cmd finished successfully and performs/schedules retry, if necessary. * Returns one of SCST_CM_STATUS_* codes. */ -static int scst_cm_err_check_retry(struct scst_cmd *cmd, - unsigned long start_time, scst_cm_retry_fn_t retry_fn) +static int scst_cm_err_check_retry(struct scst_cmd *cmd, unsigned long start_time, + scst_cm_retry_fn_t retry_fn) { int res = SCST_CM_STATUS_CMD_SUCCEEDED; unsigned long cur_time, max_retry_time, next_retry_time; @@ -220,10 +219,10 @@ static int scst_cm_err_check_retry(struct scst_cmd *cmd, /* cmd->dev and tgt_dev can be NULL here! */ - TRACE_DBG("cmd %p, status %d, aborted %d", cmd, cmd->status, - scst_cmd_aborted(cmd)); + TRACE_DBG("cmd %p, status %d, aborted %d", + cmd, cmd->status, scst_cmd_aborted(cmd)); - if (likely((cmd->status == 0) && !scst_cmd_aborted(cmd))) + if (likely(cmd->status == 0 && !scst_cmd_aborted(cmd))) goto out; cur_time = jiffies; @@ -233,8 +232,8 @@ static int scst_cm_err_check_retry(struct scst_cmd *cmd, if (test_bit(SCST_CMD_ABORTED, &cmd->cmd_flags)) { if (test_bit(SCST_CMD_ABORTED_OTHER, &cmd->cmd_flags)) { - TRACE_MGMT_DBG("Cmd %p aborted by other initiator, " - "retry possible", cmd); + TRACE_MGMT_DBG("Cmd %p aborted by other initiator, retry possible", + cmd); goto try_retry; } else { TRACE_MGMT_DBG("Cmd %p aborted, no retry ", cmd); @@ -242,21 +241,21 @@ static int scst_cm_err_check_retry(struct scst_cmd *cmd, } } - if ((cmd->status == SAM_STAT_BUSY) || - (cmd->status == SAM_STAT_TASK_SET_FULL) || - (cmd->status == SAM_STAT_RESERVATION_CONFLICT) || - (cmd->status == SAM_STAT_ACA_ACTIVE)) { + if (cmd->status == SAM_STAT_BUSY || + cmd->status == SAM_STAT_TASK_SET_FULL || + cmd->status == SAM_STAT_RESERVATION_CONFLICT || + cmd->status == SAM_STAT_ACA_ACTIVE) { TRACE_DBG("Cmd %p finished with status %d, retry possible", - cmd, cmd->status); + cmd, cmd->status); goto try_retry; } - if ((cmd->status == SAM_STAT_CHECK_CONDITION) && - scst_sense_valid(cmd->sense) && - scst_analyze_sense(cmd->sense, cmd->sense_valid_len, - SCST_SENSE_KEY_VALID, UNIT_ATTENTION, 0, 0)) { - TRACE_DBG("Cmd %p finished with UA, immediate retry " - "possible", cmd); + if (cmd->status == SAM_STAT_CHECK_CONDITION && + scst_sense_valid(cmd->sense) && + scst_analyze_sense(cmd->sense, cmd->sense_valid_len, SCST_SENSE_KEY_VALID, + UNIT_ATTENTION, 0, 0)) { + TRACE_DBG("Cmd %p finished with UA, immediate retry possible", + cmd); imm_retry = true; goto try_retry; } @@ -277,20 +276,18 @@ try_retry: next_retry_time = cur_time + SCST_CM_RETRIES_WAIT; - TRACE_DBG("Retrying cmd %p (imm_retry %d, next_retry_time %ld, " - "cur_time %ld, start_time %ld, max_retry_time %ld): going " - "to sleep", cmd, imm_retry, next_retry_time, cur_time, - start_time, max_retry_time); + TRACE_DBG("Retrying cmd %p (imm_retry %d, next_retry_time %ld, cur_time %ld, start_time %ld, max_retry_time %ld): going to sleep", + cmd, imm_retry, next_retry_time, cur_time, start_time, max_retry_time); mutex_unlock(&scst_cm_mutex); - if (retry_fn == NULL) + if (!retry_fn) goto out_retry_done; /* Wait before retry */ retry = kzalloc(sizeof(*retry), GFP_KERNEL); - if (retry == NULL) { + if (!retry) { PRINT_ERROR("Unable to allocate retry struct"); scst_set_busy(cmd); goto out_failed; @@ -306,8 +303,7 @@ try_retry: schedule_work(&retry->cm_retry_work.work); } else { TRACE_DBG("Scheduling cmd %p retry", cmd); - schedule_delayed_work(&retry->cm_retry_work, - next_retry_time - cur_time); + schedule_delayed_work(&retry->cm_retry_work, next_retry_time - cur_time); } out_retry_done: @@ -326,10 +322,11 @@ static bool scst_cm_is_ec_cmd_done(struct scst_cmd *ec_cmd) res = true; } else if (unlikely(ec_cmd->completed)) { TRACE_MGMT_DBG("EC cmd %p already completed with status (%d)", - ec_cmd, ec_cmd->status); + ec_cmd, ec_cmd->status); res = true; - } else + } else { res = false; + } TRACE_EXIT_RES(res); return res; @@ -351,8 +348,8 @@ static int scst_cm_setup_this_data_descr(struct scst_cmd *ec_cmd) TRACE_ENTRY(); - TRACE_DBG("ec_cmd %p, cm_cur_data_descr %d", ec_cmd, - priv->cm_cur_data_descr); + TRACE_DBG("ec_cmd %p, cm_cur_data_descr %d", + ec_cmd, priv->cm_cur_data_descr); EXTRACHECKS_BUG_ON(priv->cm_cur_data_descr > priv->cm_data_descrs_cnt); @@ -377,14 +374,13 @@ static int scst_cm_setup_this_data_descr(struct scst_cmd *ec_cmd) priv->cm_start_write_lba = dd->dst_lba; TRACE_DBG("len %d, src_lba %lld, dst_lba %lld", dd->data_len, - (long long)dd->src_lba, (long long)dd->dst_lba); - - if (unlikely((dd->data_len & (sd->src_tgt_dev->dev->block_size-1)) != 0) || - unlikely((dd->data_len & (sd->dst_tgt_dev->dev->block_size-1)) != 0)) { - PRINT_ERROR("Data len %d is not even for block size (src block " - "size %d, dst block size %d)", dd->data_len, - sd->src_tgt_dev->dev->block_size, - sd->dst_tgt_dev->dev->block_size); + (long long)dd->src_lba, (long long)dd->dst_lba); + + if (unlikely((dd->data_len & (sd->src_tgt_dev->dev->block_size - 1)) != 0) || + unlikely((dd->data_len & (sd->dst_tgt_dev->dev->block_size - 1)) != 0)) { + PRINT_ERROR("Data len %d is not even for block size (src block size %d, dst block size %d)", + dd->data_len, sd->src_tgt_dev->dev->block_size, + sd->dst_tgt_dev->dev->block_size); scst_set_cmd_error(ec_cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); res = -EINVAL; goto out; @@ -451,12 +447,12 @@ static void scst_cm_destroy_data_descrs(struct scst_cmd *ec_cmd) TRACE_ENTRY(); - TRACE_DBG("ec_cmd %p, data_descrs %p, data_descrs_cnt %d ", ec_cmd, - priv->cm_data_descrs, priv->cm_data_descrs_cnt); + TRACE_DBG("ec_cmd %p, data_descrs %p, data_descrs_cnt %d ", + ec_cmd, priv->cm_data_descrs, priv->cm_data_descrs_cnt); if (priv->cm_data_descrs != &priv->cm_seg_descrs[priv->cm_cur_seg_descr].data_descr) { - TRACE_DBG_FLAG(TRACE_DEBUG|TRACE_MEMORY, "Freeing " - "data_descrs %p", priv->cm_data_descrs); + TRACE_DBG_FLAG(TRACE_DEBUG | TRACE_MEMORY, "Freeing data_descrs %p", + priv->cm_data_descrs); kfree(priv->cm_data_descrs); } @@ -464,7 +460,6 @@ static void scst_cm_destroy_data_descrs(struct scst_cmd *ec_cmd) priv->cm_data_descrs_cnt = 0; TRACE_EXIT(); - return; } /* @@ -475,7 +470,7 @@ static void scst_cm_destroy_data_descrs(struct scst_cmd *ec_cmd) * and sense supposed to be set. */ static int scst_cm_setup_data_descrs(struct scst_cmd *ec_cmd, - const struct scst_ext_copy_data_descr *dds, int dds_cnt) + const struct scst_ext_copy_data_descr *dds, int dds_cnt) { int res; struct scst_cm_ec_cmd_priv *priv = ec_cmd->cmd_data_descriptors; @@ -517,8 +512,8 @@ static int scst_cm_setup_seg_descr(struct scst_cmd *ec_cmd) TRACE_ENTRY(); - TRACE_DBG("ec_cmd %p, cm_cur_seg_descr %d", ec_cmd, - priv->cm_cur_seg_descr); + TRACE_DBG("ec_cmd %p, cm_cur_seg_descr %d", + ec_cmd, priv->cm_cur_seg_descr); EXTRACHECKS_BUG_ON(priv->cm_cur_seg_descr > ec_cmd->cmd_data_descriptors_cnt); @@ -532,11 +527,11 @@ static int scst_cm_setup_seg_descr(struct scst_cmd *ec_cmd) break; priv->cm_cur_seg_descr++; - TRACE_DBG("ec_cmd %p, cm_cur_seg_descr %d", ec_cmd, - priv->cm_cur_seg_descr); + TRACE_DBG("ec_cmd %p, cm_cur_seg_descr %d", + ec_cmd, priv->cm_cur_seg_descr); } - if (priv->cm_list_id != NULL) { + if (priv->cm_list_id) { /* SCSI: including the being processed one */ priv->cm_list_id->cm_segs_processed = priv->cm_cur_seg_descr + 1; } @@ -569,7 +564,6 @@ static void scst_cm_advance_seg_descr(struct scst_cmd *ec_cmd) priv->cm_cur_seg_descr++; TRACE_EXIT(); - return; } static void scst_cm_prepare_final_sense(struct scst_cmd *ec_cmd) @@ -586,18 +580,16 @@ static void scst_cm_prepare_final_sense(struct scst_cmd *ec_cmd) if (likely(priv->cm_error == SCST_CM_ERROR_NONE)) goto out; - TRACE_DBG("ec_cmd %p, cm_error %d, sense_to_copy %d", ec_cmd, - priv->cm_error, sense_to_copy); + TRACE_DBG("ec_cmd %p, cm_error %d, sense_to_copy %d", + ec_cmd, priv->cm_error, sense_to_copy); if (sense_to_copy > (SCST_SENSE_BUFFERSIZE - 18)) { - PRINT_WARNING("Too small sense buffer, %d bytes will be " - "truncated (ec_cmd %p)", - sense_to_copy - (SCST_SENSE_BUFFERSIZE-18), ec_cmd); + PRINT_WARNING("Too small sense buffer, %d bytes will be truncated (ec_cmd %p)", + sense_to_copy - (SCST_SENSE_BUFFERSIZE - 18), ec_cmd); sense_to_copy = SCST_SENSE_BUFFERSIZE - 18; } - if ((priv->cm_error == SCST_CM_ERROR_WRITE) && - (ec_cmd->status != SAM_STAT_CHECK_CONDITION)) { + if (priv->cm_error == SCST_CM_ERROR_WRITE && ec_cmd->status != SAM_STAT_CHECK_CONDITION) { int rc; struct scst_ext_copy_seg_descr *sd = &priv->cm_seg_descrs[priv->cm_cur_seg_descr]; @@ -607,9 +599,9 @@ static void scst_cm_prepare_final_sense(struct scst_cmd *ec_cmd) if (rc != 0) goto out; - TRACE_DBG("d_sense %d, cm_cur_seg_descr %d, cur_data_descr %d, " - "tgt_descr_offs %d", d_sense, priv->cm_cur_seg_descr, - priv->cm_cur_data_descr, sd->tgt_descr_offs); + TRACE_DBG("d_sense %d, cm_cur_seg_descr %d, cur_data_descr %d, tgt_descr_offs %d", + d_sense, priv->cm_cur_seg_descr, priv->cm_cur_data_descr, + sd->tgt_descr_offs); if (d_sense) { /* Descriptor format */ @@ -650,10 +642,9 @@ static void scst_cm_prepare_final_sense(struct scst_cmd *ec_cmd) } fsense = mempool_alloc(scst_sense_mempool, GFP_KERNEL); - if (fsense == NULL) { - PRINT_ERROR("Allocation of the intermediate Extended Copy " - "sense buffer failed. Reported sense data can be " - "incorrect (ec_cmd %p)", ec_cmd); + if (!fsense) { + PRINT_ERROR("Allocation of the intermediate Extended Copy sense buffer failed. Reported sense data can be incorrect (ec_cmd %p)", + ec_cmd); goto out; } memset(fsense, 0, SCST_SENSE_BUFFERSIZE); @@ -683,8 +674,9 @@ static void scst_cm_prepare_final_sense(struct scst_cmd *ec_cmd) } else if (priv->cm_error == SCST_CM_ERROR_WRITE) { fsense[9] = 18; copy_sense = scst_sense_valid(ec_cmd->sense); - } else + } else { sBUG(); + } if (copy_sense) { TRACE_DBG("Copying %db of old sense", sense_to_copy); @@ -700,17 +692,17 @@ static void scst_cm_prepare_final_sense(struct scst_cmd *ec_cmd) fsense[7] = add_sense_len; /* additional Sense Length */ ec_cmd->status = SAM_STAT_CHECK_CONDITION; - if (ec_cmd->sense != NULL) { + if (ec_cmd->sense) { memcpy(ec_cmd->sense, fsense, sense_len); ec_cmd->sense_valid_len = sense_len; - } else + } else { scst_alloc_set_sense(ec_cmd, 0, fsense, sense_len); + } mempool_free(fsense, scst_sense_mempool); out: TRACE_EXIT(); - return; } static void scst_cm_store_list_id_details(struct scst_cmd *ec_cmd) @@ -720,10 +712,10 @@ static void scst_cm_store_list_id_details(struct scst_cmd *ec_cmd) TRACE_ENTRY(); - if (l != NULL) { - TRACE_DBG("List id %p done (status %d, sense valid %d, sense " - "len %d)", l, ec_cmd->status, scst_sense_valid(ec_cmd->sense), - ec_cmd->sense_valid_len); + if (l) { + TRACE_DBG("List id %p done (status %d, sense valid %d, sense len %d)", + l, ec_cmd->status, scst_sense_valid(ec_cmd->sense), + ec_cmd->sense_valid_len); spin_lock_irq(&scst_cm_lock); l->cm_list_id_state = SCST_CM_LIST_ID_STATE_DONE; if (ec_cmd->status != 0) { @@ -732,10 +724,8 @@ static void scst_cm_store_list_id_details(struct scst_cmd *ec_cmd) int len = ec_cmd->sense_valid_len; if (len > sizeof(l->cm_sense)) { - PRINT_WARNING("EC command's sense is " - "too big (%d) with max allowed " - "%d, truncating", len, - (int)sizeof(l->cm_sense)); + PRINT_WARNING("EC command's sense is too big (%d) with max allowed %d, truncating", + len, (int)sizeof(l->cm_sense)); len = sizeof(l->cm_sense); } l->cm_sense_len = ec_cmd->sense_valid_len; @@ -746,7 +736,6 @@ static void scst_cm_store_list_id_details(struct scst_cmd *ec_cmd) } TRACE_EXIT(); - return; } static void scst_cm_ec_cmd_done(struct scst_cmd *ec_cmd) @@ -760,7 +749,7 @@ static void scst_cm_ec_cmd_done(struct scst_cmd *ec_cmd) TRACE_DBG("ec_cmd %p finished with status %d", ec_cmd, ec_cmd->status); EXTRACHECKS_BUG_ON(priv->cm_cur_in_flight != 0); - EXTRACHECKS_BUG_ON(priv->cm_data_descrs != NULL); + EXTRACHECKS_BUG_ON(priv->cm_data_descrs); scst_cm_prepare_final_sense(ec_cmd); scst_cm_store_list_id_details(ec_cmd); @@ -769,7 +758,6 @@ static void scst_cm_ec_cmd_done(struct scst_cmd *ec_cmd) ec_cmd->scst_cmd_done(ec_cmd, SCST_CMD_STATE_DEFAULT, SCST_CONTEXT_THREAD); TRACE_EXIT(); - return; } static void scst_cm_ec_sched_next_seg(struct scst_cmd *ec_cmd) @@ -787,7 +775,6 @@ static void scst_cm_ec_sched_next_seg(struct scst_cmd *ec_cmd) scst_cm_ext_copy_exec(ec_cmd); TRACE_EXIT(); - return; } static void scst_cm_in_flight_cmd_finished(struct scst_cmd *ec_cmd) @@ -809,19 +796,18 @@ static void scst_cm_in_flight_cmd_finished(struct scst_cmd *ec_cmd) if (f > 0) goto out; - if (priv->cm_list_id != NULL) + if (priv->cm_list_id) priv->cm_list_id->cm_written_size += priv->cm_written; scst_cm_ec_sched_next_seg(ec_cmd); out: TRACE_EXIT(); - return; } -static int scst_cm_add_to_internal_cmd_list(struct scst_cmd *cmd, - struct scst_cmd *ec_cmd, struct scst_cmd *orig_cmd, - scst_i_finish_fn_t finish_fn) +static int scst_cm_add_to_internal_cmd_list(struct scst_cmd *cmd, struct scst_cmd *ec_cmd, + struct scst_cmd *orig_cmd, + scst_i_finish_fn_t finish_fn) { int res; struct scst_cm_ec_cmd_priv *priv = ec_cmd->cmd_data_descriptors; @@ -832,9 +818,9 @@ static int scst_cm_add_to_internal_cmd_list(struct scst_cmd *cmd, EXTRACHECKS_BUG_ON(ec_cmd == cmd); p = kzalloc(sizeof(*p), GFP_KERNEL); - if (p == NULL) { - PRINT_ERROR("Unable to alloc scst_cm_internal_cmd_priv " - "(size %d)", (int)sizeof(*p)); + if (!p) { + PRINT_ERROR("Unable to alloc scst_cm_internal_cmd_priv (size %d)", + (int)sizeof(*p)); goto out_enomem; } @@ -843,7 +829,7 @@ static int scst_cm_add_to_internal_cmd_list(struct scst_cmd *cmd, p->cm_cmd = cmd; TRACE_DBG("Adding internal cmd %p (priv %p, ec_cmd %p, orig_cmd %p)", - cmd, p, ec_cmd, orig_cmd); + cmd, p, ec_cmd, orig_cmd); spin_lock_irq(&scst_cm_lock); list_add_tail(&p->cm_internal_cmd_list_entry, &priv->cm_internal_cmd_list); spin_unlock_irq(&scst_cm_lock); @@ -862,16 +848,14 @@ out_enomem: goto out; } -static void scst_cm_del_free_from_internal_cmd_list(struct scst_cmd *cmd, - bool unblock_dev) +static void scst_cm_del_free_from_internal_cmd_list(struct scst_cmd *cmd, bool unblock_dev) { struct scst_cm_internal_cmd_priv *p = cmd->tgt_i_priv; TRACE_ENTRY(); - TRACE_DBG("Deleting/freeing internal cmd %p (op %s, priv %p, " - "orig_cmd %p)", cmd, scst_get_opcode_name(cmd), p, - p->cm_orig_cmd); + TRACE_DBG("Deleting/freeing internal cmd %p (op %s, priv %p, orig_cmd %p)", + cmd, scst_get_opcode_name(cmd), p, p->cm_orig_cmd); spin_lock_irq(&scst_cm_lock); list_del(&p->cm_internal_cmd_list_entry); @@ -887,14 +871,12 @@ static void scst_cm_del_free_from_internal_cmd_list(struct scst_cmd *cmd, kfree(p); TRACE_EXIT(); - return; } static void scst_cm_read_cmd_finished(struct scst_cmd *rcmd); /* cm_mutex suppose to be locked */ -static int __scst_cm_push_single_read(struct scst_cmd *ec_cmd, - int64_t lba, int blocks) +static int __scst_cm_push_single_read(struct scst_cmd *ec_cmd, int64_t lba, int blocks) { int res; struct scst_cm_ec_cmd_priv *priv = ec_cmd->cmd_data_descriptors; @@ -909,8 +891,7 @@ static int __scst_cm_push_single_read(struct scst_cmd *ec_cmd, TRACE_ENTRY(); if (unlikely(scst_cm_is_ec_cmd_done(ec_cmd))) { - TRACE_MGMT_DBG("EC cmd %p done: aborting further read " - "commands", ec_cmd); + TRACE_MGMT_DBG("EC cmd %p done: aborting further read commands", ec_cmd); priv->cm_left_to_read = 0; res = -EPIPE; goto out; @@ -936,10 +917,9 @@ static int __scst_cm_push_single_read(struct scst_cmd *ec_cmd, /* No app tag check */ } - rcmd = __scst_create_prepare_internal_cmd(read_cdb, - cdb_len, SCST_CMD_QUEUE_SIMPLE, - priv->cm_read_tgt_dev, GFP_KERNEL, false); - if (rcmd == NULL) { + rcmd = __scst_create_prepare_internal_cmd(read_cdb, cdb_len, SCST_CMD_QUEUE_SIMPLE, + priv->cm_read_tgt_dev, GFP_KERNEL, false); + if (!rcmd) { res = -ENOMEM; goto out_busy; } @@ -952,14 +932,12 @@ static int __scst_cm_push_single_read(struct scst_cmd *ec_cmd, rcmd->expected_transfer_len_full += len >> (block_shift - SCST_DIF_TAG_SHIFT); rcmd->expected_values_set = 1; - res = scst_cm_add_to_internal_cmd_list(rcmd, ec_cmd, ec_cmd, - scst_cm_read_cmd_finished); + res = scst_cm_add_to_internal_cmd_list(rcmd, ec_cmd, ec_cmd, scst_cm_read_cmd_finished); if (res != 0) goto out_free_rcmd; - TRACE_DBG("Adding ec_cmd's (%p) READ rcmd %p (lba %lld, blocks %d, " - "check_dif %d) to active cmd list", ec_cmd, rcmd, - (long long)rcmd->lba, blocks, check_dif); + TRACE_DBG("Adding ec_cmd's (%p) READ rcmd %p (lba %lld, blocks %d, check_dif %d) to active cmd list", + ec_cmd, rcmd, (long long)rcmd->lba, blocks, check_dif); spin_lock_irq(&rcmd->cmd_threads->cmd_list_lock); list_add_tail(&rcmd->cmd_list_entry, &rcmd->cmd_threads->active_cmd_list); spin_unlock_irq(&rcmd->cmd_threads->cmd_list_lock); @@ -991,7 +969,7 @@ static void scst_cm_read_retry_fn(struct scst_cmd *rcmd) mutex_lock(&priv->cm_mutex); rc = __scst_cm_push_single_read(ec_cmd, rcmd->lba, - rcmd->data_len >> priv->cm_read_tgt_dev->dev->block_shift); + rcmd->data_len >> priv->cm_read_tgt_dev->dev->block_shift); /* ec_cmd can get dead after we will drop cm_mutex! */ scst_cm_del_free_from_internal_cmd_list(rcmd, false); @@ -1004,11 +982,10 @@ static void scst_cm_read_retry_fn(struct scst_cmd *rcmd) scst_cm_in_flight_cmd_finished(ec_cmd); TRACE_EXIT(); - return; } -static int scst_cm_push_single_write(struct scst_cmd *ec_cmd, - int64_t lba, int blocks, struct scst_cmd *rcmd); +static int scst_cm_push_single_write(struct scst_cmd *ec_cmd, int64_t lba, int blocks, + struct scst_cmd *rcmd); static void scst_cm_write_retry_fn(struct scst_cmd *wcmd) { @@ -1024,8 +1001,8 @@ static void scst_cm_write_retry_fn(struct scst_cmd *wcmd) mutex_lock(&priv->cm_mutex); rc = scst_cm_push_single_write(ec_cmd, wcmd->lba, - wcmd->data_len >> priv->cm_write_tgt_dev->dev->block_shift, - rcmd); + wcmd->data_len >> priv->cm_write_tgt_dev->dev->block_shift, + rcmd); /* ec_cmd can get dead after we will drop cm_mutex! */ scst_cm_del_free_from_internal_cmd_list(wcmd, false); @@ -1038,11 +1015,9 @@ static void scst_cm_write_retry_fn(struct scst_cmd *wcmd) scst_cm_in_flight_cmd_finished(ec_cmd); TRACE_EXIT(); - return; } -static int scst_cm_push_single_read(struct scst_cmd *ec_cmd, int blocks, - bool inc_cur_in_flight); +static int scst_cm_push_single_read(struct scst_cmd *ec_cmd, int blocks, bool inc_cur_in_flight); static void scst_cm_write_cmd_finished(struct scst_cmd *wcmd) { @@ -1056,7 +1031,7 @@ static void scst_cm_write_cmd_finished(struct scst_cmd *wcmd) TRACE_ENTRY(); TRACE_DBG("Write cmd %p finished (ec_cmd %p, rcmd %p, cm_cur_in_flight %d)", - wcmd, rcmd, ec_cmd, priv->cm_cur_in_flight); + wcmd, rcmd, ec_cmd, priv->cm_cur_in_flight); EXTRACHECKS_BUG_ON(wcmd->cdb[0] != WRITE_16); @@ -1064,18 +1039,16 @@ static void scst_cm_write_cmd_finished(struct scst_cmd *wcmd) goto out_finished; rc = scst_cm_err_check_retry(wcmd, ec_cmd->start_time, scst_cm_write_retry_fn); - if (likely(rc == SCST_CM_STATUS_CMD_SUCCEEDED)) - goto cont; - else if (rc == SCST_CM_STATUS_RETRY) - goto out; - else { + if (unlikely(rc != SCST_CM_STATUS_CMD_SUCCEEDED)) { + if (rc == SCST_CM_STATUS_RETRY) + goto out; + TRACE_DBG("Write cmd %p (ec_cmd %p) finished not successfully", - wcmd, ec_cmd); - if (wcmd->status == SAM_STAT_CHECK_CONDITION) - rc = scst_set_cmd_error_sense(ec_cmd, wcmd->sense, - wcmd->sense_valid_len); - else { - sBUG_ON(wcmd->sense != NULL); + wcmd, ec_cmd); + if (wcmd->status == SAM_STAT_CHECK_CONDITION) { + rc = scst_set_cmd_error_sense(ec_cmd, wcmd->sense, wcmd->sense_valid_len); + } else { + sBUG_ON(wcmd->sense); rc = scst_set_cmd_error_status(ec_cmd, wcmd->status); } if (rc != 0) { @@ -1085,15 +1058,16 @@ static void scst_cm_write_cmd_finished(struct scst_cmd *wcmd) */ WARN_ON(scst_is_ua_sense(wcmd->sense, wcmd->sense_valid_len)); sBUG_ON(priv->cm_error == SCST_CM_ERROR_NONE); - } else + } else { priv->cm_error = SCST_CM_ERROR_WRITE; + } + goto out_finished; } -cont: priv->cm_written += wcmd->data_len; - TRACE_DBG("ec_cmd %p, cm_written %lld (data_len %lld)", ec_cmd, - (long long)priv->cm_written, (long long)wcmd->data_len); + TRACE_DBG("ec_cmd %p, cm_written %lld (data_len %lld)", + ec_cmd, (long long)priv->cm_written, (long long)wcmd->data_len); wcmd->sg = NULL; wcmd->sg_cnt = 0; @@ -1142,8 +1116,8 @@ out_finished: goto out_put; } -static int scst_cm_push_single_write(struct scst_cmd *ec_cmd, - int64_t lba, int blocks, struct scst_cmd *rcmd) +static int scst_cm_push_single_write(struct scst_cmd *ec_cmd, int64_t lba, int blocks, + struct scst_cmd *rcmd) { int res; struct scst_cm_ec_cmd_priv *priv = ec_cmd->cmd_data_descriptors; @@ -1165,10 +1139,10 @@ static int scst_cm_push_single_write(struct scst_cmd *ec_cmd, put_unaligned_be64(lba, &write16_cdb[2]); put_unaligned_be32(blocks, &write16_cdb[10]); - wcmd = __scst_create_prepare_internal_cmd(write16_cdb, - sizeof(write16_cdb), SCST_CMD_QUEUE_SIMPLE, - priv->cm_write_tgt_dev, GFP_KERNEL, false); - if (wcmd == NULL) { + wcmd = __scst_create_prepare_internal_cmd(write16_cdb, sizeof(write16_cdb), + SCST_CMD_QUEUE_SIMPLE, priv->cm_write_tgt_dev, + GFP_KERNEL, false); + if (!wcmd) { res = -ENOMEM; goto out_busy; } @@ -1179,8 +1153,7 @@ static int scst_cm_push_single_write(struct scst_cmd *ec_cmd, wcmd->expected_transfer_len_full = len; wcmd->expected_values_set = 1; - res = scst_cm_add_to_internal_cmd_list(wcmd, ec_cmd, rcmd, - scst_cm_write_cmd_finished); + res = scst_cm_add_to_internal_cmd_list(wcmd, ec_cmd, rcmd, scst_cm_write_cmd_finished); if (res != 0) goto out_free_wcmd; @@ -1190,8 +1163,8 @@ static int scst_cm_push_single_write(struct scst_cmd *ec_cmd, wcmd->tgt_i_sg_cnt = rcmd->sg_cnt; wcmd->tgt_i_data_buf_alloced = 1; - TRACE_DBG("Adding EC (%p) WRITE(16) cmd %p (lba %lld, blocks %d) to " - "active cmd list", ec_cmd, wcmd, (long long)wcmd->lba, blocks); + TRACE_DBG("Adding EC (%p) WRITE(16) cmd %p (lba %lld, blocks %d) to active cmd list", + ec_cmd, wcmd, (long long)wcmd->lba, blocks); spin_lock_irq(&wcmd->cmd_threads->cmd_list_lock); list_add_tail(&wcmd->cmd_list_entry, &wcmd->cmd_threads->active_cmd_list); wake_up(&wcmd->cmd_threads->cmd_list_waitQ); @@ -1228,18 +1201,16 @@ static void scst_cm_read_cmd_finished(struct scst_cmd *rcmd) goto out_finished; rc = scst_cm_err_check_retry(rcmd, ec_cmd->start_time, scst_cm_read_retry_fn); - if (likely(rc == SCST_CM_STATUS_CMD_SUCCEEDED)) - goto cont; - else if (rc == SCST_CM_STATUS_RETRY) - goto out; - else { + if (unlikely(rc != SCST_CM_STATUS_CMD_SUCCEEDED)) { + if (rc == SCST_CM_STATUS_RETRY) + goto out; + TRACE_DBG("Read cmd %p (ec_cmd %p) finished not successfully", - rcmd, ec_cmd); - if (rcmd->status == SAM_STAT_CHECK_CONDITION) - rc = scst_set_cmd_error_sense(ec_cmd, rcmd->sense, - rcmd->sense_valid_len); - else { - sBUG_ON(rcmd->sense != NULL); + rcmd, ec_cmd); + if (rcmd->status == SAM_STAT_CHECK_CONDITION) { + rc = scst_set_cmd_error_sense(ec_cmd, rcmd->sense, rcmd->sense_valid_len); + } else { + sBUG_ON(rcmd->sense); rc = scst_set_cmd_error_status(ec_cmd, rcmd->status); } if (rc != 0) { @@ -1249,12 +1220,12 @@ static void scst_cm_read_cmd_finished(struct scst_cmd *rcmd) */ WARN_ON(scst_is_ua_sense(rcmd->sense, rcmd->sense_valid_len)); sBUG_ON(priv->cm_error == SCST_CM_ERROR_NONE); - } else + } else { priv->cm_error = SCST_CM_ERROR_READ; + } goto out_finished; } -cont: lba = rcmd->lba - priv->cm_start_read_lba; lba <<= priv->cm_read_tgt_dev->dev->block_shift; lba >>= priv->cm_write_tgt_dev->dev->block_shift; @@ -1263,12 +1234,11 @@ cont: len = rcmd->data_len; blocks = len >> priv->cm_write_tgt_dev->dev->block_shift; - TRACE_DBG("rcmd->lba %lld, start_read_lba %lld, read shift %d, write " - "shift %d, start_write_lba %lld, lba %lld, len %d, blocks %d", - (long long)rcmd->lba, (long long)priv->cm_start_read_lba, - priv->cm_read_tgt_dev->dev->block_shift, - priv->cm_write_tgt_dev->dev->block_shift, - (long long)priv->cm_start_write_lba, lba, len, blocks); + TRACE_DBG("rcmd->lba %lld, start_read_lba %lld, read shift %d, write shift %d, start_write_lba %lld, lba %lld, len %d, blocks %d", + (long long)rcmd->lba, (long long)priv->cm_start_read_lba, + priv->cm_read_tgt_dev->dev->block_shift, + priv->cm_write_tgt_dev->dev->block_shift, + (long long)priv->cm_start_write_lba, lba, len, blocks); rc = scst_cm_push_single_write(ec_cmd, lba, blocks, rcmd); if (rc != 0) @@ -1286,17 +1256,15 @@ out_finished: } /* cm_mutex suppose to be locked */ -static int scst_cm_push_single_read(struct scst_cmd *ec_cmd, int blocks, - bool inc_cur_in_flight) +static int scst_cm_push_single_read(struct scst_cmd *ec_cmd, int blocks, bool inc_cur_in_flight) { int res; struct scst_cm_ec_cmd_priv *priv = ec_cmd->cmd_data_descriptors; TRACE_ENTRY(); - TRACE_DBG("ec_cmd %p, cm_cur_read_lba %lld, cm_left_to_read %d, " - "blocks %d", ec_cmd, (long long)priv->cm_cur_read_lba, - priv->cm_left_to_read, blocks); + TRACE_DBG("ec_cmd %p, cm_cur_read_lba %lld, cm_left_to_read %d, blocks %d", + ec_cmd, (long long)priv->cm_cur_read_lba, priv->cm_left_to_read, blocks); res = __scst_cm_push_single_read(ec_cmd, priv->cm_cur_read_lba, blocks); if (res != 0) @@ -1307,8 +1275,8 @@ static int scst_cm_push_single_read(struct scst_cmd *ec_cmd, int blocks, if (inc_cur_in_flight) { priv->cm_cur_in_flight++; - TRACE_DBG("ec_cmd %p, new cm_cur_in_flight %d", ec_cmd, - priv->cm_cur_in_flight); + TRACE_DBG("ec_cmd %p, new cm_cur_in_flight %d", + ec_cmd, priv->cm_cur_in_flight); } out: @@ -1368,16 +1336,15 @@ out: out_err: if (priv->cm_cur_in_flight != 0) goto out_wake; - else { - mutex_unlock(&priv->cm_mutex); - scst_cm_ec_cmd_done(ec_cmd); - } + + mutex_unlock(&priv->cm_mutex); + scst_cm_ec_cmd_done(ec_cmd); goto out; } /* cm_mutex suppose to be locked or no activities on this ec_cmd's priv */ static void scst_cm_process_data_descrs(struct scst_cmd *ec_cmd, - const struct scst_ext_copy_data_descr *dds, int dds_cnt) + const struct scst_ext_copy_data_descr *dds, int dds_cnt) { int rc; @@ -1435,12 +1402,12 @@ EXPORT_SYMBOL_GPL(scst_ext_copy_get_cur_seg_data_len); * If dds is NULL, then all data have been remapped, so SCST core will switch * to the next segment descriptor, if any. */ -void scst_ext_copy_remap_done(struct scst_cmd *ec_cmd, - struct scst_ext_copy_data_descr *dds, int dds_cnt) +void scst_ext_copy_remap_done(struct scst_cmd *ec_cmd, struct scst_ext_copy_data_descr *dds, + int dds_cnt) { TRACE_ENTRY(); - if (dds == NULL) + if (!dds) scst_cm_ec_sched_next_seg(ec_cmd); else scst_cm_process_data_descrs(ec_cmd, dds, dds_cnt); @@ -1448,7 +1415,6 @@ void scst_ext_copy_remap_done(struct scst_cmd *ec_cmd, /* ec_cmd can be dead here! */ TRACE_EXIT(); - return; } EXPORT_SYMBOL_GPL(scst_ext_copy_remap_done); @@ -1465,7 +1431,6 @@ static void scst_cm_remap_retry_fn(struct scst_cmd *cmd) sBUG_ON(rc != 0); TRACE_EXIT(); - return; } /* @@ -1485,7 +1450,7 @@ static int scst_cm_try_to_remap(struct scst_cmd *ec_cmd) TRACE_ENTRY(); - if (handler->ext_copy_remap == NULL) { + if (!handler->ext_copy_remap) { res = 1; goto out; } @@ -1495,17 +1460,16 @@ static int scst_cm_try_to_remap(struct scst_cmd *ec_cmd) /* !! priv data descriptors fields are not setup yet !! */ TRACE_DBG("Checking reservations on read dev %s (ec_cmd %p)", - sd->src_tgt_dev->dev->virt_name, ec_cmd); + sd->src_tgt_dev->dev->virt_name, ec_cmd); memset(cdb, 0, sizeof(cdb)); cdb[0] = READ_16; put_unaligned_be64(dd->src_lba, &cdb[2]); put_unaligned_be32(dd->data_len >> sd->src_tgt_dev->dev->block_shift, &cdb[10]); - cmd = __scst_create_prepare_internal_cmd(cdb, - sizeof(cdb), SCST_CMD_QUEUE_SIMPLE, - sd->src_tgt_dev, GFP_KERNEL, true); - if (cmd == NULL) + cmd = __scst_create_prepare_internal_cmd(cdb, sizeof(cdb), SCST_CMD_QUEUE_SIMPLE, + sd->src_tgt_dev, GFP_KERNEL, true); + if (!cmd) goto out_busy; cmd->internal_check_local_events = 1; @@ -1518,17 +1482,16 @@ static int scst_cm_try_to_remap(struct scst_cmd *ec_cmd) __scst_cmd_put(cmd); TRACE_DBG("Checking reservations on write dev %s (ec_cmd %p)", - sd->dst_tgt_dev->dev->virt_name, ec_cmd); + sd->dst_tgt_dev->dev->virt_name, ec_cmd); memset(cdb, 0, sizeof(cdb)); cdb[0] = WRITE_16; put_unaligned_be64(dd->dst_lba, &cdb[2]); put_unaligned_be32(dd->data_len >> sd->dst_tgt_dev->dev->block_shift, &cdb[10]); - cmd = __scst_create_prepare_internal_cmd(cdb, - sizeof(cdb), SCST_CMD_QUEUE_SIMPLE, - sd->dst_tgt_dev, GFP_KERNEL, true); - if (cmd == NULL) + cmd = __scst_create_prepare_internal_cmd(cdb, sizeof(cdb), SCST_CMD_QUEUE_SIMPLE, + sd->dst_tgt_dev, GFP_KERNEL, true); + if (!cmd) goto out_busy; cmd->internal_check_local_events = 1; @@ -1541,7 +1504,7 @@ static int scst_cm_try_to_remap(struct scst_cmd *ec_cmd) __scst_cmd_put(cmd); TRACE_DBG("Calling ext_copy_remap() for dev %s (ec_cmd %p)", - sd->dst_tgt_dev->dev->virt_name, ec_cmd); + sd->dst_tgt_dev->dev->virt_name, ec_cmd); handler->ext_copy_remap(ec_cmd, sd); @@ -1554,12 +1517,11 @@ out_check_retry: sBUG_ON(rc == SCST_CM_STATUS_CMD_SUCCEEDED); if (rc == SCST_CM_STATUS_CMD_FAILED) { TRACE_DBG("Remap check cmd %p (ec_cmd %p, op %s) failed", - cmd, ec_cmd, scst_get_opcode_name(cmd)); - if (cmd->status == SAM_STAT_CHECK_CONDITION) - rc = scst_set_cmd_error_sense(ec_cmd, cmd->sense, - cmd->sense_valid_len); - else { - sBUG_ON(cmd->sense != NULL); + cmd, ec_cmd, scst_get_opcode_name(cmd)); + if (cmd->status == SAM_STAT_CHECK_CONDITION) { + rc = scst_set_cmd_error_sense(ec_cmd, cmd->sense, cmd->sense_valid_len); + } else { + sBUG_ON(cmd->sense); rc = scst_set_cmd_error_status(ec_cmd, cmd->status); } if (rc != 0) { @@ -1569,9 +1531,9 @@ out_check_retry: */ WARN_ON(scst_is_ua_sense(cmd->sense, cmd->sense_valid_len)); } else { - if (cmd->cdb[0] == READ_16) + if (cmd->cdb[0] == READ_16) { priv->cm_error = SCST_CM_ERROR_READ; - else { + } else { EXTRACHECKS_BUG_ON(cmd->cdb[0] != WRITE_16); priv->cm_error = SCST_CM_ERROR_WRITE; } @@ -1605,11 +1567,10 @@ static void scst_cm_process_cur_seg_descr(struct scst_cmd *ec_cmd) /* No remapping supported */ scst_ext_copy_remap_done(ec_cmd, - &priv->cm_seg_descrs[priv->cm_cur_seg_descr].data_descr, 1); + &priv->cm_seg_descrs[priv->cm_cur_seg_descr].data_descr, 1); out: TRACE_EXIT(); - return; } enum scst_exec_res scst_cm_ext_copy_exec(struct scst_cmd *ec_cmd) @@ -1620,7 +1581,7 @@ enum scst_exec_res scst_cm_ext_copy_exec(struct scst_cmd *ec_cmd) TRACE_ENTRY(); - if (unlikely(priv == NULL)) + if (unlikely(!priv)) goto out_local_done; if (unlikely(scst_cm_is_ec_cmd_done(ec_cmd))) { @@ -1669,8 +1630,8 @@ bool scst_cm_ec_cmd_overlap(struct scst_cmd *ec_cmd, struct scst_cmd *cmd) for (i = 0; i < ec_cmd->cmd_data_descriptors_cnt; i++) { struct scst_ext_copy_seg_descr *sd = &priv->cm_seg_descrs[i]; - TRACE_DBG("type %d, dst_dev %p, dev %p", sd->type, - sd->dst_tgt_dev->dev, cmd->dev); + TRACE_DBG("type %d, dst_dev %p, dev %p", + sd->type, sd->dst_tgt_dev->dev, cmd->dev); if (sd->type != SCST_EXT_COPY_SEG_DATA) continue; @@ -1678,11 +1639,12 @@ bool scst_cm_ec_cmd_overlap(struct scst_cmd *ec_cmd, struct scst_cmd *cmd) continue; res = scst_lba1_inside_lba2(sd->data_descr.dst_lba, cmd->lba, - cmd->data_len >> cmd->dev->block_shift); + cmd->data_len >> cmd->dev->block_shift); if (res) goto out; + res = scst_lba1_inside_lba2(cmd->lba, sd->data_descr.dst_lba, - sd->data_descr.data_len >> sd->dst_tgt_dev->dev->block_shift); + sd->data_descr.data_len >> sd->dst_tgt_dev->dev->block_shift); if (res) goto out; } @@ -1746,13 +1708,12 @@ bool scst_cm_check_block_all_devs(struct scst_cmd *cmd) ec_cmd = p->cm_orig_cmd; TRACE_BLOCK("Rewaking blocked EC cmd %p (fcmd %p)", - ec_cmd, cmd); + ec_cmd, cmd); scst_check_unblock_dev(cmd); spin_lock_irq(&ec_cmd->cmd_threads->cmd_list_lock); - list_add_tail(&ec_cmd->cmd_list_entry, - &ec_cmd->cmd_threads->active_cmd_list); + list_add_tail(&ec_cmd->cmd_list_entry, &ec_cmd->cmd_threads->active_cmd_list); wake_up(&ec_cmd->cmd_threads->cmd_list_waitQ); spin_unlock_irq(&ec_cmd->cmd_threads->cmd_list_lock); @@ -1771,7 +1732,7 @@ bool scst_cm_check_block_all_devs(struct scst_cmd *cmd) scst_check_unblock_dev(ec_cmd); d = ec_cmd->cmd_data_descriptors; - if (d == NULL) { + if (!d) { spin_lock_bh(&ec_cmd->dev->dev_lock); res = scst_do_check_blocked_dev(ec_cmd); spin_unlock_bh(&ec_cmd->dev->dev_lock); @@ -1790,8 +1751,8 @@ bool scst_cm_check_block_all_devs(struct scst_cmd *cmd) TRACE_DBG("dev %p (fcmd %p)", e->cm_fcmd->dev, e->cm_fcmd); res = scst_do_check_blocked_dev(e->cm_fcmd); if (unlikely(res)) { - TRACE_BLOCK("fcmd %p (ec_cmd %p) blocked, undo " - "check blocking devices", e->cm_fcmd, ec_cmd); + TRACE_BLOCK("fcmd %p (ec_cmd %p) blocked, undo check blocking devices", + e->cm_fcmd, ec_cmd); break; } } @@ -1799,8 +1760,7 @@ bool scst_cm_check_block_all_devs(struct scst_cmd *cmd) if (unlikely(res)) { struct scst_cmd *blocked_cmd = e->cm_fcmd; - list_for_each_entry(e, &d->cm_sorted_devs_list, - cm_sorted_devs_list_entry) { + list_for_each_entry(e, &d->cm_sorted_devs_list, cm_sorted_devs_list_entry) { if (e->cm_fcmd == blocked_cmd) break; __scst_check_unblock_dev(e->cm_fcmd); @@ -1809,10 +1769,8 @@ bool scst_cm_check_block_all_devs(struct scst_cmd *cmd) } #if !defined(__CHECKER__) - list_for_each_entry_reverse(e, &d->cm_sorted_devs_list, - cm_sorted_devs_list_entry) { + list_for_each_entry_reverse(e, &d->cm_sorted_devs_list, cm_sorted_devs_list_entry) spin_unlock(&e->cm_fcmd->dev->dev_lock); - } #endif local_bh_enable(); @@ -1834,14 +1792,13 @@ void scst_cm_abort_ec_cmd(struct scst_cmd *ec_cmd) spin_lock_irqsave(&scst_cm_lock, flags); - if (p == NULL) + if (!p) goto out_unlock; TRACE_MGMT_DBG("Aborting fantom and internal commands of ec_cmd %p", - ec_cmd); + ec_cmd); - list_for_each_entry(ip, &p->cm_internal_cmd_list, - cm_internal_cmd_list_entry) { + list_for_each_entry(ip, &p->cm_internal_cmd_list, cm_internal_cmd_list_entry) { struct scst_cmd *c = ip->cm_cmd; TRACE_MGMT_DBG("Aborting (f)cmd %p", c); @@ -1852,7 +1809,6 @@ out_unlock: spin_unlock_irqrestore(&scst_cm_lock, flags); TRACE_EXIT(); - return; } static void scst_cm_del_free_list_id(struct scst_cm_list_id *l) @@ -1868,7 +1824,6 @@ static void scst_cm_del_free_list_id(struct scst_cm_list_id *l) kfree(l); TRACE_EXIT(); - return; } static void scst_cm_sched_del_list_id(struct scst_cmd *ec_cmd) @@ -1913,16 +1868,13 @@ static void scst_cm_sched_del_list_id(struct scst_cmd *ec_cmd) TRACE_DBG("Schedule pending free list id %p", l); - schedule_delayed_work(&sess->sess_cm_list_id_cleanup_work, - SCST_CM_ID_KEEP_TIME); + schedule_delayed_work(&sess->sess_cm_list_id_cleanup_work, SCST_CM_ID_KEEP_TIME); out: TRACE_EXIT(); - return; } -static struct scst_cm_list_id *scst_cm_add_list_id(struct scst_cmd *cmd, - int list_id) +static struct scst_cm_list_id *scst_cm_add_list_id(struct scst_cmd *cmd, int list_id) { struct scst_cm_list_id *res; struct scst_session *sess = cmd->sess; @@ -1931,7 +1883,7 @@ static struct scst_cm_list_id *scst_cm_add_list_id(struct scst_cmd *cmd, TRACE_ENTRY(); res = kzalloc(sizeof(*res), GFP_KERNEL); - if (res == NULL) { + if (!res) { TRACE(TRACE_OUT_OF_MEM, "Unable to allocate list_id"); scst_set_busy(cmd); goto out; @@ -1950,8 +1902,7 @@ static struct scst_cm_list_id *scst_cm_add_list_id(struct scst_cmd *cmd, } TRACE_DBG("List id %d already exists", list_id); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_operation_in_progress)); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_operation_in_progress)); goto out_unlock_free; } } @@ -1974,8 +1925,8 @@ out_unlock_free: 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); + struct scst_session *sess = container_of(work, struct scst_session, + sess_cm_list_id_cleanup_work.work); struct scst_cm_list_id *l, *t; unsigned long cur_time = jiffies; unsigned long flags; @@ -1991,18 +1942,17 @@ void sess_cm_list_id_cleanup_work_fn(struct work_struct *work) list_for_each_entry_safe(l, t, &sess->sess_cm_list_id_list, sess_cm_list_id_entry) { if (l->cm_list_id_state != SCST_CM_LIST_ID_STATE_PENDING_FREE) break; - if (time_after_eq(cur_time, l->cm_time_to_free)) + if (time_after_eq(cur_time, l->cm_time_to_free)) { scst_cm_del_free_list_id(l); - else { + } else { TRACE_DBG("Reschedule pending free list ids cleanup"); schedule_delayed_work(&sess->sess_cm_list_id_cleanup_work, - l->cm_time_to_free - cur_time); + l->cm_time_to_free - cur_time); } } spin_unlock_irqrestore(&scst_cm_lock, flags); TRACE_EXIT(); - return; } void scst_cm_free_pending_list_ids(struct scst_session *sess) @@ -2022,7 +1972,6 @@ void scst_cm_free_pending_list_ids(struct scst_session *sess) spin_unlock_irq(&scst_cm_lock); TRACE_EXIT(); - return; } static void scst_cm_copy_status(struct scst_cmd *cmd) @@ -2109,9 +2058,9 @@ static void scst_cm_failed_seg_details(struct scst_cmd *cmd) size = 60 + SCST_SENSE_BUFFERSIZE; tbuf = kzalloc(size, GFP_KERNEL); - if (tbuf == NULL) { - TRACE(TRACE_OUT_OF_MEM, "Unable to allocate FAILED SEGMENTS " - "DETAILS buffer (size %d)", size); + if (!tbuf) { + TRACE(TRACE_OUT_OF_MEM, + "Unable to allocate FAILED SEGMENTS DETAILS buffer (size %d)", size); goto out_busy; } @@ -2129,9 +2078,9 @@ static void scst_cm_failed_seg_details(struct scst_cmd *cmd) goto skip; } - if ((cmd->bufflen == 0) || - ((l->cm_status == 0) && (cmd->bufflen >= 60)) || - ((l->cm_status != 0) && (cmd->bufflen >= 60 + SCST_SENSE_BUFFERSIZE))) + if (cmd->bufflen == 0 || + (l->cm_status == 0 && cmd->bufflen >= 60) || + (l->cm_status != 0 && (cmd->bufflen >= 60 + SCST_SENSE_BUFFERSIZE))) l->cm_can_be_immed_free = 1; if (l->cm_status == 0) @@ -2140,9 +2089,9 @@ static void scst_cm_failed_seg_details(struct scst_cmd *cmd) size = 60 + l->cm_sense_len; TRACE_DBG("l %p, status %d, sense_len %d, size %d", l, - l->cm_status, l->cm_sense_len, size); + l->cm_status, l->cm_sense_len, size); - put_unaligned_be32(size-3, &tbuf[0]); + put_unaligned_be32(size - 3, &tbuf[0]); tbuf[56] = l->cm_status; EXTRACHECKS_BUG_ON(l->cm_sense_len > SCST_SENSE_BUFFERSIZE); BUILD_BUG_ON(sizeof(l->cm_sense) != SCST_SENSE_BUFFERSIZE); @@ -2192,7 +2141,7 @@ out_busy: static void scst_cm_oper_parameters(struct scst_cmd *cmd) { ssize_t length = 0; - uint8_t *buf, tbuf[44+2] /* 2 descriptors implemented */; + uint8_t *buf, tbuf[44 + 2] /* 2 descriptors implemented */; TRACE_ENTRY(); @@ -2214,7 +2163,7 @@ static void scst_cm_oper_parameters(struct scst_cmd *cmd) put_unaligned_be32(SCST_MAX_SEG_DESC_LEN, &tbuf[12]); /* MAXIMUM SEGMENT LENGTH: 256MB */ - put_unaligned_be32(256*1024*1024, &tbuf[16]); + put_unaligned_be32(256 * 1024 * 1024, &tbuf[16]); /* No inline and held data. No stream device max data size. */ @@ -2247,7 +2196,6 @@ static void scst_cm_oper_parameters(struct scst_cmd *cmd) out: TRACE_EXIT(); - return; } enum scst_exec_res scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd) @@ -2270,10 +2218,9 @@ enum scst_exec_res scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd) scst_cm_failed_seg_details(cmd); break; default: - TRACE(TRACE_MINOR, "%s: action %d not supported", cmd->op_name, - action); - scst_set_invalid_field_in_cdb(cmd, 1, - SCST_INVAL_FIELD_BIT_OFFS_VALID | 0); + TRACE(TRACE_MINOR, "%s: action %d not supported", + cmd->op_name, action); + scst_set_invalid_field_in_cdb(cmd, 1, SCST_INVAL_FIELD_BIT_OFFS_VALID | 0); break; } @@ -2291,8 +2238,8 @@ struct scst_cm_init_inq_priv { struct scst_device *dev; }; -static int scst_cm_send_init_inquiry(struct scst_device *dev, - unsigned int unpacked_lun, struct scst_cm_init_inq_priv *priv); +static int scst_cm_send_init_inquiry(struct scst_device *dev, unsigned int unpacked_lun, + struct scst_cm_init_inq_priv *priv); static void scst_cm_inq_retry_fn(struct scst_cmd *cmd) { @@ -2305,7 +2252,6 @@ static void scst_cm_inq_retry_fn(struct scst_cmd *cmd) scst_cm_send_init_inquiry(priv->dev, cmd->lun, priv); TRACE_EXIT(); - return; } static void scst_cm_update_dev_fini(struct scst_device *dev); @@ -2341,9 +2287,8 @@ static void scst_cm_init_inq_finish(struct scst_cmd *cmd) spin_unlock_bh(&dev->dev_lock); if (rc != SCST_CM_STATUS_CMD_SUCCEEDED) { - PRINT_CRIT_ERROR("Unable to perform initial INQUIRY for device " - "%s. Copy manager for this device will be disabled", - dev->virt_name); + PRINT_CRIT_ERROR("Unable to perform initial INQUIRY for device %s. Copy manager for this device will be disabled", + dev->virt_name); goto out_put_ref; } @@ -2368,9 +2313,9 @@ static void scst_cm_init_inq_finish(struct scst_cmd *cmd) } page_len = get_unaligned_be16(&buf[2]); - if (page_len+3 > cmd->resp_data_len) { + if (page_len + 3 > cmd->resp_data_len) { PRINT_WARNING("Page len (%d) doesn't match resp len (%d), ignoring", - page_len+3, cmd->resp_data_len); + page_len + 3, cmd->resp_data_len); goto out_put; } @@ -2381,31 +2326,30 @@ static void scst_cm_init_inq_finish(struct scst_cmd *cmd) if (off + 3 >= page_len) { PRINT_WARNING("Too small page len %d, (off %d), ignoring", - page_len, off); + page_len, off); goto out_put; } des_len = buf[off + 3]; if ((off + des_len) > page_len) { - PRINT_WARNING("Too small buf len %d (off %d, des_len %d), " - "ignoring", page_len, off, des_len); + PRINT_WARNING("Too small buf len %d (off %d, des_len %d), ignoring", + page_len, off, des_len); goto out_put; } des_len += 4; - if (((buf[off] & 0xF0) != 0) || ((buf[off+1] & 0xF0) != 0)) { - TRACE_DBG("Unsupported designator (%x, %x), " - "ignoring", buf[off] & 0xF0, buf[off+1] & 0xF0); + if (((buf[off] & 0xF0) != 0) || ((buf[off + 1] & 0xF0) != 0)) { + TRACE_DBG("Unsupported designator (%x, %x), ignoring", + buf[off] & 0xF0, buf[off + 1] & 0xF0); goto next; } des_alloc_len = sizeof(*des) + des_len; des = kzalloc(des_alloc_len, GFP_KERNEL); - if (des == NULL) { - PRINT_CRIT_ERROR("Unable to allocate designator (len %d, " - "type %x), ignoring it", des_alloc_len, - buf[off+1] & 0xF); + if (!des) { + PRINT_CRIT_ERROR("Unable to allocate designator (len %d, type %x), ignoring it", + des_alloc_len, buf[off + 1] & 0xF); goto out_put; } @@ -2434,11 +2378,10 @@ out_put_ref: scst_cm_update_dev_fini(dev); out: TRACE_EXIT(); - return; } -static int scst_cm_send_init_inquiry(struct scst_device *dev, - unsigned int unpacked_lun, struct scst_cm_init_inq_priv *priv) +static int scst_cm_send_init_inquiry(struct scst_device *dev, unsigned int unpacked_lun, + struct scst_cm_init_inq_priv *priv) { static const uint8_t inq_cdb[6] = { INQUIRY, 1, 0x83, 0x10, 0, 0 }; __be64 lun; @@ -2452,9 +2395,9 @@ static int scst_cm_send_init_inquiry(struct scst_device *dev, goto out; } - if (priv == NULL) { + if (!priv) { priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (priv == NULL) { + if (!priv) { PRINT_ERROR("Unable to alloc priv"); res = -ENOMEM; goto out; @@ -2466,9 +2409,9 @@ static int scst_cm_send_init_inquiry(struct scst_device *dev, lun = scst_pack_lun(unpacked_lun, scst_cm_sess->acg->addr_method); - cmd = scst_rx_cmd(scst_cm_sess, (const uint8_t *)&lun, - sizeof(lun), inq_cdb, sizeof(inq_cdb), false); - if (cmd == NULL) { + cmd = scst_rx_cmd(scst_cm_sess, (const uint8_t *)&lun, sizeof(lun), inq_cdb, + sizeof(inq_cdb), false); + if (!cmd) { res = -ENOMEM; goto out_free; } @@ -2533,7 +2476,7 @@ static unsigned int scst_cm_get_lun(const struct scst_device *dev) res = tgt_dev->lun; rcu_read_unlock(); TRACE_DBG("LUN %d found (full LUN %lld)", - res, tgt_dev->lun); + res, tgt_dev->lun); goto out; } } @@ -2584,9 +2527,8 @@ static int scst_cm_dev_register(struct scst_device *dev, uint64_t lun) lun = scst_cm_get_free_lun(); - res = scst_acg_add_lun(scst_cm_tgt->default_acg, - scst_cm_tgt->tgt_luns_kobj, dev, lun, SCST_ADD_LUN_CM, - &acg_dev); + res = scst_acg_add_lun(scst_cm_tgt->default_acg, scst_cm_tgt->tgt_luns_kobj, + dev, lun, SCST_ADD_LUN_CM, &acg_dev); if (res != 0) goto out_err; } @@ -2638,8 +2580,6 @@ static void scst_cm_dev_free_designators(struct scst_device *dev) mutex_unlock(&scst_cm_mutex); TRACE_EXIT(); - - return; } /* scst_mutex supposed to be held */ @@ -2660,8 +2600,6 @@ static void scst_cm_dev_unregister(struct scst_device *dev) scst_acg_del_lun(scst_cm_tgt->default_acg, lun, false); TRACE_EXIT(); - - return; } static int __scst_cm_update_dev(struct scst_device *dev) @@ -2762,8 +2700,6 @@ void scst_cm_update_dev(struct scst_device *dev) out: TRACE_EXIT(); - - return; } int scst_cm_on_dev_register(struct scst_device *dev) @@ -2793,7 +2729,6 @@ void scst_cm_on_dev_unregister(struct scst_device *dev) scst_cm_dev_unregister(dev); TRACE_EXIT(); - return; } /* scst_mutex supposed to be held */ @@ -2805,7 +2740,7 @@ int scst_cm_on_add_acg(struct scst_acg *acg) lockdep_assert_held(&scst_mutex); - if (scst_cm_tgt == NULL) + if (!scst_cm_tgt) goto out; if (acg->tgt != scst_cm_tgt) @@ -2831,8 +2766,7 @@ void scst_cm_on_del_acg(struct scst_acg *acg) } /* scst_mutex supposed to be held */ -int scst_cm_on_add_lun(struct scst_acg_dev *acg_dev, uint64_t lun, - unsigned int *flags) +int scst_cm_on_add_lun(struct scst_acg_dev *acg_dev, uint64_t lun, unsigned int *flags) { int res = 0; @@ -2880,9 +2814,8 @@ out: } /* scst_mutex2 supposed to be held */ -static bool scst_cm_check_access_acg(const char *initiator_name, - const struct scst_device *dev, const struct scst_acg *acg, - bool default_acg) +static bool scst_cm_check_access_acg(const char *initiator_name, const struct scst_device *dev, + const struct scst_acg *acg, bool default_acg) { bool res = true; struct scst_acg_dev *acg_dev; @@ -2911,8 +2844,8 @@ found: return res; } -static bool scst_cm_check_access(const char *initiator_name, - const struct scst_device *dev, bool *read_only) +static bool scst_cm_check_access(const char *initiator_name, const struct scst_device *dev, + bool *read_only) { bool res = true; struct scst_tgt_template *tgtt; @@ -2953,8 +2886,8 @@ static bool scst_cm_check_access(const char *initiator_name, } res = false; - PRINT_WARNING("Initiator %s not allowed to use device %s in EXTENDED " - "COPY command", initiator_name, dev->virt_name); + PRINT_WARNING("Initiator %s not allowed to use device %s in EXTENDED COPY command", + initiator_name, dev->virt_name); out_unlock_rd_only: mutex_unlock(&scst_mutex2); @@ -2973,8 +2906,8 @@ struct scst_cm_tgt_descr { }; /* Parse the copy source or copy destination (CSCD) descriptors. */ -static int scst_cm_parse_id_tgt_descr(struct scst_cmd *cmd, const uint8_t *seg, - int offs, struct scst_cm_tgt_descr *tgt_descr) +static int scst_cm_parse_id_tgt_descr(struct scst_cmd *cmd, const uint8_t *seg, int offs, + struct scst_cm_tgt_descr *tgt_descr) { int res = 32; struct scst_cm_desig *des; @@ -2989,8 +2922,8 @@ static int scst_cm_parse_id_tgt_descr(struct scst_cmd *cmd, const uint8_t *seg, if ((seg[1] & 0xC0) != 0) { PRINT_WARNING("LU ID %x not supported", seg[1] & 0xC0); - scst_set_invalid_field_in_parm_list(cmd, offs+1, - SCST_INVAL_FIELD_BIT_OFFS_VALID | 6); + scst_set_invalid_field_in_parm_list(cmd, offs + 1, + SCST_INVAL_FIELD_BIT_OFFS_VALID | 6); goto out_err; } @@ -3002,9 +2935,9 @@ static int scst_cm_parse_id_tgt_descr(struct scst_cmd *cmd, const uint8_t *seg, if ((seg[1] & 0xF) != 0) { PRINT_WARNING("PERIPHERAL DEVICE TYPE %d not supported", - seg[1] & 0xF); - scst_set_invalid_field_in_parm_list(cmd, offs+1, - SCST_INVAL_FIELD_BIT_OFFS_VALID | 0); + seg[1] & 0xF); + scst_set_invalid_field_in_parm_list(cmd, offs + 1, + SCST_INVAL_FIELD_BIT_OFFS_VALID | 0); goto out_err; } @@ -3015,8 +2948,8 @@ static int scst_cm_parse_id_tgt_descr(struct scst_cmd *cmd, const uint8_t *seg, /* ToDo: make it hash based */ list_for_each_entry(des, &scst_cm_desig_list, cm_desig_list_entry) { - TRACE_DBG("des %p (tgt_dev %p, lun %lld)", des, des->desig_tgt_dev, - (unsigned long long)des->desig_tgt_dev->lun); + TRACE_DBG("des %p (tgt_dev %p, lun %lld)", + des, des->desig_tgt_dev, (unsigned long long)des->desig_tgt_dev->lun); /* Check the code set field. */ if (seg[4] != des->desig[0]) continue; @@ -3033,35 +2966,36 @@ static int scst_cm_parse_id_tgt_descr(struct scst_cmd *cmd, const uint8_t *seg, continue; if (memcmp(&des->desig[4], &seg[8], seg[7]) == 0) { TRACE_DBG("Tgt_dev %p (lun %lld) found", - des->desig_tgt_dev, - (unsigned long long)des->desig_tgt_dev->lun); + des->desig_tgt_dev, + (unsigned long long)des->desig_tgt_dev->lun); mutex_unlock(&scst_cm_mutex); if (block != des->desig_tgt_dev->dev->block_size) { - PRINT_WARNING("Block size %d doesn't match %d", block, - des->desig_tgt_dev->dev->block_size); - scst_set_invalid_field_in_parm_list(cmd, offs+29, 0); + PRINT_WARNING("Block size %d doesn't match %d", + block, des->desig_tgt_dev->dev->block_size); + scst_set_invalid_field_in_parm_list(cmd, offs + 29, 0); goto out_err; } if (!scst_cm_check_access(cmd->sess->initiator_name, - des->desig_tgt_dev->dev, &read_only)) + des->desig_tgt_dev->dev, &read_only)) goto out_not_found; tgt_descr->tgt_dev = des->desig_tgt_dev; tgt_descr->read_only = read_only; TRACE_DBG("Found des %p (tgt_dev %p, read_only %d)", - des, tgt_descr->tgt_dev, tgt_descr->read_only); + des, tgt_descr->tgt_dev, tgt_descr->read_only); goto out; } } mutex_unlock(&scst_cm_mutex); - TRACE(TRACE_MINOR|TRACE_SCSI, "Target descriptor designator not found " - "(initiator %s, offs %d)", cmd->sess->initiator_name, offs); - TRACE_BUFF_FLAG(TRACE_MINOR|TRACE_SCSI, "Designator", seg, 32); + TRACE(TRACE_MINOR | TRACE_SCSI, + "Target descriptor designator not found (initiator %s, offs %d)", + cmd->sess->initiator_name, offs); + TRACE_BUFF_FLAG(TRACE_MINOR | TRACE_SCSI, "Designator", seg, 32); out_not_found: scst_set_invalid_field_in_parm_list(cmd, offs, 0); @@ -3074,15 +3008,15 @@ out: return res; } -static int scst_cm_set_seg_err_sense(struct scst_cmd *cmd, int asc, int ascq, - int seg_num, int offs) +static int scst_cm_set_seg_err_sense(struct scst_cmd *cmd, int asc, int ascq, int seg_num, + int offs) { int res, d_sense = scst_get_cmd_dev_d_sense(cmd); TRACE_ENTRY(); - TRACE_DBG("cmd %p, seg %d, offs %d (d_sense %d)", cmd, seg_num, offs, - d_sense); + TRACE_DBG("cmd %p, seg %d, offs %d (d_sense %d)", + cmd, seg_num, offs, d_sense); res = scst_set_cmd_error_status(cmd, SAM_STAT_CHECK_CONDITION); if (res != 0) @@ -3149,11 +3083,9 @@ static void scst_cm_fantom_cmd_finished(struct scst_cmd *cmd) /* Nothing to do */ TRACE_EXIT(); - return; } -static int scst_cm_add_to_descr_list(struct scst_cmd *ec_cmd, - struct scst_tgt_dev *tgt_dev) +static int scst_cm_add_to_descr_list(struct scst_cmd *ec_cmd, struct scst_tgt_dev *tgt_dev) { int res; struct scst_cm_ec_cmd_priv *priv = ec_cmd->cmd_data_descriptors; @@ -3167,15 +3099,15 @@ static int scst_cm_add_to_descr_list(struct scst_cmd *ec_cmd, list_for_each_entry(e, &priv->cm_sorted_devs_list, cm_sorted_devs_list_entry) { if (e->cm_fcmd->dev == tgt_dev->dev) { TRACE_DBG("Dev %p is already in cm_sorted_devs_list", - tgt_dev->dev); + tgt_dev->dev); goto out_success; } } e = kzalloc(sizeof(*e), GFP_KERNEL); - if (e == NULL) { + if (!e) { PRINT_ERROR("Unable to allocate scst_cm_dev_entry (size %d)", - (int)sizeof(*e)); + (int)sizeof(*e)); goto out_enomem; } @@ -3184,10 +3116,10 @@ static int scst_cm_add_to_descr_list(struct scst_cmd *ec_cmd, goto skip_fcmd_create; } - fcmd = __scst_create_prepare_internal_cmd(ec_cmd->cdb, - ec_cmd->cdb_len, SCST_CMD_QUEUE_SIMPLE, tgt_dev, - GFP_KERNEL, true); - if (fcmd == NULL) + fcmd = __scst_create_prepare_internal_cmd(ec_cmd->cdb, ec_cmd->cdb_len, + SCST_CMD_QUEUE_SIMPLE, tgt_dev, GFP_KERNEL, + true); + if (!fcmd) goto out_enomem_free_e; fcmd->expected_data_direction = ec_cmd->expected_data_direction; @@ -3199,14 +3131,13 @@ static int scst_cm_add_to_descr_list(struct scst_cmd *ec_cmd, fcmd->state = SCST_CMD_STATE_EXEC_CHECK_BLOCKING; - res = scst_cm_add_to_internal_cmd_list(fcmd, ec_cmd, ec_cmd, - scst_cm_fantom_cmd_finished); + res = scst_cm_add_to_internal_cmd_list(fcmd, ec_cmd, ec_cmd, scst_cm_fantom_cmd_finished); if (res != 0) goto out_free_cmd; skip_fcmd_create: - TRACE_DBG("ec_cmd %p, e %p, fcmd %p, tgt_dev %p (dev %p)", ec_cmd, e, fcmd, - tgt_dev, tgt_dev->dev); + TRACE_DBG("ec_cmd %p, e %p, fcmd %p, tgt_dev %p (dev %p)", + ec_cmd, e, fcmd, tgt_dev, tgt_dev->dev); e->cm_fcmd = fcmd; @@ -3214,16 +3145,14 @@ skip_fcmd_create: list_for_each_entry_reverse(t, &priv->cm_sorted_devs_list, cm_sorted_devs_list_entry) { EXTRACHECKS_BUG_ON(t->cm_fcmd->dev == tgt_dev->dev); if (((unsigned long)e->cm_fcmd->dev) > ((unsigned long)t->cm_fcmd->dev)) { - __list_add(&e->cm_sorted_devs_list_entry, - &t->cm_sorted_devs_list_entry, - t->cm_sorted_devs_list_entry.next); + __list_add(&e->cm_sorted_devs_list_entry, &t->cm_sorted_devs_list_entry, + t->cm_sorted_devs_list_entry.next); added = true; break; } } if (!added) - list_add(&e->cm_sorted_devs_list_entry, - &priv->cm_sorted_devs_list); + list_add(&e->cm_sorted_devs_list_entry, &priv->cm_sorted_devs_list); #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_EXTRACHECKS) { @@ -3231,7 +3160,7 @@ skip_fcmd_create: list_for_each_entry(t, &priv->cm_sorted_devs_list, cm_sorted_devs_list_entry) { TRACE_DBG("t %p, cm dev %p", t, t->cm_fcmd->dev); - if (tp != NULL) { + if (tp) { if (((unsigned long)t->cm_fcmd->dev) <= ((unsigned long)tp->cm_fcmd->dev)) { list_for_each_entry(t, &priv->cm_sorted_devs_list, cm_sorted_devs_list_entry) { pr_emerg("%s: t %p, cm dev %p\n", @@ -3267,9 +3196,9 @@ out_enomem: goto out; } -static int scst_cm_parse_b2b_seg_descr(struct scst_cmd *ec_cmd, - const uint8_t *seg, const struct scst_cm_tgt_descr *tgt_descrs, - int tgt_descrs_cnt, int seg_num) +static int scst_cm_parse_b2b_seg_descr(struct scst_cmd *ec_cmd, const uint8_t *seg, + const struct scst_cm_tgt_descr *tgt_descrs, + int tgt_descrs_cnt, int seg_num) { struct scst_cm_ec_cmd_priv *priv = ec_cmd->cmd_data_descriptors; struct scst_ext_copy_seg_descr *d = &priv->cm_seg_descrs[seg_num]; @@ -3297,7 +3226,7 @@ static int scst_cm_parse_b2b_seg_descr(struct scst_cmd *ec_cmd, } src_des = &tgt_descrs[src_des_idx]; - if (src_des->tgt_dev == NULL) { + if (!src_des->tgt_dev) { PRINT_WARNING("Segment with NULL src tgt device"); /* COPY TARGET DEVICE NOT REACHABLE */ scst_cm_set_seg_err_sense(ec_cmd, 0xD, 2, seg_num, 4); @@ -3312,7 +3241,7 @@ static int scst_cm_parse_b2b_seg_descr(struct scst_cmd *ec_cmd, } tgt_des = &tgt_descrs[tgt_des_idx]; - if (tgt_des->tgt_dev == NULL) { + if (!tgt_des->tgt_dev) { PRINT_WARNING("Segment with NULL tgt device"); /* COPY TARGET DEVICE NOT REACHABLE */ scst_cm_set_seg_err_sense(ec_cmd, 0xD, 2, seg_num, 6); @@ -3331,12 +3260,11 @@ static int scst_cm_parse_b2b_seg_descr(struct scst_cmd *ec_cmd, else len = blocks << src_des->tgt_dev->dev->block_shift; - if (unlikely((len & (src_des->tgt_dev->dev->block_size-1)) != 0) || - unlikely((len & (tgt_des->tgt_dev->dev->block_size-1)) != 0)) { - PRINT_WARNING("Data len %d is not even for block size (src block " - "size %d, dst block size %d)", len, - src_des->tgt_dev->dev->block_size, - tgt_des->tgt_dev->dev->block_size); + if (unlikely((len & (src_des->tgt_dev->dev->block_size - 1)) != 0) || + unlikely((len & (tgt_des->tgt_dev->dev->block_size - 1)) != 0)) { + PRINT_WARNING("Data len %d is not even for block size (src block size %d, dst block size %d)", + len, src_des->tgt_dev->dev->block_size, + tgt_des->tgt_dev->dev->block_size); scst_cm_set_seg_err_sense(ec_cmd, 0, 0, seg_num, 10); goto out_err; } @@ -3349,14 +3277,13 @@ static int scst_cm_parse_b2b_seg_descr(struct scst_cmd *ec_cmd, d->data_descr.dst_lba = get_unaligned_be64(&seg[20]); d->tgt_descr_offs = tgt_des->param_offs; - TRACE(TRACE_DEBUG|TRACE_SCSI, "ec_cmd %p, src dev %s, dst dev %s, " - "len %d, src_lba %lld, dst_lba %lld", ec_cmd, - d->src_tgt_dev->dev->virt_name, d->dst_tgt_dev->dev->virt_name, - len, (long long)d->data_descr.src_lba, - (long long)d->data_descr.dst_lba); + TRACE(TRACE_DEBUG | TRACE_SCSI, + "ec_cmd %p, src dev %s, dst dev %s, len %d, src_lba %lld, dst_lba %lld", + ec_cmd, d->src_tgt_dev->dev->virt_name, d->dst_tgt_dev->dev->virt_name, + len, (long long)d->data_descr.src_lba, (long long)d->data_descr.dst_lba); TRACE_DBG("src tgt_dev %p, dst tgt_dev %p, tgt_descr_of... [truncated message content] |
From: Gleb C. <lna...@ya...> - 2025-09-08 13:43:52
|
Commit: f8bfa63 GitHub URL: https://github.com/SCST-project/scst/commit/f8bfa638b692f322196822e1b08e02feb217664e Author: Tony Battersby Date: 2025-09-08T16:40:12+03:00 Log Message: ----------- scst: Export scst_tgt->sg_tablesize via sysfs This value is available in initiator mode via /sys/class/scsi_host/hostN/sg_tablesize; make it available in target mode as well. Userspace code may use it when making decisions about buffer sizes. Signed-off-by: Tony Battersby <to...@cy...> Modified Paths: -------------- scst/src/scst_sysfs.c | 21 +++++++++++++++ 1 file changed, 21 insertions(+) =================================================================== diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 340e735..131f1b1 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -2718,6 +2718,26 @@ out: static struct kobj_attribute scst_tgt_comment = __ATTR(comment, 0644, scst_tgt_comment_show, scst_tgt_comment_store); + +static ssize_t scst_tgt_sg_tablesize_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + struct scst_tgt *tgt; + int ret; + + TRACE_ENTRY(); + + tgt = container_of(kobj, struct scst_tgt, tgt_kobj); + + ret = sysfs_emit(buf, "%d\n", tgt->sg_tablesize); + + TRACE_EXIT_RES(ret); + return ret; +} + +static struct kobj_attribute scst_tgt_sg_tablesize = + __ATTR(sg_tablesize, 0444, scst_tgt_sg_tablesize_show, NULL); + /* * Creates an attribute entry for one target. Allows for target driver to * create an attribute that is not for every target. @@ -2910,6 +2930,7 @@ static struct attribute *scst_tgt_attrs[] = { &scst_tgt_aen_disabled.attr, &scst_tgt_forwarding.attr, &scst_tgt_comment.attr, + &scst_tgt_sg_tablesize.attr, &scst_tgt_addr_method.attr, &scst_tgt_io_grouping_type.attr, &scst_tgt_black_hole.attr, |
From: Gleb C. <lna...@ya...> - 2025-09-08 13:43:40
|
Commit: 70e0d81 GitHub URL: https://github.com/SCST-project/scst/commit/70e0d81436b47a1a23e527252296a1aabe83cd86 Author: Tony Battersby Date: 2025-09-08T16:40:12+03:00 Log Message: ----------- scst_user: Fix oops in SCST_USER_PARSE_EXCEPTION If dev->generic_parse() detects a math overflow and calls scst_set_cmd_error(), and scst_user is using SCST_USER_PARSE_EXCEPTION, then it will trigger a sBUG() in scst_targ.c::scst_parse_cmd() where it checks for a valid cmd->state: scst: scst_parse_cmd:1385:***CRITICAL ERROR***: Bad state for completed cmd (cmd 000000005abc21e1, state 1) BUG at /usr/src/debug/scst/3.10+git/scst/src/scst_targ.c:1387 Fix by treating negative generic_parse() errors as final. Signed-off-by: Tony Battersby <to...@cy...> Modified Paths: -------------- scst/src/dev_handlers/scst_user.c | 9 +++++++++ 1 file changed, 9 insertions(+) =================================================================== diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index cfd9ce2..88b37eb 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -757,6 +757,15 @@ static int dev_user_parse(struct scst_cmd *cmd) res = SCST_CMD_STATE_NEED_THREAD_CTX; goto out; } + if (rc < 0) { + /* + * May have already called e.g. scst_set_cmd_error(); + * too late to try user parse without cleaning up + * first. + */ + PRINT_ERROR("PARSE failed (ucmd %p, rc %d)", ucmd, rc); + goto out_error; + } fallthrough; case SCST_USER_PARSE_CALL: |
From: Gleb C. <lna...@ya...> - 2025-09-08 13:43:15
|
Commit: f9de3f4 GitHub URL: https://github.com/SCST-project/scst/commit/f9de3f4169524e9337e895a335e25914889e907b Author: Tony Battersby Date: 2025-09-08T16:40:12+03:00 Log Message: ----------- scst: Fix parsing of CDB control byte SCST_GET_CDB_LEN() returns 0 for vendor-specific opcodes such as: 0xD1 READ DYN RUNTIME ATT 0xD2 WRITE DYN RUNTIME ATTR 0xE7 INIT ELEMENT STATUS WRANGE This causes scst_set_cmd_from_cdb_info() to check cdb[-1] for the control byte, causing an out-of-bounds array read. - Move the parsing of the control byte after get_cdb_info() since that may set the CDB length to a known value. - If the CDB length is still unknown, then assume the control byte is 0 without accessing the CDB. - Check for variable-length CDBs in scst_set_cmd_from_cdb_info() rather than using the wrong control byte and then overriding it in get_cdb_info_var_len(). This is necessary because the override would no longer work after the change above. Also, the following code doesn't work: #define CONTROL_BYTE_NACA_BIT 0x04 unsigned int cmd_naca:1; cmd_naca = (control & CONTROL_BYTE_NACA_BIT); The result will always be 0. Use this instead: cmd_naca = !!(control & CONTROL_BYTE_NACA_BIT); (cmd_linked happened to work because CONTROL_BYTE_LINK_BIT is 0x01, but apply the same fix there also for consistency). Signed-off-by: Tony Battersby <to...@cy...> Modified Paths: -------------- scst/src/scst_lib.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) =================================================================== diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 7eda3aa..6b48030 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -11941,8 +11941,6 @@ static int scst_set_cmd_from_cdb_info(struct scst_cmd *cmd, int res; cmd->cdb_len = SCST_GET_CDB_LEN(cmd->cdb[0]); - cmd->cmd_naca = (cmd->cdb[cmd->cdb_len - 1] & CONTROL_BYTE_NACA_BIT); - cmd->cmd_linked = (cmd->cdb[cmd->cdb_len - 1] & CONTROL_BYTE_LINK_BIT); cmd->op_name = ptr->info_op_name; cmd->data_direction = ptr->info_data_direction; cmd->op_flags = ptr->info_op_flags | SCST_INFO_VALID; @@ -11952,6 +11950,15 @@ static int scst_set_cmd_from_cdb_info(struct scst_cmd *cmd, cmd->len_len = ptr->info_len_len; cmd->log2_max_buf_len = ptr->log2_max_buf_len; res = (*ptr->get_cdb_info)(cmd, ptr); + + /* get_cdb_info() may override cdb_len, so do this after */ + if (likely(cmd->cdb_len != 0)) { + unsigned int control = (cmd->cdb[0] == 0x7F) ? cmd->cdb[1] : + cmd->cdb[cmd->cdb_len - 1]; + cmd->cmd_naca = !!(control & CONTROL_BYTE_NACA_BIT); + cmd->cmd_linked = !!(control & CONTROL_BYTE_LINK_BIT); + } + if (!cmd->log2_max_buf_len || cmd->bufflen <= (1U << cmd->log2_max_buf_len)) return res; @@ -12047,9 +12054,6 @@ static int get_cdb_info_var_len(struct scst_cmd *cmd, res = scst_set_cmd_from_cdb_info(cmd, ptr); - cmd->cmd_naca = (cmd->cdb[1] & CONTROL_BYTE_NACA_BIT); - cmd->cmd_linked = (cmd->cdb[1] & CONTROL_BYTE_LINK_BIT); - out: TRACE_EXIT_RES(res); return res; |
From: Gleb C. <lna...@ya...> - 2025-09-08 13:42:09
|
Commit: 63f2375 GitHub URL: https://github.com/SCST-project/scst/commit/63f2375fe4c3075e066400175a2c8a74469a7f5a Author: Tony Battersby Date: 2025-09-08T16:40:12+03:00 Log Message: ----------- kbuild: Remove stack protector flags -fstack-protector-strong is controlled by the in-tree CONFIG_STACKPROTECTOR_STRONG config option. If the flag is set without the config option, scst fails to build: ERROR: modpost: "__stack_chk_fail" [scst/src/scst.ko] undefined! -fstack-clash-protection is disabled in the kernel's Makefile due to an incompatibility with randomize_kstack_offset. Fixes: 86d3d4bb1d14 ("kbuild: Enable additional compiler warnings") Signed-off-by: Tony Battersby <to...@cy...> Modified Paths: -------------- fcst/Kbuild | 2 -- iscsi-scst/kernel/Kbuild | 2 -- iscsi-scst/kernel/isert-scst/Kbuild | 2 -- qla2x00t-32gbit/Kbuild | 2 -- qla2x00t-32gbit/qla2x00-target/Kbuild | 2 -- qla2x00t/Kbuild | 2 -- qla2x00t/qla2x00-target/Kbuild | 2 -- scst/src/Kbuild | 2 -- scst/src/dev_handlers/Kbuild | 2 -- scst_local/Kbuild | 2 -- srpt/src/Kbuild | 2 -- 11 files changed, 22 deletions(-) =================================================================== diff --git a/fcst/Kbuild b/fcst/Kbuild index f9e3611..c4fc956 100644 --- a/fcst/Kbuild +++ b/fcst/Kbuild @@ -14,8 +14,6 @@ ccflags-y += -Wall \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes obj-$(CONFIG_FCST) += fcst.o diff --git a/iscsi-scst/kernel/Kbuild b/iscsi-scst/kernel/Kbuild index 6fa853e..499d825 100644 --- a/iscsi-scst/kernel/Kbuild +++ b/iscsi-scst/kernel/Kbuild @@ -30,8 +30,6 @@ ccflags-y := -I$(src)/../include \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes ccflags-y += $(CONFTEST_CFLAGS) diff --git a/iscsi-scst/kernel/isert-scst/Kbuild b/iscsi-scst/kernel/isert-scst/Kbuild index e6ecfa6..94bb3e8 100644 --- a/iscsi-scst/kernel/isert-scst/Kbuild +++ b/iscsi-scst/kernel/isert-scst/Kbuild @@ -35,8 +35,6 @@ ccflags-y := -I$(src)/../../../scst/include \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes obj-m += isert-scst.o diff --git a/qla2x00t-32gbit/Kbuild b/qla2x00t-32gbit/Kbuild index 31cb059..beab2ee 100644 --- a/qla2x00t-32gbit/Kbuild +++ b/qla2x00t-32gbit/Kbuild @@ -11,8 +11,6 @@ ccflags-y := -I$(src)/../scst/include \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes ifneq ($(CONFIG_SCSI_QLA2XXX_TARGET),) diff --git a/qla2x00t-32gbit/qla2x00-target/Kbuild b/qla2x00t-32gbit/qla2x00-target/Kbuild index 24251e3..0ceae42 100644 --- a/qla2x00t-32gbit/qla2x00-target/Kbuild +++ b/qla2x00t-32gbit/qla2x00-target/Kbuild @@ -14,8 +14,6 @@ ccflags-y := -I$(src)/../../scst/include \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes #ccflags-y += -DCONFIG_QLA_TGT_DEBUG_WORK_IN_THREAD diff --git a/qla2x00t/Kbuild b/qla2x00t/Kbuild index e3deaec..12a67aa 100644 --- a/qla2x00t/Kbuild +++ b/qla2x00t/Kbuild @@ -11,8 +11,6 @@ ccflags-y := -I$(src)/../scst/include \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes ifneq ($(CONFIG_SCSI_QLA2XXX_TARGET),) diff --git a/qla2x00t/qla2x00-target/Kbuild b/qla2x00t/qla2x00-target/Kbuild index 9f78e1b..f34982b 100644 --- a/qla2x00t/qla2x00-target/Kbuild +++ b/qla2x00t/qla2x00-target/Kbuild @@ -14,8 +14,6 @@ ccflags-y := -I$(src)/../../scst/include \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes #ccflags-y += -DCONFIG_QLA_TGT_DEBUG_WORK_IN_THREAD diff --git a/scst/src/Kbuild b/scst/src/Kbuild index 94d5af7..60c962f 100644 --- a/scst/src/Kbuild +++ b/scst/src/Kbuild @@ -11,8 +11,6 @@ ccflags-y := -I$(src)/../include \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes ccflags-y += $(shell [ -n "${BUILD_DATE}" ] && echo -DSCST_BUILD_DATE=${BUILD_DATE}) \ diff --git a/scst/src/dev_handlers/Kbuild b/scst/src/dev_handlers/Kbuild index 8a813a1..f9d9c23 100644 --- a/scst/src/dev_handlers/Kbuild +++ b/scst/src/dev_handlers/Kbuild @@ -13,8 +13,6 @@ ccflags-y := -I$(src)/../../include \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes #ccflags-y += -DCONFIG_DEBUG_EXT_COPY_REMAP diff --git a/scst_local/Kbuild b/scst_local/Kbuild index 0e9a878..3cf7804 100644 --- a/scst_local/Kbuild +++ b/scst_local/Kbuild @@ -13,8 +13,6 @@ ccflags-y := -I$(src)/../scst/include \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes obj-m := scst_local.o diff --git a/srpt/src/Kbuild b/srpt/src/Kbuild index 6962b26..034b10d 100644 --- a/srpt/src/Kbuild +++ b/srpt/src/Kbuild @@ -16,8 +16,6 @@ ccflags-y += -I$(src)/../../scst/include \ -pipe \ -g \ -grecord-gcc-switches \ - -fstack-clash-protection \ - -fstack-protector-strong \ -Wstrict-prototypes obj-m += ib_srpt.o |
From: Gleb C. <lna...@ya...> - 2025-09-08 13:40:35
|
Commit: 189ab46 GitHub URL: https://github.com/SCST-project/scst/commit/189ab46a97bcb67bac1d474031eb2e71cc62b114 Author: Tony Battersby Date: 2025-09-08T16:40:12+03:00 Log Message: ----------- scst: Fix garbage in trace_level files 'hd /sys/kernel/scst_tgt/trace_level' shows a series of extraneous nul chars at the end of the first line. Fixes: 9cbca538303f ("scst: Replace sprintf() with scnprintf() in sysfs callbacks") Signed-off-by: Tony Battersby <to...@cy...> Modified Paths: -------------- scst/src/scst_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) =================================================================== diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 66c9414..340e735 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -156,8 +156,8 @@ static ssize_t scst_trace_level_show(const struct scst_trace_log *local_tbl, { ssize_t ret = 0; - ret += scst_read_trace_tbl(scst_trace_tbl, buf, log_level, ret); - ret += scst_read_trace_tbl(local_tbl, buf, log_level, ret); + ret = scst_read_trace_tbl(scst_trace_tbl, buf, log_level, ret); + ret = scst_read_trace_tbl(local_tbl, buf, log_level, ret); ret += sysfs_emit_at(buf, ret, "\n\n\nUsage:\n" |
From: GitHub <lna...@ya...> - 2025-09-08 12:30:42
|
Commit: 1b78d50 GitHub URL: https://github.com/SCST-project/scst/commit/1b78d5076dad3290a93c08ccdb07a431c31b6c77 Author: dkambleNetapp Date: 2025-09-08T15:30:18+03:00 Log Message: ----------- INSTALL.md: Add 'which' as build dependency Update INSTALL.md to list 'which' as a required dependency. Without it, scst init script fails with: /etc/init.d/scst: line 149: which: command not found as seen in systemd logs: mp-scst-service scst[1198]: /etc/init.d/scst: line 149: which: command not found mp-scst-service systemd[1]: mp-scst.service: Control process exited, code=exited, status=1/FAILURE Stemming from the line: https://github.com/SCST-project/scst/blob/v3.9/scstadmin/init.d/scst#L162 Modified Paths: -------------- INSTALL.md | 1 + 1 file changed, 1 insertion(+) =================================================================== diff --git a/INSTALL.md b/INSTALL.md index 80c3472..7c4451d 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -4,6 +4,7 @@ If the following packages have not yet been installed, install these now: + which bzip2 gcc kernel-devel or kernel-default-devel |
From: Gleb C. <lna...@ya...> - 2025-08-18 10:24:00
|
Commit: 1ba89c3 GitHub URL: https://github.com/SCST-project/scst/commit/1ba89c391e032aba5d4be3842a1682ed897b921a Author: Gleb Chesnokov Date: 2025-08-18T13:23:30+03:00 Log Message: ----------- iscsi-scst: Accept CRC32 or LIBCRC32C for crc32c() across kernels Kernel v6.15+ removed LIBCRC32C and switched in-tree users to CRC32. Keep older kernels working by accepting either CRC32 or LIBCRC32C in Kconfig and preprocessor guards, so crc32c() usage compiles and links on both old and new kernels. Modified Paths: -------------- iscsi-scst/kernel/Kconfig | 2 +- iscsi-scst/kernel/digest.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) =================================================================== diff --git a/iscsi-scst/kernel/Kconfig b/iscsi-scst/kernel/Kconfig index c7651bc..4c6939d 100644 --- a/iscsi-scst/kernel/Kconfig +++ b/iscsi-scst/kernel/Kconfig @@ -1,6 +1,6 @@ config SCST_ISCSI tristate "ISCSI Target" - depends on SCST && INET && LIBCRC32C + depends on SCST && INET && (LIBCRC32C || CRC32) default SCST help ISCSI target driver for SCST. The iSCSI protocol has been defined in diff --git a/iscsi-scst/kernel/digest.c b/iscsi-scst/kernel/digest.c index 37796b5..5776051 100644 --- a/iscsi-scst/kernel/digest.c +++ b/iscsi-scst/kernel/digest.c @@ -26,7 +26,8 @@ void digest_alg_available(int *val) { -#if defined(CONFIG_LIBCRC32C_MODULE) || defined(CONFIG_LIBCRC32C) +#if defined(CONFIG_LIBCRC32C_MODULE) || defined(CONFIG_LIBCRC32C) || \ + defined(CONFIG_CRC32_MODULE) || defined(CONFIG_CRC32) int crc32c = 1; #else int crc32c = 0; @@ -34,7 +35,7 @@ void digest_alg_available(int *val) if ((*val & DIGEST_CRC32C) && !crc32c) { PRINT_ERROR("CRC32C digest algorithm not available in kernel"); - *val |= ~DIGEST_CRC32C; + *val &= ~DIGEST_CRC32C; } } @@ -65,7 +66,8 @@ static __be32 evaluate_crc32_from_sg(struct scatterlist *sg, int nbytes, uint32_ } #endif -#if defined(CONFIG_LIBCRC32C_MODULE) || defined(CONFIG_LIBCRC32C) +#if defined(CONFIG_LIBCRC32C_MODULE) || defined(CONFIG_LIBCRC32C) || \ + defined(CONFIG_CRC32_MODULE) || defined(CONFIG_CRC32) { int pad_bytes = ((nbytes + 3) & -4) - nbytes; |
From: Gleb C. <lna...@ya...> - 2025-08-18 08:47:54
|
Commit: 314659e GitHub URL: https://github.com/SCST-project/scst/commit/314659ed7c7b6ca3bad2f92d2cbddd4e452ddbf1 Author: Gleb Chesnokov Date: 2025-08-18T11:45:57+03:00 Log Message: ----------- scstadmin: Normalize SCST version parsing in SCST.pm scstadmin's version check assumed scstVersion() returns a bare "X.Y.Z". After changing the sysfs attribute it may return strings like "SCST version: 3.10.0-pre", which triggered a numeric warning and a false failure: Argument "SCST version: 3" isn't numeric in numeric gt (...) Parse the version number from the raw string and ignore any prefix/suffix. If no version can be parsed, keep the existing failure path. Fixes: https://github.com/SCST-project/scst/issues/296 Modified Paths: -------------- scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) =================================================================== diff --git a/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm index c8d3b20..0f5f9c8 100644 --- a/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm @@ -333,12 +333,16 @@ sub new { $self->{'debug'} = $debug; - my $scstVersion = $self->scstVersion(); + my $rawVersion = $self->scstVersion(); die("Failed to obtain SCST version information. Are the SCST modules loaded?\n") + if (!defined($rawVersion)); + + my ($scstVersion) = ($rawVersion =~ /(\d+\.\d+\.\d+)/); + + die("Failed to parse SCST version from '$rawVersion'\n") if (!defined($scstVersion)); - ($scstVersion, undef) = split(/\-/, $scstVersion); my($major, $minor, $release) = split(/\./, $scstVersion, 3); ($release, undef) = split(/\-/, $release) if ($release =~ /\-/); |
From: Gleb C. <lna...@ya...> - 2025-08-05 15:23:33
|
Commit: d0b970f GitHub URL: https://github.com/SCST-project/scst/commit/d0b970fad01e2869ed3fa05e5803fcdfa0e20636 Author: Gleb Chesnokov Date: 2025-08-05T18:15:49+03:00 Log Message: ----------- qla2x00t-32gbit: Fix DMA mapping test in qla24xx_get_port_database() dma_map_XXX() functions return as error values DMA_MAPPING_ERROR which is often ~0. The error value should be tested with dma_mapping_error() like it was done in qla26xx_dport_diagnostics(). Fixes: 818c7f87a177 ("scsi: qla2xxx: Add changes in preparation for vendor extended FDMI/RDP") Signed-off-by: Thomas Fourier <fou...@gm...> Link: https://lore.kernel.org/r/202...@gm... Signed-off-by: Martin K. Petersen <mar...@or...> [ commit c3b214719a87 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_mbx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_mbx.c b/qla2x00t-32gbit/qla_mbx.c index 0cd6f3e..13b6cb1 100644 --- a/qla2x00t-32gbit/qla_mbx.c +++ b/qla2x00t-32gbit/qla_mbx.c @@ -2147,7 +2147,7 @@ qla24xx_get_port_database(scsi_qla_host_t *vha, u16 nport_handle, pdb_dma = dma_map_single(&vha->hw->pdev->dev, pdb, sizeof(*pdb), DMA_FROM_DEVICE); - if (!pdb_dma) { + if (dma_mapping_error(&vha->hw->pdev->dev, pdb_dma)) { ql_log(ql_log_warn, vha, 0x1116, "Failed to map dma buffer.\n"); return QLA_MEMORY_ALLOC_FAILED; } |
From: Gleb C. <lna...@ya...> - 2025-08-05 15:23:11
|
Commit: 06f8d87 GitHub URL: https://github.com/SCST-project/scst/commit/06f8d870a3f4ae9bac8940024151fc530ec10bb0 Author: Gleb Chesnokov Date: 2025-08-05T18:15:49+03:00 Log Message: ----------- qla2x00t-32gbit: Remove duplicate struct crb_addr_pair In preparation for making the kmalloc family of allocators type aware, we need to make sure that the returned type from the allocation matches the type of the variable being assigned. (Before, the allocator would always return "void *", which can be implicitly cast to any pointer type.) The assigned type is "struct crb_addr_pair *" and the returned type will be a _different_ "struct crb_addr_pair *", causing a warning. This really stumped me for a bit. :) Drop the redundant declaration. Signed-off-by: Kees Cook <ke...@ke...> Link: https://lore.kernel.org/r/202...@ke... Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 386e014202f8 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_nx.c | 5 ----- 1 file changed, 5 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_nx.c b/qla2x00t-32gbit/qla_nx.c index 6d24083..bb7ec6e 100644 --- a/qla2x00t-32gbit/qla_nx.c +++ b/qla2x00t-32gbit/qla_nx.c @@ -1106,11 +1106,6 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha) unsigned offset, n; struct qla_hw_data *ha = vha->hw; - struct crb_addr_pair { - long addr; - long data; - }; - /* Halt all the individual PEGs and other blocks of the ISP */ qla82xx_rom_lock(ha); |
From: Gleb C. <lna...@ya...> - 2025-08-05 15:23:01
|
Commit: 5e3c7ea GitHub URL: https://github.com/SCST-project/scst/commit/5e3c7eaf272262c36640db0e8602d09a71e2125c Author: Gleb Chesnokov Date: 2025-08-05T18:15:49+03:00 Log Message: ----------- qla2x00t-32gbit: Remove unused module parameters ql2xetsenable last use was removed in 2020 by commit 37efd51f75f3 ("scsi: qla2xxx: Use FC generic update firmware options routine for ISP27xx") ql2xiidmaenable last use was removed in 2017 by commit 726b85487067 ("qla2xxx: Add framework for async fabric discovery") Remove them. Signed-off-by: Dr. David Alan Gilbert <li...@tr...> Link: https://lore.kernel.org/r/202...@tr... Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 3a37ab0827fd upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_gbl.h | 2 -- qla2x00t-32gbit/qla_os.c | 12 ------------ 2 files changed, 14 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_gbl.h b/qla2x00t-32gbit/qla_gbl.h index 0d2d692..5cf5608 100644 --- a/qla2x00t-32gbit/qla_gbl.h +++ b/qla2x00t-32gbit/qla_gbl.h @@ -166,10 +166,8 @@ extern int ql2xextended_error_logging; #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 5, 0) extern int ql2xextended_error_logging_ktrace; #endif -extern int ql2xiidmaenable; extern int ql2xmqsupport; extern int ql2xfwloadbin; -extern int ql2xetsenable; extern int ql2xshiftctondsd; extern int ql2xdbwr; extern int ql2xasynctmfenable; diff --git a/qla2x00t-32gbit/qla_os.c b/qla2x00t-32gbit/qla_os.c index a258000..56764e9 100644 --- a/qla2x00t-32gbit/qla_os.c +++ b/qla2x00t-32gbit/qla_os.c @@ -196,12 +196,6 @@ MODULE_PARM_DESC(ql2xenablehba_err_chk, " 1 -- Error isolation enabled only for DIX Type 0\n" " 2 -- Error isolation enabled for all Types\n"); -int ql2xiidmaenable = 1; -module_param(ql2xiidmaenable, int, S_IRUGO); -MODULE_PARM_DESC(ql2xiidmaenable, - "Enables iIDMA settings " - "Default is 1 - perform iIDMA. 0 - no iIDMA."); - int ql2xmqsupport = 1; module_param(ql2xmqsupport, int, S_IRUGO); MODULE_PARM_DESC(ql2xmqsupport, @@ -219,12 +213,6 @@ MODULE_PARM_DESC(ql2xfwloadbin, " 1 -- load firmware from flash.\n" " 0 -- use default semantics.\n"); -int ql2xetsenable; -module_param(ql2xetsenable, int, S_IRUGO); -MODULE_PARM_DESC(ql2xetsenable, - "Enables firmware ETS burst." - "Default is 0 - skip ETS enablement."); - int ql2xdbwr = 1; module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(ql2xdbwr, |
From: Gleb C. <lna...@ya...> - 2025-08-05 15:22:48
|
Commit: 61d96b8 GitHub URL: https://github.com/SCST-project/scst/commit/61d96b8b9363765dbdcf7e007cef10aca874fa53 Author: Gleb Chesnokov Date: 2025-08-05T18:15:49+03:00 Log Message: ----------- qla2x00t-32gbit: Remove unused qla2x00_gpsc() qla2x00_gpsc() was added in 2017 as part of commit 726b85487067 ("qla2xxx: Add framework for async fabric discovery") but has remained unused. Remove it. Signed-off-by: Dr. David Alan Gilbert <li...@tr...> Link: https://lore.kernel.org/r/202...@tr... Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 45838d3db750 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_gbl.h | 1 - qla2x00t-32gbit/qla_gs.c | 90 --------------- 2 files changed, 91 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_gbl.h b/qla2x00t-32gbit/qla_gbl.h index cc37d7b..0d2d692 100644 --- a/qla2x00t-32gbit/qla_gbl.h +++ b/qla2x00t-32gbit/qla_gbl.h @@ -729,7 +729,6 @@ extern void *qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *, uint32_t, uint32_t); extern void *qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *, uint32_t, uint32_t); extern int qla2x00_fdmi_register(scsi_qla_host_t *); extern int qla2x00_gfpn_id(scsi_qla_host_t *, sw_info_t *); -extern int qla2x00_gpsc(scsi_qla_host_t *, sw_info_t *); extern size_t qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *, size_t); extern int qla2x00_chk_ms_status(scsi_qla_host_t *, ms_iocb_entry_t *, struct ct_sns_rsp *, const char *); diff --git a/qla2x00t-32gbit/qla_gs.c b/qla2x00t-32gbit/qla_gs.c index d2bddca..51c7cea 100644 --- a/qla2x00t-32gbit/qla_gs.c +++ b/qla2x00t-32gbit/qla_gs.c @@ -2625,96 +2625,6 @@ qla2x00_port_speed_capability(uint16_t speed) } } -/** - * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query. - * @vha: HA context - * @list: switch info entries to populate - * - * Returns 0 on success. - */ -int -qla2x00_gpsc(scsi_qla_host_t *vha, sw_info_t *list) -{ - int rval; - uint16_t i; - struct qla_hw_data *ha = vha->hw; - ms_iocb_entry_t *ms_pkt; - struct ct_sns_req *ct_req; - struct ct_sns_rsp *ct_rsp; - struct ct_arg arg; - - if (!IS_IIDMA_CAPABLE(ha)) - return QLA_FUNCTION_FAILED; - if (!ha->flags.gpsc_supported) - return QLA_FUNCTION_FAILED; - - rval = qla2x00_mgmt_svr_login(vha); - if (rval) - return rval; - - arg.iocb = ha->ms_iocb; - arg.req_dma = ha->ct_sns_dma; - arg.rsp_dma = ha->ct_sns_dma; - arg.req_size = GPSC_REQ_SIZE; - arg.rsp_size = GPSC_RSP_SIZE; - arg.nport_handle = vha->mgmt_svr_loop_id; - - for (i = 0; i < ha->max_fibre_devices; i++) { - /* Issue GFPN_ID */ - /* Prepare common MS IOCB */ - ms_pkt = qla24xx_prep_ms_iocb(vha, &arg); - - /* Prepare CT request */ - ct_req = qla24xx_prep_ct_fm_req(ha->ct_sns, GPSC_CMD, - GPSC_RSP_SIZE); - ct_rsp = &ha->ct_sns->p.rsp; - - /* Prepare CT arguments -- port_name */ - memcpy(ct_req->req.gpsc.port_name, list[i].fabric_port_name, - WWN_SIZE); - - /* Execute MS IOCB */ - rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, - sizeof(ms_iocb_entry_t)); - if (rval != QLA_SUCCESS) { - /*EMPTY*/ - ql_dbg(ql_dbg_disc, vha, 0x2059, - "GPSC issue IOCB failed (%d).\n", rval); - } else if ((rval = qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, - "GPSC")) != QLA_SUCCESS) { - /* FM command unsupported? */ - if (rval == QLA_INVALID_COMMAND && - (ct_rsp->header.reason_code == - CT_REASON_INVALID_COMMAND_CODE || - ct_rsp->header.reason_code == - CT_REASON_COMMAND_UNSUPPORTED)) { - ql_dbg(ql_dbg_disc, vha, 0x205a, - "GPSC command unsupported, disabling " - "query.\n"); - ha->flags.gpsc_supported = 0; - rval = QLA_FUNCTION_FAILED; - break; - } - rval = QLA_FUNCTION_FAILED; - } else { - list->fp_speed = qla2x00_port_speed_capability( - be16_to_cpu(ct_rsp->rsp.gpsc.speed)); - ql_dbg(ql_dbg_disc, vha, 0x205b, - "GPSC ext entry - fpn " - "%8phN speeds=%04x speed=%04x.\n", - list[i].fabric_port_name, - be16_to_cpu(ct_rsp->rsp.gpsc.speeds), - be16_to_cpu(ct_rsp->rsp.gpsc.speed)); - } - - /* Last device exit. */ - if (list[i].d_id.b.rsvd_1 != 0) - break; - } - - return (rval); -} - /** * qla2x00_gff_id() - SNS Get FC-4 Features (GFF_ID) query. * |
From: Gleb C. <lna...@ya...> - 2025-08-05 15:22:44
|
Commit: 07f82d9 GitHub URL: https://github.com/SCST-project/scst/commit/07f82d9505804eb2abed48de8013cb0f347f280d Author: Gleb Chesnokov Date: 2025-08-05T18:15:49+03:00 Log Message: ----------- qla2x00t-32gbit: Remove unused ql_log_qp ql_log_qp() was added in 2017 as part of commit 22d84726e3b8 ("scsi: qla2xxx: Add debug logging routine for qpair") but has remained unused. Remove it. (That patch also added ql_dbg_qp but that is still used so is left in). Signed-off-by: Dr. David Alan Gilbert <li...@tr...> Link: https://lore.kernel.org/r/202...@tr... Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 33f44a50ca61 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_dbg.c | 58 --------------- qla2x00t-32gbit/qla_dbg.h | 3 - 2 files changed, 61 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_dbg.c b/qla2x00t-32gbit/qla_dbg.c index 9de6e3a..fb3a8ba 100644 --- a/qla2x00t-32gbit/qla_dbg.c +++ b/qla2x00t-32gbit/qla_dbg.c @@ -2735,64 +2735,6 @@ ql_dump_buffer(uint level, scsi_qla_host_t *vha, uint id, const void *buf, } } -/* - * This function is for formatting and logging log messages. - * It is to be used when vha is available. It formats the message - * and logs it to the messages file. All the messages will be logged - * irrespective of value of ql2xextended_error_logging. - * parameters: - * level: The level of the log messages to be printed in the - * messages file. - * vha: Pointer to the scsi_qla_host_t - * id: This is a unique id for the level. It identifies the - * part of the code from where the message originated. - * msg: The message to be displayed. - */ -void -ql_log_qp(uint32_t level, struct qla_qpair *qpair, int32_t id, - const char *fmt, ...) -{ - va_list va; - struct va_format vaf; - char pbuf[128]; - - if (level > ql_errlev) - return; - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 5, 0) - ql_ktrace(0, level, pbuf, NULL, qpair ? qpair->vha : NULL, id, fmt); - - if (!pbuf[0]) /* set by ql_ktrace */ - ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, - qpair ? qpair->vha : NULL, id); -#else - ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, qpair ? qpair->vha : NULL, id); - -#endif - - va_start(va, fmt); - - vaf.fmt = fmt; - vaf.va = &va; - - switch (level) { - case ql_log_fatal: /* FATAL LOG */ - pr_crit("%s%pV", pbuf, &vaf); - break; - case ql_log_warn: - pr_err("%s%pV", pbuf, &vaf); - break; - case ql_log_info: - pr_warn("%s%pV", pbuf, &vaf); - break; - default: - pr_info("%s%pV", pbuf, &vaf); - break; - } - - va_end(va); -} - /* * This function is for formatting and logging debug information. * It is to be used when vha is available. It formats the message diff --git a/qla2x00t-32gbit/qla_dbg.h b/qla2x00t-32gbit/qla_dbg.h index ecdc747..121a035 100644 --- a/qla2x00t-32gbit/qla_dbg.h +++ b/qla2x00t-32gbit/qla_dbg.h @@ -334,9 +334,6 @@ ql_log(uint, scsi_qla_host_t *vha, uint, const char *fmt, ...); void __attribute__((format (printf, 4, 5))) ql_log_pci(uint, struct pci_dev *pdev, uint, const char *fmt, ...); -void __attribute__((format (printf, 4, 5))) -ql_log_qp(uint32_t, struct qla_qpair *, int32_t, const char *fmt, ...); - /* Debug Levels */ /* The 0x40000000 is the max value any debug level can have * as ql2xextended_error_logging is of type signed int |
From: Gleb C. <lna...@ya...> - 2025-08-05 15:19:50
|
Commit: 4db857c GitHub URL: https://github.com/SCST-project/scst/commit/4db857c08195ab1f0c557092544b17182c914804 Author: Gleb Chesnokov Date: 2025-08-05T18:15:49+03:00 Log Message: ----------- qla2x00t-32gbit: Remove unused qla82xx_wait_for_state_change() qla82xx_wait_for_state_change() was added in 2010 as part of commit 579d12b58abb ("[SCSI] qla2xxx: Added support for quiescence mode for ISP82xx.") but has remained unused. Remove it. Signed-off-by: Dr. David Alan Gilbert <li...@tr...> Link: https://lore.kernel.org/r/202...@tr... Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 2a2f3168c510 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_gbl.h | 1 - qla2x00t-32gbit/qla_nx.c | 26 --------------- 2 files changed, 27 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_gbl.h b/qla2x00t-32gbit/qla_gbl.h index c332c50..cc37d7b 100644 --- a/qla2x00t-32gbit/qla_gbl.h +++ b/qla2x00t-32gbit/qla_gbl.h @@ -881,7 +881,6 @@ extern int qla82xx_rd_32(struct qla_hw_data *, ulong); /* ISP 8021 IDC */ extern void qla82xx_clear_drv_active(struct qla_hw_data *); -extern uint32_t qla82xx_wait_for_state_change(scsi_qla_host_t *, uint32_t); extern int qla82xx_idc_lock(struct qla_hw_data *); extern void qla82xx_idc_unlock(struct qla_hw_data *); extern int qla82xx_device_state_handler(scsi_qla_host_t *); diff --git a/qla2x00t-32gbit/qla_nx.c b/qla2x00t-32gbit/qla_nx.c index 51208bf..6d24083 100644 --- a/qla2x00t-32gbit/qla_nx.c +++ b/qla2x00t-32gbit/qla_nx.c @@ -2922,32 +2922,6 @@ qla82xx_need_qsnt_handler(scsi_qla_host_t *vha) } } -/* -* qla82xx_wait_for_state_change -* Wait for device state to change from given current state -* -* Note: -* IDC lock must not be held upon entry -* -* Return: -* Changed device state. -*/ -uint32_t -qla82xx_wait_for_state_change(scsi_qla_host_t *vha, uint32_t curr_state) -{ - struct qla_hw_data *ha = vha->hw; - uint32_t dev_state; - - do { - msleep(1000); - qla82xx_idc_lock(ha); - dev_state = qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE); - qla82xx_idc_unlock(ha); - } while (dev_state == curr_state); - - return dev_state; -} - void qla8xxx_dev_failed_handler(scsi_qla_host_t *vha) { |
From: Gleb C. <lna...@ya...> - 2025-08-05 15:19:31
|
Commit: 42bb0fb GitHub URL: https://github.com/SCST-project/scst/commit/42bb0fb1de19f750df37008c43a81e7ba9437601 Author: Gleb Chesnokov Date: 2025-08-05T18:15:49+03:00 Log Message: ----------- qla2x00t-32gbit: Remove unused qla82xx_pci_region_offset() qla82xx_pci_region_offset() has been unused since the last use was removed by 2010's commit 3711333dfbee ("[SCSI] qla2xxx: Updates for ISP82xx.") Remove it. Signed-off-by: Dr. David Alan Gilbert <li...@tr...> Link: https://lore.kernel.org/r/202...@tr... Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 89981b47f6fc upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_gbl.h | 1 - qla2x00t-32gbit/qla_nx.c | 19 --------------- 2 files changed, 20 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_gbl.h b/qla2x00t-32gbit/qla_gbl.h index e95ad2c..c332c50 100644 --- a/qla2x00t-32gbit/qla_gbl.h +++ b/qla2x00t-32gbit/qla_gbl.h @@ -838,7 +838,6 @@ extern int qlafx00_rescan_isp(scsi_qla_host_t *); /* PCI related functions */ extern int qla82xx_pci_config(struct scsi_qla_host *); extern int qla82xx_pci_mem_read_2M(struct qla_hw_data *, u64, void *, int); -extern int qla82xx_pci_region_offset(struct pci_dev *, int); extern int qla82xx_iospace_config(struct qla_hw_data *); /* Initialization related functions */ diff --git a/qla2x00t-32gbit/qla_nx.c b/qla2x00t-32gbit/qla_nx.c index a6f7d3e..51208bf 100644 --- a/qla2x00t-32gbit/qla_nx.c +++ b/qla2x00t-32gbit/qla_nx.c @@ -1602,25 +1602,6 @@ qla82xx_get_fw_offs(struct qla_hw_data *ha) return (u8 *)&ha->hablob->fw->data[offset]; } -/* PCI related functions */ -int qla82xx_pci_region_offset(struct pci_dev *pdev, int region) -{ - unsigned long val = 0; - u32 control; - - switch (region) { - case 0: - val = 0; - break; - case 1: - pci_read_config_dword(pdev, QLA82XX_PCI_REG_MSIX_TBL, &control); - val = control + QLA82XX_MSIX_TBL_SPACE; - break; - } - return val; -} - - int qla82xx_iospace_config(struct qla_hw_data *ha) { |
From: Gleb C. <lna...@ya...> - 2025-08-05 15:19:21
|
Commit: 3b945f8 GitHub URL: https://github.com/SCST-project/scst/commit/3b945f84be185671bb8b292f2008b428c06582d7 Author: Gleb Chesnokov Date: 2025-08-05T18:15:49+03:00 Log Message: ----------- qla2x00t-32gbit: Remove unused qlt_83xx_iospace_config() qlt_83xx_iospace_config() has been unused since the last use was removed by 2017's commit f54f2cb540b5 ("scsi: qla2xxx: Cleaned up queue configuration code.") Remove it. Signed-off-by: Dr. David Alan Gilbert <li...@tr...> Link: https://lore.kernel.org/r/202...@tr... Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 91453ebecccc upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_target.c | 10 ---------- qla2x00t-32gbit/qla_target.h | 1 - 2 files changed, 11 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_target.c b/qla2x00t-32gbit/qla_target.c index eec2020..f8d641d 100644 --- a/qla2x00t-32gbit/qla_target.c +++ b/qla2x00t-32gbit/qla_target.c @@ -7041,16 +7041,6 @@ qlt_81xx_config_nvram_stage2(struct scsi_qla_host *vha, } } -void -qlt_83xx_iospace_config(struct qla_hw_data *ha) -{ - if (!QLA_TGT_MODE_ENABLED()) - return; - - ha->msix_count += 1; /* For ATIO Q */ -} - - void qlt_modify_vp_config(struct scsi_qla_host *vha, struct vp_config_entry_24xx *vpmod) diff --git a/qla2x00t-32gbit/qla_target.h b/qla2x00t-32gbit/qla_target.h index 1e405c0..af0f4a4 100644 --- a/qla2x00t-32gbit/qla_target.h +++ b/qla2x00t-32gbit/qla_target.h @@ -1124,7 +1124,6 @@ extern void qlt_mem_free(struct qla_hw_data *); extern int qlt_stop_phase1(struct qla_tgt *); extern void qlt_stop_phase2(struct qla_tgt *); extern irqreturn_t qla83xx_msix_atio_q(int, void *); -extern void qlt_83xx_iospace_config(struct qla_hw_data *); extern void qlt_logo_completion_handler(fc_port_t *, int); extern void qlt_do_generation_tick(struct scsi_qla_host *, int *); |
From: Gleb C. <lna...@ya...> - 2025-08-05 15:19:06
|
Commit: 0d2807e GitHub URL: https://github.com/SCST-project/scst/commit/0d2807eff36edf011eb995132c92ac83c84ad493 Author: Gleb Chesnokov Date: 2025-08-05T18:15:49+03:00 Log Message: ----------- qla2x00t-32gbit: Remove unused qlt_fc_port_deleted() qlt_fc_port_deleted() has been unused since the last use was removed by 2017's commit 726b85487067 ("qla2xxx: Add framework for async fabric discovery") Remove it. Signed-off-by: Dr. David Alan Gilbert <li...@tr...> Link: https://lore.kernel.org/r/202...@tr... Signed-off-by: Martin K. Petersen <mar...@or...> [ commit cbb2a2ef5801 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_target.c | 44 --------------- qla2x00t-32gbit/qla_target.h | 1 - 2 files changed, 45 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_target.c b/qla2x00t-32gbit/qla_target.c index 59a23e4..eec2020 100644 --- a/qla2x00t-32gbit/qla_target.c +++ b/qla2x00t-32gbit/qla_target.c @@ -1471,50 +1471,6 @@ static struct fc_port *qlt_create_sess( return sess; } -/* - * max_gen - specifies maximum session generation - * at which this deletion requestion is still valid - */ -void -qlt_fc_port_deleted(struct scsi_qla_host *vha, fc_port_t *fcport, int max_gen) -{ - struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; - struct fc_port *sess = fcport; - unsigned long flags; - - if (!vha->hw->tgt.tgt_ops) - return; - - if (!tgt) - return; - - spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); - if (tgt->tgt_stop) { - spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); - return; - } - if (!sess->se_sess) { - spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); - return; - } - - if (max_gen - sess->generation < 0) { - spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf092, - "Ignoring stale deletion request for se_sess %p / sess %p" - " for port %8phC, req_gen %d, sess_gen %d\n", - sess->se_sess, sess, sess->port_name, max_gen, - sess->generation); - return; - } - - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf008, "qla_tgt_fc_port_deleted %p", sess); - - sess->local = 1; - spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); - qlt_schedule_sess_for_deletion(sess); -} - static inline int test_tgt_sess_count(struct qla_tgt *tgt) { struct qla_hw_data *ha = tgt->ha; diff --git a/qla2x00t-32gbit/qla_target.h b/qla2x00t-32gbit/qla_target.h index 012dcd1..1e405c0 100644 --- a/qla2x00t-32gbit/qla_target.h +++ b/qla2x00t-32gbit/qla_target.h @@ -1057,7 +1057,6 @@ extern int qlt_lport_register(void *, u64, u64, u64, extern void qlt_lport_deregister(struct scsi_qla_host *); extern void qlt_unreg_sess(struct fc_port *); extern void qlt_fc_port_added(struct scsi_qla_host *, fc_port_t *); -extern void qlt_fc_port_deleted(struct scsi_qla_host *, fc_port_t *, int); extern int __init qlt_init(void); extern void qlt_exit(void); extern void qlt_free_session_done(struct work_struct *); |
From: Gleb C. <lna...@ya...> - 2025-08-05 15:18:46
|
Commit: 4bad58a GitHub URL: https://github.com/SCST-project/scst/commit/4bad58a3d3c93686c6dce1152e70982383d31087 Author: Gleb Chesnokov Date: 2025-08-05T18:15:49+03:00 Log Message: ----------- qla2x00t-32gbit: Remove unused qlt_free_qfull_cmds() qlt_free_qfull_cmds() was added in 2014 as part of commit 33e799775593 ("qla2xxx: Add support for QFull throttling and Term Exchange retry") but has remained unused. Remove it. Signed-off-by: Dr. David Alan Gilbert <li...@tr...> Link: https://lore.kernel.org/r/202...@tr... Signed-off-by: Martin K. Petersen <mar...@or...> [ commit ae7a08bee82b upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_target.c | 75 --------------- qla2x00t-32gbit/qla_target.h | 1 - 2 files changed, 76 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_target.c b/qla2x00t-32gbit/qla_target.c index 0b938a8..59a23e4 100644 --- a/qla2x00t-32gbit/qla_target.c +++ b/qla2x00t-32gbit/qla_target.c @@ -5609,81 +5609,6 @@ qlt_alloc_qfull_cmd(struct scsi_qla_host *vha, spin_unlock_irqrestore(&vha->hw->tgt.q_full_lock, flags); } -int -qlt_free_qfull_cmds(struct qla_qpair *qpair) -{ - struct scsi_qla_host *vha = qpair->vha; - struct qla_hw_data *ha = vha->hw; - unsigned long flags; - struct qla_tgt_cmd *cmd, *tcmd; - struct list_head free_list, q_full_list; - int rc = 0; - - if (list_empty(&ha->tgt.q_full_list)) - return 0; - - INIT_LIST_HEAD(&free_list); - INIT_LIST_HEAD(&q_full_list); - - spin_lock_irqsave(&vha->hw->tgt.q_full_lock, flags); - if (list_empty(&ha->tgt.q_full_list)) { - spin_unlock_irqrestore(&vha->hw->tgt.q_full_lock, flags); - return 0; - } - - list_splice_init(&vha->hw->tgt.q_full_list, &q_full_list); - spin_unlock_irqrestore(&vha->hw->tgt.q_full_lock, flags); - - spin_lock_irqsave(qpair->qp_lock_ptr, flags); - list_for_each_entry_safe(cmd, tcmd, &q_full_list, cmd_list) { - if (cmd->q_full) - /* cmd->state is a borrowed field to hold status */ - rc = __qlt_send_busy(qpair, &cmd->atio, cmd->state); - else if (cmd->term_exchg) - rc = __qlt_send_term_exchange(qpair, NULL, &cmd->atio); - - if (rc == -ENOMEM) - break; - - if (cmd->q_full) - ql_dbg(ql_dbg_io, vha, 0x3006, - "%s: busy sent for ox_id[%04x]\n", __func__, - be16_to_cpu(cmd->atio.u.isp24.fcp_hdr.ox_id)); - else if (cmd->term_exchg) - ql_dbg(ql_dbg_io, vha, 0x3007, - "%s: Term exchg sent for ox_id[%04x]\n", __func__, - be16_to_cpu(cmd->atio.u.isp24.fcp_hdr.ox_id)); - else - ql_dbg(ql_dbg_io, vha, 0x3008, - "%s: Unexpected cmd in QFull list %p\n", __func__, - cmd); - - list_move_tail(&cmd->cmd_list, &free_list); - - /* piggy back on hardware_lock for protection */ - vha->hw->tgt.num_qfull_cmds_alloc--; - } - spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); - - cmd = NULL; - - list_for_each_entry_safe(cmd, tcmd, &free_list, cmd_list) { - list_del(&cmd->cmd_list); - /* This cmd was never sent to TCM. There is no need - * to schedule free or call free_cmd - */ - qlt_free_cmd(cmd); - } - - if (!list_empty(&q_full_list)) { - spin_lock_irqsave(&vha->hw->tgt.q_full_lock, flags); - list_splice(&q_full_list, &vha->hw->tgt.q_full_list); - spin_unlock_irqrestore(&vha->hw->tgt.q_full_lock, flags); - } - - return rc; -} - static void qlt_send_busy(struct qla_qpair *qpair, struct atio_from_isp *atio, uint16_t status) diff --git a/qla2x00t-32gbit/qla_target.h b/qla2x00t-32gbit/qla_target.h index 300501d..012dcd1 100644 --- a/qla2x00t-32gbit/qla_target.h +++ b/qla2x00t-32gbit/qla_target.h @@ -1126,7 +1126,6 @@ extern int qlt_stop_phase1(struct qla_tgt *); extern void qlt_stop_phase2(struct qla_tgt *); extern irqreturn_t qla83xx_msix_atio_q(int, void *); extern void qlt_83xx_iospace_config(struct qla_hw_data *); -extern int qlt_free_qfull_cmds(struct qla_qpair *); extern void qlt_logo_completion_handler(fc_port_t *, int); extern void qlt_do_generation_tick(struct scsi_qla_host *, int *); |
From: Gleb C. <lna...@ya...> - 2025-08-05 14:44:06
|
Commit: 1186ac2 GitHub URL: https://github.com/SCST-project/scst/commit/1186ac25c580c328f9f4ce5bfae8354c88cb3f30 Author: Gleb Chesnokov Date: 2025-08-05T17:41:32+03:00 Log Message: ----------- nightly build: Update kernel versions Another kernel versions update Modified Paths: -------------- .github/workflows/run_regression_tests.yaml | 27 ++++++++------- nightly/conf/nightly.conf | 27 ++++++++------- 2 files changed, 28 insertions(+), 26 deletions(-) =================================================================== diff --git a/.github/workflows/run_regression_tests.yaml b/.github/workflows/run_regression_tests.yaml index 65e4d77..5a7cfbf 100644 --- a/.github/workflows/run_regression_tests.yaml +++ b/.github/workflows/run_regression_tests.yaml @@ -16,27 +16,28 @@ jobs: fail-fast: false matrix: version: [ - '6.15', - '6.14.8', + '6.16', + '6.15.9', + '6.14.11', '6.13.12', - '6.12.30', + '6.12.41', '6.11.11', '6.10.14', '6.9.12', '6.8.12', '6.7.12', - '6.6.92', - '6.1.140', - '5.15.184', - '5.10.237', - '5.4.293', + '6.6.101', + '6.1.146', + '5.15.189', + '5.10.240', + '5.4.296', '4.19.325', '4.14.336', '4.9.337', '3.18.140', '3.10.108', - '6.12.0-55.9.1.el10_0^AlmaLinux^10.0', - '5.14.0-570.12.1.el9_6^AlmaLinux^9.6', + '6.12.0-55.22.1.el10_0^AlmaLinux^10.0', + '5.14.0-570.30.1.el9_6^AlmaLinux^9.6', '5.14.0-503.40.1.el9_5^AlmaLinux^9.5', '5.14.0-427.42.1.el9_4^AlmaLinux^9.4', '5.14.0-362.24.1.el9_3^AlmaLinux^9.3', @@ -53,9 +54,9 @@ jobs: '4.18.0-240.22.1.el8_3^AlmaLinux^8.3', '3.10.0-1160.118.1.el7^CentOS^7.9.2009', '3.10.0-862.14.4.el7^CentOS^7.5.1804', - '6.12.0-0.20.20.el9uek^UEK^9', - '5.15.0-308.179.6.3.el9uek^UEK^9', - '5.4.17-2136.343.5.1.el8uek^UEK^8', + '6.12.0-101.33.4.3.el10uek^UEK^10', + '5.15.0-310.184.5.3.el9uek^UEK^9', + '5.4.17-2136.345.5.3.el8uek^UEK^8', '4.14.35-2047.543.3.1.el7uek^UEK^7', '4.1.12-124.93.1.el7uek^UEK^7', '4.1.12-124.48.6.el6uek^UEK^6' diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 8f1011f..ee93949 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -3,38 +3,39 @@ ABT_DETAILS="x86_64" ABT_JOBS=5 ABT_KERNELS=" \ -6.15 \ -6.14.8-nc \ +6.16 \ +6.15.9-nc \ +6.14.11-nc \ 6.13.12-nc \ -6.12.30-nc \ +6.12.41-nc \ 6.11.11-nc \ 6.10.14-nc \ 6.9.12-nc \ 6.8.12-nc \ 6.7.12-nc \ -6.6.92-nc \ +6.6.101-nc \ 6.5.13-nc \ 6.4.16-nc \ 6.3.13-nc \ 6.2.16-nc \ -6.1.140-nc \ +6.1.146-nc \ 6.0.19-nc \ 5.19.17-nc \ 5.18.19-nc \ 5.17.15-nc \ 5.16.20-nc \ -5.15.184-nc \ +5.15.189-nc \ 5.14.21-nc \ 5.13.19-nc \ 5.12.19-nc \ 5.11.22-nc \ -5.10.237-nc \ +5.10.240-nc \ 5.9.16-nc \ 5.8.18-nc \ 5.7.19-nc \ 5.6.19-nc \ 5.5.19-nc \ -5.4.293-nc \ +5.4.296-nc \ 5.3.18-nc \ 5.2.21-nc \ 5.1.21-nc \ @@ -70,8 +71,8 @@ ABT_KERNELS=" \ 3.12.74-nc \ 3.11.10-nc \ 3.10.108-nc \ -6.12.0-55.9.1.el10_0^AlmaLinux^10.0-nc \ -5.14.0-570.12.1.el9_6^AlmaLinux^9.6-nc \ +6.12.0-55.22.1.el10_0^AlmaLinux^10.0-nc \ +5.14.0-570.30.1.el9_6^AlmaLinux^9.6-nc \ 5.14.0-503.40.1.el9_5^AlmaLinux^9.5-nc \ 5.14.0-427.42.1.el9_4^AlmaLinux^9.4-nc \ 5.14.0-362.24.1.el9_3^AlmaLinux^9.3-nc \ @@ -94,9 +95,9 @@ ABT_KERNELS=" \ 3.10.0-1062.18.1.el7^CentOS^7.7.1908-nc \ 3.10.0-957.27.2.el7^CentOS^7.6.1810-nc \ 3.10.0-862.14.4.el7^CentOS^7.5.1804-nc \ -6.12.0-0.20.20.el9uek^UEK^9-nc \ -5.15.0-308.179.6.3.el9uek^UEK^9-nc \ -5.4.17-2136.343.5.1.el8uek^UEK^8-nc \ +6.12.0-101.33.4.3.el10uek^UEK^10-nc \ +5.15.0-310.184.5.3.el9uek^UEK^9-nc \ +5.4.17-2136.345.5.3.el8uek^UEK^8-nc \ 4.14.35-2047.543.3.1.el7uek^UEK^7-nc \ 4.1.12-124.93.1.el7uek^UEK^7-nc \ 4.1.12-124.48.6.el6uek^UEK^6-nc \ |
From: Gleb C. <lna...@ya...> - 2025-08-05 13:40:11
|
Commit: 2631557 GitHub URL: https://github.com/SCST-project/scst/commit/2631557383bc892fda0a8f1e87b389ecabfbb567 Author: Gleb Chesnokov Date: 2025-08-05T16:37:31+03:00 Log Message: ----------- scst.spec.in: Replace custom Requires line with package names The scst.spec.in file used a custom Requires line that dynamically resolved the full paths of the find and rm commands using shell substitution with 'which'. This method is non-standard and can lead to issues in constrained build environments. This patch replaces the custom Requires line with explicit package names: 'findutils' for find and 'coreutils' for rm. This improves compatibility and aligns with best practices for declaring dependencies in spec files. Modified Paths: -------------- scst.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) =================================================================== diff --git a/scst.spec.in b/scst.spec.in index 6998a20..e59ddce 100644 --- a/scst.spec.in +++ b/scst.spec.in @@ -90,7 +90,7 @@ BuildRequires: %{?kernel_rpm:%{kernel_rpm} = %{krpmver} %{kernel_devel_rpm} = %{ Source: %{kmod_name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-build AutoReqProv: no -Requires: %{?kernel_rpm:%{kernel_rpm} = %{krpmver}} @depmod@ %{expand:%%(for c in find rm; do echo -n "$(PATH=/usr/sbin:/usr/bin:/sbin:/bin which $c) "; done)} +Requires: %{?kernel_rpm:%{kernel_rpm} = %{krpmver}} @depmod@ coreutils findutils Provides: scst %description |
From: Gleb C. <lna...@ya...> - 2025-08-05 13:38:31
|
Commit: 974b31f GitHub URL: https://github.com/SCST-project/scst/commit/974b31fdcbc93cb47d2b3a686ad9212edd58ea02 Author: Gleb Chesnokov Date: 2025-08-05T16:37:31+03:00 Log Message: ----------- scst: Port to Linux kernel v6.16 Support for the following timer changes in the Linux kernel v6.16: - 41cb08555c41 ("treewide, timers: Rename from_timer() to timer_container_of()") Modified Paths: -------------- qla2x00t-32gbit/qla_edif.c | 2 +- qla2x00t-32gbit/qla_init.c | 2 +- qla2x00t-32gbit/qla_os.c | 2 +- scst/include/backport.h | 8 ++++++++ 4 files changed, 11 insertions(+), 3 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_edif.c b/qla2x00t-32gbit/qla_edif.c index a91440b..ea2f11a 100644 --- a/qla2x00t-32gbit/qla_edif.c +++ b/qla2x00t-32gbit/qla_edif.c @@ -94,7 +94,7 @@ static struct edif_list_entry *qla_edif_list_find_sa_index(fc_port_t *fcport, /* timeout called when no traffic and delayed rx sa_index delete */ static void qla2x00_sa_replace_iocb_timeout(struct timer_list *t) { - struct edif_list_entry *edif_entry = from_timer(edif_entry, t, timer); + struct edif_list_entry *edif_entry = timer_container_of(edif_entry, t, timer); fc_port_t *fcport = edif_entry->fcport; struct scsi_qla_host *vha = fcport->vha; struct edif_sa_ctl *sa_ctl; diff --git a/qla2x00t-32gbit/qla_init.c b/qla2x00t-32gbit/qla_init.c index 13484b0..950b72f 100644 --- a/qla2x00t-32gbit/qla_init.c +++ b/qla2x00t-32gbit/qla_init.c @@ -45,7 +45,7 @@ static void __qla24xx_handle_gpdb_event(scsi_qla_host_t *, struct event_arg *); void qla2x00_sp_timeout(struct timer_list *t) { - srb_t *sp = from_timer(sp, t, u.iocb_cmd.timer); + srb_t *sp = timer_container_of(sp, t, u.iocb_cmd.timer); struct srb_iocb *iocb; scsi_qla_host_t *vha = sp->vha; diff --git a/qla2x00t-32gbit/qla_os.c b/qla2x00t-32gbit/qla_os.c index 24f45ff..a258000 100644 --- a/qla2x00t-32gbit/qla_os.c +++ b/qla2x00t-32gbit/qla_os.c @@ -7506,7 +7506,7 @@ static void qla_wind_down_chip(scsi_qla_host_t *vha) void qla2x00_timer(struct timer_list *t) { - scsi_qla_host_t *vha = from_timer(vha, t, timer); + scsi_qla_host_t *vha = timer_container_of(vha, t, timer); unsigned long cpu_flags = 0; int start_dpc = 0; int index; diff --git a/scst/include/backport.h b/scst/include/backport.h index 72e2972..ef02080 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -1733,6 +1733,14 @@ static inline int timer_delete(struct timer_list *timer) container_of(callback_timer, typeof(*var), timer_fieldname) #endif +/* + * See also commit 41cb08555c41 ("treewide, timers: Rename from_timer() to + * timer_container_of()") # v6.16. + */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) +#define timer_container_of from_timer +#endif + /* * See also commit 1d27e3e2252b ("timer: Remove expires and data arguments * from DEFINE_TIMER"). |
From: Gleb C. <lna...@ya...> - 2025-08-05 13:38:12
|
Commit: c6d16dd GitHub URL: https://github.com/SCST-project/scst/commit/c6d16dd86e0b7fce4be560a3f62dca8462870d15 Author: Gleb Chesnokov Date: 2025-08-05T16:37:31+03:00 Log Message: ----------- qla2x00t, qla2x00t-32gbit: Constify 'struct bin_attribute' The sysfs core now allows instances of 'struct bin_attribute' to be moved into read-only memory. Make use of that to protect them against accidental or malicious modifications. Modified Paths: -------------- qla2x00t-32gbit/qla_attr.c | 78 ++++++++-- qla2x00t/qla_attr.c | 111 ++++++++++----- 2 files changed, 142 insertions(+), 47 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_attr.c b/qla2x00t-32gbit/qla_attr.c index 713b69d..31659b2 100644 --- a/qla2x00t-32gbit/qla_attr.c +++ b/qla2x00t-32gbit/qla_attr.c @@ -17,7 +17,11 @@ static int qla24xx_vport_disable(struct fc_vport *, bool); static ssize_t qla2x00_sysfs_read_fw_dump(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -58,7 +62,11 @@ qla2x00_sysfs_read_fw_dump(struct file *filp, struct kobject *kobj, static ssize_t qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -168,7 +176,7 @@ qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute sysfs_fw_dump_attr = { +static const struct bin_attribute sysfs_fw_dump_attr = { .attr = { .name = "fw_dump", .mode = S_IRUSR | S_IWUSR, @@ -180,7 +188,11 @@ static struct bin_attribute sysfs_fw_dump_attr = { static ssize_t qla2x00_sysfs_read_nvram(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -220,7 +232,11 @@ skip: static ssize_t qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -282,7 +298,7 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute sysfs_nvram_attr = { +static const struct bin_attribute sysfs_nvram_attr = { .attr = { .name = "nvram", .mode = S_IRUSR | S_IWUSR, @@ -294,7 +310,11 @@ static struct bin_attribute sysfs_nvram_attr = { static ssize_t qla2x00_sysfs_read_optrom(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -318,7 +338,11 @@ out: static ssize_t qla2x00_sysfs_write_optrom(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -344,7 +368,7 @@ qla2x00_sysfs_write_optrom(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute sysfs_optrom_attr = { +static const struct bin_attribute sysfs_optrom_attr = { .attr = { .name = "optrom", .mode = S_IRUSR | S_IWUSR, @@ -356,7 +380,11 @@ static struct bin_attribute sysfs_optrom_attr = { static ssize_t qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -529,7 +557,7 @@ out: return rval; } -static struct bin_attribute sysfs_optrom_ctl_attr = { +static const struct bin_attribute sysfs_optrom_ctl_attr = { .attr = { .name = "optrom_ctl", .mode = S_IWUSR, @@ -540,7 +568,11 @@ static struct bin_attribute sysfs_optrom_ctl_attr = { static ssize_t qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -587,7 +619,11 @@ skip: static ssize_t qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -642,7 +678,7 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute sysfs_vpd_attr = { +static const struct bin_attribute sysfs_vpd_attr = { .attr = { .name = "vpd", .mode = S_IRUSR | S_IWUSR, @@ -654,7 +690,11 @@ static struct bin_attribute sysfs_vpd_attr = { static ssize_t qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -679,7 +719,7 @@ qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute sysfs_sfp_attr = { +static const struct bin_attribute sysfs_sfp_attr = { .attr = { .name = "sfp", .mode = S_IRUSR | S_IWUSR, @@ -690,7 +730,11 @@ static struct bin_attribute sysfs_sfp_attr = { static ssize_t qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -823,7 +867,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute sysfs_reset_attr = { +static const struct bin_attribute sysfs_reset_attr = { .attr = { .name = "reset", .mode = S_IWUSR, @@ -834,7 +878,11 @@ static struct bin_attribute sysfs_reset_attr = { static ssize_t qla2x00_issue_logo(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -866,7 +914,7 @@ qla2x00_issue_logo(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute sysfs_issue_logo_attr = { +static const struct bin_attribute sysfs_issue_logo_attr = { .attr = { .name = "issue_logo", .mode = S_IWUSR, @@ -877,7 +925,11 @@ static struct bin_attribute sysfs_issue_logo_attr = { static ssize_t qla2x00_sysfs_read_xgmac_stats(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -929,7 +981,7 @@ do_read: return count; } -static struct bin_attribute sysfs_xgmac_stats_attr = { +static const struct bin_attribute sysfs_xgmac_stats_attr = { .attr = { .name = "xgmac_stats", .mode = S_IRUSR, @@ -940,7 +992,11 @@ static struct bin_attribute sysfs_xgmac_stats_attr = { static ssize_t qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -987,7 +1043,7 @@ do_read: return count; } -static struct bin_attribute sysfs_dcbx_tlv_attr = { +static const struct bin_attribute sysfs_dcbx_tlv_attr = { .attr = { .name = "dcbx_tlv", .mode = S_IRUSR, @@ -998,7 +1054,7 @@ static struct bin_attribute sysfs_dcbx_tlv_attr = { static struct sysfs_entry { char *name; - struct bin_attribute *attr; + const struct bin_attribute *attr; int type; } bin_file_entries[] = { { "fw_dump", &sysfs_fw_dump_attr, }, diff --git a/qla2x00t/qla_attr.c b/qla2x00t/qla_attr.c index bfa29e5..e8fcb47 100644 --- a/qla2x00t/qla_attr.c +++ b/qla2x00t/qla_attr.c @@ -441,9 +441,12 @@ static DEVICE_ATTR(port_database, #endif /* CONFIG_SCSI_QLA2XXX_TARGET */ static ssize_t -qla2x00_sysfs_read_fw_dump(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_read_fw_dump(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -470,9 +473,12 @@ qla2x00_sysfs_read_fw_dump(struct file *file, } static ssize_t -qla2x00_sysfs_write_fw_dump(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_write_fw_dump(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -538,7 +544,7 @@ qla2x00_sysfs_write_fw_dump(struct file *file, return count; } -static struct bin_attribute sysfs_fw_dump_attr = { +static const struct bin_attribute sysfs_fw_dump_attr = { .attr = { .name = "fw_dump", .mode = S_IRUSR | S_IWUSR, @@ -549,9 +555,12 @@ static struct bin_attribute sysfs_fw_dump_attr = { }; static ssize_t -qla2x00_sysfs_read_nvram(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_read_nvram(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -569,9 +578,12 @@ qla2x00_sysfs_read_nvram(struct file *file, } static ssize_t -qla2x00_sysfs_write_nvram(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_write_nvram(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -627,7 +639,7 @@ qla2x00_sysfs_write_nvram(struct file *file, return count; } -static struct bin_attribute sysfs_nvram_attr = { +static const struct bin_attribute sysfs_nvram_attr = { .attr = { .name = "nvram", .mode = S_IRUSR | S_IWUSR, @@ -638,9 +650,12 @@ static struct bin_attribute sysfs_nvram_attr = { }; static ssize_t -qla2x00_sysfs_read_optrom(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_read_optrom(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -655,9 +670,12 @@ qla2x00_sysfs_read_optrom(struct file *file, } static ssize_t -qla2x00_sysfs_write_optrom(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_write_optrom(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -676,7 +694,7 @@ qla2x00_sysfs_write_optrom(struct file *file, return count; } -static struct bin_attribute sysfs_optrom_attr = { +static const struct bin_attribute sysfs_optrom_attr = { .attr = { .name = "optrom", .mode = S_IRUSR | S_IWUSR, @@ -687,9 +705,12 @@ static struct bin_attribute sysfs_optrom_attr = { }; static ssize_t -qla2x00_sysfs_write_optrom_ctl(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_write_optrom_ctl(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -842,7 +863,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *file, return count; } -static struct bin_attribute sysfs_optrom_ctl_attr = { +static const struct bin_attribute sysfs_optrom_ctl_attr = { .attr = { .name = "optrom_ctl", .mode = S_IWUSR, @@ -852,9 +873,12 @@ static struct bin_attribute sysfs_optrom_ctl_attr = { }; static ssize_t -qla2x00_sysfs_read_vpd(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_read_vpd(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -874,9 +898,12 @@ qla2x00_sysfs_read_vpd(struct file *file, } static ssize_t -qla2x00_sysfs_write_vpd(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_write_vpd(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -917,7 +944,7 @@ qla2x00_sysfs_write_vpd(struct file *file, return count; } -static struct bin_attribute sysfs_vpd_attr = { +static const struct bin_attribute sysfs_vpd_attr = { .attr = { .name = "vpd", .mode = S_IRUSR | S_IWUSR, @@ -928,9 +955,12 @@ static struct bin_attribute sysfs_vpd_attr = { }; static ssize_t -qla2x00_sysfs_read_sfp(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_read_sfp(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -980,7 +1010,7 @@ do_read: return count; } -static struct bin_attribute sysfs_sfp_attr = { +static const struct bin_attribute sysfs_sfp_attr = { .attr = { .name = "sfp", .mode = S_IRUSR | S_IWUSR, @@ -990,9 +1020,12 @@ static struct bin_attribute sysfs_sfp_attr = { }; static ssize_t -qla2x00_sysfs_write_reset(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_write_reset(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -1056,7 +1089,7 @@ qla2x00_sysfs_write_reset(struct file *file, return count; } -static struct bin_attribute sysfs_reset_attr = { +static const struct bin_attribute sysfs_reset_attr = { .attr = { .name = "reset", .mode = S_IWUSR, @@ -1066,9 +1099,12 @@ static struct bin_attribute sysfs_reset_attr = { }; static ssize_t -qla2x00_sysfs_read_xgmac_stats(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_read_xgmac_stats(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -1109,7 +1145,7 @@ do_read: return count; } -static struct bin_attribute sysfs_xgmac_stats_attr = { +static const struct bin_attribute sysfs_xgmac_stats_attr = { .attr = { .name = "xgmac_stats", .mode = S_IRUSR, @@ -1119,9 +1155,12 @@ static struct bin_attribute sysfs_xgmac_stats_attr = { }; static ssize_t -qla2x00_sysfs_read_dcbx_tlv(struct file *file, - struct kobject *kobj, +qla2x00_sysfs_read_dcbx_tlv(struct file *file, struct kobject *kobj, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0) struct bin_attribute *bin_attr, +#else + const struct bin_attribute *bin_attr, +#endif char *buf, loff_t off, size_t count) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, @@ -1159,7 +1198,7 @@ do_read: return count; } -static struct bin_attribute sysfs_dcbx_tlv_attr = { +static const struct bin_attribute sysfs_dcbx_tlv_attr = { .attr = { .name = "dcbx_tlv", .mode = S_IRUSR, @@ -1170,7 +1209,7 @@ static struct bin_attribute sysfs_dcbx_tlv_attr = { static struct sysfs_entry { char *name; - struct bin_attribute *attr; + const struct bin_attribute *attr; int is4GBp_only; } bin_file_entries[] = { { "fw_dump", &sysfs_fw_dump_attr, }, |