erofs-utils: lib: drop the dead bmgr initializer
PATCH 1/2 erofs-utils: lib: drop the dead bmgr initializer
The chain below covers all three signs of device_id, so the initializer that runs before it is always overwritten. For device_id > 0 it also resolves to the metadata zone instead of the device.
The call is not elided either: erofs_metadata_bmgr() sits in another translation unit, so erofs_allocate_inode_bh_data() calls it twice. Dropping the initializer removes one call and 10 of the function's 101 instructions on x86-64 with gcc 13.
---
Requested here:
https://lore.kernel.org/linux-erofs/[email protected]/
lib/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
lib/inode.c +1 -2
@@ -201,8 +201,7 @@ int erofs_allocate_inode_bh_data(struct erofs_inode *inode, erofs_blk_t nblocks, int device_id) {struct erofs_sb_info *sbi = inode->sbi; -struct erofs_bufmgr *bmgr = device_id ? -erofs_metadata_bmgr (sbi, false) : sbi->bmgr; +struct erofs_bufmgr *bmgr;struct erofs_buffer_head *bh;int ret, type;
base-commit: 0beeaae8e8ccc907fd2a49ee054aa882c76b40d4
Signature · 1 line
2.43.0
PATCH 2/2 erofs-utils: lib: name the metadata zone in the allocation error
Before the device_id conversion this error named its target:
cannot allocate data in the metazone when unavailable for %s
It is now a single device message, and device_id < 0 means the metadata zone rather than a device, so that case prints the sentinel:
cannot allocate data on unavailable device -1 for ...
Reachable with mkfs.erofs --incremental --MZ over an image built with --MZ. Name the metadata zone again there.
--- lib/inode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
lib/inode.c +6 -2
@@ -213,8 +213,12 @@ int erofs_allocate_inode_bh_data(struct erofs_inode *inode, erofs_blk_t nblocks, bmgr = sbi->devs[device_id -1 ].bmgr;if (!bmgr) { -erofs_err ("cannot allocate data on unavailable device %d for %s" , - device_id, inode->i_srcpath); +if (device_id <0 ) +erofs_err ("cannot allocate data in the unavailable metadata zone for %s" , + inode->i_srcpath); +else +erofs_err ("cannot allocate data on unavailable device %d for %s" , + device_id, inode->i_srcpath);return -EINVAL ; }
Signature · 1 line
2.43.0