* [PATCH 1/3] ext4: add i_data_sem sanity check
@ 2014-07-21 15:04 Dmitry Monakhov
2014-07-21 15:04 ` [PATCH 2/3] ext4: use correct depth value Dmitry Monakhov
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Dmitry Monakhov @ 2014-07-21 15:04 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, Dmitry Monakhov
Each caller of ext4_ext_dirty must hold i_data_sem,
The only exception is migration code, let's make it convenient.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/ext4/extents.c | 2 ++
fs/ext4/migrate.c | 7 +++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index b30172d..ee93f82 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -161,6 +161,8 @@ int __ext4_ext_dirty(const char *where, unsigned int line, handle_t *handle,
struct inode *inode, struct ext4_ext_path *path)
{
int err;
+
+ WARN_ON(!rwsem_is_locked(&EXT4_I(inode)->i_data_sem));
if (path->p_bh) {
ext4_extent_block_csum_set(inode, ext_block_hdr(path->p_bh));
/* path points to block */
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index ec09243..d3567f2 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -39,6 +39,8 @@ static int finish_range(handle_t *handle, struct inode *inode,
newext.ee_block = cpu_to_le32(lb->first_block);
newext.ee_len = cpu_to_le16(lb->last_block - lb->first_block + 1);
ext4_ext_store_pblock(&newext, lb->first_pblock);
+ /* Locking only for convinience since we are operating on temp inode */
+ down_write(&EXT4_I(inode)->i_data_sem);
path = ext4_ext_find_extent(inode, lb->first_block, NULL, 0);
if (IS_ERR(path)) {
@@ -61,7 +63,9 @@ static int finish_range(handle_t *handle, struct inode *inode,
*/
if (needed && ext4_handle_has_enough_credits(handle,
EXT4_RESERVE_TRANS_BLOCKS)) {
+ up_write((&EXT4_I(inode)->i_data_sem));
retval = ext4_journal_restart(handle, needed);
+ down_write((&EXT4_I(inode)->i_data_sem));
if (retval)
goto err_out;
} else if (needed) {
@@ -70,13 +74,16 @@ static int finish_range(handle_t *handle, struct inode *inode,
/*
* IF not able to extend the journal restart the journal
*/
+ up_write((&EXT4_I(inode)->i_data_sem));
retval = ext4_journal_restart(handle, needed);
+ down_write((&EXT4_I(inode)->i_data_sem));
if (retval)
goto err_out;
}
}
retval = ext4_ext_insert_extent(handle, inode, path, &newext, 0);
err_out:
+ up_write((&EXT4_I(inode)->i_data_sem));
if (path) {
ext4_ext_drop_refs(path);
kfree(path);
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] ext4: use correct depth value
2014-07-21 15:04 [PATCH 1/3] ext4: add i_data_sem sanity check Dmitry Monakhov
@ 2014-07-21 15:04 ` Dmitry Monakhov
2014-07-21 19:48 ` Jan Kara
2014-07-21 15:04 ` [PATCH 3/3] ext4: fix incorrect locking in move_extent_per_page Dmitry Monakhov
2014-07-21 19:35 ` [PATCH 1/3] ext4: add i_data_sem sanity check Jan Kara
2 siblings, 1 reply; 9+ messages in thread
From: Dmitry Monakhov @ 2014-07-21 15:04 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, Dmitry Monakhov
Inode's depth can be changed from here:
ext4_ext_try_to_merge() ->ext4_ext_try_to_merge_up()
We must use correct value.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/ext4/extents.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index ee93f82..6950bab 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3254,7 +3254,7 @@ out:
fix_extent_len:
ex->ee_len = orig_ex.ee_len;
- ext4_ext_dirty(handle, inode, path + depth);
+ ext4_ext_dirty(handle, inode, path + path->p_depth);
return err;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] ext4: fix incorrect locking in move_extent_per_page
2014-07-21 15:04 [PATCH 1/3] ext4: add i_data_sem sanity check Dmitry Monakhov
2014-07-21 15:04 ` [PATCH 2/3] ext4: use correct depth value Dmitry Monakhov
@ 2014-07-21 15:04 ` Dmitry Monakhov
2014-07-21 19:51 ` Jan Kara
2014-07-21 19:35 ` [PATCH 1/3] ext4: add i_data_sem sanity check Jan Kara
2 siblings, 1 reply; 9+ messages in thread
From: Dmitry Monakhov @ 2014-07-21 15:04 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, Dmitry Monakhov
If we have to copy data we must drop i_data_sem because of
get_blocks() will be called inside mext_page_mkuptodate(), but later we must
reacquire it again because we are about to change extent's tree
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/ext4/move_extent.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index 2484c7e..671a74b 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -1013,10 +1013,11 @@ data_copy:
*err = -EBUSY;
goto unlock_pages;
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] ext4: add i_data_sem sanity check
2014-07-21 15:04 [PATCH 1/3] ext4: add i_data_sem sanity check Dmitry Monakhov
2014-07-21 15:04 ` [PATCH 2/3] ext4: use correct depth value Dmitry Monakhov
2014-07-21 15:04 ` [PATCH 3/3] ext4: fix incorrect locking in move_extent_per_page Dmitry Monakhov
@ 2014-07-21 19:35 ` Jan Kara
2014-07-28 2:29 ` Theodore Ts'o
2 siblings, 1 reply; 9+ messages in thread
From: Jan Kara @ 2014-07-21 19:35 UTC (permalink / raw)
To: Dmitry Monakhov; +Cc: linux-ext4, tytso
On Mon 21-07-14 19:04:47, Dmitry Monakhov wrote:
> Each caller of ext4_ext_dirty must hold i_data_sem,
> The only exception is migration code, let's make it convenient.
>
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/extents.c | 2 ++
> fs/ext4/migrate.c | 7 +++++++
> 2 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index b30172d..ee93f82 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -161,6 +161,8 @@ int __ext4_ext_dirty(const char *where, unsigned int line, handle_t *handle,
> struct inode *inode, struct ext4_ext_path *path)
> {
> int err;
> +
> + WARN_ON(!rwsem_is_locked(&EXT4_I(inode)->i_data_sem));
> if (path->p_bh) {
> ext4_extent_block_csum_set(inode, ext_block_hdr(path->p_bh));
> /* path points to block */
> diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
> index ec09243..d3567f2 100644
> --- a/fs/ext4/migrate.c
> +++ b/fs/ext4/migrate.c
> @@ -39,6 +39,8 @@ static int finish_range(handle_t *handle, struct inode *inode,
> newext.ee_block = cpu_to_le32(lb->first_block);
> newext.ee_len = cpu_to_le16(lb->last_block - lb->first_block + 1);
> ext4_ext_store_pblock(&newext, lb->first_pblock);
> + /* Locking only for convinience since we are operating on temp inode */
> + down_write(&EXT4_I(inode)->i_data_sem);
> path = ext4_ext_find_extent(inode, lb->first_block, NULL, 0);
>
> if (IS_ERR(path)) {
> @@ -61,7 +63,9 @@ static int finish_range(handle_t *handle, struct inode *inode,
> */
> if (needed && ext4_handle_has_enough_credits(handle,
> EXT4_RESERVE_TRANS_BLOCKS)) {
> + up_write((&EXT4_I(inode)->i_data_sem));
> retval = ext4_journal_restart(handle, needed);
> + down_write((&EXT4_I(inode)->i_data_sem));
> if (retval)
> goto err_out;
> } else if (needed) {
> @@ -70,13 +74,16 @@ static int finish_range(handle_t *handle, struct inode *inode,
> /*
> * IF not able to extend the journal restart the journal
> */
> + up_write((&EXT4_I(inode)->i_data_sem));
> retval = ext4_journal_restart(handle, needed);
> + down_write((&EXT4_I(inode)->i_data_sem));
> if (retval)
> goto err_out;
> }
> }
> retval = ext4_ext_insert_extent(handle, inode, path, &newext, 0);
> err_out:
> + up_write((&EXT4_I(inode)->i_data_sem));
> if (path) {
> ext4_ext_drop_refs(path);
> kfree(path);
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] ext4: use correct depth value
2014-07-21 15:04 ` [PATCH 2/3] ext4: use correct depth value Dmitry Monakhov
@ 2014-07-21 19:48 ` Jan Kara
2014-07-28 2:31 ` Theodore Ts'o
0 siblings, 1 reply; 9+ messages in thread
From: Jan Kara @ 2014-07-21 19:48 UTC (permalink / raw)
To: Dmitry Monakhov; +Cc: linux-ext4, tytso
On Mon 21-07-14 19:04:48, Dmitry Monakhov wrote:
> Inode's depth can be changed from here:
> ext4_ext_try_to_merge() ->ext4_ext_try_to_merge_up()
> We must use correct value.
Looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
>
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> ---
> fs/ext4/extents.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index ee93f82..6950bab 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -3254,7 +3254,7 @@ out:
>
> fix_extent_len:
> ex->ee_len = orig_ex.ee_len;
> - ext4_ext_dirty(handle, inode, path + depth);
> + ext4_ext_dirty(handle, inode, path + path->p_depth);
> return err;
> }
>
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] ext4: fix incorrect locking in move_extent_per_page
2014-07-21 15:04 ` [PATCH 3/3] ext4: fix incorrect locking in move_extent_per_page Dmitry Monakhov
@ 2014-07-21 19:51 ` Jan Kara
2014-07-28 2:33 ` Theodore Ts'o
0 siblings, 1 reply; 9+ messages in thread
From: Jan Kara @ 2014-07-21 19:51 UTC (permalink / raw)
To: Dmitry Monakhov; +Cc: linux-ext4, tytso
On Mon 21-07-14 19:04:49, Dmitry Monakhov wrote:
> If we have to copy data we must drop i_data_sem because of
> get_blocks() will be called inside mext_page_mkuptodate(), but later we must
> reacquire it again because we are about to change extent's tree
>
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/move_extent.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
> index 2484c7e..671a74b 100644
> --- a/fs/ext4/move_extent.c
> +++ b/fs/ext4/move_extent.c
> @@ -1013,10 +1013,11 @@ data_copy:
> *err = -EBUSY;
> goto unlock_pages;
> }
> -
> + ext4_double_down_write_data_sem(orig_inode, donor_inode);
> replaced_count = mext_replace_branches(handle, orig_inode, donor_inode,
> orig_blk_offset,
> block_len_in_page, err);
> + ext4_double_up_write_data_sem(orig_inode, donor_inode);
> if (*err) {
> if (replaced_count) {
> block_len_in_page = replaced_count;
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] ext4: add i_data_sem sanity check
2014-07-21 19:35 ` [PATCH 1/3] ext4: add i_data_sem sanity check Jan Kara
@ 2014-07-28 2:29 ` Theodore Ts'o
0 siblings, 0 replies; 9+ messages in thread
From: Theodore Ts'o @ 2014-07-28 2:29 UTC (permalink / raw)
To: Jan Kara; +Cc: Dmitry Monakhov, linux-ext4
On Mon, Jul 21, 2014 at 09:35:10PM +0200, Jan Kara wrote:
> On Mon 21-07-14 19:04:47, Dmitry Monakhov wrote:
> > Each caller of ext4_ext_dirty must hold i_data_sem,
> > The only exception is migration code, let's make it convenient.
> >
> > Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> Looks good. You can add:
> Reviewed-by: Jan Kara <jack@suse.cz>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] ext4: use correct depth value
2014-07-21 19:48 ` Jan Kara
@ 2014-07-28 2:31 ` Theodore Ts'o
0 siblings, 0 replies; 9+ messages in thread
From: Theodore Ts'o @ 2014-07-28 2:31 UTC (permalink / raw)
To: Jan Kara; +Cc: Dmitry Monakhov, linux-ext4
On Mon, Jul 21, 2014 at 09:48:37PM +0200, Jan Kara wrote:
> On Mon 21-07-14 19:04:48, Dmitry Monakhov wrote:
> > Inode's depth can be changed from here:
> > ext4_ext_try_to_merge() ->ext4_ext_try_to_merge_up()
> > We must use correct value.
> Looks good. You can add:
> Reviewed-by: Jan Kara <jack@suse.cz>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] ext4: fix incorrect locking in move_extent_per_page
2014-07-21 19:51 ` Jan Kara
@ 2014-07-28 2:33 ` Theodore Ts'o
0 siblings, 0 replies; 9+ messages in thread
From: Theodore Ts'o @ 2014-07-28 2:33 UTC (permalink / raw)
To: Jan Kara; +Cc: Dmitry Monakhov, linux-ext4
On Mon, Jul 21, 2014 at 09:51:02PM +0200, Jan Kara wrote:
> On Mon 21-07-14 19:04:49, Dmitry Monakhov wrote:
> > If we have to copy data we must drop i_data_sem because of
> > get_blocks() will be called inside mext_page_mkuptodate(), but later we must
> > reacquire it again because we are about to change extent's tree
> >
> > Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> Looks good. You can add:
> Reviewed-by: Jan Kara <jack@suse.cz>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-07-28 2:33 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-21 15:04 [PATCH 1/3] ext4: add i_data_sem sanity check Dmitry Monakhov
2014-07-21 15:04 ` [PATCH 2/3] ext4: use correct depth value Dmitry Monakhov
2014-07-21 19:48 ` Jan Kara
2014-07-28 2:31 ` Theodore Ts'o
2014-07-21 15:04 ` [PATCH 3/3] ext4: fix incorrect locking in move_extent_per_page Dmitry Monakhov
2014-07-21 19:51 ` Jan Kara
2014-07-28 2:33 ` Theodore Ts'o
2014-07-21 19:35 ` [PATCH 1/3] ext4: add i_data_sem sanity check Jan Kara
2014-07-28 2:29 ` 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;
as well as URLs for NNTP newsgroup(s).