diff mbox series

[5/7] fs/writeback: only calculate dirtied_before when b_io is empty

Message ID 20240208172024.23625-6-shikemeng@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series Fixes and cleanups to fs-writeback | expand

Commit Message

Kemeng Shi Feb. 8, 2024, 5:20 p.m. UTC
The dirtied_before is only used when b_io is not empty, so only calculate
when b_io is not empty.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 fs/fs-writeback.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

Comments

Jan Kara Feb. 23, 2024, 1:58 p.m. UTC | #1
On Fri 09-02-24 01:20:22, Kemeng Shi wrote:
> The dirtied_before is only used when b_io is not empty, so only calculate
> when b_io is not empty.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
>  fs/fs-writeback.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)

OK, but please wrap the comment at 80 columns as well.

								Honza

> 
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index b61bf2075931..e8868e814e0a 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -2118,20 +2118,21 @@ static long wb_writeback(struct bdi_writeback *wb,
>  
>  		spin_lock(&wb->list_lock);
>  
> -		/*
> -		 * Kupdate and background works are special and we want to
> -		 * include all inodes that need writing. Livelock avoidance is
> -		 * handled by these works yielding to any other work so we are
> -		 * safe.
> -		 */
> -		if (work->for_kupdate) {
> -			dirtied_before = jiffies -
> -				msecs_to_jiffies(dirty_expire_interval * 10);
> -		} else if (work->for_background)
> -			dirtied_before = jiffies;
> -
>  		trace_writeback_start(wb, work);
>  		if (list_empty(&wb->b_io)) {
> +			/*
> +			 * Kupdate and background works are special and we want to
> +			 * include all inodes that need writing. Livelock avoidance is
> +			 * handled by these works yielding to any other work so we are
> +			 * safe.
> +			 */
> +			if (work->for_kupdate) {
> +				dirtied_before = jiffies -
> +					msecs_to_jiffies(dirty_expire_interval *
> +							 10);
> +			} else if (work->for_background)
> +				dirtied_before = jiffies;
> +
>  			queue_io(wb, work, dirtied_before);
>  			queued = true;
>  		}
> -- 
> 2.30.0
>
Kemeng Shi Feb. 26, 2024, 11:50 a.m. UTC | #2
on 2/23/2024 9:58 PM, Jan Kara wrote:
> On Fri 09-02-24 01:20:22, Kemeng Shi wrote:
>> The dirtied_before is only used when b_io is not empty, so only calculate
>> when b_io is not empty.
>>
>> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
>> ---
>>  fs/fs-writeback.c | 25 +++++++++++++------------
>>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> OK, but please wrap the comment at 80 columns as well.
Sorry for missing this as I rely too much on checkpatch.pl to report this
while the script didn't catch it. Will fix it in next version. Thanks for
review.
> 
> 								Honza
> 
>>
>> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
>> index b61bf2075931..e8868e814e0a 100644
>> --- a/fs/fs-writeback.c
>> +++ b/fs/fs-writeback.c
>> @@ -2118,20 +2118,21 @@ static long wb_writeback(struct bdi_writeback *wb,
>>  
>>  		spin_lock(&wb->list_lock);
>>  
>> -		/*
>> -		 * Kupdate and background works are special and we want to
>> -		 * include all inodes that need writing. Livelock avoidance is
>> -		 * handled by these works yielding to any other work so we are
>> -		 * safe.
>> -		 */
>> -		if (work->for_kupdate) {
>> -			dirtied_before = jiffies -
>> -				msecs_to_jiffies(dirty_expire_interval * 10);
>> -		} else if (work->for_background)
>> -			dirtied_before = jiffies;
>> -
>>  		trace_writeback_start(wb, work);
>>  		if (list_empty(&wb->b_io)) {
>> +			/*
>> +			 * Kupdate and background works are special and we want to
>> +			 * include all inodes that need writing. Livelock avoidance is
>> +			 * handled by these works yielding to any other work so we are
>> +			 * safe.
>> +			 */
>> +			if (work->for_kupdate) {
>> +				dirtied_before = jiffies -
>> +					msecs_to_jiffies(dirty_expire_interval *
>> +							 10);
>> +			} else if (work->for_background)
>> +				dirtied_before = jiffies;
>> +
>>  			queue_io(wb, work, dirtied_before);
>>  			queued = true;
>>  		}
>> -- 
>> 2.30.0
>>
diff mbox series

Patch

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index b61bf2075931..e8868e814e0a 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -2118,20 +2118,21 @@  static long wb_writeback(struct bdi_writeback *wb,
 
 		spin_lock(&wb->list_lock);
 
-		/*
-		 * Kupdate and background works are special and we want to
-		 * include all inodes that need writing. Livelock avoidance is
-		 * handled by these works yielding to any other work so we are
-		 * safe.
-		 */
-		if (work->for_kupdate) {
-			dirtied_before = jiffies -
-				msecs_to_jiffies(dirty_expire_interval * 10);
-		} else if (work->for_background)
-			dirtied_before = jiffies;
-
 		trace_writeback_start(wb, work);
 		if (list_empty(&wb->b_io)) {
+			/*
+			 * Kupdate and background works are special and we want to
+			 * include all inodes that need writing. Livelock avoidance is
+			 * handled by these works yielding to any other work so we are
+			 * safe.
+			 */
+			if (work->for_kupdate) {
+				dirtied_before = jiffies -
+					msecs_to_jiffies(dirty_expire_interval *
+							 10);
+			} else if (work->for_background)
+				dirtied_before = jiffies;
+
 			queue_io(wb, work, dirtied_before);
 			queued = true;
 		}