mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
btrfs: plumb fs_info into btrfs_work
In order to provide an fsid for trace events, we'll need a btrfs_fs_info pointer. The most lightweight way to do that for btrfs_work structures is to associate it with the __btrfs_workqueue structure. Each queued btrfs_work structure has a workqueue associated with it, so that's a natural fit. It's a privately defined structures, so we add accessors to retrieve the fs_info pointer. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
9f8d49095b
commit
cb001095ca
4 changed files with 63 additions and 31 deletions
|
@ -34,6 +34,10 @@
|
|||
|
||||
struct __btrfs_workqueue {
|
||||
struct workqueue_struct *normal_wq;
|
||||
|
||||
/* File system this workqueue services */
|
||||
struct btrfs_fs_info *fs_info;
|
||||
|
||||
/* List head pointing to ordered work list */
|
||||
struct list_head ordered_list;
|
||||
|
||||
|
@ -70,6 +74,18 @@ void btrfs_##name(struct work_struct *arg) \
|
|||
normal_work_helper(work); \
|
||||
}
|
||||
|
||||
struct btrfs_fs_info *
|
||||
btrfs_workqueue_owner(struct __btrfs_workqueue *wq)
|
||||
{
|
||||
return wq->fs_info;
|
||||
}
|
||||
|
||||
struct btrfs_fs_info *
|
||||
btrfs_work_owner(struct btrfs_work *work)
|
||||
{
|
||||
return work->wq->fs_info;
|
||||
}
|
||||
|
||||
BTRFS_WORK_HELPER(worker_helper);
|
||||
BTRFS_WORK_HELPER(delalloc_helper);
|
||||
BTRFS_WORK_HELPER(flush_delalloc_helper);
|
||||
|
@ -94,14 +110,15 @@ BTRFS_WORK_HELPER(scrubnc_helper);
|
|||
BTRFS_WORK_HELPER(scrubparity_helper);
|
||||
|
||||
static struct __btrfs_workqueue *
|
||||
__btrfs_alloc_workqueue(const char *name, unsigned int flags, int limit_active,
|
||||
int thresh)
|
||||
__btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, const char *name,
|
||||
unsigned int flags, int limit_active, int thresh)
|
||||
{
|
||||
struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_KERNEL);
|
||||
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
ret->fs_info = fs_info;
|
||||
ret->limit_active = limit_active;
|
||||
atomic_set(&ret->pending, 0);
|
||||
if (thresh == 0)
|
||||
|
@ -143,7 +160,8 @@ __btrfs_alloc_workqueue(const char *name, unsigned int flags, int limit_active,
|
|||
static inline void
|
||||
__btrfs_destroy_workqueue(struct __btrfs_workqueue *wq);
|
||||
|
||||
struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
|
||||
struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info,
|
||||
const char *name,
|
||||
unsigned int flags,
|
||||
int limit_active,
|
||||
int thresh)
|
||||
|
@ -153,7 +171,8 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
|
|||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
ret->normal = __btrfs_alloc_workqueue(name, flags & ~WQ_HIGHPRI,
|
||||
ret->normal = __btrfs_alloc_workqueue(fs_info, name,
|
||||
flags & ~WQ_HIGHPRI,
|
||||
limit_active, thresh);
|
||||
if (!ret->normal) {
|
||||
kfree(ret);
|
||||
|
@ -161,8 +180,8 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
|
|||
}
|
||||
|
||||
if (flags & WQ_HIGHPRI) {
|
||||
ret->high = __btrfs_alloc_workqueue(name, flags, limit_active,
|
||||
thresh);
|
||||
ret->high = __btrfs_alloc_workqueue(fs_info, name, flags,
|
||||
limit_active, thresh);
|
||||
if (!ret->high) {
|
||||
__btrfs_destroy_workqueue(ret->normal);
|
||||
kfree(ret);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue