writeback: clear auto_free in initializaiton
PATCH 1/1 writeback: clear auto_free in initializaiton
From: Tom Rix <[email protected]>
Review fs/fs-writeback.c bdi_split_work_to_wbs The CONFIG_CGROUP_WRITEBACK version contains this line
base_work->auto_free = 0;
Which seems like a strange place to set auto_free as it is not where the rest of base_work is initialized.
In the default version of bdi_split_work_to_wbs, if a successful malloc happens, base_work is copied and auto_free is set to 1, else the base_work is copied to another local valarible and its auto_free is set to 0.
So move the clearing of auto_free to the initialization of the local base_work structures.
--- fs/fs-writeback.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/fs-writeback.c +3 -4
@@ -881,7 +881,6 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi, work = &fallback_work; *work = *base_work; work->nr_pages = nr_pages; - work->auto_free =0 ; work->done = &fallback_work_done;wb_queue_work (wb, work);
@@ -1055,10 +1054,8 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi, {might_sleep (); -if (!skip_if_busy || !writeback_in_progress (&bdi->wb)) { - base_work->auto_free =0 ; +if (!skip_if_busy || !writeback_in_progress (&bdi->wb))wb_queue_work (&bdi->wb, base_work); - } }#endif /* CONFIG_CGROUP_WRITEBACK */
@@ -2459,6 +2456,7 @@ static void __writeback_inodes_sb_nr(struct super_block *sb, unsigned long nr, .done = &done, .nr_pages = nr, .reason = reason, + .auto_free = 0, };if (!bdi_has_dirty_io (bdi) || bdi == &noop_backing_dev_info)
@@ -2538,6 +2536,7 @@ void sync_inodes_sb(struct super_block *sb) .done = &done, .reason = WB_REASON_SYNC, .for_sync = 1, + .auto_free = 0, };/*
Signature · 1 line
2.18.1
Jan Kara
reviewerQuoted 5 lines · On Tue 18-08-20 07:13:30, [email protected] wrote:
From: Tom Rix <[email protected]>
Review
fs/fs-writeback.cbdi_split_work_to_wbsTheCONFIG_CGROUP_WRITEBACKversion contains this linebase_work->auto_free = 0;
It is actually the !CONFIG_CGROUP_WRITEBACK version...
Quoted 2 lines
Which seems like a strange place to set
auto_freeas it is not where the rest ofbase_workis initialized.
Otherwise I agree it's a strange place. I've added Tejun to CC just in case he remembers why he's added that.
Quoted 10 lines
In the default version of
bdi_split_work_to_wbs, if a successful malloc happens,base_workis copied andauto_freeis set to 1, else thebase_workis copied to another local valarible and itsauto_freeis set to 0.So move the clearing of
auto_freeto the initialization of the localbase_workstructures.Signed-off-by Tom Rix <[email protected]>
Some more comments below.
Quoted 9 lines
--- fs/fs-writeback.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)fs/fs-writeback.c +0
-0
fs/fs-writeback.c static void bdi_split_work_to_wbs(struct backing_dev_info *bdi, · line 884
Quoted 5 lines
fs/fs-writeback.c +0
-1@@ -881,7 +881,6 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi, work = &fallback_work; *work = *base_work; work->nr_pages = nr_pages; - work->auto_free =0 ; work->done = &fallback_work_done;
Honestly, I'd leave this alone. Although base_work should have auto_free == 0, this assignment IMO helps readability.
fs/fs-writeback.c static void bdi_split_work_to_wbs(struct backing_dev_info *bdi, · line 1061
Quoted 9 lines
fs/fs-writeback.c +1
-3@@ -1055,10 +1054,8 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi, {might_sleep (); -if (!skip_if_busy || !writeback_in_progress (&bdi->wb)) { - base_work->auto_free =0 ; +if (!skip_if_busy || !writeback_in_progress (&bdi->wb))wb_queue_work (&bdi->wb, base_work); - }
Agreed with this.
Quoted 9 lines
fs/fs-writeback.c +1
-0@@ -2459,6 +2456,7 @@ static void __writeback_inodes_sb_nr(struct super_block *sb, unsigned long nr, .done = &done, .nr_pages = nr, .reason = reason, + .auto_free = 0, };if (!bdi_has_dirty_io (bdi) || bdi == &noop_backing_dev_info)
fs/fs-writeback.c void sync_inodes_sb(struct super_block *sb) · line 2540
Quoted 5 lines
fs/fs-writeback.c +1
-0@@ -2538,6 +2536,7 @@ void sync_inodes_sb(struct super_block *sb) .done = &done, .reason = WB_REASON_SYNC, .for_sync = 1, + .auto_free = 0, };
No need for explicit initialization to 0 - that is implicit with the initializers.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Hello,
Quoted 5 lines · Jan Kara
Quoted 2 lines
Which seems like a strange place to set
auto_freeas it is not where the rest ofbase_workis initialized.Otherwise I agree it's a strange place. I've added Tejun to CC just in case he remembers why he's added that.
I don't remember exactly but maybe I was trying to mirror the CGROUP_WRITEBACK counterpart without actually thinking about it? The patch looks good to me.
Thanks.
Signature · 1 line
tejun