Message ID | 20240826071036.2445717-2-lizetao1@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | fs: Introduce the scope-based resource management for folio_lock/unlock | expand |
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index d9c7edb6422b..ed1831c115cc 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1537,4 +1537,8 @@ unsigned int i_blocks_per_folio(struct inode *inode, struct folio *folio) { return folio_size(folio) >> inode->i_blkbits; } + +DEFINE_LOCK_GUARD_1(folio, struct folio, folio_lock(_T->lock), folio_unlock(_T->lock)) +DEFINE_LOCK_GUARD_1_COND(folio, _try, folio_trylock(_T->lock)) + #endif /* _LINUX_PAGEMAP_H */
By introducing the DEFINE_LOCK_GUARD_1 definition, it is possible to lock and unlock of folio's lock based on scope. At the same time, the use of folio_trylock is also supported. Signed-off-by: Li Zetao <lizetao1@huawei.com> --- include/linux/pagemap.h | 4 ++++ 1 file changed, 4 insertions(+)