All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: <linux-fsdevel@vger.kernel.org>
Cc: <linux-ext4@vger.kernel.org>,
	Matthew Wilcox <willy@infradead.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 2/9] udf: Avoid GFP_NOFS allocation in udf_symlink()
Date: Tue, 23 Jan 2024 16:25:01 +0100	[thread overview]
Message-ID: <20240123152520.4294-2-jack@suse.cz> (raw)
In-Reply-To: <20240123152113.13352-1-jack@suse.cz>

The GFP_NOFS allocation in udf_symlink() is called only under
inode->i_rwsem and UDF_I(inode)->i_data_sem. The first is safe wrt
reclaim, the second should be as well but allocating unde this lock is
actually unnecessary. Move the allocation from under i_data_sem and
change it to GFP_KERNEL.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/udf/namei.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 1f14a0621a91..1308109fd42d 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -566,7 +566,7 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
 static int udf_symlink(struct mnt_idmap *idmap, struct inode *dir,
 		       struct dentry *dentry, const char *symname)
 {
-	struct inode *inode = udf_new_inode(dir, S_IFLNK | 0777);
+	struct inode *inode;
 	struct pathComponent *pc;
 	const char *compstart;
 	struct extent_position epos = {};
@@ -579,17 +579,20 @@ static int udf_symlink(struct mnt_idmap *idmap, struct inode *dir,
 	struct udf_inode_info *iinfo;
 	struct super_block *sb = dir->i_sb;
 
-	if (IS_ERR(inode))
-		return PTR_ERR(inode);
-
-	iinfo = UDF_I(inode);
-	down_write(&iinfo->i_data_sem);
-	name = kmalloc(UDF_NAME_LEN_CS0, GFP_NOFS);
+	name = kmalloc(UDF_NAME_LEN_CS0, GFP_KERNEL);
 	if (!name) {
 		err = -ENOMEM;
-		goto out_no_entry;
+		goto out;
+	}
+
+	inode = udf_new_inode(dir, S_IFLNK | 0777);
+	if (IS_ERR(inode)) {
+		err = PTR_ERR(inode);
+		goto out;
 	}
 
+	iinfo = UDF_I(inode);
+	down_write(&iinfo->i_data_sem);
 	inode->i_data.a_ops = &udf_symlink_aops;
 	inode->i_op = &udf_symlink_inode_operations;
 	inode_nohighmem(inode);
-- 
2.35.3


  parent reply	other threads:[~2024-01-23 15:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 15:24 [PATCH 0/9] Remove GFP_NOFS uses from ext2, udf, and quota code Jan Kara
2024-01-23 15:25 ` [PATCH 1/9] udf: Remove GFP_NOFS from dir iteration code Jan Kara
2024-01-23 15:25 ` Jan Kara [this message]
2024-01-23 15:25 ` [PATCH 3/9] udf: Avoid GFP_NOFS allocation in udf_load_pvoldesc() Jan Kara
2024-01-23 15:25 ` [PATCH 4/9] udf: Remove GFP_NOFS allocation in udf_expand_file_adinicb() Jan Kara
2024-01-23 15:25 ` [PATCH 5/9] ext2: Drop GFP_NOFS allocation from ext2_init_block_alloc_info() Jan Kara
2024-01-23 15:25 ` [PATCH 6/9] ext2: Drop GFP_NOFS use in ext2_get_blocks() Jan Kara
2024-01-23 15:25 ` [PATCH 7/9] ext2: Remove GFP_NOFS use in ext2_xattr_cache_insert() Jan Kara
2024-01-23 15:25 ` [PATCH 8/9] quota: Set nofs allocation context when acquiring dqio_sem Jan Kara
2024-01-23 15:25 ` [PATCH 9/9] quota: Drop GFP_NOFS instances under dquot->dq_lock and dqio_sem 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=20240123152520.4294-2-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --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.