[PATCH 1/7] jbd2: correctly compare tids with tid_geq function in jbd2_fc_begin_commit

Kemeng Shi posted 7 patches 1 year, 6 months ago
There is a newer version of this series
[PATCH 1/7] jbd2: correctly compare tids with tid_geq function in jbd2_fc_begin_commit
Posted by Kemeng Shi 1 year, 6 months ago
Use tid_geq to compare tids to work over sequence number wraps.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 fs/jbd2/journal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 1ebf2393bfb7..da5a56d700f1 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -710,7 +710,7 @@ int jbd2_fc_begin_commit(journal_t *journal, tid_t tid)
 		return -EINVAL;
 
 	write_lock(&journal->j_state_lock);
-	if (tid <= journal->j_commit_sequence) {
+	if (tid_geq(journal->j_commit_sequence, tid)) {
 		write_unlock(&journal->j_state_lock);
 		return -EALREADY;
 	}
-- 
2.30.0
Re: [PATCH 1/7] jbd2: correctly compare tids with tid_geq function in jbd2_fc_begin_commit
Posted by Zhang Yi 1 year, 6 months ago
On 2024/7/30 19:33, Kemeng Shi wrote:
> Use tid_geq to compare tids to work over sequence number wraps.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

Looks good to me.

Reviewed-by: Zhang Yi <yi.zhang@huawei.com>

> ---
>  fs/jbd2/journal.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index 1ebf2393bfb7..da5a56d700f1 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -710,7 +710,7 @@ int jbd2_fc_begin_commit(journal_t *journal, tid_t tid)
>  		return -EINVAL;
>  
>  	write_lock(&journal->j_state_lock);
> -	if (tid <= journal->j_commit_sequence) {
> +	if (tid_geq(journal->j_commit_sequence, tid)) {
>  		write_unlock(&journal->j_state_lock);
>  		return -EALREADY;
>  	}
>
Re: [PATCH 1/7] jbd2: correctly compare tids with tid_geq function in jbd2_fc_begin_commit
Posted by Jan Kara 1 year, 6 months ago
On Tue 30-07-24 19:33:29, Kemeng Shi wrote:
> Use tid_geq to compare tids to work over sequence number wraps.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
>  fs/jbd2/journal.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Indeed, Luis seems to have missed this when fixing these bugs recently.
Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index 1ebf2393bfb7..da5a56d700f1 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -710,7 +710,7 @@ int jbd2_fc_begin_commit(journal_t *journal, tid_t tid)
>  		return -EINVAL;
>  
>  	write_lock(&journal->j_state_lock);
> -	if (tid <= journal->j_commit_sequence) {
> +	if (tid_geq(journal->j_commit_sequence, tid)) {
>  		write_unlock(&journal->j_state_lock);
>  		return -EALREADY;
>  	}
> -- 
> 2.30.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR
Re: [PATCH 1/7] jbd2: correctly compare tids with tid_geq function in jbd2_fc_begin_commit
Posted by Luis Henriques 1 year, 6 months ago
On Tue, Jul 30 2024, Jan Kara wrote:

> On Tue 30-07-24 19:33:29, Kemeng Shi wrote:
>> Use tid_geq to compare tids to work over sequence number wraps.
>> 
>> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
>> ---
>>  fs/jbd2/journal.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Indeed, Luis seems to have missed this when fixing these bugs recently.

Ah! It looks like I did missed it.  Thanks!

Cheers,
-- 
Luís

> Feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
>
> 								Honza
>
>> 
>> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
>> index 1ebf2393bfb7..da5a56d700f1 100644
>> --- a/fs/jbd2/journal.c
>> +++ b/fs/jbd2/journal.c
>> @@ -710,7 +710,7 @@ int jbd2_fc_begin_commit(journal_t *journal, tid_t tid)
>>  		return -EINVAL;
>>  
>>  	write_lock(&journal->j_state_lock);
>> -	if (tid <= journal->j_commit_sequence) {
>> +	if (tid_geq(journal->j_commit_sequence, tid)) {
>>  		write_unlock(&journal->j_state_lock);
>>  		return -EALREADY;
>>  	}
>> -- 
>> 2.30.0
>> 
> -- 
> Jan Kara <jack@suse.com>
> SUSE Labs, CR