dm: some changes just staged for 6.3
Mike Snitzer
maintainerPATCH 1/6 dm: add cond_resched() to dm_wq_work()
In reply to Mike SnitzerFrom: Pingfan Liu <[email protected]>
Otherwise the while() loop in dm_wq_work() can result in a "dead loop" on systems that have preemption disabled. This is particularly problematic on single cpu systems.
--- drivers/md/dm.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/dm.c +1 -0
@@ -2570,6 +2570,7 @@ static void dm_wq_work(struct work_struct *work)break ;submit_bio_noacct (bio); +cond_resched (); } }
Signature · 6 lines
2.37.0 (Apple Git-136) -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Mike Snitzer
maintainercover dm: some changes just staged for 6.3
Hou Tao (1):
dm ioctl: remove unnecessary check when using dm_get_mdptr()
Mike Snitzer (4):
dm: add cond_resched() to dm_wq_requeue_work() dm thin: add cond_resched() to various workqueue loops dm cache: add cond_resched() to various workqueue loops dm ioctl: assert _hash_lock is held in __hash_remove
Pingfan Liu (1):
dm: add cond_resched() to dm_wq_work()
drivers/md/dm-cache-target.c | 4 ++++ drivers/md/dm-ioctl.c | 10 +++++++--- drivers/md/dm-thin.c | 2 ++ drivers/md/dm.c | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-)
Signature · 6 lines
2.37.0 (Apple Git-136) -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Mike Snitzer
maintainerPATCH 3/6 dm thin: add cond_resched() to various workqueue loops
Otherwise on resource constrained systems these workqueues may be too greedy.
--- drivers/md/dm-thin.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/dm-thin.c +2 -0
@@ -2209,6 +2209,7 @@ static void process_thin_deferred_bios(struct thin_c *tc)throttle_work_update (&pool->throttle);dm_pool_issue_prefetches (pool->pmd); } +cond_resched (); }blk_finish_plug (&plug); }
@@ -2291,6 +2292,7 @@ static void process_thin_deferred_cells(struct thin_c *tc)else pool->process_cell (tc, cell); } +cond_resched (); }while (!list_empty (&cells)); }
Signature · 6 lines
2.37.0 (Apple Git-136) -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Mike Snitzer
maintainerPATCH 5/6 dm ioctl: assert _hash_lock is held in __hash_remove
In reply to Mike SnitzerAlso update dm_early_create() to take _hash_lock when calling both __get_name_cell and __hash_remove -- given dm_early_create()'s early boot usecase this locking isn't about correctness but it allows lockdep_assert_held() to be added to __hash_remove.
--- drivers/md/dm-ioctl.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/dm-ioctl.c +4 -0
@@ -310,6 +310,8 @@ static struct dm_table *__hash_remove(struct hash_cell *hc)struct dm_table *table;int srcu_idx; +lockdep_assert_held (&_hash_lock); +/* remove from the dev trees */ __unlink_name (hc);__unlink_uuid (hc);
@@ -2263,7 +2265,9 @@ int __init dm_early_create(struct dm_ioctl *dmi, err_destroy_table:dm_table_destroy (t); err_hash_remove: +down_write (&_hash_lock); (void )__hash_remove (__get_name_cell (dmi->name)); +up_write (&_hash_lock);/* release reference from __get_name_cell */ dm_put (md); err_destroy_dm:
Signature · 6 lines
2.37.0 (Apple Git-136) -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Mike Snitzer
maintainerPATCH 4/6 dm cache: add cond_resched() to various workqueue loops
In reply to Mike SnitzerOtherwise on resource constrained systems these workqueues may be too greedy.
--- drivers/md/dm-cache-target.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/dm-cache-target.c +4 -0
@@ -1829,6 +1829,7 @@ static void process_deferred_bios(struct work_struct *ws)else commit_needed =process_bio (cache, bio) || commit_needed; +cond_resched (); }if (commit_needed)
@@ -1852,6 +1853,7 @@ static void requeue_deferred_bios(struct cache *cache)while ((bio =bio_list_pop (&bios))) { bio->bi_status =BLK_STS_DM_REQUEUE ;bio_endio (bio); +cond_resched (); } }
@@ -1892,6 +1894,8 @@ static void check_migrations(struct work_struct *ws) r =mg_start (cache, op,NULL );if (r)break ; + +cond_resched (); } }
Signature · 6 lines
2.37.0 (Apple Git-136) -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Mike Snitzer
maintainerPATCH 6/6 dm ioctl: remove unnecessary check when using dm_get_mdptr()
In reply to Mike SnitzerFrom: Hou Tao <[email protected]>
__hash_remove() removes hash_cell with _hash_lock locked, so acquiring _hash_lock can guarantee no-NULL hc returned from dm_get_mdptr() must have not been removed and hc->md must still be md.
__hash_remove() also acquires dm_hash_cells_mutex before setting mdptr as NULL. So in dm_copy_name_and_uuid(), after acquiring dm_hash_cells_mutex and ensuring returned hc is not NULL, the returned hc must still be alive and hc->md must still be md.
Remove the unnecessary hc->md != md checks when using dm_get_mdptr() with _hash_lock or dm_hash_cells_mutex acquired.
--- drivers/md/dm-ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/md/dm-ioctl.c +3 -3
@@ -789,7 +789,7 @@ static struct dm_table *dm_get_inactive_table(struct mapped_device *md, int *srcdown_read (&_hash_lock); hc =dm_get_mdptr (md); -if (!hc || hc->md != md) { +if (!hc) {DMERR ("device has been removed from the dev hash table." ); goto out; }
@@ -1500,7 +1500,7 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si/* stage inactive table */ down_write (&_hash_lock); hc =dm_get_mdptr (md); -if (!hc || hc->md != md) { +if (!hc) {DMERR ("device has been removed from the dev hash table." );up_write (&_hash_lock); r = -ENXIO ;
@@ -2152,7 +2152,7 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)mutex_lock (&dm_hash_cells_mutex); hc =dm_get_mdptr (md); -if (!hc || hc->md != md) { +if (!hc) { r = -ENXIO ; goto out; }
Signature · 6 lines
2.37.0 (Apple Git-136) -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Mike Snitzer
maintainerPATCH 2/6 dm: add cond_resched() to dm_wq_requeue_work()
In reply to Mike SnitzerOtherwise the while() loop in dm_wq_requeue_work() can result in a "dead loop" on systems that have preemption disabled. This is particularly problematic on single cpu systems.
--- drivers/md/dm.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/dm.c +1 -0
@@ -1009,6 +1009,7 @@ static void dm_wq_requeue_work(struct work_struct *work) io->next =NULL ;__dm_io_complete (io, false); io = next; +cond_resched (); } }
Signature · 6 lines
2.37.0 (Apple Git-136) -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel