From 972b9dd4e4180fbb2352bf2f0e015b7b63f5cca0 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 26 Mar 2026 10:54:16 +0100 Subject: fs: Ignore inode metadata buffers in inode_lru_isolate() There are only a few filesystems that use generic tracking of inode metadata buffer heads. As such the logic to reclaim tracked metadata buffer heads in inode_lru_isolate() doesn't bring a benefit big enough to justify intertwining of inode reclaim and metadata buffer head tracking. Just treat tracked metadata buffer heads as any other metadata filesystem has to properly clean up on inode eviction and stop handling it in inode_lru_isolate(). As a result filesystems using generic tracking of metadata buffer heads may now see dirty metadata buffers in their .evict methods more often which can slow down inode reclaim but given these filesystems aren't used in performance demanding setups we should be fine. Signed-off-by: Jan Kara Link: https://patch.msgid.link/20260326095354.16340-64-jack@suse.cz Tested-by: syzbot@syzkaller.appspotmail.com Signed-off-by: Christian Brauner --- include/linux/buffer_head.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include/linux/buffer_head.h') diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index b16b88bfbc3e..631bf971efc0 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -517,7 +517,6 @@ void buffer_init(void); bool try_to_free_buffers(struct folio *folio); int inode_has_buffers(struct inode *inode); void invalidate_inode_buffers(struct inode *inode); -int remove_inode_buffers(struct inode *inode); int sync_mapping_buffers(struct address_space *mapping); void invalidate_bh_lrus(void); void invalidate_bh_lrus_cpu(void); @@ -528,9 +527,7 @@ extern int buffer_heads_over_limit; static inline void buffer_init(void) {} static inline bool try_to_free_buffers(struct folio *folio) { return true; } -static inline int inode_has_buffers(struct inode *inode) { return 0; } static inline void invalidate_inode_buffers(struct inode *inode) {} -static inline int remove_inode_buffers(struct inode *inode) { return 1; } static inline int sync_mapping_buffers(struct address_space *mapping) { return 0; } static inline void invalidate_bh_lrus(void) {} static inline void invalidate_bh_lrus_cpu(void) {} -- cgit v1.2.3 From c86f5d25514c2a60fcf5ea0aa11c5d8bd1a313ef Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 26 Mar 2026 10:54:25 +0100 Subject: fs: Make bhs point to mapping_metadata_bhs Make buffer heads point to mapping_metadata_bhs instead of struct address_space. This makes the code more self contained. For the (only) case of IO error handling where we really need to reach struct address_space add a pointer to the mapping from mapping_metadata_bhs. Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara Link: https://patch.msgid.link/20260326095354.16340-73-jack@suse.cz Signed-off-by: Christian Brauner --- fs/buffer.c | 34 ++++++++++++++++------------------ fs/inode.c | 1 + include/linux/buffer_head.h | 4 ++-- include/linux/fs.h | 1 + 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'include/linux/buffer_head.h') diff --git a/fs/buffer.c b/fs/buffer.c index 294f9cd07f42..67b3d4624503 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -497,13 +497,12 @@ static void __remove_assoc_queue(struct mapping_metadata_bhs *mmb, { lockdep_assert_held(&mmb->lock); list_del_init(&bh->b_assoc_buffers); - WARN_ON(!bh->b_assoc_map); - bh->b_assoc_map = NULL; + WARN_ON(!bh->b_mmb); + bh->b_mmb = NULL; } static void remove_assoc_queue(struct buffer_head *bh) { - struct address_space *mapping; struct mapping_metadata_bhs *mmb; /* @@ -514,13 +513,12 @@ static void remove_assoc_queue(struct buffer_head *bh) * opportunistically acquire the lock and then recheck the bh * didn't move under us. */ - while (bh->b_assoc_map) { + while (bh->b_mmb) { rcu_read_lock(); - mapping = READ_ONCE(bh->b_assoc_map); - if (mapping) { - mmb = &mapping->i_metadata_bhs; + mmb = READ_ONCE(bh->b_mmb); + if (mmb) { spin_lock(&mmb->lock); - if (bh->b_assoc_map == mapping) + if (bh->b_mmb == mmb) __remove_assoc_queue(mmb, bh); spin_unlock(&mmb->lock); } @@ -551,9 +549,9 @@ EXPORT_SYMBOL_GPL(inode_has_buffers); * Do this in two main stages: first we copy dirty buffers to a * temporary inode list, queueing the writes as we go. Then we clean * up, waiting for those writes to complete. mark_buffer_dirty_inode() - * doesn't touch b_assoc_buffers list if b_assoc_map is not NULL so we - * are sure the buffer stays on our list until IO completes (at which point - * it can be reaped). + * doesn't touch b_assoc_buffers list if b_mmb is not NULL so we are sure the + * buffer stays on our list until IO completes (at which point it can be + * reaped). */ int sync_mapping_buffers(struct address_space *mapping) { @@ -571,14 +569,14 @@ int sync_mapping_buffers(struct address_space *mapping) spin_lock(&mmb->lock); while (!list_empty(&mmb->list)) { bh = BH_ENTRY(mmb->list.next); - WARN_ON_ONCE(bh->b_assoc_map != mapping); + WARN_ON_ONCE(bh->b_mmb != mmb); __remove_assoc_queue(mmb, bh); /* Avoid race with mark_buffer_dirty_inode() which does * a lockless check and we rely on seeing the dirty bit */ smp_mb(); if (buffer_dirty(bh) || buffer_locked(bh)) { list_add(&bh->b_assoc_buffers, &tmp); - bh->b_assoc_map = mapping; + bh->b_mmb = mmb; if (buffer_dirty(bh)) { get_bh(bh); spin_unlock(&mmb->lock); @@ -616,7 +614,7 @@ int sync_mapping_buffers(struct address_space *mapping) smp_mb(); if (buffer_dirty(bh)) { list_add(&bh->b_assoc_buffers, &mmb->list); - bh->b_assoc_map = mapping; + bh->b_mmb = mmb; } spin_unlock(&mmb->lock); wait_on_buffer(bh); @@ -724,11 +722,11 @@ void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode) struct address_space *mapping = inode->i_mapping; mark_buffer_dirty(bh); - if (!bh->b_assoc_map) { + if (!bh->b_mmb) { spin_lock(&mapping->i_metadata_bhs.lock); list_move_tail(&bh->b_assoc_buffers, &mapping->i_metadata_bhs.list); - bh->b_assoc_map = mapping; + bh->b_mmb = &mapping->i_metadata_bhs; spin_unlock(&mapping->i_metadata_bhs.lock); } } @@ -1124,8 +1122,8 @@ void mark_buffer_write_io_error(struct buffer_head *bh) /* FIXME: do we need to set this in both places? */ if (bh->b_folio && bh->b_folio->mapping) mapping_set_error(bh->b_folio->mapping, -EIO); - if (bh->b_assoc_map) - mapping_set_error(bh->b_assoc_map, -EIO); + if (bh->b_mmb) + mapping_set_error(bh->b_mmb->mapping, -EIO); } EXPORT_SYMBOL(mark_buffer_write_io_error); diff --git a/fs/inode.c b/fs/inode.c index 393f586d050a..3874b933abdb 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -276,6 +276,7 @@ int inode_init_always_gfp(struct super_block *sb, struct inode *inode, gfp_t gfp mapping->a_ops = &empty_aops; mapping->host = inode; + mapping->i_metadata_bhs.mapping = mapping; mapping->flags = 0; mapping->wb_err = 0; atomic_set(&mapping->i_mmap_writable, 0); diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 631bf971efc0..20636599d858 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -73,8 +73,8 @@ struct buffer_head { bh_end_io_t *b_end_io; /* I/O completion */ void *b_private; /* reserved for b_end_io */ struct list_head b_assoc_buffers; /* associated with another mapping */ - struct address_space *b_assoc_map; /* mapping this buffer is - associated with */ + struct mapping_metadata_bhs *b_mmb; /* head of the list of metadata bhs + * this buffer is associated with */ atomic_t b_count; /* users using this buffer_head */ spinlock_t b_uptodate_lock; /* Used by the first bh in a page, to * serialise IO completion of other diff --git a/include/linux/fs.h b/include/linux/fs.h index 76360b0040e0..fa2a812bd718 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -447,6 +447,7 @@ extern const struct address_space_operations empty_aops; /* Structure for tracking metadata buffer heads associated with the mapping */ struct mapping_metadata_bhs { + struct address_space *mapping; /* Mapping bhs are associated with */ spinlock_t lock; /* Lock protecting bh list */ struct list_head list; /* The list of bhs (b_assoc_buffers) */ }; -- cgit v1.2.3 From 025c9af1a20c8353f586c9bfd30705dfe4a277de Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 26 Mar 2026 10:54:26 +0100 Subject: fs: Switch inode_has_buffers() to take mapping_metadata_bhs As part of a move towards placing mapping_metadata_bhs in fs-private inode part, switch inode_has_buffers() to take mapping_metadata_bhs and rename the function to mmb_has_buffers(). Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara Link: https://patch.msgid.link/20260326095354.16340-74-jack@suse.cz Signed-off-by: Christian Brauner --- fs/buffer.c | 14 +++++++------- fs/ext4/inode.c | 2 +- include/linux/buffer_head.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'include/linux/buffer_head.h') diff --git a/fs/buffer.c b/fs/buffer.c index 67b3d4624503..b0436481d0f1 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -468,7 +468,7 @@ EXPORT_SYMBOL(mark_buffer_async_write); * written back and waited upon before fsync() returns. * * The functions mark_buffer_dirty_inode(), fsync_inode_buffers(), - * inode_has_buffers() and invalidate_inode_buffers() are provided for the + * mmb_has_buffers() and invalidate_inode_buffers() are provided for the * management of a list of dependent buffers in mapping_metadata_bhs struct. * * The locking is a little subtle: The list of buffer heads is protected by @@ -526,11 +526,11 @@ static void remove_assoc_queue(struct buffer_head *bh) } } -int inode_has_buffers(struct inode *inode) +bool mmb_has_buffers(struct mapping_metadata_bhs *mmb) { - return !list_empty(&inode->i_data.i_metadata_bhs.list); + return !list_empty(&mmb->list); } -EXPORT_SYMBOL_GPL(inode_has_buffers); +EXPORT_SYMBOL_GPL(mmb_has_buffers); /** * sync_mapping_buffers - write out & wait upon a mapping's "associated" buffers @@ -561,7 +561,7 @@ int sync_mapping_buffers(struct address_space *mapping) struct blk_plug plug; LIST_HEAD(tmp); - if (list_empty(&mmb->list)) + if (!mmb_has_buffers(mmb)) return 0; blk_start_plug(&plug); @@ -803,9 +803,9 @@ EXPORT_SYMBOL(block_dirty_folio); */ void invalidate_inode_buffers(struct inode *inode) { - if (inode_has_buffers(inode)) { - struct mapping_metadata_bhs *mmb = &inode->i_data.i_metadata_bhs; + struct mapping_metadata_bhs *mmb = &inode->i_data.i_metadata_bhs; + if (mmb_has_buffers(mmb)) { spin_lock(&mmb->lock); while (!list_empty(&mmb->list)) __remove_assoc_queue(mmb, BH_ENTRY(mmb->list.next)); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 6f892abef003..011cb2eb16a2 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3436,7 +3436,7 @@ static bool ext4_inode_datasync_dirty(struct inode *inode) } /* Any metadata buffers to write? */ - if (inode_has_buffers(inode)) + if (mmb_has_buffers(&inode->i_mapping->i_metadata_bhs)) return true; return inode_state_read_once(inode) & I_DIRTY_DATASYNC; } diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 20636599d858..44094fd476f5 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -515,7 +515,7 @@ bool block_dirty_folio(struct address_space *mapping, struct folio *folio); void buffer_init(void); bool try_to_free_buffers(struct folio *folio); -int inode_has_buffers(struct inode *inode); +bool mmb_has_buffers(struct mapping_metadata_bhs *mmb); void invalidate_inode_buffers(struct inode *inode); int sync_mapping_buffers(struct address_space *mapping); void invalidate_bh_lrus(void); -- cgit v1.2.3 From a8c8122a3dac55d25a1912b8fec9b8cd7366c37a Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 26 Mar 2026 10:54:27 +0100 Subject: fs: Provide functions for handling mapping_metadata_bhs directly As part of transition toward moving mapping_metadata_bhs to fs-private part of the inode, provide functions for operations on this list directly instead of going through the inode / mapping. Signed-off-by: Jan Kara Link: https://patch.msgid.link/20260326095354.16340-75-jack@suse.cz Signed-off-by: Christian Brauner --- fs/buffer.c | 110 ++++++++++++++++++++------------------------ include/linux/buffer_head.h | 44 ++++++++++++++---- 2 files changed, 87 insertions(+), 67 deletions(-) (limited to 'include/linux/buffer_head.h') diff --git a/fs/buffer.c b/fs/buffer.c index b0436481d0f1..cbed175f418b 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -467,31 +467,25 @@ EXPORT_SYMBOL(mark_buffer_async_write); * a successful fsync(). For example, ext2 indirect blocks need to be * written back and waited upon before fsync() returns. * - * The functions mark_buffer_dirty_inode(), fsync_inode_buffers(), - * mmb_has_buffers() and invalidate_inode_buffers() are provided for the - * management of a list of dependent buffers in mapping_metadata_bhs struct. + * The functions mmb_mark_buffer_dirty(), mmb_sync(), mmb_has_buffers() + * and mmb_invalidate() are provided for the management of a list of dependent + * buffers in mapping_metadata_bhs struct. * * The locking is a little subtle: The list of buffer heads is protected by * the lock in mapping_metadata_bhs so functions coming from bdev mapping * (such as try_to_free_buffers()) need to safely get to mapping_metadata_bhs * using RCU, grab the lock, verify we didn't race with somebody detaching the * bh / moving it to different inode and only then proceeding. - * - * FIXME: mark_buffer_dirty_inode() is a data-plane operation. It should - * take an address_space, not an inode. And it should be called - * mark_buffer_dirty_fsync() to clearly define why those buffers are being - * queued up. - * - * FIXME: mark_buffer_dirty_inode() doesn't need to add the buffer to the - * list if it is already on a list. Because if the buffer is on a list, - * it *must* already be on the right one. If not, the filesystem is being - * silly. This will save a ton of locking. But first we have to ensure - * that buffers are taken *off* the old inode's list when they are freed - * (presumably in truncate). That requires careful auditing of all - * filesystems (do it inside bforget()). It could also be done by bringing - * b_inode back. */ +void mmb_init(struct mapping_metadata_bhs *mmb, struct address_space *mapping) +{ + spin_lock_init(&mmb->lock); + INIT_LIST_HEAD(&mmb->list); + mmb->mapping = mapping; +} +EXPORT_SYMBOL(mmb_init); + static void __remove_assoc_queue(struct mapping_metadata_bhs *mmb, struct buffer_head *bh) { @@ -533,12 +527,12 @@ bool mmb_has_buffers(struct mapping_metadata_bhs *mmb) EXPORT_SYMBOL_GPL(mmb_has_buffers); /** - * sync_mapping_buffers - write out & wait upon a mapping's "associated" buffers - * @mapping: the mapping which wants those buffers written + * mmb_sync - write out & wait upon all buffers in a list + * @mmb: the list of buffers to write * - * Starts I/O against the buffers at mapping->i_metadata_bhs and waits upon - * that I/O. Basically, this is a convenience function for fsync(). @mapping - * is a file or directory which needs those buffers to be written for a + * Starts I/O against the buffers in the given list and waits upon + * that I/O. Basically, this is a convenience function for fsync(). @mmb is + * for a file or directory which needs those buffers to be written for a * successful fsync(). * * We have conflicting pressures: we want to make sure that all @@ -553,9 +547,8 @@ EXPORT_SYMBOL_GPL(mmb_has_buffers); * buffer stays on our list until IO completes (at which point it can be * reaped). */ -int sync_mapping_buffers(struct address_space *mapping) +int mmb_sync(struct mapping_metadata_bhs *mmb) { - struct mapping_metadata_bhs *mmb = &mapping->i_metadata_bhs; struct buffer_head *bh; int err = 0; struct blk_plug plug; @@ -626,33 +619,35 @@ int sync_mapping_buffers(struct address_space *mapping) spin_unlock(&mmb->lock); return err; } -EXPORT_SYMBOL(sync_mapping_buffers); +EXPORT_SYMBOL(mmb_sync); /** - * generic_buffers_fsync_noflush - generic buffer fsync implementation - * for simple filesystems with no inode lock + * mmb_fsync_noflush - fsync implementation for simple filesystems with + * metadata buffers list * * @file: file to synchronize + * @mmb: list of metadata bhs to flush * @start: start offset in bytes * @end: end offset in bytes (inclusive) * @datasync: only synchronize essential metadata if true * - * This is a generic implementation of the fsync method for simple - * filesystems which track all non-inode metadata in the buffers list - * hanging off the address_space structure. + * This is an implementation of the fsync method for simple filesystems which + * track all non-inode metadata in the buffers list hanging off the @mmb + * structure. */ -int generic_buffers_fsync_noflush(struct file *file, loff_t start, loff_t end, - bool datasync) +int mmb_fsync_noflush(struct file *file, struct mapping_metadata_bhs *mmb, + loff_t start, loff_t end, bool datasync) { struct inode *inode = file->f_mapping->host; int err; - int ret; + int ret = 0; err = file_write_and_wait_range(file, start, end); if (err) return err; - ret = sync_mapping_buffers(inode->i_mapping); + if (mmb) + ret = mmb_sync(mmb); if (!(inode_state_read_once(inode) & I_DIRTY_ALL)) goto out; if (datasync && !(inode_state_read_once(inode) & I_DIRTY_DATASYNC)) @@ -669,34 +664,35 @@ out: ret = err; return ret; } -EXPORT_SYMBOL(generic_buffers_fsync_noflush); +EXPORT_SYMBOL(mmb_fsync_noflush); /** - * generic_buffers_fsync - generic buffer fsync implementation - * for simple filesystems with no inode lock + * mmb_fsync - fsync implementation for simple filesystems with metadata + * buffers list * * @file: file to synchronize + * @mmb: list of metadata bhs to flush * @start: start offset in bytes * @end: end offset in bytes (inclusive) * @datasync: only synchronize essential metadata if true * - * This is a generic implementation of the fsync method for simple - * filesystems which track all non-inode metadata in the buffers list - * hanging off the address_space structure. This also makes sure that - * a device cache flush operation is called at the end. + * This is an implementation of the fsync method for simple filesystems which + * track all non-inode metadata in the buffers list hanging off the @mmb + * structure. This also makes sure that a device cache flush operation is + * called at the end. */ -int generic_buffers_fsync(struct file *file, loff_t start, loff_t end, - bool datasync) +int mmb_fsync(struct file *file, struct mapping_metadata_bhs *mmb, + loff_t start, loff_t end, bool datasync) { struct inode *inode = file->f_mapping->host; int ret; - ret = generic_buffers_fsync_noflush(file, start, end, datasync); + ret = mmb_fsync_noflush(file, mmb, start, end, datasync); if (!ret) ret = blkdev_issue_flush(inode->i_sb->s_bdev); return ret; } -EXPORT_SYMBOL(generic_buffers_fsync); +EXPORT_SYMBOL(mmb_fsync); /* * Called when we've recently written block `bblock', and it is known that @@ -717,20 +713,18 @@ void write_boundary_block(struct block_device *bdev, } } -void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode) +void mmb_mark_buffer_dirty(struct buffer_head *bh, + struct mapping_metadata_bhs *mmb) { - struct address_space *mapping = inode->i_mapping; - mark_buffer_dirty(bh); if (!bh->b_mmb) { - spin_lock(&mapping->i_metadata_bhs.lock); - list_move_tail(&bh->b_assoc_buffers, - &mapping->i_metadata_bhs.list); - bh->b_mmb = &mapping->i_metadata_bhs; - spin_unlock(&mapping->i_metadata_bhs.lock); + spin_lock(&mmb->lock); + list_move_tail(&bh->b_assoc_buffers, &mmb->list); + bh->b_mmb = mmb; + spin_unlock(&mmb->lock); } } -EXPORT_SYMBOL(mark_buffer_dirty_inode); +EXPORT_SYMBOL(mmb_mark_buffer_dirty); /** * block_dirty_folio - Mark a folio as dirty. @@ -797,14 +791,12 @@ bool block_dirty_folio(struct address_space *mapping, struct folio *folio) EXPORT_SYMBOL(block_dirty_folio); /* - * Invalidate any and all dirty buffers on a given inode. We are + * Invalidate any and all dirty buffers on a given buffers list. We are * probably unmounting the fs, but that doesn't mean we have already * done a sync(). Just drop the buffers from the inode list. */ -void invalidate_inode_buffers(struct inode *inode) +void mmb_invalidate(struct mapping_metadata_bhs *mmb) { - struct mapping_metadata_bhs *mmb = &inode->i_data.i_metadata_bhs; - if (mmb_has_buffers(mmb)) { spin_lock(&mmb->lock); while (!list_empty(&mmb->list)) @@ -812,7 +804,7 @@ void invalidate_inode_buffers(struct inode *inode) spin_unlock(&mmb->lock); } } -EXPORT_SYMBOL(invalidate_inode_buffers); +EXPORT_SYMBOL(mmb_invalidate); /* * Create the appropriate buffers when given a folio for data area and diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 44094fd476f5..e207dcca7a25 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -205,12 +205,30 @@ struct buffer_head *create_empty_buffers(struct folio *folio, void end_buffer_read_sync(struct buffer_head *bh, int uptodate); void end_buffer_write_sync(struct buffer_head *bh, int uptodate); -/* Things to do with buffers at mapping->private_list */ -void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode); -int generic_buffers_fsync_noflush(struct file *file, loff_t start, loff_t end, - bool datasync); -int generic_buffers_fsync(struct file *file, loff_t start, loff_t end, - bool datasync); +/* Things to do with metadata buffers list */ +void mmb_mark_buffer_dirty(struct buffer_head *bh, struct mapping_metadata_bhs *mmb); +static inline void mark_buffer_dirty_inode(struct buffer_head *bh, + struct inode *inode) +{ + mmb_mark_buffer_dirty(bh, &inode->i_data.i_metadata_bhs); +} +int mmb_fsync_noflush(struct file *file, struct mapping_metadata_bhs *mmb, + loff_t start, loff_t end, bool datasync); +static inline int generic_buffers_fsync_noflush(struct file *file, + loff_t start, loff_t end, + bool datasync) +{ + return mmb_fsync_noflush(file, &file->f_mapping->i_metadata_bhs, + start, end, datasync); +} +int mmb_fsync(struct file *file, struct mapping_metadata_bhs *mmb, + loff_t start, loff_t end, bool datasync); +static inline int generic_buffers_fsync(struct file *file, + loff_t start, loff_t end, bool datasync) +{ + return mmb_fsync(file, &file->f_mapping->i_metadata_bhs, + start, end, datasync); +} void clean_bdev_aliases(struct block_device *bdev, sector_t block, sector_t len); static inline void clean_bdev_bh_alias(struct buffer_head *bh) @@ -515,9 +533,18 @@ bool block_dirty_folio(struct address_space *mapping, struct folio *folio); void buffer_init(void); bool try_to_free_buffers(struct folio *folio); +void mmb_init(struct mapping_metadata_bhs *mmb, struct address_space *mapping); bool mmb_has_buffers(struct mapping_metadata_bhs *mmb); -void invalidate_inode_buffers(struct inode *inode); -int sync_mapping_buffers(struct address_space *mapping); +void mmb_invalidate(struct mapping_metadata_bhs *mmb); +int mmb_sync(struct mapping_metadata_bhs *mmb); +static inline void invalidate_inode_buffers(struct inode *inode) +{ + mmb_invalidate(&inode->i_data.i_metadata_bhs); +} +static inline int sync_mapping_buffers(struct address_space *mapping) +{ + return mmb_sync(&mapping->i_metadata_bhs); +} void invalidate_bh_lrus(void); void invalidate_bh_lrus_cpu(void); bool has_bh_in_lru(int cpu, void *dummy); @@ -527,6 +554,7 @@ extern int buffer_heads_over_limit; static inline void buffer_init(void) {} static inline bool try_to_free_buffers(struct folio *folio) { return true; } +static inline int mmb_sync(struct mapping_metadata_bhs *mmb) { return 0; } static inline void invalidate_inode_buffers(struct inode *inode) {} static inline int sync_mapping_buffers(struct address_space *mapping) { return 0; } static inline void invalidate_bh_lrus(void) {} -- cgit v1.2.3 From cb6d109b9ccc374d09812c2387ab826499ee6562 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 26 Mar 2026 10:54:35 +0100 Subject: fs: Drop mapping_metadata_bhs from address space Nobody uses mapping_metadata_bhs in struct address_space anymore. Just remove it and with it all helper functions using it. Signed-off-by: Jan Kara Link: https://patch.msgid.link/20260326095354.16340-83-jack@suse.cz Signed-off-by: Christian Brauner --- fs/inode.c | 3 --- include/linux/buffer_head.h | 28 ---------------------------- include/linux/fs.h | 1 - 3 files changed, 32 deletions(-) (limited to 'include/linux/buffer_head.h') diff --git a/fs/inode.c b/fs/inode.c index 3874b933abdb..d5774e627a9c 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -276,7 +276,6 @@ int inode_init_always_gfp(struct super_block *sb, struct inode *inode, gfp_t gfp mapping->a_ops = &empty_aops; mapping->host = inode; - mapping->i_metadata_bhs.mapping = mapping; mapping->flags = 0; mapping->wb_err = 0; atomic_set(&mapping->i_mmap_writable, 0); @@ -484,8 +483,6 @@ static void __address_space_init_once(struct address_space *mapping) init_rwsem(&mapping->i_mmap_rwsem); INIT_LIST_HEAD(&mapping->i_private_list); spin_lock_init(&mapping->i_private_lock); - spin_lock_init(&mapping->i_metadata_bhs.lock); - INIT_LIST_HEAD(&mapping->i_metadata_bhs.list); mapping->i_mmap = RB_ROOT_CACHED; } diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index e207dcca7a25..e4939e33b4b5 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -207,28 +207,10 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate); /* Things to do with metadata buffers list */ void mmb_mark_buffer_dirty(struct buffer_head *bh, struct mapping_metadata_bhs *mmb); -static inline void mark_buffer_dirty_inode(struct buffer_head *bh, - struct inode *inode) -{ - mmb_mark_buffer_dirty(bh, &inode->i_data.i_metadata_bhs); -} int mmb_fsync_noflush(struct file *file, struct mapping_metadata_bhs *mmb, loff_t start, loff_t end, bool datasync); -static inline int generic_buffers_fsync_noflush(struct file *file, - loff_t start, loff_t end, - bool datasync) -{ - return mmb_fsync_noflush(file, &file->f_mapping->i_metadata_bhs, - start, end, datasync); -} int mmb_fsync(struct file *file, struct mapping_metadata_bhs *mmb, loff_t start, loff_t end, bool datasync); -static inline int generic_buffers_fsync(struct file *file, - loff_t start, loff_t end, bool datasync) -{ - return mmb_fsync(file, &file->f_mapping->i_metadata_bhs, - start, end, datasync); -} void clean_bdev_aliases(struct block_device *bdev, sector_t block, sector_t len); static inline void clean_bdev_bh_alias(struct buffer_head *bh) @@ -537,14 +519,6 @@ void mmb_init(struct mapping_metadata_bhs *mmb, struct address_space *mapping); bool mmb_has_buffers(struct mapping_metadata_bhs *mmb); void mmb_invalidate(struct mapping_metadata_bhs *mmb); int mmb_sync(struct mapping_metadata_bhs *mmb); -static inline void invalidate_inode_buffers(struct inode *inode) -{ - mmb_invalidate(&inode->i_data.i_metadata_bhs); -} -static inline int sync_mapping_buffers(struct address_space *mapping) -{ - return mmb_sync(&mapping->i_metadata_bhs); -} void invalidate_bh_lrus(void); void invalidate_bh_lrus_cpu(void); bool has_bh_in_lru(int cpu, void *dummy); @@ -555,8 +529,6 @@ extern int buffer_heads_over_limit; static inline void buffer_init(void) {} static inline bool try_to_free_buffers(struct folio *folio) { return true; } static inline int mmb_sync(struct mapping_metadata_bhs *mmb) { return 0; } -static inline void invalidate_inode_buffers(struct inode *inode) {} -static inline int sync_mapping_buffers(struct address_space *mapping) { return 0; } static inline void invalidate_bh_lrus(void) {} static inline void invalidate_bh_lrus_cpu(void) {} static inline bool has_bh_in_lru(int cpu, void *dummy) { return false; } diff --git a/include/linux/fs.h b/include/linux/fs.h index fa2a812bd718..ccfa696253c8 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -491,7 +491,6 @@ struct address_space { errseq_t wb_err; spinlock_t i_private_lock; struct list_head i_private_list; - struct mapping_metadata_bhs i_metadata_bhs; struct rw_semaphore i_mmap_rwsem; } __attribute__((aligned(sizeof(long)))) __randomize_layout; /* -- cgit v1.2.3