Skip to content
Permalink
Browse files

Linux 5.2 compat: rwsem_tryupgrade()

Commit torvalds/linux@46ad084 has removed the architecture specific
rwsem source and headers leaving only the generic version.  As part
of this change the RWSEM_ACTIVE_READ_BIAS and RWSEM_ACTIVE_WRITE_BIAS
macros were moved to the private kernel/locking/rwsem.h header.
This results in a build failure because these macros were required
to implement the rwsem_tryupgrade() compatibility function.

In practice, this isn't a major problem because there are no longer
any consumers of rwsem_tryupgrade() in the code base.  So we could
remove this functionality entirely.  However, since there may still
be external consumers thit commit instead updates the code to
provide a version of rwsem_tryupgrade() which always fails to
upgrade the rwsem.  This is safe because any consumer of this
interface is expected to fallback to rwsem_enter().

That said, the rwsem_tryupgrade() compatibility function should be
removed in a future release.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
  • Loading branch information...
behlendorf committed May 8, 2019
1 parent 3b77084 commit d0028d3ed12574a8dddc80ca963dcdb2e1a07663
Showing with 10 additions and 2 deletions.
  1. +1 −1 include/spl/sys/rwlock.h
  2. +9 −1 module/spl/spl-rwlock.c
@@ -36,7 +36,7 @@
#elif defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
#define SPL_RWSEM_SINGLE_READER_VALUE (1)
#define SPL_RWSEM_SINGLE_WRITER_VALUE (-1)
#else
#elif defined(RWSEM_ACTIVE_MASK)
#define SPL_RWSEM_SINGLE_READER_VALUE (RWSEM_ACTIVE_READ_BIAS)
#define SPL_RWSEM_SINGLE_WRITER_VALUE (RWSEM_ACTIVE_WRITE_BIAS)
#endif
@@ -85,7 +85,8 @@ __rwsem_tryupgrade(struct rw_semaphore *rwsem)
spl_rwsem_unlock_irqrestore(&rwsem->wait_lock, flags);
return (ret);
}
#elif defined(HAVE_RWSEM_ATOMIC_LONG_COUNT)
#elif defined(RWSEM_ACTIVE_MASK)
#if defined(HAVE_RWSEM_ATOMIC_LONG_COUNT)
static int
__rwsem_tryupgrade(struct rw_semaphore *rwsem)
{
@@ -104,6 +105,13 @@ __rwsem_tryupgrade(struct rw_semaphore *rwsem)
return (val == SPL_RWSEM_SINGLE_READER_VALUE);
}
#endif
#else
static int
__rwsem_tryupgrade(struct rw_semaphore *rwsem)
{
return (0);
}
#endif

int
rwsem_tryupgrade(struct rw_semaphore *rwsem)

0 comments on commit d0028d3

Please sign in to comment.
You can’t perform that action at this time.