From: Simon Glass <simon.glass@canonical.com> Create linux/writeback.h with wbc_to_tag() function, WB_REASON_* constants, and try_to_writeback_inodes_sb() stub for filesystem writeback control. Update ext4_uboot.h to use linux/writeback.h instead of duplicating these definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 14 +++-------- include/linux/writeback.h | 49 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 include/linux/writeback.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index bfeb31f465c..873f02cf508 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -863,19 +863,11 @@ static inline unsigned long memweight(const void *ptr, size_t bytes) #include <linux/pagemap.h> #include <linux/xarray.h> -/* wbc_to_tag - convert writeback control to pagecache tag */ -static inline xa_mark_t wbc_to_tag(struct writeback_control *wbc) -{ - if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) - return PAGECACHE_TAG_TOWRITE; - return PAGECACHE_TAG_DIRTY; -} +/* wbc_to_tag, WB_REASON_* - use linux/writeback.h */ +#include <linux/writeback.h> /* blk_plug is now in linux/blkdev.h */ -/* Writeback reasons */ -#define WB_REASON_FS_FREE_SPACE 0 - /* address_space_operations is in linux/fs.h */ /* buffer_migrate_folio, buffer_migrate_folio_norefs, noop_dirty_folio are in linux/buffer_head.h */ /* readahead_control, FGP_*, kmap/kunmap, folio stubs are in linux/pagemap.h */ @@ -952,7 +944,7 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* percpu_counter_sub is in linux/percpu_counter.h */ /* Filemap operations are in linux/pagemap.h */ -#define try_to_writeback_inodes_sb(sb, r) do { } while (0) +/* try_to_writeback_inodes_sb is in linux/writeback.h */ /* Buffer operations - additional */ #define getblk_unmovable(bdev, block, size) sb_getblk(bdev->bd_super, block) diff --git a/include/linux/writeback.h b/include/linux/writeback.h new file mode 100644 index 00000000000..e408e3ddebb --- /dev/null +++ b/include/linux/writeback.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Writeback definitions for U-Boot + * + * Based on Linux writeback.h - writeback control and operations. + * U-Boot stub - writeback operations are no-ops. + */ +#ifndef WRITEBACK_H +#define WRITEBACK_H + +#include <linux/pagemap.h> +#include <linux/xarray.h> + +/* Forward declarations */ +struct super_block; +struct writeback_control; + +/* Writeback reasons */ +#define WB_REASON_FS_FREE_SPACE 0 +#define WB_REASON_SYNC 1 +#define WB_REASON_PERIODIC 2 +#define WB_REASON_LAPTOP_TIMER 3 +#define WB_REASON_VMSCAN 4 +#define WB_REASON_FORKER_THREAD 5 + +/** + * wbc_to_tag() - convert writeback control to pagecache tag + * @wbc: writeback control structure + * + * Return: PAGECACHE_TAG_TOWRITE for sync writes, PAGECACHE_TAG_DIRTY otherwise + */ +static inline xa_mark_t wbc_to_tag(struct writeback_control *wbc) +{ + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) + return PAGECACHE_TAG_TOWRITE; + return PAGECACHE_TAG_DIRTY; +} + +/** + * try_to_writeback_inodes_sb() - try to start writeback on superblock + * @sb: superblock to writeback + * @reason: reason for writeback + * + * U-Boot stub - no-op since writeback is synchronous. + */ +#define try_to_writeback_inodes_sb(sb, reason) \ + do { (void)(sb); (void)(reason); } while (0) + +#endif /* WRITEBACK_H */ -- 2.43.0