Skip to content

Commit

Permalink
Linux compat 4.16: blk_queue_flag_{set,clear}
Browse files Browse the repository at this point in the history
The HAVE_BLK_QUEUE_WRITE_CACHE_GPL_ONLY case was overlooked in
the original 10f88c5 commit because blk_queue_write_cache()
was available for the in-kernel builds.

Update the blk_queue_flag_{set,clear} wrappers to call the locked
versions to avoid confusion.  This is safe for all existing callers.

The blk_queue_set_write_cache() function has been updated to use
these wrappers.  This means setting/clearing both QUEUE_FLAG_WC
and QUEUE_FLAG_FUA is no longer atomic but this only done early
in zvol_alloc() prior to any requests so there is no issue.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Kash Pande <kash@tripleback.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes openzfs#7428
Closes openzfs#7431
  • Loading branch information
behlendorf authored and tonyhutter committed May 4, 2018
1 parent 521e21f commit e45d782
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions include/linux/blkdev_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ typedef unsigned __bitwise__ fmode_t;
static inline void
blk_queue_flag_set(unsigned int flag, struct request_queue *q)
{
queue_flag_set_unlocked(flag, q);
queue_flag_set(flag, q);
}
#endif

#ifndef HAVE_BLK_QUEUE_FLAG_CLEAR
static inline void
blk_queue_flag_clear(unsigned int flag, struct request_queue *q)
{
queue_flag_clear_unlocked(flag, q);
queue_flag_clear(flag, q);
}
#endif

Expand All @@ -72,16 +72,14 @@ static inline void
blk_queue_set_write_cache(struct request_queue *q, bool wc, bool fua)
{
#if defined(HAVE_BLK_QUEUE_WRITE_CACHE_GPL_ONLY)
spin_lock_irq(q->queue_lock);
if (wc)
queue_flag_set(QUEUE_FLAG_WC, q);
blk_queue_flag_set(QUEUE_FLAG_WC, q);
else
queue_flag_clear(QUEUE_FLAG_WC, q);
blk_queue_flag_clear(QUEUE_FLAG_WC, q);
if (fua)
queue_flag_set(QUEUE_FLAG_FUA, q);
blk_queue_flag_set(QUEUE_FLAG_FUA, q);
else
queue_flag_clear(QUEUE_FLAG_FUA, q);
spin_unlock_irq(q->queue_lock);
blk_queue_flag_clear(QUEUE_FLAG_FUA, q);
#elif defined(HAVE_BLK_QUEUE_WRITE_CACHE)
blk_queue_write_cache(q, wc, fua);
#elif defined(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY)
Expand Down

0 comments on commit e45d782

Please sign in to comment.