Skip to content

Commit

Permalink
Fix abd_enter/exit_critical wrappers
Browse files Browse the repository at this point in the history
Commit fc551d7 introduced the wrappers abd_enter_critical() and
abd_exit_critical() to mark critical sections.  On Linux these are
implemented with the local_irq_save() and local_irq_restore() macros
which set the 'flags' argument when saving.  By wrapping them with
a function the local variable is no longer set by the macro and is
no longer properly restored.

Convert abd_enter_critical() and abd_exit_critical() to macros to
resolve this issue and ensure the flags are properly restored.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #10332
  • Loading branch information
behlendorf authored May 15, 2020
1 parent eeb8fae commit 2ade659
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
15 changes: 13 additions & 2 deletions include/sys/abd_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ void abd_update_scatter_stats(abd_t *, abd_stats_op_t);
void abd_update_linear_stats(abd_t *, abd_stats_op_t);
void abd_verify_scatter(abd_t *);
void abd_free_linear_page(abd_t *);
void abd_enter_critical(unsigned long);
void abd_exit_critical(unsigned long);
/* OS specific abd_iter functions */
void abd_iter_init(struct abd_iter *, abd_t *);
boolean_t abd_iter_at_end(struct abd_iter *);
Expand All @@ -119,6 +117,19 @@ void abd_iter_unmap(struct abd_iter *);
#define ABD_SCATTER(abd) (abd->abd_u.abd_scatter)
#define ABD_LINEAR_BUF(abd) (abd->abd_u.abd_linear.abd_buf)

#if defined(_KERNEL)
#if defined(__FreeBSD__)
#define abd_enter_critical(flags) critical_enter()
#define abd_exit_critical(flags) critical_exit()
#else
#define abd_enter_critical(flags) local_irq_save(flags)
#define abd_exit_critical(flags) local_irq_restore(flags)
#endif
#else /* !_KERNEL */
#define abd_enter_critical(flags) ((void)0)
#define abd_exit_critical(flags) ((void)0)
#endif

#ifdef __cplusplus
}
#endif
Expand Down
12 changes: 0 additions & 12 deletions module/os/freebsd/zfs/abd_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,3 @@ abd_iter_unmap(struct abd_iter *aiter)
aiter->iter_mapaddr = NULL;
aiter->iter_mapsize = 0;
}

void
abd_enter_critical(unsigned long flags)
{
critical_enter();
}

void
abd_exit_critical(unsigned long flags)
{
critical_exit();
}
12 changes: 0 additions & 12 deletions module/os/linux/zfs/abd_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,18 +803,6 @@ abd_iter_unmap(struct abd_iter *aiter)
aiter->iter_mapsize = 0;
}

void
abd_enter_critical(unsigned long flags)
{
local_irq_save(flags);
}

void
abd_exit_critical(unsigned long flags)
{
local_irq_restore(flags);
}

#if defined(_KERNEL)
/*
* bio_nr_pages for ABD.
Expand Down
4 changes: 2 additions & 2 deletions module/zfs/abd.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ abd_raidz_gen_iterate(abd_t **cabds, abd_t *dabd,
struct abd_iter caiters[3];
struct abd_iter daiter = {0};
void *caddrs[3];
unsigned long flags = 0;
unsigned long flags __maybe_unused = 0;

ASSERT3U(parity, <=, 3);

Expand Down Expand Up @@ -800,7 +800,7 @@ abd_raidz_rec_iterate(abd_t **cabds, abd_t **tabds,
struct abd_iter citers[3];
struct abd_iter xiters[3];
void *caddrs[3], *xaddrs[3];
unsigned long flags = 0;
unsigned long flags __maybe_unused = 0;

ASSERT3U(parity, <=, 3);

Expand Down

0 comments on commit 2ade659

Please sign in to comment.