Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

buffer: fix __bread and __bread_gfp kernel-doc

The extra indentation confused the kernel-doc parser, so remove it. Fix
some other wording while I'm here, and advise the user they need to call
brelse() on this buffer.

__bread_gfp() isn't used directly by filesystems, but the other wrappers
for it don't have documentation, so document it accordingly.

Link: https://lkml.kernel.org/r/20240416031754.4076917-5-willy@infradead.org
Co-developed-by: Pankaj Raghav <p.raghav@samsung.com>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
324ecaee b1888d14

+34 -21
+21 -12
fs/buffer.c
··· 1453 1453 EXPORT_SYMBOL(__breadahead); 1454 1454 1455 1455 /** 1456 - * __bread_gfp() - reads a specified block and returns the bh 1457 - * @bdev: the block_device to read from 1458 - * @block: number of block 1459 - * @size: size (in bytes) to read 1460 - * @gfp: page allocation flag 1456 + * __bread_gfp() - Read a block. 1457 + * @bdev: The block device to read from. 1458 + * @block: Block number in units of block size. 1459 + * @size: The block size of this device in bytes. 1460 + * @gfp: Not page allocation flags; see below. 1461 1461 * 1462 - * Reads a specified block, and returns buffer head that contains it. 1463 - * The page cache can be allocated from non-movable area 1464 - * not to prevent page migration if you set gfp to zero. 1465 - * It returns NULL if the block was unreadable. 1462 + * You are not expected to call this function. You should use one of 1463 + * sb_bread(), sb_bread_unmovable() or __bread(). 1464 + * 1465 + * Read a specified block, and return the buffer head that refers to it. 1466 + * If @gfp is 0, the memory will be allocated using the block device's 1467 + * default GFP flags. If @gfp is __GFP_MOVABLE, the memory may be 1468 + * allocated from a movable area. Do not pass in a complete set of 1469 + * GFP flags. 1470 + * 1471 + * The returned buffer head has its refcount increased. The caller should 1472 + * call brelse() when it has finished with the buffer. 1473 + * 1474 + * Context: May sleep waiting for I/O. 1475 + * Return: NULL if the block was unreadable. 1466 1476 */ 1467 - struct buffer_head * 1468 - __bread_gfp(struct block_device *bdev, sector_t block, 1469 - unsigned size, gfp_t gfp) 1477 + struct buffer_head *__bread_gfp(struct block_device *bdev, sector_t block, 1478 + unsigned size, gfp_t gfp) 1470 1479 { 1471 1480 struct buffer_head *bh; 1472 1481
+13 -9
include/linux/buffer_head.h
··· 437 437 } 438 438 439 439 /** 440 - * __bread() - reads a specified block and returns the bh 441 - * @bdev: the block_device to read from 442 - * @block: number of block 443 - * @size: size (in bytes) to read 440 + * __bread() - Read a block. 441 + * @bdev: The block device to read from. 442 + * @block: Block number in units of block size. 443 + * @size: The block size of this device in bytes. 444 444 * 445 - * Reads a specified block, and returns buffer head that contains it. 446 - * The page cache is allocated from movable area so that it can be migrated. 447 - * It returns NULL if the block was unreadable. 445 + * Read a specified block, and return the buffer head that refers 446 + * to it. The memory is allocated from the movable area so that it can 447 + * be migrated. The returned buffer head has its refcount increased. 448 + * The caller should call brelse() when it has finished with the buffer. 449 + * 450 + * Context: May sleep waiting for I/O. 451 + * Return: NULL if the block was unreadable. 448 452 */ 449 - static inline struct buffer_head * 450 - __bread(struct block_device *bdev, sector_t block, unsigned size) 453 + static inline struct buffer_head *__bread(struct block_device *bdev, 454 + sector_t block, unsigned size) 451 455 { 452 456 return __bread_gfp(bdev, block, size, __GFP_MOVABLE); 453 457 }