Skip to content

Commit e6fa396

Browse files
apopple-nvidiaakpm00
authored andcommitted
fs/dax: refactor wait for dax idle page
A FS DAX page is considered idle when its refcount drops to one. This is currently open-coded in all file systems supporting FS DAX. Move the idle detection to a common function to make future changes easier. Link: https://lkml.kernel.org/r/c2c9d269110b90224eeb1dc661ffbc1d82aa20c9.1740713401.git-series.apopple@nvidia.com Signed-off-by: Alistair Popple <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Dan Williams <[email protected]> Acked-by: Theodore Ts'o <[email protected]> Tested-by: Alison Schofield <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Asahi Lina <[email protected]> Cc: Balbir Singh <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Chunyan Zhang <[email protected]> Cc: "Darrick J. Wong" <[email protected]> Cc: Dave Chinner <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Dave Jiang <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Ira Weiny <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: John Hubbard <[email protected]> Cc: linmiaohe <[email protected]> Cc: Logan Gunthorpe <[email protected]> Cc: Matthew Wilcow (Oracle) <[email protected]> Cc: Michael "Camp Drill Sergeant" Ellerman <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Peter Xu <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Vishal Verma <[email protected]> Cc: Vivek Goyal <[email protected]> Cc: WANG Xuerui <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6be3e21 commit e6fa396

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

fs/ext4/inode.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3922,10 +3922,7 @@ int ext4_break_layouts(struct inode *inode)
39223922
if (!page)
39233923
return 0;
39243924

3925-
error = ___wait_var_event(&page->_refcount,
3926-
atomic_read(&page->_refcount) == 1,
3927-
TASK_INTERRUPTIBLE, 0, 0,
3928-
ext4_wait_dax_page(inode));
3925+
error = dax_wait_page_idle(page, ext4_wait_dax_page, inode);
39293926
} while (error == 0);
39303927

39313928
return error;

fs/fuse/dax.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,7 @@ static int __fuse_dax_break_layouts(struct inode *inode, bool *retry,
677677
return 0;
678678

679679
*retry = true;
680-
return ___wait_var_event(&page->_refcount,
681-
atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE,
682-
0, 0, fuse_wait_dax_page(inode));
680+
return dax_wait_page_idle(page, fuse_wait_dax_page, inode);
683681
}
684682

685683
int fuse_dax_break_layouts(struct inode *inode, u64 dmap_start,

fs/xfs/xfs_inode.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,9 +3020,7 @@ xfs_break_dax_layouts(
30203020
return 0;
30213021

30223022
*retry = true;
3023-
return ___wait_var_event(&page->_refcount,
3024-
atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE,
3025-
0, 0, xfs_wait_dax_page(inode));
3023+
return dax_wait_page_idle(page, xfs_wait_dax_page, inode);
30263024
}
30273025

30283026
int

include/linux/dax.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ int dax_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero,
207207
int dax_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,
208208
const struct iomap_ops *ops);
209209

210+
static inline int dax_wait_page_idle(struct page *page,
211+
void (cb)(struct inode *),
212+
struct inode *inode)
213+
{
214+
return ___wait_var_event(page, page_ref_count(page) == 1,
215+
TASK_INTERRUPTIBLE, 0, 0, cb(inode));
216+
}
217+
210218
#if IS_ENABLED(CONFIG_DAX)
211219
int dax_read_lock(void);
212220
void dax_read_unlock(int id);

0 commit comments

Comments
 (0)