[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <544847e2-4771-9344-e840-5f394fa3df8a@virtuozzo.com>
Date: Thu, 30 Jul 2020 17:20:23 +0300
From: Kirill Tkhai <ktkhai@...tuozzo.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: viro@...iv.linux.org.uk, adobriyan@...il.com, davem@...emloft.net,
ebiederm@...ssion.com, akpm@...ux-foundation.org,
christian.brauner@...ntu.com, areber@...hat.com, serge@...lyn.com,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 09/23] ns: Introduce ns_idr to be able to iterate all
allocated namespaces in the system
On 30.07.2020 17:15, Matthew Wilcox wrote:
> On Thu, Jul 30, 2020 at 05:12:09PM +0300, Kirill Tkhai wrote:
>> On 30.07.2020 16:56, Matthew Wilcox wrote:
>>> On Thu, Jul 30, 2020 at 04:32:22PM +0300, Kirill Tkhai wrote:
>>>> On 30.07.2020 15:23, Matthew Wilcox wrote:
>>>>> xa_erase_irqsave();
>>>>
>>>> static inline void *xa_erase_irqsave(struct xarray *xa, unsigned long index)
>>>> {
>>>> unsigned long flags;
>>>> void *entry;
>>>>
>>>> xa_lock_irqsave(xa, flags);
>>>> entry = __xa_erase(xa, index);
>>>> xa_unlock_irqrestore(xa, flags);
>>>>
>>>> return entry;
>>>> }
>>>
>>> was there a question here?
>>
>> No, I just I will add this in separate patch.
>
> Ah, yes. Thanks!
>
>>>>>> +struct ns_common *ns_get_next(unsigned int *id)
>>>>>> +{
>>>>>> + struct ns_common *ns;
>>>>>> +
>>>>>> + if (*id < PROC_NS_MIN_INO - 1)
>>>>>> + *id = PROC_NS_MIN_INO - 1;
>>>>>> +
>>>>>> + *id += 1;
>>>>>> + *id -= PROC_NS_MIN_INO;
>>>>>> +
>>>>>> + rcu_read_lock();
>>>>>> + do {
>>>>>> + ns = idr_get_next(&ns_idr, id);
>>>>>> + if (!ns)
>>>>>> + break;
>>>>>
>>>>> xa_find_after();
>>>>>
>>>>> You'll want a temporary unsigned long to work with ...
>>>>>
>>>>>> + if (!refcount_inc_not_zero(&ns->count)) {
>>>>>> + ns = NULL;
>>>>>> + *id += 1;
>>>>>
>>>>> you won't need this increment.
>>>>
>>>> Why? I don't see a way xarray allows to avoid this.
>>>
>>> It's embedded in xa_find_after().
>>
>> How is it embedded to check ns->count that it knows nothing?
>
> I meant you won't need to increment '*id'. The refcount is, of course,
> your business.
Ok, this brings comfort to me, because first time I thought xarray is a
big brother, which knows everything about my counters :)
Powered by blists - more mailing lists