Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 297214
b: refs/heads/master
c: c999a22
h: refs/heads/master
v: v3
  • Loading branch information
Dave Chinner authored and Ben Myers committed Mar 22, 2012
1 parent 7db5ffd commit 32a5e20
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1a1d772433d42aaff7315b3468fef5951604f5c6
refs/heads/master: c999a223c2f0d31c64ef7379814cea1378b2b800
34 changes: 33 additions & 1 deletion trunk/fs/xfs/xfs_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "xfs_error.h"
#include "xfs_trace.h"

struct workqueue_struct *xfs_alloc_wq;

#define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b)))

Expand Down Expand Up @@ -2207,7 +2208,7 @@ xfs_alloc_read_agf(
* group or loop over the allocation groups to find the result.
*/
int /* error */
xfs_alloc_vextent(
__xfs_alloc_vextent(
xfs_alloc_arg_t *args) /* allocation argument structure */
{
xfs_agblock_t agsize; /* allocation group size */
Expand Down Expand Up @@ -2417,6 +2418,37 @@ xfs_alloc_vextent(
return error;
}

static void
xfs_alloc_vextent_worker(
struct work_struct *work)
{
struct xfs_alloc_arg *args = container_of(work,
struct xfs_alloc_arg, work);
unsigned long pflags;

/* we are in a transaction context here */
current_set_flags_nested(&pflags, PF_FSTRANS);

args->result = __xfs_alloc_vextent(args);
complete(args->done);

current_restore_flags_nested(&pflags, PF_FSTRANS);
}


int /* error */
xfs_alloc_vextent(
xfs_alloc_arg_t *args) /* allocation argument structure */
{
DECLARE_COMPLETION_ONSTACK(done);

args->done = &done;
INIT_WORK(&args->work, xfs_alloc_vextent_worker);
queue_work(xfs_alloc_wq, &args->work);
wait_for_completion(&done);
return args->result;
}

/*
* Free an extent.
* Just break up the extent address and hand off to xfs_free_ag_extent
Expand Down
5 changes: 5 additions & 0 deletions trunk/fs/xfs/xfs_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct xfs_perag;
struct xfs_trans;
struct xfs_busy_extent;

extern struct workqueue_struct *xfs_alloc_wq;

/*
* Freespace allocation types. Argument to xfs_alloc_[v]extent.
*/
Expand Down Expand Up @@ -119,6 +121,9 @@ typedef struct xfs_alloc_arg {
char isfl; /* set if is freelist blocks - !acctg */
char userdata; /* set if this is user data */
xfs_fsblock_t firstblock; /* io first block allocated */
struct completion *done;
struct work_struct work;
int result;
} xfs_alloc_arg_t;

/*
Expand Down
16 changes: 16 additions & 0 deletions trunk/fs/xfs/xfs_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,12 +1607,28 @@ xfs_init_workqueues(void)
xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_NON_REENTRANT, 0);
if (!xfs_syncd_wq)
return -ENOMEM;

/*
* The allocation workqueue can be used in memory reclaim situations
* (writepage path), and parallelism is only limited by the number of
* AGs in all the filesystems mounted. Hence use the default large
* max_active value for this workqueue.
*/
xfs_alloc_wq = alloc_workqueue("xfsalloc", WQ_MEM_RECLAIM, 0);
if (!xfs_alloc_wq)
goto out_destroy_syncd;

return 0;

out_destroy_syncd:
destroy_workqueue(xfs_syncd_wq);
return -ENOMEM;
}

STATIC void
xfs_destroy_workqueues(void)
{
destroy_workqueue(xfs_alloc_wq);
destroy_workqueue(xfs_syncd_wq);
}

Expand Down

0 comments on commit 32a5e20

Please sign in to comment.