* [PATCH] ext4: BUG_ON assertion repeated for inode1, not done for inode2
@ 2015-05-26 17:42 David Moore
2015-05-26 20:44 ` Eric Sandeen
0 siblings, 1 reply; 3+ messages in thread
From: David Moore @ 2015-05-26 17:42 UTC (permalink / raw)
To: tytso; +Cc: linux-ext4
During a source code review of fs/ext4/extents.c I noted identical
consecutive lines. An assertion is repeated for inode1 and never done
for inode2. This is not in keeping with the rest of the code in the
ext4_swap_extents function and appears to be a bug.
Assert that the inode2 mutex is not locked.
Signed-off-by: David Moore <dmoorefo@gmail.com>
---
fs/ext4/extents.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index e003a1e..f38a6d6 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5542,7 +5542,7 @@ ext4_swap_extents(handle_t *handle, struct inode
*inode1,
BUG_ON(!rwsem_is_locked(&EXT4_I(inode1)->i_data_sem));
BUG_ON(!rwsem_is_locked(&EXT4_I(inode2)->i_data_sem));
BUG_ON(!mutex_is_locked(&inode1->i_mutex));
- BUG_ON(!mutex_is_locked(&inode1->i_mutex));
+ BUG_ON(!mutex_is_locked(&inode2->i_mutex));
*erp = ext4_es_remove_extent(inode1, lblk1, count);
if (unlikely(*erp))
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: BUG_ON assertion repeated for inode1, not done for inode2
2015-05-26 17:42 [PATCH] ext4: BUG_ON assertion repeated for inode1, not done for inode2 David Moore
@ 2015-05-26 20:44 ` Eric Sandeen
2015-06-08 15:59 ` Theodore Ts'o
0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2015-05-26 20:44 UTC (permalink / raw)
To: David Moore, tytso; +Cc: linux-ext4
On 5/26/15 12:42 PM, David Moore wrote:
> During a source code review of fs/ext4/extents.c I noted identical
> consecutive lines. An assertion is repeated for inode1 and never done
> for inode2. This is not in keeping with the rest of the code in the
> ext4_swap_extents function and appears to be a bug.
>
> Assert that the inode2 mutex is not locked.
Yep, it's been that way since
fcf6b1b ext4: refactor ext4_move_extents code base
and it's pretty obviously not right as it is, and
if there's any doubt the comments make it clear:
+ * Locking:
+ * i_mutex is held for both inodes
+ * i_data_sem is locked for write for both inodes
Thanks,
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> Signed-off-by: David Moore <dmoorefo@gmail.com>
> ---
> fs/ext4/extents.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index e003a1e..f38a6d6 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -5542,7 +5542,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
> BUG_ON(!rwsem_is_locked(&EXT4_I(inode1)->i_data_sem));
> BUG_ON(!rwsem_is_locked(&EXT4_I(inode2)->i_data_sem));
> BUG_ON(!mutex_is_locked(&inode1->i_mutex));
> - BUG_ON(!mutex_is_locked(&inode1->i_mutex));
> + BUG_ON(!mutex_is_locked(&inode2->i_mutex));
>
> *erp = ext4_es_remove_extent(inode1, lblk1, count);
> if (unlikely(*erp))
>
> --
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: BUG_ON assertion repeated for inode1, not done for inode2
2015-05-26 20:44 ` Eric Sandeen
@ 2015-06-08 15:59 ` Theodore Ts'o
0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2015-06-08 15:59 UTC (permalink / raw)
To: Eric Sandeen; +Cc: David Moore, linux-ext4
On Tue, May 26, 2015 at 03:44:24PM -0500, Eric Sandeen wrote:
> On 5/26/15 12:42 PM, David Moore wrote:
> > During a source code review of fs/ext4/extents.c I noted identical
> > consecutive lines. An assertion is repeated for inode1 and never done
> > for inode2. This is not in keeping with the rest of the code in the
> > ext4_swap_extents function and appears to be a bug.
> >
> > Assert that the inode2 mutex is not locked.
>
> Yep, it's been that way since
>
> fcf6b1b ext4: refactor ext4_move_extents code base
>
> and it's pretty obviously not right as it is, and
> if there's any doubt the comments make it clear:
>
> + * Locking:
> + * i_mutex is held for both inodes
> + * i_data_sem is locked for write for both inodes
>
> Thanks,
>
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-08 15:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-26 17:42 [PATCH] ext4: BUG_ON assertion repeated for inode1, not done for inode2 David Moore
2015-05-26 20:44 ` Eric Sandeen
2015-06-08 15:59 ` 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).