* [PATCH v2 0/5] Some cleanups and refactoring of the inline data code
@ 2025-01-07 4:46 Julian Sun
2025-01-07 4:46 ` [PATCH v2 1/5] ext4: Remove a redundant return statement Julian Sun
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Julian Sun @ 2025-01-07 4:46 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, adilger.kernel, jack, Julian Sun
Here are some cleanups and refactoring of the inline data code. Please see
patches for details.
Julian Sun (5):
ext4: Remove a redundant return statement
ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodes
ext4: Introduce a new helper function ext4_generic_write_inline_data()
ext4: Replace ext4_da_write_inline_data_begin() with
ext4_generic_write_inline_data().
ext4: Refactor out ext4_try_to_write_inline_data()
fs/ext4/ext4.h | 10 +-
fs/ext4/extents_status.c | 1 -
fs/ext4/ialloc.c | 2 +-
fs/ext4/inline.c | 199 +++++++++++++--------------------------
fs/ext4/inode.c | 4 +-
5 files changed, 75 insertions(+), 141 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/5] ext4: Remove a redundant return statement
2025-01-07 4:46 [PATCH v2 0/5] Some cleanups and refactoring of the inline data code Julian Sun
@ 2025-01-07 4:46 ` Julian Sun
2025-01-07 4:46 ` [PATCH v2 2/5] ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodes Julian Sun
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Julian Sun @ 2025-01-07 4:46 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, adilger.kernel, jack, Julian Sun
Remove a redundant return statements in the
ext4_es_remove_extent() function.
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
fs/ext4/extents_status.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index c786691dabd3..c56fb682a27e 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -1551,7 +1551,6 @@ void ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
ext4_es_print_tree(inode);
ext4_da_release_space(inode, reserved);
- return;
}
static int __es_shrink(struct ext4_sb_info *sbi, int nr_to_scan,
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/5] ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodes
2025-01-07 4:46 [PATCH v2 0/5] Some cleanups and refactoring of the inline data code Julian Sun
2025-01-07 4:46 ` [PATCH v2 1/5] ext4: Remove a redundant return statement Julian Sun
@ 2025-01-07 4:46 ` Julian Sun
2025-01-07 4:55 ` [PATCH v2 3/5] ext4: Introduce a new helper function ext4_generic_write_inline_data() Julian Sun
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Julian Sun @ 2025-01-07 4:46 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, adilger.kernel, jack, Julian Sun
Setting the EXT4_STATE_MAY_INLINE_DATA flag for ea inodes
is meaningless because ea inodes do not use functions
like ext4_write_begin().
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
fs/ext4/ialloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 7f1a5f90dbbd..49b112bfbd93 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1297,7 +1297,7 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
ei->i_extra_isize = sbi->s_want_extra_isize;
ei->i_inline_off = 0;
if (ext4_has_feature_inline_data(sb) &&
- (!(ei->i_flags & EXT4_DAX_FL) || S_ISDIR(mode)))
+ (!(ei->i_flags & (EXT4_DAX_FL|EXT4_EA_INODE_FL)) || S_ISDIR(mode)))
ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
ret = inode;
err = dquot_alloc_inode(inode);
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/5] ext4: Introduce a new helper function ext4_generic_write_inline_data()
2025-01-07 4:46 [PATCH v2 0/5] Some cleanups and refactoring of the inline data code Julian Sun
2025-01-07 4:46 ` [PATCH v2 1/5] ext4: Remove a redundant return statement Julian Sun
2025-01-07 4:46 ` [PATCH v2 2/5] ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodes Julian Sun
@ 2025-01-07 4:55 ` Julian Sun
2025-01-07 4:57 ` [PATCH v2 4/5] ext4: Replace ext4_da_write_inline_data_begin() with ext4_generic_write_inline_data() Julian Sun
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Julian Sun @ 2025-01-07 4:55 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, adilger.kernel, jack, Julian Sun
A new function, ext4_generic_write_inline_data(), is introduced
to provide a generic implementation of the common logic found in
ext4_da_write_inline_data_begin() and ext4_try_to_write_inline_data().
This function will be utilized in the subsequent two patches.
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
fs/ext4/inline.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 3536ca7e4fcc..3e103e003afb 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -20,6 +20,11 @@
#define EXT4_INLINE_DOTDOT_OFFSET 2
#define EXT4_INLINE_DOTDOT_SIZE 4
+
+static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping,
+ struct inode *inode,
+ void **fsdata);
+
static int ext4_get_inline_size(struct inode *inode)
{
if (EXT4_I(inode)->i_inline_off)
@@ -652,6 +657,87 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
return ret;
}
+static int ext4_generic_write_inline_data(struct address_space *mapping,
+ struct inode *inode,
+ loff_t pos, unsigned len,
+ struct folio **foliop,
+ void **fsdata, bool da)
+{
+ 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_release_bh;
+ }
+
+ ret = ext4_prepare_inline_data(handle, inode, pos + len);
+ if (ret && ret != -ENOSPC)
+ goto out_stop_journal;
+
+ if (ret == -ENOSPC) {
+ ext4_journal_stop(handle);
+ if (!da) {
+ brelse(iloc.bh);
+ /* Retry inside */
+ return ext4_convert_inline_data_to_extent(mapping, inode);
+ }
+
+ 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_release_bh;
+ }
+
+ folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
+ mapping_gfp_mask(mapping));
+ if (IS_ERR(folio)) {
+ ret = PTR_ERR(folio);
+ goto out_stop_journal;
+ }
+
+ down_read(&EXT4_I(inode)->xattr_sem);
+ /* Someone else had converted it to extent */
+ if (!ext4_has_inline_data(inode)) {
+ ret = 0;
+ goto out_release_folio;
+ }
+
+ if (!folio_test_uptodate(folio)) {
+ ret = ext4_read_inline_folio(inode, folio);
+ if (ret < 0)
+ goto out_release_folio;
+ }
+
+ ret = ext4_journal_get_write_access(handle, inode->i_sb, iloc.bh, EXT4_JTR_NONE);
+ if (ret)
+ goto out_release_folio;
+ *foliop = folio;
+ up_read(&EXT4_I(inode)->xattr_sem);
+ brelse(iloc.bh);
+ return 1;
+
+out_release_folio:
+ up_read(&EXT4_I(inode)->xattr_sem);
+ folio_unlock(folio);
+ folio_put(folio);
+out_stop_journal:
+ ext4_journal_stop(handle);
+out_release_bh:
+ brelse(iloc.bh);
+ return ret;
+}
+
/*
* Try to write data in the inode.
* If the inode has inline data, check whether the new write can be
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/5] ext4: Replace ext4_da_write_inline_data_begin() with ext4_generic_write_inline_data().
2025-01-07 4:46 [PATCH v2 0/5] Some cleanups and refactoring of the inline data code Julian Sun
` (2 preceding siblings ...)
2025-01-07 4:55 ` [PATCH v2 3/5] ext4: Introduce a new helper function ext4_generic_write_inline_data() Julian Sun
@ 2025-01-07 4:57 ` Julian Sun
2025-01-07 10:54 ` Jan Kara
2025-01-07 4:57 ` [PATCH v2 5/5] ext4: Refactor out ext4_try_to_write_inline_data() Julian Sun
2025-03-18 3:41 ` [PATCH v2 0/5] Some cleanups and refactoring of the inline data code Theodore Ts'o
5 siblings, 1 reply; 8+ messages in thread
From: Julian Sun @ 2025-01-07 4:57 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, adilger.kernel, jack, Julian Sun
Replace the call to ext4_da_write_inline_data_begin() with
ext4_generic_write_inline_data(), and delete the
ext4_da_write_inline_data_begin().
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
---
fs/ext4/ext4.h | 10 ++---
fs/ext4/inline.c | 98 +++++-------------------------------------------
fs/ext4/inode.c | 4 +-
3 files changed, 16 insertions(+), 96 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 44b0d418143c..78dd3408ff39 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3569,11 +3569,11 @@ extern int ext4_try_to_write_inline_data(struct address_space *mapping,
struct folio **foliop);
int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
unsigned copied, struct folio *folio);
-extern int ext4_da_write_inline_data_begin(struct address_space *mapping,
- struct inode *inode,
- loff_t pos, unsigned len,
- struct folio **foliop,
- void **fsdata);
+extern int ext4_generic_write_inline_data(struct address_space *mapping,
+ struct inode *inode,
+ loff_t pos, unsigned len,
+ struct folio **foliop,
+ void **fsdata, bool da);
extern int ext4_try_add_inline_entry(handle_t *handle,
struct ext4_filename *fname,
struct inode *dir, struct inode *inode);
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 3e103e003afb..58d8fcfbecba 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -657,7 +657,15 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
return ret;
}
-static int ext4_generic_write_inline_data(struct address_space *mapping,
+/*
+ * Prepare the write for the inline data.
+ * If the data can be written into the inode, we just read
+ * the page and make it uptodate, and start the journal.
+ * Otherwise read the page, makes it dirty so that it can be
+ * handle in writepages(the i_disksize update is left to the
+ * normal ext4_da_write_end).
+ */
+int ext4_generic_write_inline_data(struct address_space *mapping,
struct inode *inode,
loff_t pos, unsigned len,
struct folio **foliop,
@@ -967,94 +975,6 @@ static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping,
return ret;
}
-/*
- * Prepare the write for the inline data.
- * If the data can be written into the inode, we just read
- * the page and make it uptodate, and start the journal.
- * Otherwise read the page, makes it dirty so that it can be
- * handle in writepages(the i_disksize update is left to the
- * normal ext4_da_write_end).
- */
-int ext4_da_write_inline_data_begin(struct address_space *mapping,
- struct inode *inode,
- loff_t pos, unsigned len,
- 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;
-}
-
#ifdef INLINE_DIR_DEBUG
void ext4_show_inline_dir(struct inode *dir, struct buffer_head *bh,
void *inline_start, int inline_size)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 54bdd4884fe6..24a3b0ff4c8a 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2918,8 +2918,8 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
trace_ext4_da_write_begin(inode, pos, len);
if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) {
- ret = ext4_da_write_inline_data_begin(mapping, inode, pos, len,
- foliop, fsdata);
+ ret = ext4_generic_write_inline_data(mapping, inode, pos, len,
+ foliop, fsdata, true);
if (ret < 0)
return ret;
if (ret == 1)
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 5/5] ext4: Refactor out ext4_try_to_write_inline_data()
2025-01-07 4:46 [PATCH v2 0/5] Some cleanups and refactoring of the inline data code Julian Sun
` (3 preceding siblings ...)
2025-01-07 4:57 ` [PATCH v2 4/5] ext4: Replace ext4_da_write_inline_data_begin() with ext4_generic_write_inline_data() Julian Sun
@ 2025-01-07 4:57 ` Julian Sun
2025-03-18 3:41 ` [PATCH v2 0/5] Some cleanups and refactoring of the inline data code Theodore Ts'o
5 siblings, 0 replies; 8+ messages in thread
From: Julian Sun @ 2025-01-07 4:57 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, adilger.kernel, jack, Julian Sun
Refactor ext4_try_to_write_inline_data() to simplify its
implementation by directly invoking ext4_generic_write_inline_data().
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
fs/ext4/inline.c | 77 ++----------------------------------------------
1 file changed, 3 insertions(+), 74 deletions(-)
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 58d8fcfbecba..a651a033e518 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -757,81 +757,10 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
loff_t pos, unsigned len,
struct folio **foliop)
{
- int ret;
- handle_t *handle;
- struct folio *folio;
- struct ext4_iloc iloc;
-
if (pos + len > ext4_get_max_inline_size(inode))
- goto convert;
-
- ret = ext4_get_inode_loc(inode, &iloc);
- if (ret)
- return ret;
-
- /*
- * The possible write could happen in the inode,
- * so try to reserve the space in inode first.
- */
- handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
- if (IS_ERR(handle)) {
- ret = PTR_ERR(handle);
- handle = NULL;
- goto out;
- }
-
- ret = ext4_prepare_inline_data(handle, inode, pos + len);
- if (ret && ret != -ENOSPC)
- goto out;
-
- /* We don't have space in inline inode, so convert it to extent. */
- if (ret == -ENOSPC) {
- ext4_journal_stop(handle);
- brelse(iloc.bh);
- goto convert;
- }
-
- ret = ext4_journal_get_write_access(handle, inode->i_sb, iloc.bh,
- EXT4_JTR_NONE);
- if (ret)
- goto out;
-
- folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
- mapping_gfp_mask(mapping));
- if (IS_ERR(folio)) {
- ret = PTR_ERR(folio);
- goto out;
- }
-
- *foliop = folio;
- down_read(&EXT4_I(inode)->xattr_sem);
- if (!ext4_has_inline_data(inode)) {
- ret = 0;
- folio_unlock(folio);
- folio_put(folio);
- goto out_up_read;
- }
-
- if (!folio_test_uptodate(folio)) {
- ret = ext4_read_inline_folio(inode, folio);
- if (ret < 0) {
- folio_unlock(folio);
- folio_put(folio);
- goto out_up_read;
- }
- }
-
- ret = 1;
- handle = NULL;
-out_up_read:
- up_read(&EXT4_I(inode)->xattr_sem);
-out:
- if (handle && (ret != 1))
- ext4_journal_stop(handle);
- brelse(iloc.bh);
- return ret;
-convert:
- return ext4_convert_inline_data_to_extent(mapping, inode);
+ return ext4_convert_inline_data_to_extent(mapping, inode);
+ return ext4_generic_write_inline_data(mapping, inode, pos, len,
+ foliop, NULL, false);
}
int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 4/5] ext4: Replace ext4_da_write_inline_data_begin() with ext4_generic_write_inline_data().
2025-01-07 4:57 ` [PATCH v2 4/5] ext4: Replace ext4_da_write_inline_data_begin() with ext4_generic_write_inline_data() Julian Sun
@ 2025-01-07 10:54 ` Jan Kara
0 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2025-01-07 10:54 UTC (permalink / raw)
To: Julian Sun; +Cc: linux-ext4, tytso, adilger.kernel, jack
On Tue 07-01-25 12:57:10, Julian Sun wrote:
> Replace the call to ext4_da_write_inline_data_begin() with
> ext4_generic_write_inline_data(), and delete the
> ext4_da_write_inline_data_begin().
>
> Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/ext4.h | 10 ++---
> fs/ext4/inline.c | 98 +++++-------------------------------------------
> fs/ext4/inode.c | 4 +-
> 3 files changed, 16 insertions(+), 96 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 44b0d418143c..78dd3408ff39 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3569,11 +3569,11 @@ extern int ext4_try_to_write_inline_data(struct address_space *mapping,
> struct folio **foliop);
> int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
> unsigned copied, struct folio *folio);
> -extern int ext4_da_write_inline_data_begin(struct address_space *mapping,
> - struct inode *inode,
> - loff_t pos, unsigned len,
> - struct folio **foliop,
> - void **fsdata);
> +extern int ext4_generic_write_inline_data(struct address_space *mapping,
> + struct inode *inode,
> + loff_t pos, unsigned len,
> + struct folio **foliop,
> + void **fsdata, bool da);
> extern int ext4_try_add_inline_entry(handle_t *handle,
> struct ext4_filename *fname,
> struct inode *dir, struct inode *inode);
> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> index 3e103e003afb..58d8fcfbecba 100644
> --- a/fs/ext4/inline.c
> +++ b/fs/ext4/inline.c
> @@ -657,7 +657,15 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
> return ret;
> }
>
> -static int ext4_generic_write_inline_data(struct address_space *mapping,
> +/*
> + * Prepare the write for the inline data.
> + * If the data can be written into the inode, we just read
> + * the page and make it uptodate, and start the journal.
> + * Otherwise read the page, makes it dirty so that it can be
> + * handle in writepages(the i_disksize update is left to the
> + * normal ext4_da_write_end).
> + */
> +int ext4_generic_write_inline_data(struct address_space *mapping,
> struct inode *inode,
> loff_t pos, unsigned len,
> struct folio **foliop,
> @@ -967,94 +975,6 @@ static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping,
> return ret;
> }
>
> -/*
> - * Prepare the write for the inline data.
> - * If the data can be written into the inode, we just read
> - * the page and make it uptodate, and start the journal.
> - * Otherwise read the page, makes it dirty so that it can be
> - * handle in writepages(the i_disksize update is left to the
> - * normal ext4_da_write_end).
> - */
> -int ext4_da_write_inline_data_begin(struct address_space *mapping,
> - struct inode *inode,
> - loff_t pos, unsigned len,
> - 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;
> -}
> -
> #ifdef INLINE_DIR_DEBUG
> void ext4_show_inline_dir(struct inode *dir, struct buffer_head *bh,
> void *inline_start, int inline_size)
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 54bdd4884fe6..24a3b0ff4c8a 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -2918,8 +2918,8 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
> trace_ext4_da_write_begin(inode, pos, len);
>
> if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) {
> - ret = ext4_da_write_inline_data_begin(mapping, inode, pos, len,
> - foliop, fsdata);
> + ret = ext4_generic_write_inline_data(mapping, inode, pos, len,
> + foliop, fsdata, true);
> if (ret < 0)
> return ret;
> if (ret == 1)
> --
> 2.39.5
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/5] Some cleanups and refactoring of the inline data code
2025-01-07 4:46 [PATCH v2 0/5] Some cleanups and refactoring of the inline data code Julian Sun
` (4 preceding siblings ...)
2025-01-07 4:57 ` [PATCH v2 5/5] ext4: Refactor out ext4_try_to_write_inline_data() Julian Sun
@ 2025-03-18 3:41 ` Theodore Ts'o
5 siblings, 0 replies; 8+ messages in thread
From: Theodore Ts'o @ 2025-03-18 3:41 UTC (permalink / raw)
To: linux-ext4, Julian Sun; +Cc: Theodore Ts'o, adilger.kernel, jack
On Tue, 07 Jan 2025 12:46:57 +0800, Julian Sun wrote:
> Here are some cleanups and refactoring of the inline data code. Please see
> patches for details.
>
> Julian Sun (5):
> ext4: Remove a redundant return statement
> ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodes
> ext4: Introduce a new helper function ext4_generic_write_inline_data()
> ext4: Replace ext4_da_write_inline_data_begin() with
> ext4_generic_write_inline_data().
> ext4: Refactor out ext4_try_to_write_inline_data()
>
> [...]
Applied, thanks!
[1/5] ext4: Remove a redundant return statement
commit: f896776a7019ebc6403504262cd4239aaa9b99ba
[2/5] ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodes
commit: 90c764b4b7f683ca62dbeeceea0ea3a0c6831200
[3/5] ext4: Introduce a new helper function ext4_generic_write_inline_data()
commit: 3db572f780e9dd7be33d5ac3fb3f0e70a9d4a82d
[4/5] ext4: Replace ext4_da_write_inline_data_begin() with ext4_generic_write_inline_data().
commit: f9bdb042dfae981d34911a6184157a720fce5e3d
[5/5] ext4: Refactor out ext4_try_to_write_inline_data()
commit: 30cbe84d48d7d704fdaaf5179a0f4e0764ca35ab
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-03-18 3:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-07 4:46 [PATCH v2 0/5] Some cleanups and refactoring of the inline data code Julian Sun
2025-01-07 4:46 ` [PATCH v2 1/5] ext4: Remove a redundant return statement Julian Sun
2025-01-07 4:46 ` [PATCH v2 2/5] ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodes Julian Sun
2025-01-07 4:55 ` [PATCH v2 3/5] ext4: Introduce a new helper function ext4_generic_write_inline_data() Julian Sun
2025-01-07 4:57 ` [PATCH v2 4/5] ext4: Replace ext4_da_write_inline_data_begin() with ext4_generic_write_inline_data() Julian Sun
2025-01-07 10:54 ` Jan Kara
2025-01-07 4:57 ` [PATCH v2 5/5] ext4: Refactor out ext4_try_to_write_inline_data() Julian Sun
2025-03-18 3:41 ` [PATCH v2 0/5] Some cleanups and refactoring of the inline data code Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox