Commit 2455881c authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers

xfs: introduce XFS_BMAPI_STACK_SWITCH

Certain allocation paths through xfs_bmapi_write() are in situations
where we have limited stack available. These are almost always in
the buffered IO writeback path when convertion delayed allocation
extents to real extents.

The current stack switch occurs for userdata allocations, which
means we also do stack switches for preallocation, direct IO and
unwritten extent conversion, even those these call chains have never
been implicated in a stack overrun.

Hence, let's target just the single stack overun offended for stack
switches. To do that, introduce a XFS_BMAPI_STACK_SWITCH flag that
the caller can pass xfs_bmapi_write() to indicate it should switch
stacks if it needs to do allocation.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent a0041684
...@@ -2447,7 +2447,7 @@ xfs_alloc_vextent( ...@@ -2447,7 +2447,7 @@ xfs_alloc_vextent(
{ {
DECLARE_COMPLETION_ONSTACK(done); DECLARE_COMPLETION_ONSTACK(done);
if (!args->userdata) if (!args->stack_switch)
return __xfs_alloc_vextent(args); return __xfs_alloc_vextent(args);
......
...@@ -123,6 +123,7 @@ typedef struct xfs_alloc_arg { ...@@ -123,6 +123,7 @@ typedef struct xfs_alloc_arg {
struct completion *done; struct completion *done;
struct work_struct work; struct work_struct work;
int result; int result;
char stack_switch;
} xfs_alloc_arg_t; } xfs_alloc_arg_t;
/* /*
......
...@@ -2441,6 +2441,7 @@ xfs_bmap_btalloc( ...@@ -2441,6 +2441,7 @@ xfs_bmap_btalloc(
args.tp = ap->tp; args.tp = ap->tp;
args.mp = mp; args.mp = mp;
args.fsbno = ap->blkno; args.fsbno = ap->blkno;
args.stack_switch = ap->stack_switch;
/* Trim the allocation back to the maximum an AG can fit. */ /* Trim the allocation back to the maximum an AG can fit. */
args.maxlen = MIN(ap->length, XFS_ALLOC_AG_MAX_USABLE(mp)); args.maxlen = MIN(ap->length, XFS_ALLOC_AG_MAX_USABLE(mp));
...@@ -4675,6 +4676,9 @@ xfs_bmapi_allocate( ...@@ -4675,6 +4676,9 @@ xfs_bmapi_allocate(
return error; return error;
} }
if (flags & XFS_BMAPI_STACK_SWITCH)
bma->stack_switch = 1;
error = xfs_bmap_alloc(bma); error = xfs_bmap_alloc(bma);
if (error) if (error)
return error; return error;
......
...@@ -77,6 +77,7 @@ typedef struct xfs_bmap_free ...@@ -77,6 +77,7 @@ typedef struct xfs_bmap_free
* from written to unwritten, otherwise convert from unwritten to written. * from written to unwritten, otherwise convert from unwritten to written.
*/ */
#define XFS_BMAPI_CONVERT 0x040 #define XFS_BMAPI_CONVERT 0x040
#define XFS_BMAPI_STACK_SWITCH 0x080
#define XFS_BMAPI_FLAGS \ #define XFS_BMAPI_FLAGS \
{ XFS_BMAPI_ENTIRE, "ENTIRE" }, \ { XFS_BMAPI_ENTIRE, "ENTIRE" }, \
...@@ -85,7 +86,8 @@ typedef struct xfs_bmap_free ...@@ -85,7 +86,8 @@ typedef struct xfs_bmap_free
{ XFS_BMAPI_PREALLOC, "PREALLOC" }, \ { XFS_BMAPI_PREALLOC, "PREALLOC" }, \
{ XFS_BMAPI_IGSTATE, "IGSTATE" }, \ { XFS_BMAPI_IGSTATE, "IGSTATE" }, \
{ XFS_BMAPI_CONTIG, "CONTIG" }, \ { XFS_BMAPI_CONTIG, "CONTIG" }, \
{ XFS_BMAPI_CONVERT, "CONVERT" } { XFS_BMAPI_CONVERT, "CONVERT" }, \
{ XFS_BMAPI_STACK_SWITCH, "STACK_SWITCH" }
static inline int xfs_bmapi_aflag(int w) static inline int xfs_bmapi_aflag(int w)
...@@ -133,6 +135,7 @@ typedef struct xfs_bmalloca { ...@@ -133,6 +135,7 @@ typedef struct xfs_bmalloca {
char userdata;/* set if is user data */ char userdata;/* set if is user data */
char aeof; /* allocated space at eof */ char aeof; /* allocated space at eof */
char conv; /* overwriting unwritten extents */ char conv; /* overwriting unwritten extents */
char stack_switch;
} xfs_bmalloca_t; } xfs_bmalloca_t;
/* /*
......
...@@ -575,7 +575,9 @@ xfs_iomap_write_allocate( ...@@ -575,7 +575,9 @@ xfs_iomap_write_allocate(
* pointer that the caller gave to us. * pointer that the caller gave to us.
*/ */
error = xfs_bmapi_write(tp, ip, map_start_fsb, error = xfs_bmapi_write(tp, ip, map_start_fsb,
count_fsb, 0, &first_block, 1, count_fsb,
XFS_BMAPI_STACK_SWITCH,
&first_block, 1,
imap, &nimaps, &free_list); imap, &nimaps, &free_list);
if (error) if (error)
goto trans_cancel; goto trans_cancel;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment