Skip to content

Commit 205f87f

Browse files
Badari PulavartyLinus Torvalds
authored andcommitted
[PATCH] change buffer_head.b_size to size_t
Increase the size of the buffer_head b_size field (only) for 64 bit platforms. Update some old and moldy comments in and around the structure as well. The b_size increase allows us to perform larger mappings and allocations for large I/O requests from userspace, which tie in with other changes allowing the get_block_t() interface to map multiple blocks at once. Signed-off-by: Nathan Scott <nathans@sgi.com> Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent d48589b commit 205f87f

4 files changed

Lines changed: 17 additions & 12 deletions

File tree

‎fs/buffer.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,10 @@ __find_get_block_slow(struct block_device *bdev, sector_t block)
426426
if (all_mapped) {
427427
printk("__find_get_block_slow() failed. "
428428
"block=%llu, b_blocknr=%llu\n",
429-
(unsigned long long)block, (unsigned long long)bh->b_blocknr);
430-
printk("b_state=0x%08lx, b_size=%u\n", bh->b_state, bh->b_size);
429+
(unsigned long long)block,
430+
(unsigned long long)bh->b_blocknr);
431+
printk("b_state=0x%08lx, b_size=%zu\n",
432+
bh->b_state, bh->b_size);
431433
printk("device blocksize: %d\n", 1 << bd_inode->i_blkbits);
432434
}
433435
out_unlock:

‎fs/ocfs2/journal.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle,
377377
BUG_ON(!bh);
378378
BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED));
379379

380-
mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %hu\n",
380+
mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %zu\n",
381381
(unsigned long long)bh->b_blocknr, type,
382382
(type == OCFS2_JOURNAL_ACCESS_CREATE) ?
383383
"OCFS2_JOURNAL_ACCESS_CREATE" :

‎fs/reiserfs/prints.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static void sprintf_buffer_head(char *buf, struct buffer_head *bh)
143143
char b[BDEVNAME_SIZE];
144144

145145
sprintf(buf,
146-
"dev %s, size %d, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)",
146+
"dev %s, size %zd, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)",
147147
bdevname(bh->b_bdev, b), bh->b_size,
148148
(unsigned long long)bh->b_blocknr, atomic_read(&(bh->b_count)),
149149
bh->b_state, bh->b_page,

‎include/linux/buffer_head.h‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,28 @@ struct address_space;
4646
typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
4747

4848
/*
49-
* Keep related fields in common cachelines. The most commonly accessed
50-
* field (b_state) goes at the start so the compiler does not generate
51-
* indexed addressing for it.
49+
* Historically, a buffer_head was used to map a single block
50+
* within a page, and of course as the unit of I/O through the
51+
* filesystem and block layers. Nowadays the basic I/O unit
52+
* is the bio, and buffer_heads are used for extracting block
53+
* mappings (via a get_block_t call), for tracking state within
54+
* a page (via a page_mapping) and for wrapping bio submission
55+
* for backward compatibility reasons (e.g. submit_bh).
5256
*/
5357
struct buffer_head {
54-
/* First cache line: */
5558
unsigned long b_state; /* buffer state bitmap (see above) */
5659
struct buffer_head *b_this_page;/* circular list of page's buffers */
5760
struct page *b_page; /* the page this bh is mapped to */
58-
atomic_t b_count; /* users using this block */
59-
u32 b_size; /* block size */
6061

61-
sector_t b_blocknr; /* block number */
62-
char *b_data; /* pointer to data block */
62+
sector_t b_blocknr; /* start block number */
63+
size_t b_size; /* size of mapping */
64+
char *b_data; /* pointer to data within the page */
6365

6466
struct block_device *b_bdev;
6567
bh_end_io_t *b_end_io; /* I/O completion */
6668
void *b_private; /* reserved for b_end_io */
6769
struct list_head b_assoc_buffers; /* associated with another mapping */
70+
atomic_t b_count; /* users using this buffer_head */
6871
};
6972

7073
/*

0 commit comments

Comments
 (0)