Skip to content

Commit 439bc39

Browse files
Christoph Hellwigaxboe
authored andcommitted
fs: move sb_init_dio_done_wq out of direct-io.c
sb_init_dio_done_wq is also used by the iomap code, so move it to super.c in preparation for building direct-io.c conditionally. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Eric Biggers <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 2241ab5 commit 439bc39

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

fs/direct-io.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -558,30 +558,6 @@ static inline int dio_bio_reap(struct dio *dio, struct dio_submit *sdio)
558558
return ret;
559559
}
560560

561-
/*
562-
* Create workqueue for deferred direct IO completions. We allocate the
563-
* workqueue when it's first needed. This avoids creating workqueue for
564-
* filesystems that don't need it and also allows us to create the workqueue
565-
* late enough so the we can include s_id in the name of the workqueue.
566-
*/
567-
int sb_init_dio_done_wq(struct super_block *sb)
568-
{
569-
struct workqueue_struct *old;
570-
struct workqueue_struct *wq = alloc_workqueue("dio/%s",
571-
WQ_MEM_RECLAIM, 0,
572-
sb->s_id);
573-
if (!wq)
574-
return -ENOMEM;
575-
/*
576-
* This has to be atomic as more DIOs can race to create the workqueue
577-
*/
578-
old = cmpxchg(&sb->s_dio_done_wq, NULL, wq);
579-
/* Someone created workqueue before us? Free ours... */
580-
if (old)
581-
destroy_workqueue(wq);
582-
return 0;
583-
}
584-
585561
static int dio_set_defer_completion(struct dio *dio)
586562
{
587563
struct super_block *sb = dio->inode->i_sb;

fs/internal.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ extern bool trylock_super(struct super_block *sb);
120120
struct super_block *user_get_super(dev_t, bool excl);
121121
void put_super(struct super_block *sb);
122122
extern bool mount_capable(struct fs_context *);
123+
int sb_init_dio_done_wq(struct super_block *sb);
123124

124125
/*
125126
* open.c
@@ -187,9 +188,6 @@ extern void mnt_pin_kill(struct mount *m);
187188
*/
188189
extern const struct dentry_operations ns_dentry_operations;
189190

190-
/* direct-io.c: */
191-
int sb_init_dio_done_wq(struct super_block *sb);
192-
193191
/*
194192
* fs/stat.c:
195193
*/

fs/super.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,3 +1764,27 @@ int thaw_super(struct super_block *sb)
17641764
return thaw_super_locked(sb);
17651765
}
17661766
EXPORT_SYMBOL(thaw_super);
1767+
1768+
/*
1769+
* Create workqueue for deferred direct IO completions. We allocate the
1770+
* workqueue when it's first needed. This avoids creating workqueue for
1771+
* filesystems that don't need it and also allows us to create the workqueue
1772+
* late enough so the we can include s_id in the name of the workqueue.
1773+
*/
1774+
int sb_init_dio_done_wq(struct super_block *sb)
1775+
{
1776+
struct workqueue_struct *old;
1777+
struct workqueue_struct *wq = alloc_workqueue("dio/%s",
1778+
WQ_MEM_RECLAIM, 0,
1779+
sb->s_id);
1780+
if (!wq)
1781+
return -ENOMEM;
1782+
/*
1783+
* This has to be atomic as more DIOs can race to create the workqueue
1784+
*/
1785+
old = cmpxchg(&sb->s_dio_done_wq, NULL, wq);
1786+
/* Someone created workqueue before us? Free ours... */
1787+
if (old)
1788+
destroy_workqueue(wq);
1789+
return 0;
1790+
}

0 commit comments

Comments
 (0)