2024-02-08 09:26:29

by Kemeng Shi

[permalink] [raw]
Subject: [PATCH 4/7] fs/writeback: remove unneeded check in writeback_single_inode

I_DIRTY_ALL consists of I_DIRTY_TIME and I_DIRTY, so I_DIRTY_TIME must
be set when any bit of I_DIRTY_ALL is set but I_DIRTY is not set.

Signed-off-by: Kemeng Shi <[email protected]>
---
fs/fs-writeback.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 2619f74ced70..b61bf2075931 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -1788,7 +1788,7 @@ static int writeback_single_inode(struct inode *inode,
else if (!(inode->i_state & I_SYNC_QUEUED)) {
if ((inode->i_state & I_DIRTY))
redirty_tail_locked(inode, wb);
- else if (inode->i_state & I_DIRTY_TIME) {
+ else {
inode->dirtied_when = jiffies;
inode_io_list_move_locked(inode,
wb,
--
2.30.0



2024-02-08 19:34:53

by Tim Chen

[permalink] [raw]
Subject: Re: [PATCH 4/7] fs/writeback: remove unneeded check in writeback_single_inode

On Fri, 2024-02-09 at 01:20 +0800, Kemeng Shi wrote:
> I_DIRTY_ALL consists of I_DIRTY_TIME and I_DIRTY, so I_DIRTY_TIME must
> be set when any bit of I_DIRTY_ALL is set but I_DIRTY is not set.

/s/any bit of/some bit in/

>
> Signed-off-by: Kemeng Shi <[email protected]>

Reviewed by: Tim Chen <[email protected]>

> ---
> fs/fs-writeback.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 2619f74ced70..b61bf2075931 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -1788,7 +1788,7 @@ static int writeback_single_inode(struct inode *inode,
> else if (!(inode->i_state & I_SYNC_QUEUED)) {
> if ((inode->i_state & I_DIRTY))
> redirty_tail_locked(inode, wb);
> - else if (inode->i_state & I_DIRTY_TIME) {
> + else {
> inode->dirtied_when = jiffies;
> inode_io_list_move_locked(inode,
> wb,


2024-02-10 00:56:21

by Dave Chinner

[permalink] [raw]
Subject: Re: [PATCH 4/7] fs/writeback: remove unneeded check in writeback_single_inode

On Fri, Feb 09, 2024 at 01:20:21AM +0800, Kemeng Shi wrote:
> I_DIRTY_ALL consists of I_DIRTY_TIME and I_DIRTY, so I_DIRTY_TIME must
> be set when any bit of I_DIRTY_ALL is set but I_DIRTY is not set.
>
> Signed-off-by: Kemeng Shi <[email protected]>
> ---
> fs/fs-writeback.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 2619f74ced70..b61bf2075931 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -1788,7 +1788,7 @@ static int writeback_single_inode(struct inode *inode,
> else if (!(inode->i_state & I_SYNC_QUEUED)) {
> if ((inode->i_state & I_DIRTY))
> redirty_tail_locked(inode, wb);
> - else if (inode->i_state & I_DIRTY_TIME) {
> + else {
> inode->dirtied_when = jiffies;
> inode_io_list_move_locked(inode,
> wb,

NAK.

The code is correct and the behaviour that is intended it obvious
from the code as it stands.

It is -incorrect- to move any inode that does not have I_DIRTY_TIME
to the wb->b_dirty_time list. By removing the I_DIRTY_TIME guard
from this code, you are leaving a nasty, undocumented logic trap in
the code that somebody is guaranteed to trip over into in the
future. That's making the code worse, not better....

-Dave.
--
Dave Chinner
[email protected]

2024-02-18 02:37:51

by Kemeng Shi

[permalink] [raw]
Subject: Re: [PATCH 4/7] fs/writeback: remove unneeded check in writeback_single_inode



on 2/10/2024 8:46 AM, Dave Chinner wrote:
> On Fri, Feb 09, 2024 at 01:20:21AM +0800, Kemeng Shi wrote:
>> I_DIRTY_ALL consists of I_DIRTY_TIME and I_DIRTY, so I_DIRTY_TIME must
>> be set when any bit of I_DIRTY_ALL is set but I_DIRTY is not set.
>>
>> Signed-off-by: Kemeng Shi <[email protected]>
>> ---
>> fs/fs-writeback.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
>> index 2619f74ced70..b61bf2075931 100644
>> --- a/fs/fs-writeback.c
>> +++ b/fs/fs-writeback.c
>> @@ -1788,7 +1788,7 @@ static int writeback_single_inode(struct inode *inode,
>> else if (!(inode->i_state & I_SYNC_QUEUED)) {
>> if ((inode->i_state & I_DIRTY))
>> redirty_tail_locked(inode, wb);
>> - else if (inode->i_state & I_DIRTY_TIME) {
>> + else {
>> inode->dirtied_when = jiffies;
>> inode_io_list_move_locked(inode,
>> wb,
>
> NAK.
>
> The code is correct and the behaviour that is intended it obvious
> from the code as it stands.
>
> It is -incorrect- to move any inode that does not have I_DIRTY_TIME
> to the wb->b_dirty_time list. By removing the I_DIRTY_TIME guard
> from this code, you are leaving a nasty, undocumented logic trap in
> the code that somebody is guaranteed to trip over into in the
> future. That's making the code worse, not better....
Sure, I will remove this one in next version. Thanks for the
explanation.
>
> -Dave.
>