All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kirill Tkhai <ktkhai@virtuozzo.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: akpm@linux-foundation.org, jack@suse.cz, amir73il@gmail.com,
	linux-fsdevel@vger.kernel.org, gorcunov@virtuozzo.com
Subject: Re: [PATCH] inotify: Extend ioctl to allow to request id of new watch descriptor
Date: Fri, 9 Feb 2018 11:26:01 +0300	[thread overview]
Message-ID: <041af224-8e9b-1b62-fd99-7ffec367138e@virtuozzo.com> (raw)
In-Reply-To: <20180208160228.GE15846@bombadil.infradead.org>

On 08.02.2018 19:02, Matthew Wilcox wrote:
> On Thu, Feb 08, 2018 at 06:07:37PM +0300, Kirill Tkhai wrote:
>> The new code is under CONFIG_CHECKPOINT_RESTORE #define, so small system
>> may exclude it. The only change in generic inotify part is idr_alloc_cyclic()
>> end argument. We had 0 there, and idr subsystem replaced it with INT_MAX
>> in idr_get_free(). So, the max possible id was INT_MAX (see idr_get_free()
>> again).
>>
>> Since I need INOTIFY_IDR_END to check ioctl's third argument, it's better
>> it's defined as positive number. But when not-zero value is passed
>> to idr_get_free(), this function decrements it. Also, idr_alloc_cyclic()
>> defined @end as int argument. So, it's impossible to pass positive @end
>> argument to idr_alloc_cyclic() to get INT_MAX id. And after this patch
>> inotify watch descriptors ids will take numbers [1, INT_MAX-1], INT_MAX
>> will be unavailable.
> 
> Ummm.  Why not just do:
> 
> +#ifdef CONFIG_CHECKPOINT_RESTORE
> +	case INOTIFY_IOC_SETNEXTWD:
> +		ret = -EINVAL;
> +		if (arg >= 1 && arg <= INT_MAX) {
> +			spin_lock(&data->idr_lock);
> +			idr_set_cursor(&data->idr, (unsigned int)arg);
> +			spin_unlock(&data->idr_lock);
> +			ret = 0;
> +		}
> +		break;
> +#endif /* CONFIG_CHECKPOINT_RESTORE */

INT_MAX is generic constant, and the fact, it is used in the above hunk,
does not make feel it's the same constant as used in inotify_add_to_idr().

Specific constant underlines these two places are connected, and it makes
the code more readable for a reader.

Kirill

  reply	other threads:[~2018-02-09  8:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-08 15:07 [PATCH] inotify: Extend ioctl to allow to request id of new watch descriptor Kirill Tkhai
2018-02-08 16:02 ` Matthew Wilcox
2018-02-09  8:26   ` Kirill Tkhai [this message]
2018-02-09 13:28     ` Matthew Wilcox
2018-02-09 15:05       ` Kirill Tkhai
2018-02-08 16:14 ` Jan Kara
2018-02-08 16:14   ` Jan Kara
2018-02-08 17:58   ` Cyrill Gorcunov
2018-02-09 15:04 ` [PATCH v2] " Kirill Tkhai
2018-02-09 15:04   ` Kirill Tkhai
2018-02-09 15:14   ` Matthew Wilcox
2018-02-09 20:56   ` Andrew Morton
2018-02-09 22:45     ` Kirill Tkhai
2018-02-11 11:30       ` Stef Bon
2018-02-12  8:42         ` Kirill Tkhai
2018-02-12  8:42           ` Kirill Tkhai
2018-02-14 10:18       ` Jan Kara
2018-02-14 10:18         ` Jan Kara

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=041af224-8e9b-1b62-fd99-7ffec367138e@virtuozzo.com \
    --to=ktkhai@virtuozzo.com \
    --cc=akpm@linux-foundation.org \
    --cc=amir73il@gmail.com \
    --cc=gorcunov@virtuozzo.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=willy@infradead.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.