2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* include/linux/buffer_head.h
|
|
|
|
*
|
|
|
|
* Everything to do with buffer_heads.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_BUFFER_HEAD_H
|
|
|
|
#define _LINUX_BUFFER_HEAD_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <asm/atomic.h>
|
|
|
|
|
[PATCH] BLOCK: Make it possible to disable the block layer [try #6]
Make it possible to disable the block layer. Not all embedded devices require
it, some can make do with just JFFS2, NFS, ramfs, etc - none of which require
the block layer to be present.
This patch does the following:
(*) Introduces CONFIG_BLOCK to disable the block layer, buffering and blockdev
support.
(*) Adds dependencies on CONFIG_BLOCK to any configuration item that controls
an item that uses the block layer. This includes:
(*) Block I/O tracing.
(*) Disk partition code.
(*) All filesystems that are block based, eg: Ext3, ReiserFS, ISOFS.
(*) The SCSI layer. As far as I can tell, even SCSI chardevs use the
block layer to do scheduling. Some drivers that use SCSI facilities -
such as USB storage - end up disabled indirectly from this.
(*) Various block-based device drivers, such as IDE and the old CDROM
drivers.
(*) MTD blockdev handling and FTL.
(*) JFFS - which uses set_bdev_super(), something it could avoid doing by
taking a leaf out of JFFS2's book.
(*) Makes most of the contents of linux/blkdev.h, linux/buffer_head.h and
linux/elevator.h contingent on CONFIG_BLOCK being set. sector_div() is,
however, still used in places, and so is still available.
(*) Also made contingent are the contents of linux/mpage.h, linux/genhd.h and
parts of linux/fs.h.
(*) Makes a number of files in fs/ contingent on CONFIG_BLOCK.
(*) Makes mm/bounce.c (bounce buffering) contingent on CONFIG_BLOCK.
(*) set_page_dirty() doesn't call __set_page_dirty_buffers() if CONFIG_BLOCK
is not enabled.
(*) fs/no-block.c is created to hold out-of-line stubs and things that are
required when CONFIG_BLOCK is not set:
(*) Default blockdev file operations (to give error ENODEV on opening).
(*) Makes some /proc changes:
(*) /proc/devices does not list any blockdevs.
(*) /proc/diskstats and /proc/partitions are contingent on CONFIG_BLOCK.
(*) Makes some compat ioctl handling contingent on CONFIG_BLOCK.
(*) If CONFIG_BLOCK is not defined, makes sys_quotactl() return -ENODEV if
given command other than Q_SYNC or if a special device is specified.
(*) In init/do_mounts.c, no reference is made to the blockdev routines if
CONFIG_BLOCK is not defined. This does not prohibit NFS roots or JFFS2.
(*) The bdflush, ioprio_set and ioprio_get syscalls can now be absent (return
error ENOSYS by way of cond_syscall if so).
(*) The seclvl_bd_claim() and seclvl_bd_release() security calls do nothing if
CONFIG_BLOCK is not set, since they can't then happen.
Signed-Off-By: David Howells <dhowells@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2006-10-01 02:45:40 +08:00
|
|
|
#ifdef CONFIG_BLOCK
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
enum bh_state_bits {
|
|
|
|
BH_Uptodate, /* Contains valid data */
|
|
|
|
BH_Dirty, /* Is dirty */
|
|
|
|
BH_Lock, /* Is locked */
|
|
|
|
BH_Req, /* Has been submitted for I/O */
|
2005-07-08 08:56:56 +08:00
|
|
|
BH_Uptodate_Lock,/* Used by the first bh in a page, to serialise
|
|
|
|
* IO completion of other buffers in the page
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
BH_Mapped, /* Has a disk mapping */
|
|
|
|
BH_New, /* Disk mapping was newly created by get_block */
|
|
|
|
BH_Async_Read, /* Is under end_buffer_async_read I/O */
|
|
|
|
BH_Async_Write, /* Is under end_buffer_async_write I/O */
|
|
|
|
BH_Delay, /* Buffer is not yet allocated on disk */
|
|
|
|
BH_Boundary, /* Block is followed by a discontiguity */
|
|
|
|
BH_Write_EIO, /* I/O error on write */
|
|
|
|
BH_Eopnotsupp, /* operation not supported (barrier) */
|
2007-02-12 16:51:41 +08:00
|
|
|
BH_Unwritten, /* Buffer is allocated on disk but not written */
|
block: Supress Buffer I/O errors when SCSI REQ_QUIET flag set
Allow the scsi request REQ_QUIET flag to be propagated to the buffer
file system layer. The basic ideas is to pass the flag from the scsi
request to the bio (block IO) and then to the buffer layer. The buffer
layer can then suppress needless printks.
This patch declutters the kernel log by removed the 40-50 (per lun)
buffer io error messages seen during a boot in my multipath setup . It
is a good chance any real errors will be missed in the "noise" it the
logs without this patch.
During boot I see blocks of messages like
"
__ratelimit: 211 callbacks suppressed
Buffer I/O error on device sdm, logical block 5242879
Buffer I/O error on device sdm, logical block 5242879
Buffer I/O error on device sdm, logical block 5242847
Buffer I/O error on device sdm, logical block 1
Buffer I/O error on device sdm, logical block 5242878
Buffer I/O error on device sdm, logical block 5242879
Buffer I/O error on device sdm, logical block 5242879
Buffer I/O error on device sdm, logical block 5242879
Buffer I/O error on device sdm, logical block 5242879
Buffer I/O error on device sdm, logical block 5242872
"
in my logs.
My disk environment is multipath fiber channel using the SCSI_DH_RDAC
code and multipathd. This topology includes an "active" and "ghost"
path for each lun. IO's to the "ghost" path will never complete and the
SCSI layer, via the scsi device handler rdac code, quick returns the IOs
to theses paths and sets the REQ_QUIET scsi flag to suppress the scsi
layer messages.
I am wanting to extend the QUIET behavior to include the buffer file
system layer to deal with these errors as well. I have been running this
patch for a while now on several boxes without issue. A few runs of
bonnie++ show no noticeable difference in performance in my setup.
Thanks for John Stultz for the quiet_error finalization.
Submitted-by: Keith Mannthey <kmannth@us.ibm.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
2008-11-25 17:24:35 +08:00
|
|
|
BH_Quiet, /* Buffer Error Prinks to be quiet */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
BH_PrivateStart,/* not a state bit, but the first bit available
|
|
|
|
* for private allocation by other entities
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)
|
|
|
|
|
|
|
|
struct page;
|
|
|
|
struct buffer_head;
|
|
|
|
struct address_space;
|
|
|
|
typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
|
|
|
|
|
|
|
|
/*
|
2006-03-26 17:38:00 +08:00
|
|
|
* Historically, a buffer_head was used to map a single block
|
|
|
|
* within a page, and of course as the unit of I/O through the
|
|
|
|
* filesystem and block layers. Nowadays the basic I/O unit
|
|
|
|
* is the bio, and buffer_heads are used for extracting block
|
|
|
|
* mappings (via a get_block_t call), for tracking state within
|
|
|
|
* a page (via a page_mapping) and for wrapping bio submission
|
|
|
|
* for backward compatibility reasons (e.g. submit_bh).
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
struct buffer_head {
|
|
|
|
unsigned long b_state; /* buffer state bitmap (see above) */
|
|
|
|
struct buffer_head *b_this_page;/* circular list of page's buffers */
|
|
|
|
struct page *b_page; /* the page this bh is mapped to */
|
|
|
|
|
2006-03-26 17:38:00 +08:00
|
|
|
sector_t b_blocknr; /* start block number */
|
|
|
|
size_t b_size; /* size of mapping */
|
|
|
|
char *b_data; /* pointer to data within the page */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct block_device *b_bdev;
|
|
|
|
bh_end_io_t *b_end_io; /* I/O completion */
|
|
|
|
void *b_private; /* reserved for b_end_io */
|
|
|
|
struct list_head b_assoc_buffers; /* associated with another mapping */
|
2006-10-17 15:10:19 +08:00
|
|
|
struct address_space *b_assoc_map; /* mapping this buffer is
|
|
|
|
associated with */
|
2006-03-26 17:38:00 +08:00
|
|
|
atomic_t b_count; /* users using this buffer_head */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
|
|
|
|
* and buffer_foo() functions.
|
|
|
|
*/
|
|
|
|
#define BUFFER_FNS(bit, name) \
|
|
|
|
static inline void set_buffer_##name(struct buffer_head *bh) \
|
|
|
|
{ \
|
|
|
|
set_bit(BH_##bit, &(bh)->b_state); \
|
|
|
|
} \
|
|
|
|
static inline void clear_buffer_##name(struct buffer_head *bh) \
|
|
|
|
{ \
|
|
|
|
clear_bit(BH_##bit, &(bh)->b_state); \
|
|
|
|
} \
|
|
|
|
static inline int buffer_##name(const struct buffer_head *bh) \
|
|
|
|
{ \
|
|
|
|
return test_bit(BH_##bit, &(bh)->b_state); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* test_set_buffer_foo() and test_clear_buffer_foo()
|
|
|
|
*/
|
|
|
|
#define TAS_BUFFER_FNS(bit, name) \
|
|
|
|
static inline int test_set_buffer_##name(struct buffer_head *bh) \
|
|
|
|
{ \
|
|
|
|
return test_and_set_bit(BH_##bit, &(bh)->b_state); \
|
|
|
|
} \
|
|
|
|
static inline int test_clear_buffer_##name(struct buffer_head *bh) \
|
|
|
|
{ \
|
|
|
|
return test_and_clear_bit(BH_##bit, &(bh)->b_state); \
|
|
|
|
} \
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Emit the buffer bitops functions. Note that there are also functions
|
|
|
|
* of the form "mark_buffer_foo()". These are higher-level functions which
|
|
|
|
* do something in addition to setting a b_state bit.
|
|
|
|
*/
|
|
|
|
BUFFER_FNS(Uptodate, uptodate)
|
|
|
|
BUFFER_FNS(Dirty, dirty)
|
|
|
|
TAS_BUFFER_FNS(Dirty, dirty)
|
|
|
|
BUFFER_FNS(Lock, locked)
|
|
|
|
BUFFER_FNS(Req, req)
|
|
|
|
TAS_BUFFER_FNS(Req, req)
|
|
|
|
BUFFER_FNS(Mapped, mapped)
|
|
|
|
BUFFER_FNS(New, new)
|
|
|
|
BUFFER_FNS(Async_Read, async_read)
|
|
|
|
BUFFER_FNS(Async_Write, async_write)
|
|
|
|
BUFFER_FNS(Delay, delay)
|
|
|
|
BUFFER_FNS(Boundary, boundary)
|
|
|
|
BUFFER_FNS(Write_EIO, write_io_error)
|
|
|
|
BUFFER_FNS(Eopnotsupp, eopnotsupp)
|
2007-02-12 16:51:41 +08:00
|
|
|
BUFFER_FNS(Unwritten, unwritten)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
|
|
|
|
#define touch_buffer(bh) mark_page_accessed(bh->b_page)
|
|
|
|
|
|
|
|
/* If we *know* page->private refers to buffer_heads */
|
|
|
|
#define page_buffers(page) \
|
|
|
|
({ \
|
[PATCH] mm: split page table lock
Christoph Lameter demonstrated very poor scalability on the SGI 512-way, with
a many-threaded application which concurrently initializes different parts of
a large anonymous area.
This patch corrects that, by using a separate spinlock per page table page, to
guard the page table entries in that page, instead of using the mm's single
page_table_lock. (But even then, page_table_lock is still used to guard page
table allocation, and anon_vma allocation.)
In this implementation, the spinlock is tucked inside the struct page of the
page table page: with a BUILD_BUG_ON in case it overflows - which it would in
the case of 32-bit PA-RISC with spinlock debugging enabled.
Splitting the lock is not quite for free: another cacheline access. Ideally,
I suppose we would use split ptlock only for multi-threaded processes on
multi-cpu machines; but deciding that dynamically would have its own costs.
So for now enable it by config, at some number of cpus - since the Kconfig
language doesn't support inequalities, let preprocessor compare that with
NR_CPUS. But I don't think it's worth being user-configurable: for good
testing of both split and unsplit configs, split now at 4 cpus, and perhaps
change that to 8 later.
There is a benefit even for singly threaded processes: kswapd can be attacking
one part of the mm while another part is busy faulting.
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-10-30 09:16:40 +08:00
|
|
|
BUG_ON(!PagePrivate(page)); \
|
|
|
|
((struct buffer_head *)page_private(page)); \
|
2005-04-17 06:20:36 +08:00
|
|
|
})
|
|
|
|
#define page_has_buffers(page) PagePrivate(page)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Declarations
|
|
|
|
*/
|
|
|
|
|
2008-02-14 07:03:15 +08:00
|
|
|
void mark_buffer_dirty(struct buffer_head *bh);
|
2005-04-17 06:20:36 +08:00
|
|
|
void init_buffer(struct buffer_head *, bh_end_io_t *, void *);
|
|
|
|
void set_bh_page(struct buffer_head *bh,
|
|
|
|
struct page *page, unsigned long offset);
|
|
|
|
int try_to_free_buffers(struct page *);
|
|
|
|
struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
|
|
|
|
int retry);
|
|
|
|
void create_empty_buffers(struct page *, unsigned long,
|
|
|
|
unsigned long b_state);
|
|
|
|
void end_buffer_read_sync(struct buffer_head *bh, int uptodate);
|
|
|
|
void end_buffer_write_sync(struct buffer_head *bh, int uptodate);
|
2009-04-16 01:22:38 +08:00
|
|
|
void end_buffer_async_write(struct buffer_head *bh, int uptodate);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Things to do with buffers at mapping->private_list */
|
|
|
|
void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode);
|
|
|
|
int inode_has_buffers(struct inode *);
|
|
|
|
void invalidate_inode_buffers(struct inode *);
|
|
|
|
int remove_inode_buffers(struct inode *inode);
|
|
|
|
int sync_mapping_buffers(struct address_space *mapping);
|
|
|
|
void unmap_underlying_metadata(struct block_device *bdev, sector_t block);
|
|
|
|
|
|
|
|
void mark_buffer_async_write(struct buffer_head *bh);
|
|
|
|
void __wait_on_buffer(struct buffer_head *);
|
|
|
|
wait_queue_head_t *bh_waitq_head(struct buffer_head *bh);
|
2007-02-12 16:52:14 +08:00
|
|
|
struct buffer_head *__find_get_block(struct block_device *bdev, sector_t block,
|
|
|
|
unsigned size);
|
|
|
|
struct buffer_head *__getblk(struct block_device *bdev, sector_t block,
|
|
|
|
unsigned size);
|
2005-04-17 06:20:36 +08:00
|
|
|
void __brelse(struct buffer_head *);
|
|
|
|
void __bforget(struct buffer_head *);
|
2007-02-12 16:52:14 +08:00
|
|
|
void __breadahead(struct block_device *, sector_t block, unsigned int size);
|
|
|
|
struct buffer_head *__bread(struct block_device *, sector_t block, unsigned size);
|
2007-05-07 05:49:55 +08:00
|
|
|
void invalidate_bh_lrus(void);
|
2005-10-07 14:46:04 +08:00
|
|
|
struct buffer_head *alloc_buffer_head(gfp_t gfp_flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
void free_buffer_head(struct buffer_head * bh);
|
2008-02-14 07:03:15 +08:00
|
|
|
void unlock_buffer(struct buffer_head *bh);
|
|
|
|
void __lock_buffer(struct buffer_head *bh);
|
2005-04-17 06:20:36 +08:00
|
|
|
void ll_rw_block(int, int, struct buffer_head * bh[]);
|
|
|
|
int sync_dirty_buffer(struct buffer_head *bh);
|
2010-08-11 23:05:45 +08:00
|
|
|
int __sync_dirty_buffer(struct buffer_head *bh, int rw);
|
2010-08-11 23:06:24 +08:00
|
|
|
void write_dirty_buffer(struct buffer_head *bh, int rw);
|
2005-04-17 06:20:36 +08:00
|
|
|
int submit_bh(int, struct buffer_head *);
|
|
|
|
void write_boundary_block(struct block_device *bdev,
|
|
|
|
sector_t bblock, unsigned blocksize);
|
2008-01-29 12:58:26 +08:00
|
|
|
int bh_uptodate_or_lock(struct buffer_head *bh);
|
|
|
|
int bh_submit_read(struct buffer_head *bh);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
extern int buffer_heads_over_limit;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic address_space_operations implementations for buffer_head-backed
|
|
|
|
* address_spaces.
|
|
|
|
*/
|
2006-03-26 17:37:18 +08:00
|
|
|
void block_invalidatepage(struct page *page, unsigned long offset);
|
2005-04-17 06:20:36 +08:00
|
|
|
int block_write_full_page(struct page *page, get_block_t *get_block,
|
|
|
|
struct writeback_control *wbc);
|
2009-04-16 01:22:38 +08:00
|
|
|
int block_write_full_page_endio(struct page *page, get_block_t *get_block,
|
|
|
|
struct writeback_control *wbc, bh_end_io_t *handler);
|
2005-04-17 06:20:36 +08:00
|
|
|
int block_read_full_page(struct page*, get_block_t*);
|
vfs: pagecache usage optimization for pagesize!=blocksize
When we read some part of a file through pagecache, if there is a
pagecache of corresponding index but this page is not uptodate, read IO
is issued and this page will be uptodate.
I think this is good for pagesize == blocksize environment but there is
room for improvement on pagesize != blocksize environment. Because in
this case a page can have multiple buffers and even if a page is not
uptodate, some buffers can be uptodate.
So I suggest that when all buffers which correspond to a part of a file
that we want to read are uptodate, use this pagecache and copy data from
this pagecache to user buffer even if a page is not uptodate. This can
reduce read IO and improve system throughput.
I wrote a benchmark program and got result number with this program.
This benchmark do:
1: mount and open a test file.
2: create a 512MB file.
3: close a file and umount.
4: mount and again open a test file.
5: pwrite randomly 300000 times on a test file. offset is aligned
by IO size(1024bytes).
6: measure time of preading randomly 100000 times on a test file.
The result was:
2.6.26
330 sec
2.6.26-patched
226 sec
Arch:i386
Filesystem:ext3
Blocksize:1024 bytes
Memory: 1GB
On ext3/4, a file is written through buffer/block. So random read/write
mixed workloads or random read after random write workloads are optimized
with this patch under pagesize != blocksize environment. This test result
showed this.
The benchmark program is as follows:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#define LEN 1024
#define LOOP 1024*512 /* 512MB */
main(void)
{
unsigned long i, offset, filesize;
int fd;
char buf[LEN];
time_t t1, t2;
if (mount("/dev/sda1", "/root/test1/", "ext3", 0, 0) < 0) {
perror("cannot mount\n");
exit(1);
}
memset(buf, 0, LEN);
fd = open("/root/test1/testfile", O_CREAT|O_RDWR|O_TRUNC);
if (fd < 0) {
perror("cannot open file\n");
exit(1);
}
for (i = 0; i < LOOP; i++)
write(fd, buf, LEN);
close(fd);
if (umount("/root/test1/") < 0) {
perror("cannot umount\n");
exit(1);
}
if (mount("/dev/sda1", "/root/test1/", "ext3", 0, 0) < 0) {
perror("cannot mount\n");
exit(1);
}
fd = open("/root/test1/testfile", O_RDWR);
if (fd < 0) {
perror("cannot open file\n");
exit(1);
}
filesize = LEN * LOOP;
for (i = 0; i < 300000; i++){
offset = (random() % filesize) & (~(LEN - 1));
pwrite(fd, buf, LEN, offset);
}
printf("start test\n");
time(&t1);
for (i = 0; i < 100000; i++){
offset = (random() % filesize) & (~(LEN - 1));
pread(fd, buf, LEN, offset);
}
time(&t2);
printf("%ld sec\n", t2-t1);
close(fd);
if (umount("/root/test1/") < 0) {
perror("cannot umount\n");
exit(1);
}
}
Signed-off-by: Hisashi Hifumi <hifumi.hisashi@oss.ntt.co.jp>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Jan Kara <jack@ucw.cz>
Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-07-29 06:46:36 +08:00
|
|
|
int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc,
|
|
|
|
unsigned long from);
|
2010-06-04 17:29:58 +08:00
|
|
|
int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len,
|
|
|
|
unsigned flags, struct page **pagep, get_block_t *get_block);
|
2010-06-04 17:29:57 +08:00
|
|
|
int __block_write_begin(struct page *page, loff_t pos, unsigned len,
|
|
|
|
get_block_t *get_block);
|
2007-10-16 16:25:01 +08:00
|
|
|
int block_write_end(struct file *, struct address_space *,
|
|
|
|
loff_t, unsigned, unsigned,
|
|
|
|
struct page *, void *);
|
|
|
|
int generic_write_end(struct file *, struct address_space *,
|
|
|
|
loff_t, unsigned, unsigned,
|
|
|
|
struct page *, void *);
|
|
|
|
void page_zero_new_buffers(struct page *page, unsigned from, unsigned to);
|
2005-04-17 06:20:36 +08:00
|
|
|
int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
|
2007-10-16 16:25:07 +08:00
|
|
|
int cont_write_begin(struct file *, struct address_space *, loff_t,
|
|
|
|
unsigned, unsigned, struct page **, void **,
|
|
|
|
get_block_t *, loff_t *);
|
2006-01-08 17:02:13 +08:00
|
|
|
int generic_cont_expand_simple(struct inode *inode, loff_t size);
|
2005-04-17 06:20:36 +08:00
|
|
|
int block_commit_write(struct page *page, unsigned from, unsigned to);
|
2009-04-01 06:23:21 +08:00
|
|
|
int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
|
2007-07-19 15:39:55 +08:00
|
|
|
get_block_t get_block);
|
2006-03-26 17:37:17 +08:00
|
|
|
void block_sync_page(struct page *);
|
2005-04-17 06:20:36 +08:00
|
|
|
sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *);
|
|
|
|
int block_truncate_page(struct address_space *, loff_t, get_block_t *);
|
2010-06-04 17:29:54 +08:00
|
|
|
int nobh_write_begin(struct address_space *, loff_t, unsigned, unsigned,
|
2007-10-16 16:25:25 +08:00
|
|
|
struct page **, void **, get_block_t*);
|
|
|
|
int nobh_write_end(struct file *, struct address_space *,
|
|
|
|
loff_t, unsigned, unsigned,
|
|
|
|
struct page *, void *);
|
|
|
|
int nobh_truncate_page(struct address_space *, loff_t, get_block_t *);
|
2005-04-17 06:20:36 +08:00
|
|
|
int nobh_writepage(struct page *page, get_block_t *get_block,
|
|
|
|
struct writeback_control *wbc);
|
|
|
|
|
2006-06-27 17:53:54 +08:00
|
|
|
void buffer_init(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* inline definitions
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline void attach_page_buffers(struct page *page,
|
|
|
|
struct buffer_head *head)
|
|
|
|
{
|
|
|
|
page_cache_get(page);
|
|
|
|
SetPagePrivate(page);
|
[PATCH] mm: split page table lock
Christoph Lameter demonstrated very poor scalability on the SGI 512-way, with
a many-threaded application which concurrently initializes different parts of
a large anonymous area.
This patch corrects that, by using a separate spinlock per page table page, to
guard the page table entries in that page, instead of using the mm's single
page_table_lock. (But even then, page_table_lock is still used to guard page
table allocation, and anon_vma allocation.)
In this implementation, the spinlock is tucked inside the struct page of the
page table page: with a BUILD_BUG_ON in case it overflows - which it would in
the case of 32-bit PA-RISC with spinlock debugging enabled.
Splitting the lock is not quite for free: another cacheline access. Ideally,
I suppose we would use split ptlock only for multi-threaded processes on
multi-cpu machines; but deciding that dynamically would have its own costs.
So for now enable it by config, at some number of cpus - since the Kconfig
language doesn't support inequalities, let preprocessor compare that with
NR_CPUS. But I don't think it's worth being user-configurable: for good
testing of both split and unsplit configs, split now at 4 cpus, and perhaps
change that to 8 later.
There is a benefit even for singly threaded processes: kswapd can be attacking
one part of the mm while another part is busy faulting.
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-10-30 09:16:40 +08:00
|
|
|
set_page_private(page, (unsigned long)head);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void get_bh(struct buffer_head *bh)
|
|
|
|
{
|
|
|
|
atomic_inc(&bh->b_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void put_bh(struct buffer_head *bh)
|
|
|
|
{
|
|
|
|
smp_mb__before_atomic_dec();
|
|
|
|
atomic_dec(&bh->b_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void brelse(struct buffer_head *bh)
|
|
|
|
{
|
|
|
|
if (bh)
|
|
|
|
__brelse(bh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void bforget(struct buffer_head *bh)
|
|
|
|
{
|
|
|
|
if (bh)
|
|
|
|
__bforget(bh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct buffer_head *
|
|
|
|
sb_bread(struct super_block *sb, sector_t block)
|
|
|
|
{
|
|
|
|
return __bread(sb->s_bdev, block, sb->s_blocksize);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
sb_breadahead(struct super_block *sb, sector_t block)
|
|
|
|
{
|
|
|
|
__breadahead(sb->s_bdev, block, sb->s_blocksize);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct buffer_head *
|
|
|
|
sb_getblk(struct super_block *sb, sector_t block)
|
|
|
|
{
|
|
|
|
return __getblk(sb->s_bdev, block, sb->s_blocksize);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct buffer_head *
|
|
|
|
sb_find_get_block(struct super_block *sb, sector_t block)
|
|
|
|
{
|
|
|
|
return __find_get_block(sb->s_bdev, block, sb->s_blocksize);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
map_bh(struct buffer_head *bh, struct super_block *sb, sector_t block)
|
|
|
|
{
|
|
|
|
set_buffer_mapped(bh);
|
|
|
|
bh->b_bdev = sb->s_bdev;
|
|
|
|
bh->b_blocknr = block;
|
2006-03-26 17:38:00 +08:00
|
|
|
bh->b_size = sb->s_blocksize;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void wait_on_buffer(struct buffer_head *bh)
|
|
|
|
{
|
|
|
|
might_sleep();
|
2010-08-10 08:18:42 +08:00
|
|
|
if (buffer_locked(bh))
|
2005-04-17 06:20:36 +08:00
|
|
|
__wait_on_buffer(bh);
|
|
|
|
}
|
|
|
|
|
2008-08-02 18:02:13 +08:00
|
|
|
static inline int trylock_buffer(struct buffer_head *bh)
|
|
|
|
{
|
2008-10-19 11:27:00 +08:00
|
|
|
return likely(!test_and_set_bit_lock(BH_Lock, &bh->b_state));
|
2008-08-02 18:02:13 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static inline void lock_buffer(struct buffer_head *bh)
|
|
|
|
{
|
|
|
|
might_sleep();
|
2008-08-02 18:02:13 +08:00
|
|
|
if (!trylock_buffer(bh))
|
2005-04-17 06:20:36 +08:00
|
|
|
__lock_buffer(bh);
|
|
|
|
}
|
|
|
|
|
2006-08-30 02:05:54 +08:00
|
|
|
extern int __set_page_dirty_buffers(struct page *page);
|
[PATCH] BLOCK: Make it possible to disable the block layer [try #6]
Make it possible to disable the block layer. Not all embedded devices require
it, some can make do with just JFFS2, NFS, ramfs, etc - none of which require
the block layer to be present.
This patch does the following:
(*) Introduces CONFIG_BLOCK to disable the block layer, buffering and blockdev
support.
(*) Adds dependencies on CONFIG_BLOCK to any configuration item that controls
an item that uses the block layer. This includes:
(*) Block I/O tracing.
(*) Disk partition code.
(*) All filesystems that are block based, eg: Ext3, ReiserFS, ISOFS.
(*) The SCSI layer. As far as I can tell, even SCSI chardevs use the
block layer to do scheduling. Some drivers that use SCSI facilities -
such as USB storage - end up disabled indirectly from this.
(*) Various block-based device drivers, such as IDE and the old CDROM
drivers.
(*) MTD blockdev handling and FTL.
(*) JFFS - which uses set_bdev_super(), something it could avoid doing by
taking a leaf out of JFFS2's book.
(*) Makes most of the contents of linux/blkdev.h, linux/buffer_head.h and
linux/elevator.h contingent on CONFIG_BLOCK being set. sector_div() is,
however, still used in places, and so is still available.
(*) Also made contingent are the contents of linux/mpage.h, linux/genhd.h and
parts of linux/fs.h.
(*) Makes a number of files in fs/ contingent on CONFIG_BLOCK.
(*) Makes mm/bounce.c (bounce buffering) contingent on CONFIG_BLOCK.
(*) set_page_dirty() doesn't call __set_page_dirty_buffers() if CONFIG_BLOCK
is not enabled.
(*) fs/no-block.c is created to hold out-of-line stubs and things that are
required when CONFIG_BLOCK is not set:
(*) Default blockdev file operations (to give error ENODEV on opening).
(*) Makes some /proc changes:
(*) /proc/devices does not list any blockdevs.
(*) /proc/diskstats and /proc/partitions are contingent on CONFIG_BLOCK.
(*) Makes some compat ioctl handling contingent on CONFIG_BLOCK.
(*) If CONFIG_BLOCK is not defined, makes sys_quotactl() return -ENODEV if
given command other than Q_SYNC or if a special device is specified.
(*) In init/do_mounts.c, no reference is made to the blockdev routines if
CONFIG_BLOCK is not defined. This does not prohibit NFS roots or JFFS2.
(*) The bdflush, ioprio_set and ioprio_get syscalls can now be absent (return
error ENOSYS by way of cond_syscall if so).
(*) The seclvl_bd_claim() and seclvl_bd_release() security calls do nothing if
CONFIG_BLOCK is not set, since they can't then happen.
Signed-Off-By: David Howells <dhowells@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2006-10-01 02:45:40 +08:00
|
|
|
|
|
|
|
#else /* CONFIG_BLOCK */
|
|
|
|
|
|
|
|
static inline void buffer_init(void) {}
|
|
|
|
static inline int try_to_free_buffers(struct page *page) { return 1; }
|
|
|
|
static inline int inode_has_buffers(struct inode *inode) { return 0; }
|
|
|
|
static inline void invalidate_inode_buffers(struct inode *inode) {}
|
|
|
|
static inline int remove_inode_buffers(struct inode *inode) { return 1; }
|
|
|
|
static inline int sync_mapping_buffers(struct address_space *mapping) { return 0; }
|
|
|
|
|
|
|
|
#endif /* CONFIG_BLOCK */
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* _LINUX_BUFFER_HEAD_H */
|