diff options
Diffstat (limited to 'fs/xfs/xfs_alloc.c')
-rw-r--r-- | fs/xfs/xfs_alloc.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index ce84ffd0264c..0f0df2759b09 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "xfs_error.h" | 35 | #include "xfs_error.h" |
36 | #include "xfs_trace.h" | 36 | #include "xfs_trace.h" |
37 | 37 | ||
38 | struct workqueue_struct *xfs_alloc_wq; | ||
38 | 39 | ||
39 | #define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) | 40 | #define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) |
40 | 41 | ||
@@ -68,7 +69,7 @@ xfs_alloc_lookup_eq( | |||
68 | * Lookup the first record greater than or equal to [bno, len] | 69 | * Lookup the first record greater than or equal to [bno, len] |
69 | * in the btree given by cur. | 70 | * in the btree given by cur. |
70 | */ | 71 | */ |
71 | STATIC int /* error */ | 72 | int /* error */ |
72 | xfs_alloc_lookup_ge( | 73 | xfs_alloc_lookup_ge( |
73 | struct xfs_btree_cur *cur, /* btree cursor */ | 74 | struct xfs_btree_cur *cur, /* btree cursor */ |
74 | xfs_agblock_t bno, /* starting block of extent */ | 75 | xfs_agblock_t bno, /* starting block of extent */ |
@@ -2207,7 +2208,7 @@ xfs_alloc_read_agf( | |||
2207 | * group or loop over the allocation groups to find the result. | 2208 | * group or loop over the allocation groups to find the result. |
2208 | */ | 2209 | */ |
2209 | int /* error */ | 2210 | int /* error */ |
2210 | xfs_alloc_vextent( | 2211 | __xfs_alloc_vextent( |
2211 | xfs_alloc_arg_t *args) /* allocation argument structure */ | 2212 | xfs_alloc_arg_t *args) /* allocation argument structure */ |
2212 | { | 2213 | { |
2213 | xfs_agblock_t agsize; /* allocation group size */ | 2214 | xfs_agblock_t agsize; /* allocation group size */ |
@@ -2417,6 +2418,37 @@ error0: | |||
2417 | return error; | 2418 | return error; |
2418 | } | 2419 | } |
2419 | 2420 | ||
2421 | static void | ||
2422 | xfs_alloc_vextent_worker( | ||
2423 | struct work_struct *work) | ||
2424 | { | ||
2425 | struct xfs_alloc_arg *args = container_of(work, | ||
2426 | struct xfs_alloc_arg, work); | ||
2427 | unsigned long pflags; | ||
2428 | |||
2429 | /* we are in a transaction context here */ | ||
2430 | current_set_flags_nested(&pflags, PF_FSTRANS); | ||
2431 | |||
2432 | args->result = __xfs_alloc_vextent(args); | ||
2433 | complete(args->done); | ||
2434 | |||
2435 | current_restore_flags_nested(&pflags, PF_FSTRANS); | ||
2436 | } | ||
2437 | |||
2438 | |||
2439 | int /* error */ | ||
2440 | xfs_alloc_vextent( | ||
2441 | xfs_alloc_arg_t *args) /* allocation argument structure */ | ||
2442 | { | ||
2443 | DECLARE_COMPLETION_ONSTACK(done); | ||
2444 | |||
2445 | args->done = &done; | ||
2446 | INIT_WORK(&args->work, xfs_alloc_vextent_worker); | ||
2447 | queue_work(xfs_alloc_wq, &args->work); | ||
2448 | wait_for_completion(&done); | ||
2449 | return args->result; | ||
2450 | } | ||
2451 | |||
2420 | /* | 2452 | /* |
2421 | * Free an extent. | 2453 | * Free an extent. |
2422 | * Just break up the extent address and hand off to xfs_free_ag_extent | 2454 | * Just break up the extent address and hand off to xfs_free_ag_extent |