mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Li Zefan <lizefan@huawei.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Song Liu <liu.song.a23@gmail.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Reinette Chatre <reinette.chatre@intel.com>
Subject: Re: [PATCH 2/2] kernfs: Allow creation with external gen + ino numbers
Date: Thu, 24 Oct 2019 10:52:01 -0700	[thread overview]
Message-ID: <20191024175201.GB3622521@devbig004.ftw2.facebook.com> (raw)
In-Reply-To: <20191016125019.157144-3-namhyung@kernel.org>

On Wed, Oct 16, 2019 at 09:50:19PM +0900, Namhyung Kim wrote:
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index 6ebae6bbe6a5..f2e54532c110 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -618,10 +618,10 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
>  					     struct kernfs_node *parent,
>  					     const char *name, umode_t mode,
>  					     kuid_t uid, kgid_t gid,
> +					     u32 gen, int ino,

Shouldn't this be ino_t so that we can use 64bit uniq id as ino
directly where possible?  Also, it might make more sense if ino comes
before gen.

> @@ -635,11 +635,24 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
>  
>  	idr_preload(GFP_KERNEL);
>  	spin_lock(&kernfs_idr_lock);
> -	cursor = idr_get_cursor(&root->ino_idr);
> -	ret = idr_alloc_cyclic(&root->ino_idr, kn, 1, 0, GFP_ATOMIC);
> -	if (ret >= 0 && ret < cursor)
> -		root->next_generation++;
> -	gen = root->next_generation;
> +
> +	if (ino == 0) {
> +		cursor = idr_get_cursor(&root->ino_idr);
> +		ret = idr_alloc_cyclic(&root->ino_idr, kn, 1, 0, GFP_ATOMIC);
> +		if (ret >= 0 && ret < cursor)
> +			root->next_generation++;
> +		gen = root->next_generation;
> +	} else {
> +		ret = idr_alloc(&root->ino_idr, kn, ino, ino + 1, GFP_ATOMIC);
> +		if (ret != ino) {
> +			WARN_ONCE(1, "kernfs ino was used: %d", ino);
> +			ret = -EINVAL;
> +		} else {
> +			WARN_ON(root->next_generation > gen);
> +			root->next_generation = gen;
> +		}
> +	}

Oh, I see, so the code is still depending on idr and thus the use of
32bit ino.  Hmm....

>  static inline struct kernfs_node *
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index 44c67d26c1fe..13d0d181a9f8 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -3916,16 +3916,22 @@ static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp,
>  	char name[CGROUP_FILE_NAME_MAX];
>  	struct kernfs_node *kn;
>  	struct lock_class_key *key = NULL;
> +	struct cgroup_root *root = cgrp->root;
> +	int ino, gen;
>  	int ret;
>  
>  #ifdef CONFIG_DEBUG_LOCK_ALLOC
>  	key = &cft->lockdep_key;
>  #endif
> +
> +	ino = cgroup_idr_alloc(&root->cgroup_idr, NULL, false, GFP_KERNEL);
> +	gen = root->cgroup_idr.generation;
> +
>  	kn = __kernfs_create_file(cgrp->kn, cgroup_file_name(cgrp, cft, name),
>  				  cgroup_file_mode(cft),
>  				  GLOBAL_ROOT_UID, GLOBAL_ROOT_GID,
>  				  0, cft->kf_ops, cft,
> -				  NULL, key);
> +				  NULL, key, gen, ino);

Can we move this to a separate patch so that this patch can be an
identity conversion?

Thanks.

-- 
tejun

  reply	other threads:[~2019-10-24 17:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 12:50 [PATCH 0/2] cgroup: Sync cgroup id and inode number Namhyung Kim
2019-10-16 12:50 ` [PATCH 1/2] cgroup: Add generation number with cgroup id Namhyung Kim
2019-10-24 17:44   ` Tejun Heo
2019-10-25  8:30     ` Namhyung Kim
2019-10-25  9:38       ` Namhyung Kim
2019-10-25 10:56         ` Tejun Heo
2019-10-26 11:32           ` Namhyung Kim
2019-10-25 11:06       ` Tejun Heo
2019-10-25 18:47         ` Tejun Heo
2019-10-26 11:42           ` Namhyung Kim
2019-11-01  0:47             ` Namhyung Kim
2019-10-26 11:40         ` Namhyung Kim
2019-10-16 12:50 ` [PATCH 2/2] kernfs: Allow creation with external gen + ino numbers Namhyung Kim
2019-10-24 17:52   ` Tejun Heo [this message]
2019-10-25  8:46     ` Namhyung Kim

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=20191024175201.GB3622521@devbig004.ftw2.facebook.com \
    --to=tj@kernel.org \
    --cc=fenghua.yu@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liu.song.a23@gmail.com \
    --cc=lizefan@huawei.com \
    --cc=namhyung@kernel.org \
    --cc=rafael@kernel.org \
    --cc=reinette.chatre@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®