Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,17 @@ static void __loop_clr_fd(struct loop_device *lo)
struct file *filp;
gfp_t gfp = lo->old_gfp_mask;

/*
* Now that loop_queue_rq() sees lo->lo_state != Lo_bound,
* wait for already started loop_queue_rq() to complete.
*/
synchronize_rcu();
/*
* Now that no more works are scheduled by loop_queue_rq(),
* wait for already scheduled works to complete.
*/
drain_workqueue(lo->workqueue);

spin_lock_irq(&lo->lo_lock);
filp = lo->lo_backing_file;
lo->lo_backing_file = NULL;
Expand Down