[PATCH 34/41] bfs: Track metadata bhs in fs-private inode part

Jan Kara
2026-03-20T13:43:40Z

Track metadata bhs for an inode in fs-private part of the inode.

Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/bfs/bfs.h | 1 +
fs/bfs/dir.c | 16 ++++++++++++----
fs/bfs/inode.c | 6 ++++--
3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h
index 606f9378b2f0..b08afe733e63 100644
--- a/fs/bfs/bfs.h
+++ b/fs/bfs/bfs.h
@@ -35,6 +35,7 @@ struct bfs_inode_info {
unsigned long i_dsk_ino; /* inode number from the disk, can be 0 */
unsigned long i_sblock;
unsigned long i_eblock;
+ struct mapping_metadata_bhs i_metadata_bhs;
struct inode vfs_inode;
};

diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 1b140981dbf3..1dbce745d1ad 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -68,10 +68,17 @@ static int bfs_readdir(struct file *f, struct dir_context *ctx)
return 0;
}

+static int bfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
+{
+ return generic_mmb_fsync(file,
+ &BFS_I(file->f_mapping->host)->i_metadata_bhs,
+ start, end, datasync);
+}
+
const struct file_operations bfs_dir_operations = {
.read = generic_read_dir,
.iterate_shared = bfs_readdir,
- .fsync = generic_buffers_fsync,
+ .fsync = bfs_fsync,
.llseek = generic_file_llseek,
};

@@ -186,7 +193,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
set_nlink(inode, 1);
}
de->ino = 0;
- mark_buffer_dirty_inode(bh, dir);
+ mmb_mark_buffer_dirty(bh, &BFS_I(dir)->i_metadata_bhs);
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
mark_inode_dirty(dir);
inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
@@ -246,7 +253,7 @@ static int bfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
inode_set_ctime_current(new_inode);
inode_dec_link_count(new_inode);
}
- mark_buffer_dirty_inode(old_bh, old_dir);
+ mmb_mark_buffer_dirty(old_bh, &BFS_I(old_dir)->i_metadata_bhs);
error = 0;

end_rename:
@@ -296,7 +303,8 @@ static int bfs_add_entry(struct inode *dir, const struct qstr *child, int ino)
for (i = 0; i < BFS_NAMELEN; i++)
de->name[i] =
(i < namelen) ? name[i] : 0;
- mark_buffer_dirty_inode(bh, dir);
+ mmb_mark_buffer_dirty(bh,
+ &BFS_I(dir)->i_metadata_bhs);
brelse(bh);
return 0;
}
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index e0e50a9dbe9c..89f3da14e8c6 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -188,8 +188,8 @@ static void bfs_evict_inode(struct inode *inode)

truncate_inode_pages_final(&inode->i_data);
if (inode->i_nlink)
- sync_mapping_buffers(&inode->i_data);
- invalidate_inode_buffers(inode);
+ mmb_sync_buffers(&BFS_I(inode)->i_metadata_bhs);
+ mmb_invalidate_buffers(&BFS_I(inode)->i_metadata_bhs);
clear_inode(inode);

if (inode->i_nlink)
@@ -259,6 +259,8 @@ static struct inode *bfs_alloc_inode(struct super_block *sb)
bi = alloc_inode_sb(sb, bfs_inode_cachep, GFP_KERNEL);
if (!bi)
return NULL;
+ mmb_init(&bi->i_metadata_bhs, &bi->vfs_inode.i_data);
+
return &bi->vfs_inode;
}

--
2.51.0