RE: drivers/scsi/fnic/fdls_disc.c:263 fdls_schedule_oxid_free_retry_work() warn: inconsistent indenting
From: Karan Tilak Kumar (kartilak)
Date: Sat Feb 15 2025 - 16:04:34 EST
On Friday, February 14, 2025 7:03 AM, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
>
> On Fri, Feb 14, 2025 at 05:42:25PM +0300, Dan Carpenter wrote:
> >
> > I guess we can't call schedule_delayed_work() without holding the
> > spin_lock? It's a strange thing.
>
> Actually, I see now that we're just dropping the lock to avoid a sleeping
> in atomic warning with the GFP_ATOMIC allocation... I bet you could make
> the code under the lock much smaller. Just the test_and_clear_bit() stuff
> basically.
>
> regards,
> dan carpenter
>
> diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
> index 11211c469583..ed141236a4aa 100644
> --- a/drivers/scsi/fnic/fdls_disc.c
> +++ b/drivers/scsi/fnic/fdls_disc.c
> @@ -308,31 +308,22 @@ void fdls_schedule_oxid_free_retry_work(struct work_struct *work)
> struct fnic *fnic = iport->fnic;
> struct reclaim_entry_s *reclaim_entry;
> unsigned long delay_j = msecs_to_jiffies(OXID_RECLAIM_TOV(iport));
> + unsigned long flags;
> int idx;
>
> - spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
> -
> for_each_set_bit(idx, oxid_pool->pending_schedule_free, FNIC_OXID_POOL_SZ) {
>
> FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
> "Schedule oxid free. oxid idx: %d\n", idx);
>
> - spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> - reclaim_entry = (struct reclaim_entry_s *)
> - kzalloc(sizeof(struct reclaim_entry_s), GFP_KERNEL);
> - spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
> -
> + reclaim_entry = kzalloc(sizeof(*reclaim_entry), GFP_KERNEL);
> if (!reclaim_entry) {
> - FNIC_FCS_DBG(KERN_WARNING, fnic->host, fnic->fnic_num,
> - "Failed to allocate memory for reclaim struct for oxid idx: 0x%x\n",
> - idx);
> -
> schedule_delayed_work(&oxid_pool->schedule_oxid_free_retry,
> msecs_to_jiffies(SCHEDULE_OXID_FREE_RETRY_TIME));
> - spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> return;
> }
>
> + spin_lock_irqsave(&fnic->fnic_lock, flags);
> if (test_and_clear_bit(idx, oxid_pool->pending_schedule_free)) {
> reclaim_entry->oxid_idx = idx;
> reclaim_entry->expires = round_jiffies(jiffies + delay_j);
> @@ -342,9 +333,8 @@ void fdls_schedule_oxid_free_retry_work(struct work_struct *work)
> /* unlikely scenario, free the allocated memory and continue */
> kfree(reclaim_entry);
> }
> -}
> -
> - spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> + spin_unlock_irqrestore(&fnic->fnic_lock, flags);
> + }
> }
>
> static bool fdls_is_oxid_fabric_req(uint16_t oxid)
>
>
Thanks for the comments and changes Dan. Appreciate your help.
The team will review these changes and get back to you.
Regards,
Karan