From: Simon Glass <simon.glass@canonical.com>
Move block device operation stubs and declarations from ext4_uboot.h
to include/linux/blkdev.h where they belong.
This includes:
- bdev_read_only(), bdev_write_zeroes_unmap_sectors()
- bdev_dma_alignment(), bdev_nonrot(), bdev_discard_granularity()
- bdev_max_discard_sectors(), bdev_fput(), bdev_file_open_by_dev()
- bdev_getblk(), __bread(), set_blocksize()
- sync_blockdev(), invalidate_bdev()
- blkdev_issue_flush(), blkdev_issue_discard(), blkdev_issue_zeroout()
- BLK_MAX_SEGMENT_SIZE constant
Move bdev_read_only() implementation to stub.c since it needs the full
struct block_device definition.
Co-developed-by: Claude (Anthropic)
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
fs/ext4l/ext4_uboot.h | 46 +-----------------------------------------
fs/ext4l/stub.c | 5 +++++
include/linux/blkdev.h | 39 +++++++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+), 45 deletions(-)
@@ -131,9 +131,6 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode,
bool is_create);
#endif
-/* Block device operations - stubs */
-#define blkdev_issue_flush(bdev) ({ (void)(bdev); 0; })
-
#include <linux/rcupdate.h>
#include <linux/slab.h>
@@ -175,11 +172,6 @@ struct readahead_control;
struct fiemap_extent_info;
struct folio;
-static inline int bdev_read_only(struct block_device *bdev)
-{
- return bdev ? bdev->read_only : 0;
-}
-
#define WHITEOUT_DEV 0
#define WHITEOUT_MODE 0
@@ -233,9 +225,6 @@ struct dx_hash_info {
/* Memory retry wait */
#define memalloc_retry_wait(g) do { } while (0)
-/* bdev operations */
-#define bdev_write_zeroes_unmap_sectors(b) ({ (void)(b); 0; })
-
/* indirect.c stubs */
/* ext4_sb_bread_nofail is stubbed in interface.c */
@@ -311,9 +300,6 @@ extern struct inode *iget_locked(struct super_block *sb, unsigned long ino);
#define iomap_bmap(m, b, o) ({ (void)(m); (void)(b); (void)(o); 0UL; })
#define iomap_swapfile_activate(s, f, sp, o) ({ (void)(s); (void)(f); (void)(sp); (void)(o); -EOPNOTSUPP; })
-/* Block device alignment */
-#define bdev_dma_alignment(bd) (0)
-
/*
* Additional stubs for dir.c
*/
@@ -411,9 +397,7 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate);
/* blockgroup_lock - use linux/blockgroup_lock.h */
#include <linux/blockgroup_lock.h>
-/* Buffer submission stubs - declarations for stub.c implementations */
-struct buffer_head *bdev_getblk(struct block_device *bdev, sector_t block,
- unsigned int size, gfp_t gfp);
+/* Buffer submission stubs - declaration for stub.c */
int trylock_buffer(struct buffer_head *bh);
/* Trace stubs for super.c - declaration for stub.c implementation */
@@ -428,10 +412,6 @@ void fsnotify_sb_error(struct super_block *sb, struct inode *inode, int error);
char *file_path(struct file *file, char *buf, int buflen);
struct block_device *file_bdev(struct file *file);
-/* Block device sync - declarations for stub.c */
-int sync_blockdev(struct block_device *bdev);
-void invalidate_bdev(struct block_device *bdev);
-
/* kobject_put is now in linux/kobject.h */
/* wait_for_completion is now a macro in linux/completion.h */
@@ -454,26 +434,15 @@ void free_page(unsigned long addr);
void *fs_dax_get_by_bdev(struct block_device *bdev, u64 *start, u64 *len,
void *holder);
-/* Block device size - declaration for stub.c */
-unsigned int bdev_max_discard_sectors(struct block_device *bdev);
#include <linux/mbcache.h>
/* xattr helper stubs for xattr.c */
#define xattr_handler_can_list(h, d) ({ (void)(h); (void)(d); 0; })
#define xattr_prefix(h) ({ (void)(h); (const char *)NULL; })
-/* Block device operations - declarations for stub.c */
-void bdev_fput(void *file);
-void *bdev_file_open_by_dev(dev_t dev, int flags, void *holder,
- const struct blk_holder_ops *ops);
-
/* Filesystem sync - declaration for stub.c */
int sync_filesystem(void *sb);
-/* Block device file operations - stubs */
-#define set_blocksize(f, size) ({ (void)(f); (void)(size); 0; })
-struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned size);
-
/*
* Stubs for mballoc.c
*/
@@ -488,18 +457,9 @@ struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned
#define DEFINE_RAW_FLEX(type, name, member, count) \
type *name = NULL
-/* Block layer constants */
-#define BLK_MAX_SEGMENT_SIZE 65536
-
-/* Block device properties */
-#define bdev_nonrot(bdev) ({ (void)(bdev); 0; })
-
/* raw_cpu_ptr - get pointer to per-CPU data for current CPU */
#define raw_cpu_ptr(ptr) (ptr)
-#define bdev_discard_granularity(bdev) \
- ({ (void)(bdev); 0U; })
-
/*
* Stubs for page-io.c - bio types are in linux/bio.h
*/
@@ -556,10 +516,6 @@ int bmap(struct inode *inode, sector_t *block);
/* Block device operations for journal.c */
#define truncate_inode_pages_range(m, s, e) \
do { (void)(m); (void)(s); (void)(e); } while (0)
-#define blkdev_issue_discard(bdev, s, n, gfp) \
- ({ (void)(bdev); (void)(s); (void)(n); (void)(gfp); 0; })
-#define blkdev_issue_zeroout(bdev, s, n, gfp, f) \
- ({ (void)(bdev); (void)(s); (void)(n); (void)(gfp); (void)(f); 0; })
/* Memory allocation for journal.c */
#define __get_free_pages(gfp, order) ((unsigned long)memalign(PAGE_SIZE, PAGE_SIZE << (order)))
@@ -433,6 +433,11 @@ void invalidate_bdev(struct block_device *bdev)
{
}
+int bdev_read_only(struct block_device *bdev)
+{
+ return bdev ? bdev->read_only : 0;
+}
+
struct block_device *file_bdev(struct file *file)
{
return NULL;
@@ -55,4 +55,43 @@ struct blk_plug {
#define bdev_atomic_write_unit_max_bytes(bdev) ({ (void)(bdev); (unsigned int)0; })
#define bdev_atomic_write_unit_min_bytes(bdev) ({ (void)(bdev); 0UL; })
+/* Block device read-only check - implemented in ext4l/stub.c */
+int bdev_read_only(struct block_device *bdev);
+
+/* Block device property stubs */
+#define bdev_write_zeroes_unmap_sectors(b) ({ (void)(b); 0; })
+#define bdev_dma_alignment(bd) (0)
+#define bdev_nonrot(bdev) ({ (void)(bdev); 0; })
+#define bdev_discard_granularity(bdev) ({ (void)(bdev); 0U; })
+#define set_blocksize(f, size) ({ (void)(f); (void)(size); 0; })
+
+/* Block layer constants */
+#define BLK_MAX_SEGMENT_SIZE 65536
+
+/* Block device I/O operations - stubs */
+#define blkdev_issue_flush(bdev) ({ (void)(bdev); 0; })
+#define blkdev_issue_discard(bdev, s, n, gfp) \
+ ({ (void)(bdev); (void)(s); (void)(n); (void)(gfp); 0; })
+#define blkdev_issue_zeroout(bdev, s, n, gfp, f) \
+ ({ (void)(bdev); (void)(s); (void)(n); (void)(gfp); (void)(f); 0; })
+
+/* Block device sync - implemented in ext4l/stub.c */
+int sync_blockdev(struct block_device *bdev);
+void invalidate_bdev(struct block_device *bdev);
+
+/* Block device size - implemented in ext4l/stub.c */
+unsigned int bdev_max_discard_sectors(struct block_device *bdev);
+
+/* Block device file operations - implemented in ext4l/stub.c */
+struct blk_holder_ops;
+void bdev_fput(void *file);
+void *bdev_file_open_by_dev(dev_t dev, int flags, void *holder,
+ const struct blk_holder_ops *ops);
+
+/* Buffer operations on block devices - implemented in ext4l/stub.c */
+struct buffer_head *bdev_getblk(struct block_device *bdev, sector_t block,
+ unsigned int size, gfp_t gfp);
+struct buffer_head *__bread(struct block_device *bdev, sector_t block,
+ unsigned int size);
+
#endif /* _LINUX_BLKDEV_H */