scsi: lpfc: Update lpfc_ramp_down_queue_handler() logic
Subsystems (5)
Sasha Levin
maintainerPATCH 1/7 scsi: lpfc: Update lpfc_ramp_down_queue_handler() logic
From: Justin Tee <[email protected]>
[ Upstream commit bb011631435c705cdeddca68d5c85fd40a4320f9 ]
Typically when an out of resource CQE status is detected, the lpfc_ramp_down_queue_handler() logic is called to help reduce I/O load by reducing an sdev's queue_depth.
However, the current lpfc_rampdown_queue_depth() logic does not help reduce queue_depth. num_cmd_success is never updated and is always zero, which means new_queue_depth will always be set to sdev->queue_depth. So, new_queue_depth = sdev->queue_depth - new_queue_depth always sets new_queue_depth to zero. And, scsi_change_queue_depth(sdev, 0) is essentially a no-op.
Change the lpfc_ramp_down_queue_handler() logic to set new_queue_depth equal to sdev->queue_depth subtracted from number of times num_rsrc_err was incremented. If num_rsrc_err is >= sdev->queue_depth, then set new_queue_depth equal to 1. Eventually, the frequency of Good_Status frames will signal SCSI upper layer to auto increase the queue_depth back to the driver default of 64 via scsi_handle_queue_ramp_up().
--- drivers/scsi/lpfc/lpfc.h | 1 - drivers/scsi/lpfc/lpfc_scsi.c | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-)
drivers/scsi/lpfc/lpfc.h +0 -1
@@ -1065,7 +1065,6 @@ struct lpfc_hba {unsigned long bit_flags;#define FABRIC_COMANDS_BLOCKED 0atomic_t num_rsrc_err; -atomic_t num_cmd_success;unsigned long last_rsrc_error_time;unsigned long last_ramp_down_time;#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
drivers/scsi/lpfc/lpfc_scsi.c +4 -9
@@ -246,11 +246,10 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)struct Scsi_Host *shost;struct scsi_device *sdev;unsigned long new_queue_depth; -unsigned long num_rsrc_err, num_cmd_success; +unsigned long num_rsrc_err;int i; num_rsrc_err =atomic_read (&phba->num_rsrc_err); - num_cmd_success =atomic_read (&phba->num_cmd_success);/* * The error and success command counters are global per
@@ -265,20 +264,16 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)for (i =0 ; i <= phba->max_vports && vports[i] !=NULL ; i++) { shost =lpfc_shost_from_vport (vports[i]);shost_for_each_device (sdev, shost) { - new_queue_depth = - sdev->queue_depth * num_rsrc_err / - (num_rsrc_err + num_cmd_success); -if (!new_queue_depth) - new_queue_depth = sdev->queue_depth -1 ; +if (num_rsrc_err >= sdev->queue_depth) + new_queue_depth =1 ;else new_queue_depth = sdev->queue_depth - - new_queue_depth; + num_rsrc_err;scsi_change_queue_depth (sdev, new_queue_depth); } }lpfc_destroy_vport_work_array (phba, vports);atomic_set (&phba->num_rsrc_err,0 ); -atomic_set (&phba->num_cmd_success,0 ); }/**
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/7 gfs2: Fix invalid metadata access in punch_hole
From: Andrew Price <[email protected]>
[ Upstream commit c95346ac918c5badf51b9a7ac58a26d3bd5bb224 ]
In punch_hole(), when the offset lies in the final block for a given height, there is no hole to punch, but the maximum size check fails to detect that. Consequently, punch_hole() will try to punch a hole beyond the end of the metadata and fail. Fix the maximum size check.
--- fs/gfs2/bmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/gfs2/bmap.c +3 -2
@@ -1758,7 +1758,8 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)struct buffer_head *dibh, *bh;struct gfs2_holder rd_gh;unsigned int bsize_shift = sdp->sd_sb.sb_bsize_shift; -u64 lblock = (offset + (1 << bsize_shift) -1 ) >> bsize_shift; +unsigned int bsize =1 << bsize_shift; +u64 lblock = (offset + bsize -1 ) >> bsize_shift;__u16 start_list[GFS2_MAX_META_HEIGHT ];__u16 __end_list[GFS2_MAX_META_HEIGHT ], *end_list =NULL ;unsigned int start_aligned, end_aligned;
@@ -1769,7 +1770,7 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)u64 prev_bnr =0 ;__be64 *start, *end; -if (offset >= maxsize) { +if (offset + bsize -1 >= maxsize) {/* * The starting point lies beyond the allocated meta-data; * there are no blocks do deallocate.
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/7 wifi: mac80211: fix ieee80211_bss_*_flags kernel-doc
In reply to Sasha LevinFrom: Jeff Johnson <[email protected]>
[ Upstream commit 774f8841f55d7ac4044c79812691649da203584a ]
Running kernel-doc on ieee80211_i.h flagged the following:net/mac80211/ieee80211_i.h:145: warning: expecting prototype for enum ieee80211_corrupt_data_flags. Prototype was for enum ieee80211_bss_corrupt_data_flags instead net/mac80211/ieee80211_i.h:162: warning: expecting prototype for enum ieee80211_valid_data_flags. Prototype was for enum ieee80211_bss_valid_data_flags instead
Fix these warnings.
--- net/mac80211/ieee80211_i.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/mac80211/ieee80211_i.h +2 -2
@@ -112,7 +112,7 @@ struct ieee80211_bss { };/** -* enum ieee80211_corrupt_data_flags - BSS data corruption flags +* enum ieee80211_bss_corrupt_data_flags - BSS data corruption flags * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted *
@@ -125,7 +125,7 @@ enum ieee80211_bss_corrupt_data_flags { };/** -* enum ieee80211_valid_data_flags - BSS valid data flags +* enum ieee80211_bss_valid_data_flags - BSS valid data flags * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/7 wifi: cfg80211: fix rdev_dump_mpp() arguments order
In reply to Sasha LevinFrom: Igor Artemiev <[email protected]>
[ Upstream commit ec50f3114e55406a1aad24b7dfaa1c3f4336d8eb ]
Fix the order of arguments in the TP_ARGS macro
for the rdev_dump_mpp tracepoint event.
Found by Linux Verification Center (linuxtesting.org).
--- net/wireless/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/trace.h +1 -1
@@ -968,7 +968,7 @@ TRACE_EVENT(rdev_get_mpp, TRACE_EVENT(rdev_dump_mpp, TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int _idx, u8 *dst, u8 *mpp), - TP_ARGS(wiphy, netdev, _idx, mpp, dst), + TP_ARGS(wiphy, netdev, _idx, dst, mpp), TP_STRUCT__entry( WIPHY_ENTRY NETDEV_ENTRY
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/7 net: mark racy access on sk->sk_rcvbuf
In reply to Sasha LevinFrom: linke li <[email protected]>
[ Upstream commit c2deb2e971f5d9aca941ef13ee05566979e337a4 ]
sk->sk_rcvbuf in __sock_queue_rcv_skb() and __sk_receive_skb() can be changed by other threads. Mark this as benign using READ_ONCE().
This patch is aimed at reducing the number of benign races reported by KCSAN in order to focus future debugging effort on harmful races.
--- net/core/sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/sock.c +2 -2
@@ -440,7 +440,7 @@ int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)unsigned long flags;struct sk_buff_head *list = &sk->sk_receive_queue; -if (atomic_read (&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) { +if (atomic_read (&sk->sk_rmem_alloc) >=READ_ONCE (sk->sk_rcvbuf)) {atomic_inc (&sk->sk_drops);trace_sock_rcvqueue_full (sk, skb);return -ENOMEM ;
@@ -492,7 +492,7 @@ int __sk_receive_skb(struct sock *sk, struct sk_buff *skb, skb->dev =NULL ; -if (sk_rcvqueues_full (sk, sk->sk_rcvbuf)) { +if (sk_rcvqueues_full (sk,READ_ONCE (sk->sk_rcvbuf))) {atomic_inc (&sk->sk_drops); goto discard_and_relse; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/7 scsi: bnx2fc: Remove spin_lock_bh while releasing resources after upload
In reply to Sasha LevinFrom: Saurav Kashyap <[email protected]>
[ Upstream commit c214ed2a4dda35b308b0b28eed804d7ae66401f9 ]
The session resources are used by FW and driver when session is offloaded, once session is uploaded these resources are not used. The lock is not required as these fields won't be used any longer. The offload and upload calls are sequential, hence lock is not required.
This will suppress following BUG_ON():
[ 449.843143] ------------[ cut here ]------------ [ 449.848302] kernel BUG at mm/vmalloc.c:2727! [ 449.853072] invalid opcode: 0000 [#1] PREEMPT SMP PTI [ 449.858712] CPU: 5 PID: 1996 Comm: kworker/u24:2 Not tainted 5.14.0-118.el9.x86_64 #1 Rebooting. [ 449.867454] Hardware name: Dell Inc. PowerEdge R730/0WCJNT, BIOS 2.3.4 11/08/2016 [ 449.876966] Workqueue: fc_rport_eq fc_rport_work [libfc] [ 449.882910] RIP: 0010:vunmap+0x2e/0x30 [ 449.887098] Code: 00 65 8b 05 14 a2 f0 4a a9 00 ff ff 00 75 1b 55 48 89 fd e8 34 36 79 00 48 85 ed 74 0b 48 89 ef 31 f6 5d e9 14 fc ff ff 5d c3 <0f> 0b 0f 1f 44 00 00 41 57 41 56 49 89 ce 41 55 49 89 fd 41 54 41 [ 449.908054] RSP: 0018:ffffb83d878b3d68 EFLAGS: 00010206 [ 449.913887] RAX: 0000000080000201 RBX: ffff8f4355133550 RCX: 000000000d400005 [ 449.921843] RDX: 0000000000000001 RSI: 0000000000001000 RDI: ffffb83da53f5000 [ 449.929808] RBP: ffff8f4ac6675800 R08: ffffb83d878b3d30 R09: 00000000000efbdf [ 449.937774] R10: 0000000000000003 R11: ffff8f434573e000 R12: 0000000000001000 [ 449.945736] R13: 0000000000001000 R14: ffffb83da53f5000 R15: ffff8f43d4ea3ae0 [ 449.953701] FS: 0000000000000000(0000) GS:ffff8f529fc80000(0000) knlGS:0000000000000000 [ 449.962732] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 449.969138] CR2: 00007f8cf993e150 CR3: 0000000efbe10003 CR4: 00000000003706e0 [ 449.977102] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 449.985065] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 449.993028] Call Trace: [ 449.995756] __iommu_dma_free+0x96/0x100 [ 450.000139] bnx2fc_free_session_resc+0x67/0x240 [bnx2fc] [ 450.006171] bnx2fc_upload_session+0xce/0x100 [bnx2fc] [ 450.011910] bnx2fc_rport_event_handler+0x9f/0x240 [bnx2fc] [ 450.018136] fc_rport_work+0x103/0x5b0 [libfc] [ 450.023103] process_one_work+0x1e8/0x3c0 [ 450.027581] worker_thread+0x50/0x3b0 [ 450.031669] ? rescuer_thread+0x370/0x370 [ 450.036143] kthread+0x149/0x170 [ 450.039744] ? set_kthread_struct+0x40/0x40 [ 450.044411] ret_from_fork+0x22/0x30 [ 450.048404] Modules linked in: vfat msdos fat xfs nfs_layout_nfsv41_files rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver dm_service_time qedf qed crc8 bnx2fc libfcoe libfc scsi_transport_fc intel_rapl_msr intel_rapl_common x86_pkg_temp_thermal intel_powerclamp dcdbas rapl intel_cstate intel_uncore mei_me pcspkr mei ipmi_ssif lpc_ich ipmi_si fuse zram ext4 mbcache jbd2 loop nfsv3 nfs_acl nfs lockd grace fscache netfs irdma ice sd_mod t10_pi sg ib_uverbs ib_core 8021q garp mrp stp llc mgag200 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt mxm_wmi fb_sys_fops cec crct10dif_pclmul ahci crc32_pclmul bnx2x drm ghash_clmulni_intel libahci rfkill i40e libata megaraid_sas mdio wmi sunrpc lrw dm_crypt dm_round_robin dm_multipath dm_snapshot dm_bufio dm_mirror dm_region_hash dm_log dm_zero dm_mod linear raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx raid6_pq libcrc32c crc32c_intel raid1 raid0 iscsi_ibft squashfs be2iscsi bnx2i cnic uio cxgb4i cxgb4 tls [ 450.048497] libcxgbi libcxgb qla4xxx iscsi_boot_sysfs iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi edd ipmi_devintf ipmi_msghandler [ 450.159753] ---[ end trace 712de2c57c64abc8 ]---
--- drivers/scsi/bnx2fc/bnx2fc_tgt.c | 2 -- 1 file changed, 2 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_tgt.c +0 -2
@@ -833,7 +833,6 @@ static void bnx2fc_free_session_resc(struct bnx2fc_hba *hba,BNX2FC_TGT_DBG (tgt,"Freeing up session resources\n" ); -spin_lock_bh (&tgt->cq_lock); ctx_base_ptr = tgt->ctx_base; tgt->ctx_base =NULL ;
@@ -889,7 +888,6 @@ static void bnx2fc_free_session_resc(struct bnx2fc_hba *hba, tgt->sq, tgt->sq_dma); tgt->sq =NULL ; } -spin_unlock_bh (&tgt->cq_lock);if (ctx_base_ptr)iounmap (ctx_base_ptr);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/7 btrfs: return accurate error code on open failure in open_fs_devices()
In reply to Sasha LevinFrom: Anand Jain <[email protected]>
[ Upstream commit 2f1aeab9fca1a5f583be1add175d1ee95c213cfa ]
When attempting to exclusive open a device which has no exclusive open permission, such as a physical device associated with the flakey dm device, the open operation will fail, resulting in a mount failure.
In this particular scenario, we erroneously return -EINVAL instead of the correct error code provided by the bdev_open_by_path() function, which is -EBUSY.
Fix this, by returning error code from the bdev_open_by_path() function. With this correction, the mount error message will align with that of ext4 and xfs.
--- fs/btrfs/volumes.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
fs/btrfs/volumes.c +12 -5
@@ -1266,25 +1266,32 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices,struct btrfs_device *device;struct btrfs_device *latest_dev =NULL ;struct btrfs_device *tmp_device; +int ret =0 ; flags |=FMODE_EXCL ;list_for_each_entry_safe (device, tmp_device, &fs_devices->devices, dev_list) { -int ret; +int ret2; - ret =btrfs_open_one_device (fs_devices, device, flags, holder); -if (ret ==0 && + ret2 =btrfs_open_one_device (fs_devices, device, flags, holder); +if (ret2 ==0 && (!latest_dev || device->generation > latest_dev->generation)) { latest_dev = device; - }else if (ret == -ENODATA ) { + }else if (ret2 == -ENODATA ) { fs_devices->num_devices--;list_del (&device->dev_list);btrfs_free_device (device); } +if (ret ==0 && ret2 !=0 ) + ret = ret2; } -if (fs_devices->open_devices ==0 ) + +if (fs_devices->open_devices ==0 ) { +if (ret) +return ret;return -EINVAL ; + } fs_devices->opened =1 ; fs_devices->latest_bdev = latest_dev->bdev;
Signature · 1 line
2.43.0