From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDCED329378 for ; Fri, 20 Mar 2026 13:43:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774014192; cv=none; b=JfmoE8OaD+OZEwXp3Der+zvfqK8t2E1MLKeYbDxEy/7ojKRL2LXl2YnPhFYjSWJRSNWjMynNjQdBKkqEqCUcIosU+DKLhuU8pCnzBLhjQbOb/QwUrx+wa4lHLxVtN+uDBsSm9cmQylSsCXQvSFbG7JUGiZxY7fs40PSezvkUNAw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774014192; c=relaxed/simple; bh=mdP2kASBf0yhnD0I35SUu4LGJDwskVC25FLk12a/mT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qGRZHqH/IVaenEcKdzpz5t4qFzHTBsTh1/hw6N74c16g+UiVpUggnozl5DdeOjGmZAiOoGB5TiNjTZ0vsqzhaivWnt93RmKCZjph91cSAW3z11pUKKo2EXXU3VlXrSJkR2WEoGSBMtltxT2so4BPqTjeI6v9wBluGjglqkKLNto= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=NnPjWetv; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=V1AUCraM; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=NnPjWetv; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=V1AUCraM; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="NnPjWetv"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="V1AUCraM"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="NnPjWetv"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="V1AUCraM" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 784D64D29D; Fri, 20 Mar 2026 13:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1774014105; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X/R3AGN6dIap1MXQgjeMm6isvpHyScocBtEis1Qb+TE=; b=NnPjWetvBmZtfTD3MTjGEYO7Q6u6qJgLQCH71ENSuqeMpffO19rjGmfA12TXdx8ewuvLBZ +VrcgZQDM8Aii7zC6EiyPWtSlZP8njw936/cZpnDWR0Pp8sX9SjyNW9jSCqVqURJkSxYdu tcSEnI2xNV86aIC2X6k36ClNBCIgLvE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1774014105; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X/R3AGN6dIap1MXQgjeMm6isvpHyScocBtEis1Qb+TE=; b=V1AUCraMDhgLYYKySi22zLtem+w2pkUEPBh53U/gku9ZoZ9le/oHUzk9zsDOFJ9bzuBNKf FB4iMiX//hk8t2Bg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1774014105; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X/R3AGN6dIap1MXQgjeMm6isvpHyScocBtEis1Qb+TE=; b=NnPjWetvBmZtfTD3MTjGEYO7Q6u6qJgLQCH71ENSuqeMpffO19rjGmfA12TXdx8ewuvLBZ +VrcgZQDM8Aii7zC6EiyPWtSlZP8njw936/cZpnDWR0Pp8sX9SjyNW9jSCqVqURJkSxYdu tcSEnI2xNV86aIC2X6k36ClNBCIgLvE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1774014105; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X/R3AGN6dIap1MXQgjeMm6isvpHyScocBtEis1Qb+TE=; b=V1AUCraMDhgLYYKySi22zLtem+w2pkUEPBh53U/gku9ZoZ9le/oHUzk9zsDOFJ9bzuBNKf FB4iMiX//hk8t2Bg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 610824281D; Fri, 20 Mar 2026 13:41:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id /v6uF5lOvWl6CQAAD6G6ig (envelope-from ); Fri, 20 Mar 2026 13:41:45 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 1B5CBA0B4E; Fri, 20 Mar 2026 14:41:45 +0100 (CET) From: Jan Kara To: Cc: , Christian Brauner , Al Viro , , Ted Tso , "Tigran A. Aivazian" , David Sterba , OGAWA Hirofumi , Muchun Song , Oscar Salvador , David Hildenbrand , linux-mm@kvack.org, linux-aio@kvack.org, Benjamin LaHaise , Jan Kara Subject: [PATCH 23/41] aio: Stop using i_private_data and i_private_lock Date: Fri, 20 Mar 2026 14:41:18 +0100 Message-ID: <20260320134100.20731-64-jack@suse.cz> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260320131728.6449-1-jack@suse.cz> References: <20260320131728.6449-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4888; i=jack@suse.cz; h=from:subject; bh=mdP2kASBf0yhnD0I35SUu4LGJDwskVC25FLk12a/mT4=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBpvU6AGGJT8GdQ+e+wtuFtTkXrw0gaAb7TMpeEt l5v77h9SHyJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCab1OgAAKCRCcnaoHP2RA 2b+PCACTnCG17oEenDQltzLldovJYV5viY+YhbnvX5R6+yyoQQ6SOBjIDorPklUNd2IET23qpLz Xx6dR8A++9iS5FuLNl5bb5uSpPbUNwR2vVlmgrpBI8v9r6Ydycp4WeYrn3qKlbgYIl/16X4uJUc w3kAub00KlyyTK6KcdiMcqO2/yk/8EfiKrK2LzD5m0q1t5PA4ncJU2KUrEXh9c75/+fhPdH+ZAQ AWG9YzLd+Od6tNs5qMw2w3wGIWJIf4+hePdrGJus2I0U3XeiXz8l8+OvOytctWZhd9HtvkpTuA3 g+EGzwn0dniI74zAM6AnGbsmTSpP4h/4ZdYD4/8HI15idmbF X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-5.30 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; TAGGED_RCPT(0.00)[]; RCPT_COUNT_TWELVE(0.00)[16]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_CC(0.00)[vger.kernel.org,kernel.org,ZenIV.linux.org.uk,mit.edu,gmail.com,suse.com,mail.parknet.co.jp,linux.dev,suse.de,kvack.org,suse.cz]; R_RATELIMIT(0.00)[to_ip_from(RLck8brw5hxmszoarioc7838it)]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_LAST(0.00)[]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:mid,suse.cz:email,imap1.dmz-prg2.suse.org:helo]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Flag: NO X-Spam-Score: -5.30 X-Spam-Level: Instead of using i_private_data and i_private_lock, just create aio inodes with appropriate necessary fields. Signed-off-by: Jan Kara --- fs/aio.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 12 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index a07bdd1aaaa6..ba9b9fa2446b 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -218,6 +218,17 @@ struct aio_kiocb { struct eventfd_ctx *ki_eventfd; }; +struct aio_inode_info { + struct inode vfs_inode; + spinlock_t migrate_lock; + struct kioctx *ctx; +}; + +static inline struct aio_inode_info *AIO_I(struct inode *inode) +{ + return container_of(inode, struct aio_inode_info, vfs_inode); +} + /*------ sysctl variables----*/ static DEFINE_SPINLOCK(aio_nr_lock); static unsigned long aio_nr; /* current system wide number of aio requests */ @@ -251,6 +262,7 @@ static void __init aio_sysctl_init(void) static struct kmem_cache *kiocb_cachep; static struct kmem_cache *kioctx_cachep; +static struct kmem_cache *aio_inode_cachep; static struct vfsmount *aio_mnt; @@ -261,11 +273,12 @@ static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages) { struct file *file; struct inode *inode = alloc_anon_inode(aio_mnt->mnt_sb); + if (IS_ERR(inode)) return ERR_CAST(inode); inode->i_mapping->a_ops = &aio_ctx_aops; - inode->i_mapping->i_private_data = ctx; + AIO_I(inode)->ctx = ctx; inode->i_size = PAGE_SIZE * nr_pages; file = alloc_file_pseudo(inode, aio_mnt, "[aio]", @@ -275,14 +288,49 @@ static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages) return file; } +static struct inode *aio_alloc_inode(struct super_block *sb) +{ + struct aio_inode_info *ai; + + ai = alloc_inode_sb(sb, aio_inode_cachep, GFP_KERNEL); + if (!ai) + return NULL; + ai->ctx = NULL; + + return &ai->vfs_inode; +} + +static void aio_free_inode(struct inode *inode) +{ + kmem_cache_free(aio_inode_cachep, AIO_I(inode)); +} + +static const struct super_operations aio_super_operations = { + .alloc_inode = aio_alloc_inode, + .free_inode = aio_free_inode, + .statfs = simple_statfs, +}; + static int aio_init_fs_context(struct fs_context *fc) { - if (!init_pseudo(fc, AIO_RING_MAGIC)) + struct pseudo_fs_context *pfc; + + pfc = init_pseudo(fc, AIO_RING_MAGIC); + if (!pfc) return -ENOMEM; fc->s_iflags |= SB_I_NOEXEC; + pfc->ops = &aio_super_operations; return 0; } +static void init_once(void *obj) +{ + struct aio_inode_info *ai = obj; + + inode_init_once(&ai->vfs_inode); + spin_lock_init(&ai->migrate_lock); +} + /* aio_setup * Creates the slab caches used by the aio routines, panic on * failure as this is done early during the boot sequence. @@ -294,6 +342,11 @@ static int __init aio_setup(void) .init_fs_context = aio_init_fs_context, .kill_sb = kill_anon_super, }; + + aio_inode_cachep = kmem_cache_create("aio_inode_cache", + sizeof(struct aio_inode_info), 0, + (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_ACCOUNT), + init_once); aio_mnt = kern_mount(&aio_fs); if (IS_ERR(aio_mnt)) panic("Failed to create aio fs mount."); @@ -308,17 +361,17 @@ __initcall(aio_setup); static void put_aio_ring_file(struct kioctx *ctx) { struct file *aio_ring_file = ctx->aio_ring_file; - struct address_space *i_mapping; if (aio_ring_file) { - truncate_setsize(file_inode(aio_ring_file), 0); + struct inode *inode = file_inode(aio_ring_file); + + truncate_setsize(inode, 0); /* Prevent further access to the kioctx from migratepages */ - i_mapping = aio_ring_file->f_mapping; - spin_lock(&i_mapping->i_private_lock); - i_mapping->i_private_data = NULL; + spin_lock(&AIO_I(inode)->migrate_lock); + AIO_I(inode)->ctx = NULL; ctx->aio_ring_file = NULL; - spin_unlock(&i_mapping->i_private_lock); + spin_unlock(&AIO_I(inode)->migrate_lock); fput(aio_ring_file); } @@ -408,13 +461,14 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, enum migrate_mode mode) { struct kioctx *ctx; + struct aio_inode_info *ai = AIO_I(mapping->host); unsigned long flags; pgoff_t idx; int rc = 0; - /* mapping->i_private_lock here protects against the kioctx teardown. */ - spin_lock(&mapping->i_private_lock); - ctx = mapping->i_private_data; + /* ai->migrate_lock here protects against the kioctx teardown. */ + spin_lock(&ai->migrate_lock); + ctx = ai->ctx; if (!ctx) { rc = -EINVAL; goto out; @@ -467,7 +521,7 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst, out_unlock: mutex_unlock(&ctx->ring_lock); out: - spin_unlock(&mapping->i_private_lock); + spin_unlock(&ai->migrate_lock); return rc; } #else -- 2.51.0