All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <mchristi@redhat.com>
To: target-devel@vger.kernel.org
Subject: Re: [PATCHv2] tcmu: allow userspace to reset netlink
Date: Fri, 13 Apr 2018 17:21:45 +0000	[thread overview]
Message-ID: <5AD0E729.4030307@redhat.com> (raw)
In-Reply-To: <1522903193-13947-1-git-send-email-xiubli@redhat.com>

On 04/12/2018 10:08 PM, Xiubo Li wrote:
> 
>>> +
>>> +    if (val != 1) {
>>> +        pr_err("Invalid block value %d\n", val);
>> I think you wanted
>>
>> "Invalid reset value %d\n"
> Yeah, just copied it from other place.
>>
>>> +        return -EINVAL;
>>> +    }
>>> +
>>> +    spin_unlock(&udev->nl_cmd_lock);
>> Need spin_lock() instead of unlock.
>>
>>
>> I think before calling the code below you need to check if a nl command
>> is even waiting. If you just run this with no nl commands waiting then
>> next time we send a command nl_cmd->complete will be true and
>> tcmu_wait_genl_cmd_reply's wait_event call will return right away.
> Will fix this.
> 
>>
>>> +    nl_cmd->complete = true;
>>> +    nl_cmd->status = -EINTR;
>>> +    wake_up(&udev->complete_wq);
>> Instead of the code above, I think you need to take some of the guts out
>> of tcmu_genl_cmd_done to handle removal which is an odd cases due to the
>> refcoutning/locking and configfs use.
>>
>> For non removal commands we need to do a target_undepend_item. For
>> remove, we don't want to since we came through configfs and teardown
>> already started.
>>
>> So instead of the above lines take:
>>
>>          if (nl_cmd->cmd != completed_cmd) {
>>                  printk(KERN_ERR "Mismatched commands (Expecting reply
>> for %d. Current %d).\n",
>>                         completed_cmd, nl_cmd->cmd);
>>                  ret = -EINVAL;
>>          } else {
>>                  nl_cmd->status = rc;
>>          }
>>
>>     // Note: I changed this from the is_removed
>>          if (completed_cmd != TCMU_CMD_REMOVED_DEVICE)
>>                   target_undepend_item(&dev->dev_group.cg_item);
>>          if (!ret) {
>>                  nl_cmd->complete = true;
>>                  wake_up(&udev->complete_wq);
>>          }
>>
> Sorry, this part I couldn't totally understand.
> 
> Do you mean take the code above you pasted by introducing
> target_undepend_item() for none removal paths just like in
> tcmu_genl_cmd_done() does?
> While in tcmu_genl_cmd_done(), the target_depend_item() is called by
> target_find_device() and then it should do target_undepend_item() after
> that, but in
> reset_netlink_store(), should it need target_undepend_item() ? If so
> they won't be in pairs.
> 

Yes, you are right. I thought we took a count when we sent the nl cmd.

> I think we should only take this part:
> 
>         if (nl_cmd->cmd != completed_cmd) {
>                 printk(KERN_ERR "Mismatched commands (Expecting reply
> for %d. Current %d).\n",
>                        completed_cmd, nl_cmd->cmd);
>                 ret = -EINVAL;
>         } else {
>                 nl_cmd->status = rc;
>         }
> 
> from the tcmu_genl_cmd_done(), right ?
> 

We want the complete and wake up part too right?

>>                  nl_cmd->complete = true;
>>                  wake_up(&udev->complete_wq);


> Thanks,
> BRs
> 
> 
>> from tcmu_genl_cmd_done and make a function that takes the status code
>> and completed_cmd. You would just then do
>>
>> __tcmu_genl_cmd_done(&udev->curr_nl_cmd.cmd, -EINTR);
>>
>>
>>
>>
>>> +    spin_unlock(&udev->nl_cmd_lock);
>>> +
>>> +    return count;
>>> +}
>>> +CONFIGFS_ATTR_WO(tcmu_, reset_netlink);
>>> +
>>>   static ssize_t tcmu_reset_ring_store(struct config_item *item,
>>> const char *page,
>>>                        size_t count)
>>>   {
>>> @@ -2363,6 +2400,7 @@ static ssize_t tcmu_reset_ring_store(struct
>>> config_item *item, const char *page,
>>>   static struct configfs_attribute *tcmu_action_attrs[] = {
>>>       &tcmu_attr_block_dev,
>>>       &tcmu_attr_reset_ring,
>>> +    &tcmu_attr_reset_netlink,
>>>       NULL,
>>>   };
>>>  
> 


  parent reply	other threads:[~2018-04-13 17:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05  4:39 [PATCHv2] tcmu: allow userspace to reset netlink xiubli
2018-04-12 17:48 ` Mike Christie
2018-04-13  3:08 ` Xiubo Li
2018-04-13 17:21 ` Mike Christie [this message]
2018-04-14  0:16 ` Xiubo Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5AD0E729.4030307@redhat.com \
    --to=mchristi@redhat.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.