linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Naoto Kobayashi <naoto.kobayashi4c@gmail.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca
Cc: Naoto Kobayashi <naoto.kobayashi4c@gmail.com>,
	linux-ext4@vger.kernel.org
Subject: [PATCH v2 2/3] ext4: Rename ext4_kvmalloc() to ext4_kvmalloc_nofs() and drop its flags argument
Date: Fri, 27 Dec 2019 17:05:22 +0900	[thread overview]
Message-ID: <20191227080523.31808-3-naoto.kobayashi4c@gmail.com> (raw)
In-Reply-To: <20191227080523.31808-1-naoto.kobayashi4c@gmail.com>

Rename ext4_kvmalloc() to ext4_kvmalloc_nofs() and drop
its flags argument, because ext4_kvmalloc() callers must be
under GFP_NOFS (otherwise, they should use generic kvmalloc()
helper function).

Signed-off-by: Naoto Kobayashi <naoto.kobayashi4c@gmail.com>
---
 fs/ext4/ext4.h   |  2 +-
 fs/ext4/resize.c | 10 ++++------
 fs/ext4/super.c  |  6 +++---
 fs/ext4/xattr.c  |  2 +-
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index b25089e3896d..e1bdeffca0ad 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2677,7 +2677,7 @@ extern struct buffer_head *ext4_sb_bread(struct super_block *sb,
 extern int ext4_seq_options_show(struct seq_file *seq, void *offset);
 extern int ext4_calculate_overhead(struct super_block *sb);
 extern void ext4_superblock_csum_set(struct super_block *sb);
-extern void *ext4_kvmalloc(size_t size, gfp_t flags);
+extern void *ext4_kvmalloc_nofs(size_t size);
 extern int ext4_alloc_flex_bg_array(struct super_block *sb,
 				    ext4_group_t ngroup);
 extern const char *ext4_decode_error(struct super_block *sb, int errno,
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index a8c0f2b5b6e1..7998bbe66eed 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -824,9 +824,8 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
 	if (unlikely(err))
 		goto errout;

-	n_group_desc = ext4_kvmalloc((gdb_num + 1) *
-				     sizeof(struct buffer_head *),
-				     GFP_NOFS);
+	n_group_desc = ext4_kvmalloc_nofs((gdb_num + 1) *
+				     sizeof(struct buffer_head *));
 	if (!n_group_desc) {
 		err = -ENOMEM;
 		ext4_warning(sb, "not enough memory for %lu groups",
@@ -900,9 +899,8 @@ static int add_new_gdb_meta_bg(struct super_block *sb,
 	gdb_bh = ext4_sb_bread(sb, gdblock, 0);
 	if (IS_ERR(gdb_bh))
 		return PTR_ERR(gdb_bh);
-	n_group_desc = ext4_kvmalloc((gdb_num + 1) *
-				     sizeof(struct buffer_head *),
-				     GFP_NOFS);
+	n_group_desc = ext4_kvmalloc_nofs((gdb_num + 1) *
+				     sizeof(struct buffer_head *));
 	if (!n_group_desc) {
 		brelse(gdb_bh);
 		err = -ENOMEM;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 83a231dedcbf..e8965aa6ecce 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -204,13 +204,13 @@ void ext4_superblock_csum_set(struct super_block *sb)
 	es->s_checksum = ext4_superblock_csum(sb, es);
 }

-void *ext4_kvmalloc(size_t size, gfp_t flags)
+void *ext4_kvmalloc_nofs(size_t size)
 {
 	void *ret;

-	ret = kmalloc(size, flags | __GFP_NOWARN);
+	ret = kmalloc(size, GFP_NOFS | __GFP_NOWARN);
 	if (!ret)
-		ret = __vmalloc(size, flags, PAGE_KERNEL);
+		ret = __vmalloc(size, GFP_NOFS, PAGE_KERNEL);
 	return ret;
 }

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 8966a5439a22..d5bc970ef331 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1456,7 +1456,7 @@ ext4_xattr_inode_cache_find(struct inode *inode, const void *value,
 	if (!ce)
 		return NULL;

-	ea_data = ext4_kvmalloc(value_len, GFP_NOFS);
+	ea_data = ext4_kvmalloc_nofs(value_len);
 	if (!ea_data) {
 		mb_cache_entry_put(ea_inode_cache, ce);
 		return NULL;
--
2.16.6


  parent reply	other threads:[~2019-12-27  8:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-27  8:05 [PATCH v2 0/3] ext4: Prevent memory reclaim from re-entering the filesystem and deadlocking Naoto Kobayashi
2019-12-27  8:05 ` [PATCH v2 1/3] ext4: Delete ext4_kvzvalloc() Naoto Kobayashi
2020-01-09  9:51   ` Jan Kara
2020-01-13 22:32   ` Theodore Y. Ts'o
2019-12-27  8:05 ` Naoto Kobayashi [this message]
2020-01-09 10:00   ` [PATCH v2 2/3] ext4: Rename ext4_kvmalloc() to ext4_kvmalloc_nofs() and drop its flags argument Jan Kara
2020-01-13 22:32   ` Theodore Y. Ts'o
2020-01-16 12:37     ` Jan Kara
2020-01-16 15:12       ` Theodore Y. Ts'o
2020-01-16 15:50         ` [PATCH] ext4: drop ext4_kvmalloc() Theodore Ts'o
2020-01-17 10:30           ` Jan Kara
2020-01-17 16:36             ` Theodore Y. Ts'o
2019-12-27  8:05 ` [PATCH v2 3/3] ext4: Prevent ext4_kvmalloc_nofs() from re-entering the filesystem and deadlocking Naoto Kobayashi

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=20191227080523.31808-3-naoto.kobayashi4c@gmail.com \
    --to=naoto.kobayashi4c@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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;
as well as URLs for NNTP newsgroup(s).