From: Yang Chenzhi <yang.chenzhi@xxxxxxxx> Since __hfs_bnode_read and hfs_bnode_read have the same implementation, make hfs_bnode_read call __hfs_bnode_read and report errors when detected, while keeping the original function logic unchanged. Signed-off-by: Yang Chenzhi <yang.chenzhi@xxxxxxxx> --- fs/hfs/bnode.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c index da0ab993921d..b0bbaf016b8d 100644 --- a/fs/hfs/bnode.c +++ b/fs/hfs/bnode.c @@ -112,40 +112,18 @@ static int __hfs_bnode_read_u8(struct hfs_bnode *node, u8* buf, u16 off) void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len) { - struct page *page; - int pagenum; - int bytes_read; - int bytes_to_read; - - if (!is_bnode_offset_valid(node, off)) - return; + int res; - if (len == 0) { - pr_err("requested zero length: " + len = check_and_correct_requested_length(node, off, len); + res = __hfs_bnode_read(node, buf, (u16)off, (u16)len); + if (res) { + pr_err("hfs_bnode_read error: " "NODE: id %u, type %#x, height %u, " "node_size %u, offset %d, len %d\n", node->this, node->type, node->height, node->tree->node_size, off, len); - return; - } - - len = check_and_correct_requested_length(node, off, len); - - off += node->page_offset; - pagenum = off >> PAGE_SHIFT; - off &= ~PAGE_MASK; /* compute page offset for the first page */ - - for (bytes_read = 0; bytes_read < len; bytes_read += bytes_to_read) { - if (pagenum >= node->tree->pages_per_bnode) - break; - page = node->page[pagenum]; - bytes_to_read = min_t(int, len - bytes_read, PAGE_SIZE - off); - - memcpy_from_page(buf + bytes_read, page, off, bytes_to_read); - - pagenum++; - off = 0; /* page offset only applies to the first page */ } + return; } u16 hfs_bnode_read_u16(struct hfs_bnode *node, int off) -- 2.43.0