From: Julian Sun <sunjunchao2870@gmail.com>
To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
boyu.mt@taobao.com, tm@tao.ma,
Julian Sun <sunjunchao2870@gmail.com>
Subject: [PATCH 5/7] ext4: Refactor out ext4_da_write_inline_data_begin()
Date: Fri, 20 Dec 2024 23:16:23 +0800 [thread overview]
Message-ID: <20241220151625.19769-6-sunjunchao2870@gmail.com> (raw)
In-Reply-To: <20241220151625.19769-1-sunjunchao2870@gmail.com>
Refactor ext4_da_write_inline_data_begin() to simplify its
implementation by directly invoking ext4_generic_write_inline_data().
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
---
fs/ext4/inline.c | 74 ++----------------------------------------------
1 file changed, 2 insertions(+), 72 deletions(-)
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 7eaa578e1021..5dd91524b2ca 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -979,78 +979,8 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
struct folio **foliop,
void **fsdata)
{
- int ret;
- handle_t *handle;
- struct folio *folio;
- struct ext4_iloc iloc;
- int retries = 0;
-
- ret = ext4_get_inode_loc(inode, &iloc);
- if (ret)
- return ret;
-
-retry_journal:
- handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
- if (IS_ERR(handle)) {
- ret = PTR_ERR(handle);
- goto out;
- }
-
- ret = ext4_prepare_inline_data(handle, inode, pos + len);
- if (ret && ret != -ENOSPC)
- goto out_journal;
-
- if (ret == -ENOSPC) {
- ext4_journal_stop(handle);
- ret = ext4_da_convert_inline_data_to_extent(mapping,
- inode,
- fsdata);
- if (ret == -ENOSPC &&
- ext4_should_retry_alloc(inode->i_sb, &retries))
- goto retry_journal;
- goto out;
- }
-
- /*
- * We cannot recurse into the filesystem as the transaction
- * is already started.
- */
- folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
- mapping_gfp_mask(mapping));
- if (IS_ERR(folio)) {
- ret = PTR_ERR(folio);
- goto out_journal;
- }
-
- down_read(&EXT4_I(inode)->xattr_sem);
- if (!ext4_has_inline_data(inode)) {
- ret = 0;
- goto out_release_page;
- }
-
- if (!folio_test_uptodate(folio)) {
- ret = ext4_read_inline_folio(inode, folio);
- if (ret < 0)
- goto out_release_page;
- }
- ret = ext4_journal_get_write_access(handle, inode->i_sb, iloc.bh,
- EXT4_JTR_NONE);
- if (ret)
- goto out_release_page;
-
- up_read(&EXT4_I(inode)->xattr_sem);
- *foliop = folio;
- brelse(iloc.bh);
- return 1;
-out_release_page:
- up_read(&EXT4_I(inode)->xattr_sem);
- folio_unlock(folio);
- folio_put(folio);
-out_journal:
- ext4_journal_stop(handle);
-out:
- brelse(iloc.bh);
- return ret;
+ return ext4_generic_write_inline_data(mapping, inode, pos, len,
+ foliop, fsdata, true);
}
#ifdef INLINE_DIR_DEBUG
--
2.39.5
next prev parent reply other threads:[~2024-12-20 15:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 15:16 [PATCH 0/7] ext4: Convert truncated extent data to inline data Julian Sun
2024-12-20 15:16 ` [PATCH 1/7] ext4: Modify ei->i_flags before calling ext4_mark_iloc_dirty() Julian Sun
2025-01-06 15:25 ` Jan Kara
2025-01-07 2:53 ` Julian Sun
2024-12-20 15:16 ` [PATCH 2/7] ext4: Remove a redundant return statement Julian Sun
2025-01-06 15:23 ` Jan Kara
2024-12-20 15:16 ` [PATCH 3/7] ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodes Julian Sun
2025-01-06 15:23 ` Jan Kara
2024-12-20 15:16 ` [PATCH 4/7] ext4: Introduce a new helper function ext4_generic_write_inline_data() Julian Sun
2025-01-06 15:35 ` Jan Kara
2025-01-07 2:57 ` Julian Sun
2024-12-20 15:16 ` Julian Sun [this message]
2025-01-06 15:39 ` [PATCH 5/7] ext4: Refactor out ext4_da_write_inline_data_begin() Jan Kara
2025-01-07 2:58 ` Julian Sun
2024-12-20 15:16 ` [PATCH 6/7] ext4: Refactor out ext4_try_to_write_inline_data() Julian Sun
2025-01-06 15:40 ` Jan Kara
2024-12-20 15:16 ` [PATCH 7/7] ext4: Store truncated large files as inline data Julian Sun
2025-01-06 15:51 ` [PATCH 0/7] ext4: Convert truncated extent data to " Jan Kara
2025-01-07 6:03 ` Julian Sun
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=20241220151625.19769-6-sunjunchao2870@gmail.com \
--to=sunjunchao2870@gmail.com \
--cc=adilger.kernel@dilger.ca \
--cc=boyu.mt@taobao.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tm@tao.ma \
--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
all inboxes | Powered by JetHome®