linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "André Almeida" <andrealmeid@igalia.com>
To: Nathan Chancellor <nathan@kernel.org>
Cc: Hugh Dickins <hughd@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	krisman@kernel.org, Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com,
	Theodore Ts'o <tytso@mit.edu>
Subject: Re: [PATCH 3/3] tmpfs: Initialize sysfs during tmpfs init
Date: Fri, 1 Nov 2024 13:23:55 -0300	[thread overview]
Message-ID: <3754d3af-13bd-499b-9bca-633de721724f@igalia.com> (raw)
In-Reply-To: <20241101071942.GB2962282@thelio-3990X>

Em 01/11/2024 04:19, Nathan Chancellor escreveu:
> Hi André,
> 
> On Thu, Oct 31, 2024 at 10:37:41PM -0300, André Almeida wrote:
>> Instead of using fs_initcall(), initialize sysfs with the rest of the
>> filesystem. This is the right way to do it because otherwise any error
>> during tmpfs_sysfs_init() would get silently ignored. It's also useful
>> if tmpfs' sysfs ever need to display runtime information.
>>
>> Signed-off-by: André Almeida <andrealmeid@igalia.com>
>> ---
>>   mm/shmem.c | 130 ++++++++++++++++++++++++++++-------------------------
>>   1 file changed, 68 insertions(+), 62 deletions(-)
>>
>> diff --git a/mm/shmem.c b/mm/shmem.c
>> index 6038e1d11987..8ff2f619f531 100644
>> --- a/mm/shmem.c
>> +++ b/mm/shmem.c
>> @@ -5126,6 +5126,66 @@ static struct file_system_type shmem_fs_type = {
>>   	.fs_flags	= FS_USERNS_MOUNT | FS_ALLOW_IDMAP | FS_MGTIME,
>>   };
>>   
>> +#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS)
> 
> This condition...
> 
>> +static int __init tmpfs_sysfs_init(void)
>> +{
>> +	int ret;
>> +
>> +	tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj);
>> +	if (!tmpfs_kobj)
>> +		return -ENOMEM;
>> +
>> +	ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group);
>> +	if (ret)
>> +		kobject_put(tmpfs_kobj);
>> +
>> +	return ret;
>> +}
>> +#endif /* CONFIG_SYSFS && CONFIG_TMPFS */
>> +
>>   void __init shmem_init(void)
>>   {
>>   	int error;
>> @@ -5149,6 +5209,14 @@ void __init shmem_init(void)
>>   		goto out1;
>>   	}
>>   
>> +#ifdef CONFIG_SYSFS
> 
> and this condition are not the same, so there will be a compile error if
> CONFIG_SHMEM and CONFIG_SYSFS are enabled but CONFIG_TMPFS is not, such
> as with ARCH=x86_64 allnoconfig for me:
> 
>    mm/shmem.c: In function 'shmem_init':
>    mm/shmem.c:5243:17: error: implicit declaration of function 'tmpfs_sysfs_init'; did you mean 'uids_sysfs_init'? [-Wimplicit-function-declaration]
>     5243 |         error = tmpfs_sysfs_init();
>          |                 ^~~~~~~~~~~~~~~~
>          |                 uids_sysfs_init
> 

Thanks for the catch! Fixed for v2

>> +	error = tmpfs_sysfs_init();
>> +	if (error) {
>> +		pr_err("Could not init tmpfs sysfs\n");
>> +		goto out1;
>> +	}
>> +#endif
> 
> Cheers,
> Nathan



      reply	other threads:[~2024-11-01 16:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-01  1:37 [PATCH 0/3] tmpfs: Casefold fixes André Almeida
2024-11-01  1:37 ` [PATCH 1/3] libfs: Fix kernel-doc warning in generic_ci_validate_strict_name André Almeida
2024-11-01  1:37 ` [PATCH 2/3] tmpfs: Fix type for sysfs' casefold attribute André Almeida
2024-11-01  7:12   ` Nathan Chancellor
2024-11-01  1:37 ` [PATCH 3/3] tmpfs: Initialize sysfs during tmpfs init André Almeida
2024-11-01  7:19   ` Nathan Chancellor
2024-11-01 16:23     ` André Almeida [this message]

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=3754d3af-13bd-499b-9bca-633de721724f@igalia.com \
    --to=andrealmeid@igalia.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=hughd@google.com \
    --cc=jack@suse.cz \
    --cc=kernel-dev@igalia.com \
    --cc=krisman@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nathan@kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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