From patchwork Wed Jan 21 22:08:23 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1736 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033393; bh=NNKkoRRnDFInCxTli1KUyyxIVSO2MTBi5l01zfckvs8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=hRmc/oc0VcH1Zy8vsgHqNfOGZSklBP1+S5xVLF5HW4LHcPr1GZt6PlnBPuLLQ34En 2+eS7cDvHnB9sBoYlgNPQuG0ouKUF2VMnN74n+f8QNdqdw8aDZCrgsuuAR//+a8Axc VO2Ahg3Amdg4BpkzUYc1nq+cj3idqtaiud+g/XkwjTMqSRNGCEhYltpQl85Vp6ffz0 9PsXk/4qdyON2D5eQcvbATdLIsMw8n3OGmlqwznTDlc7tegSet9KrrJpNrDFievl3h 63I4Nh4aFOuDuAMdSvWvHeercvR6pstnJJqlw/jgaPODSjRXh6413m+2ARuX9Gtxzt R/CPTVyCEOKDA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D49A969601 for ; Wed, 21 Jan 2026 15:09:53 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ShKdVF-9S2s0 for ; Wed, 21 Jan 2026 15:09:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033393; bh=NNKkoRRnDFInCxTli1KUyyxIVSO2MTBi5l01zfckvs8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=hRmc/oc0VcH1Zy8vsgHqNfOGZSklBP1+S5xVLF5HW4LHcPr1GZt6PlnBPuLLQ34En 2+eS7cDvHnB9sBoYlgNPQuG0ouKUF2VMnN74n+f8QNdqdw8aDZCrgsuuAR//+a8Axc VO2Ahg3Amdg4BpkzUYc1nq+cj3idqtaiud+g/XkwjTMqSRNGCEhYltpQl85Vp6ffz0 9PsXk/4qdyON2D5eQcvbATdLIsMw8n3OGmlqwznTDlc7tegSet9KrrJpNrDFievl3h 63I4Nh4aFOuDuAMdSvWvHeercvR6pstnJJqlw/jgaPODSjRXh6413m+2ARuX9Gtxzt R/CPTVyCEOKDA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BEED2695FB for ; Wed, 21 Jan 2026 15:09:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033391; bh=ETnnvwM6gXMFTF4twep0duezV2phPORDOq0MmLETh7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qGjVMnHlVSHbmLMIEgEk/b3w1ZskiALwN8wRQAVm3ivNz46Uw0xlBR40wgKeDQcZ5 N5Letl1bH7TqtLAAcobj33v+qfMeHFLLXUXkf87OoYzDqlILvj4xM7MzYhsmRksYT0 ZWk1y7cgsgajoNxNgaOtxqIdyi5pWGI2+oBXClmrGItPV5+aqa3e5ZyfzfwkkvcSoZ 46x7cnVR+ws3l8kaich54c+YIritw28YZRC1NSDOjz5RcZYd9DRwUr+b3dVWS489Or 2+BzksxRTO+5AJsnV6uTQjxlRV1B5yPp+wCFetYdA2HGboMjclspxX9MWUN0ylMUgo TxewMttVtpJvQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C68DB695FB; Wed, 21 Jan 2026 15:09:51 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id seHi9dkS75Rr; Wed, 21 Jan 2026 15:09:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033386; bh=HQ8+QODphPaPS2BusZRynWTp57bheQ8kiWSR+k/k7pc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rP7tSq1NnzaxitoyF/gag0Ov2of2J2qZevIH+XWuAAG/lGupnibDB+iCkg0FJJOg0 0d202JzpCTwC5dtjqfI9AMDiB1yoyH9eXli6ggTqdYtgEZR+yfXW+vfYuGWGRYHwWM DKlxJnrvllqTLUcsE0iGHNp7yqTONoPl9V5tyyeDyFCLTmsQQ2Vq/Wcuok3alXgVS/ 4IEHaamy7k8iaZOdiIF4wpMiRLf3zcv5H4HWEgsG3DtXO9yV9//T6zSFqSq7zSYFDC qphnWXKc9hFpJ5moTcvCGJ6NelgzZyR0mHXmcymnA311HXO+VlhpGy/sJLqooWzif/ Df52ySUUuxZOg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6CEE2695F7; Wed, 21 Jan 2026 15:09:46 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 21 Jan 2026 15:08:23 -0700 Message-ID: <20260121220857.2137568-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260121220857.2137568-1-sjg@u-boot.org> References: <20260121220857.2137568-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: H6FFXCKXC6UD77ERNBEBMPR67GPOTGTW X-Message-ID-Hash: H6FFXCKXC6UD77ERNBEBMPR67GPOTGTW X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/33] ext4l: Move block device operations to linux/blkdev.h List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 --- fs/ext4l/ext4_uboot.h | 46 +----------------------------------------- fs/ext4l/stub.c | 5 +++++ include/linux/blkdev.h | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 35626a95cf8..f12dbe2b76d 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -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 #include @@ -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 -/* 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 /* 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))) diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index 1b9c72a6cc2..3da511fa1cf 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -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; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index eaf2984c08f..89d284dab26 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -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 */