btree.c (498495dba268b20e8eadd7fe93c140c68b6cc9d2) | btree.c (d92915c35bfaf763d78bf1d5ac7f183420e3bd99) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/fs/hfsplus/btree.c 4 * 5 * Copyright (C) 2001 6 * Brad Boyer (flar@allandria.com) 7 * (C) 2003 Ardis Technologies <roman@ardistech.com> 8 * --- 328 unchanged lines hidden (view full) --- 337 hfs_bnode_write(node, &desc, 0, sizeof(desc)); 338 hfs_bnode_write_u16(node, 14, 0x8000); 339 hfs_bnode_write_u16(node, tree->node_size - 2, 14); 340 hfs_bnode_write_u16(node, tree->node_size - 4, tree->node_size - 6); 341 342 return node; 343} 344 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/fs/hfsplus/btree.c 4 * 5 * Copyright (C) 2001 6 * Brad Boyer (flar@allandria.com) 7 * (C) 2003 Ardis Technologies <roman@ardistech.com> 8 * --- 328 unchanged lines hidden (view full) --- 337 hfs_bnode_write(node, &desc, 0, sizeof(desc)); 338 hfs_bnode_write_u16(node, 14, 0x8000); 339 hfs_bnode_write_u16(node, tree->node_size - 2, 14); 340 hfs_bnode_write_u16(node, tree->node_size - 4, tree->node_size - 6); 341 342 return node; 343} 344 |
345struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) | 345/* Make sure @tree has enough space for the @rsvd_nodes */ 346int hfs_bmap_reserve(struct hfs_btree *tree, int rsvd_nodes) |
346{ | 347{ |
347 struct hfs_bnode *node, *next_node; 348 struct page **pagep; 349 u32 nidx, idx; 350 unsigned off; 351 u16 off16; 352 u16 len; 353 u8 *data, byte, m; 354 int i; | 348 struct inode *inode = tree->inode; 349 struct hfsplus_inode_info *hip = HFSPLUS_I(inode); 350 u32 count; 351 int res; |
355 | 352 |
356 while (!tree->free_nodes) { 357 struct inode *inode = tree->inode; 358 struct hfsplus_inode_info *hip = HFSPLUS_I(inode); 359 u32 count; 360 int res; | 353 if (rsvd_nodes <= 0) 354 return 0; |
361 | 355 |
356 while (tree->free_nodes < rsvd_nodes) { |
|
362 res = hfsplus_file_extend(inode, hfs_bnode_need_zeroout(tree)); 363 if (res) | 357 res = hfsplus_file_extend(inode, hfs_bnode_need_zeroout(tree)); 358 if (res) |
364 return ERR_PTR(res); | 359 return res; |
365 hip->phys_size = inode->i_size = 366 (loff_t)hip->alloc_blocks << 367 HFSPLUS_SB(tree->sb)->alloc_blksz_shift; 368 hip->fs_blocks = 369 hip->alloc_blocks << HFSPLUS_SB(tree->sb)->fs_shift; 370 inode_set_bytes(inode, inode->i_size); 371 count = inode->i_size >> tree->node_size_shift; | 360 hip->phys_size = inode->i_size = 361 (loff_t)hip->alloc_blocks << 362 HFSPLUS_SB(tree->sb)->alloc_blksz_shift; 363 hip->fs_blocks = 364 hip->alloc_blocks << HFSPLUS_SB(tree->sb)->fs_shift; 365 inode_set_bytes(inode, inode->i_size); 366 count = inode->i_size >> tree->node_size_shift; |
372 tree->free_nodes = count - tree->node_count; | 367 tree->free_nodes += count - tree->node_count; |
373 tree->node_count = count; 374 } | 368 tree->node_count = count; 369 } |
370 return 0; 371} |
|
375 | 372 |
373struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) 374{ 375 struct hfs_bnode *node, *next_node; 376 struct page **pagep; 377 u32 nidx, idx; 378 unsigned off; 379 u16 off16; 380 u16 len; 381 u8 *data, byte, m; 382 int i, res; 383 384 res = hfs_bmap_reserve(tree, 1); 385 if (res) 386 return ERR_PTR(res); 387 |
|
376 nidx = 0; 377 node = hfs_bnode_find(tree, nidx); 378 if (IS_ERR(node)) 379 return node; 380 len = hfs_brec_lenoff(node, 2, &off16); 381 off = off16; 382 383 off += node->page_offset; --- 115 unchanged lines hidden --- | 388 nidx = 0; 389 node = hfs_bnode_find(tree, nidx); 390 if (IS_ERR(node)) 391 return node; 392 len = hfs_brec_lenoff(node, 2, &off16); 393 off = off16; 394 395 off += node->page_offset; --- 115 unchanged lines hidden --- |