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 <hch@lst.de> Reviewed-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20230125065839.191256-2-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
2241ab53cb
commit
439bc39b3c
|
@ -558,30 +558,6 @@ static inline int dio_bio_reap(struct dio *dio, struct dio_submit *sdio)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Create workqueue for deferred direct IO completions. We allocate the
|
|
||||||
* workqueue when it's first needed. This avoids creating workqueue for
|
|
||||||
* filesystems that don't need it and also allows us to create the workqueue
|
|
||||||
* late enough so the we can include s_id in the name of the workqueue.
|
|
||||||
*/
|
|
||||||
int sb_init_dio_done_wq(struct super_block *sb)
|
|
||||||
{
|
|
||||||
struct workqueue_struct *old;
|
|
||||||
struct workqueue_struct *wq = alloc_workqueue("dio/%s",
|
|
||||||
WQ_MEM_RECLAIM, 0,
|
|
||||||
sb->s_id);
|
|
||||||
if (!wq)
|
|
||||||
return -ENOMEM;
|
|
||||||
/*
|
|
||||||
* This has to be atomic as more DIOs can race to create the workqueue
|
|
||||||
*/
|
|
||||||
old = cmpxchg(&sb->s_dio_done_wq, NULL, wq);
|
|
||||||
/* Someone created workqueue before us? Free ours... */
|
|
||||||
if (old)
|
|
||||||
destroy_workqueue(wq);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dio_set_defer_completion(struct dio *dio)
|
static int dio_set_defer_completion(struct dio *dio)
|
||||||
{
|
{
|
||||||
struct super_block *sb = dio->inode->i_sb;
|
struct super_block *sb = dio->inode->i_sb;
|
||||||
|
|
|
@ -120,6 +120,7 @@ extern bool trylock_super(struct super_block *sb);
|
||||||
struct super_block *user_get_super(dev_t, bool excl);
|
struct super_block *user_get_super(dev_t, bool excl);
|
||||||
void put_super(struct super_block *sb);
|
void put_super(struct super_block *sb);
|
||||||
extern bool mount_capable(struct fs_context *);
|
extern bool mount_capable(struct fs_context *);
|
||||||
|
int sb_init_dio_done_wq(struct super_block *sb);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* open.c
|
* open.c
|
||||||
|
@ -187,9 +188,6 @@ extern void mnt_pin_kill(struct mount *m);
|
||||||
*/
|
*/
|
||||||
extern const struct dentry_operations ns_dentry_operations;
|
extern const struct dentry_operations ns_dentry_operations;
|
||||||
|
|
||||||
/* direct-io.c: */
|
|
||||||
int sb_init_dio_done_wq(struct super_block *sb);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fs/stat.c:
|
* fs/stat.c:
|
||||||
*/
|
*/
|
||||||
|
|
24
fs/super.c
24
fs/super.c
|
@ -1764,3 +1764,27 @@ int thaw_super(struct super_block *sb)
|
||||||
return thaw_super_locked(sb);
|
return thaw_super_locked(sb);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(thaw_super);
|
EXPORT_SYMBOL(thaw_super);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create workqueue for deferred direct IO completions. We allocate the
|
||||||
|
* workqueue when it's first needed. This avoids creating workqueue for
|
||||||
|
* filesystems that don't need it and also allows us to create the workqueue
|
||||||
|
* late enough so the we can include s_id in the name of the workqueue.
|
||||||
|
*/
|
||||||
|
int sb_init_dio_done_wq(struct super_block *sb)
|
||||||
|
{
|
||||||
|
struct workqueue_struct *old;
|
||||||
|
struct workqueue_struct *wq = alloc_workqueue("dio/%s",
|
||||||
|
WQ_MEM_RECLAIM, 0,
|
||||||
|
sb->s_id);
|
||||||
|
if (!wq)
|
||||||
|
return -ENOMEM;
|
||||||
|
/*
|
||||||
|
* This has to be atomic as more DIOs can race to create the workqueue
|
||||||
|
*/
|
||||||
|
old = cmpxchg(&sb->s_dio_done_wq, NULL, wq);
|
||||||
|
/* Someone created workqueue before us? Free ours... */
|
||||||
|
if (old)
|
||||||
|
destroy_workqueue(wq);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue