aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-09-30 14:45:40 -0400
committerJens Axboe <axboe@nelson.home.kernel.dk>2006-09-30 14:52:31 -0400
commit9361401eb7619c033e2394e4f9f6d410d6719ac7 (patch)
tree04b94a71f2366988c17740d1c16cfbdec41d5d2e /include/linux
parentd366e40a1cabd453be6e2609caa7e12f9ca17b1f (diff)
[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>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/blkdev.h50
-rw-r--r--include/linux/buffer_head.h16
-rw-r--r--include/linux/compat_ioctl.h2
-rw-r--r--include/linux/elevator.h3
-rw-r--r--include/linux/fs.h25
-rw-r--r--include/linux/genhd.h4
-rw-r--r--include/linux/mpage.h3
-rw-r--r--include/linux/raid/md.h3
-rw-r--r--include/linux/raid/md_k.h3
9 files changed, 92 insertions, 17 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 2c01a90998a7..3e36107d342a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -16,6 +16,22 @@
16 16
17#include <asm/scatterlist.h> 17#include <asm/scatterlist.h>
18 18
19#ifdef CONFIG_LBD
20# include <asm/div64.h>
21# define sector_div(a, b) do_div(a, b)
22#else
23# define sector_div(n, b)( \
24{ \
25 int _res; \
26 _res = (n) % (b); \
27 (n) /= (b); \
28 _res; \
29} \
30)
31#endif
32
33#ifdef CONFIG_BLOCK
34
19struct scsi_ioctl_command; 35struct scsi_ioctl_command;
20 36
21struct request_queue; 37struct request_queue;
@@ -818,24 +834,30 @@ struct work_struct;
818int kblockd_schedule_work(struct work_struct *work); 834int kblockd_schedule_work(struct work_struct *work);
819void kblockd_flush(void); 835void kblockd_flush(void);
820 836
821#ifdef CONFIG_LBD
822# include <asm/div64.h>
823# define sector_div(a, b) do_div(a, b)
824#else
825# define sector_div(n, b)( \
826{ \
827 int _res; \
828 _res = (n) % (b); \
829 (n) /= (b); \
830 _res; \
831} \
832)
833#endif
834
835#define MODULE_ALIAS_BLOCKDEV(major,minor) \ 837#define MODULE_ALIAS_BLOCKDEV(major,minor) \
836 MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor)) 838 MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor))
837#define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \ 839#define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \
838 MODULE_ALIAS("block-major-" __stringify(major) "-*") 840 MODULE_ALIAS("block-major-" __stringify(major) "-*")
839 841
840 842
843#else /* CONFIG_BLOCK */
844/*
845 * stubs for when the block layer is configured out
846 */
847#define buffer_heads_over_limit 0
848
849static inline long blk_congestion_wait(int rw, long timeout)
850{
851 return timeout;
852}
853
854static inline long nr_blockdev_pages(void)
855{
856 return 0;
857}
858
859static inline void exit_io_context(void) {}
860
861#endif /* CONFIG_BLOCK */
862
841#endif 863#endif
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 64b508e35d2a..131ffd37e716 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -14,6 +14,8 @@
14#include <linux/wait.h> 14#include <linux/wait.h>
15#include <asm/atomic.h> 15#include <asm/atomic.h>
16 16
17#ifdef CONFIG_BLOCK
18
17enum bh_state_bits { 19enum bh_state_bits {
18 BH_Uptodate, /* Contains valid data */ 20 BH_Uptodate, /* Contains valid data */
19 BH_Dirty, /* Is dirty */ 21 BH_Dirty, /* Is dirty */
@@ -301,4 +303,18 @@ static inline void lock_buffer(struct buffer_head *bh)
301} 303}
302 304
303extern int __set_page_dirty_buffers(struct page *page); 305extern int __set_page_dirty_buffers(struct page *page);
306
307#else /* CONFIG_BLOCK */
308
309static inline void buffer_init(void) {}
310static inline int try_to_free_buffers(struct page *page) { return 1; }
311static inline int sync_blockdev(struct block_device *bdev) { return 0; }
312static inline int inode_has_buffers(struct inode *inode) { return 0; }
313static inline void invalidate_inode_buffers(struct inode *inode) {}
314static inline int remove_inode_buffers(struct inode *inode) { return 1; }
315static inline int sync_mapping_buffers(struct address_space *mapping) { return 0; }
316static inline void invalidate_bdev(struct block_device *bdev, int destroy_dirty_buffers) {}
317
318
319#endif /* CONFIG_BLOCK */
304#endif /* _LINUX_BUFFER_HEAD_H */ 320#endif /* _LINUX_BUFFER_HEAD_H */
diff --git a/include/linux/compat_ioctl.h b/include/linux/compat_ioctl.h
index 98d40e08ba6e..d61ef5951538 100644
--- a/include/linux/compat_ioctl.h
+++ b/include/linux/compat_ioctl.h
@@ -90,6 +90,7 @@ COMPATIBLE_IOCTL(FDTWADDLE)
90COMPATIBLE_IOCTL(FDFMTTRK) 90COMPATIBLE_IOCTL(FDFMTTRK)
91COMPATIBLE_IOCTL(FDRAWCMD) 91COMPATIBLE_IOCTL(FDRAWCMD)
92/* 0x12 */ 92/* 0x12 */
93#ifdef CONFIG_BLOCK
93COMPATIBLE_IOCTL(BLKRASET) 94COMPATIBLE_IOCTL(BLKRASET)
94COMPATIBLE_IOCTL(BLKROSET) 95COMPATIBLE_IOCTL(BLKROSET)
95COMPATIBLE_IOCTL(BLKROGET) 96COMPATIBLE_IOCTL(BLKROGET)
@@ -103,6 +104,7 @@ COMPATIBLE_IOCTL(BLKTRACESETUP)
103COMPATIBLE_IOCTL(BLKTRACETEARDOWN) 104COMPATIBLE_IOCTL(BLKTRACETEARDOWN)
104ULONG_IOCTL(BLKRASET) 105ULONG_IOCTL(BLKRASET)
105ULONG_IOCTL(BLKFRASET) 106ULONG_IOCTL(BLKFRASET)
107#endif
106/* RAID */ 108/* RAID */
107COMPATIBLE_IOCTL(RAID_VERSION) 109COMPATIBLE_IOCTL(RAID_VERSION)
108COMPATIBLE_IOCTL(GET_ARRAY_INFO) 110COMPATIBLE_IOCTL(GET_ARRAY_INFO)
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index 9c5a04f6114c..b3370ef5164d 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -3,6 +3,8 @@
3 3
4#include <linux/percpu.h> 4#include <linux/percpu.h>
5 5
6#ifdef CONFIG_BLOCK
7
6typedef int (elevator_merge_fn) (request_queue_t *, struct request **, 8typedef int (elevator_merge_fn) (request_queue_t *, struct request **,
7 struct bio *); 9 struct bio *);
8 10
@@ -203,4 +205,5 @@ enum {
203 __val; \ 205 __val; \
204}) 206})
205 207
208#endif /* CONFIG_BLOCK */
206#endif 209#endif
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b73a47582dbe..5baf3a153403 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1482,6 +1482,7 @@ extern void __init vfs_caches_init(unsigned long);
1482extern void putname(const char *name); 1482extern void putname(const char *name);
1483#endif 1483#endif
1484 1484
1485#ifdef CONFIG_BLOCK
1485extern int register_blkdev(unsigned int, const char *); 1486extern int register_blkdev(unsigned int, const char *);
1486extern int unregister_blkdev(unsigned int, const char *); 1487extern int unregister_blkdev(unsigned int, const char *);
1487extern struct block_device *bdget(dev_t); 1488extern struct block_device *bdget(dev_t);
@@ -1490,11 +1491,15 @@ extern void bd_forget(struct inode *inode);
1490extern void bdput(struct block_device *); 1491extern void bdput(struct block_device *);
1491extern struct block_device *open_by_devnum(dev_t, unsigned); 1492extern struct block_device *open_by_devnum(dev_t, unsigned);
1492extern struct block_device *open_partition_by_devnum(dev_t, unsigned); 1493extern struct block_device *open_partition_by_devnum(dev_t, unsigned);
1493extern const struct file_operations def_blk_fops;
1494extern const struct address_space_operations def_blk_aops; 1494extern const struct address_space_operations def_blk_aops;
1495#else
1496static inline void bd_forget(struct inode *inode) {}
1497#endif
1498extern const struct file_operations def_blk_fops;
1495extern const struct file_operations def_chr_fops; 1499extern const struct file_operations def_chr_fops;
1496extern const struct file_operations bad_sock_fops; 1500extern const struct file_operations bad_sock_fops;
1497extern const struct file_operations def_fifo_fops; 1501extern const struct file_operations def_fifo_fops;
1502#ifdef CONFIG_BLOCK
1498extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 1503extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1499extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long); 1504extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long);
1500extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 1505extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
@@ -1510,6 +1515,7 @@ extern void bd_release_from_disk(struct block_device *, struct gendisk *);
1510#define bd_claim_by_disk(bdev, holder, disk) bd_claim(bdev, holder) 1515#define bd_claim_by_disk(bdev, holder, disk) bd_claim(bdev, holder)
1511#define bd_release_from_disk(bdev, disk) bd_release(bdev) 1516#define bd_release_from_disk(bdev, disk) bd_release(bdev)
1512#endif 1517#endif
1518#endif
1513 1519
1514/* fs/char_dev.c */ 1520/* fs/char_dev.c */
1515#define CHRDEV_MAJOR_HASH_SIZE 255 1521#define CHRDEV_MAJOR_HASH_SIZE 255
@@ -1523,14 +1529,19 @@ extern int chrdev_open(struct inode *, struct file *);
1523extern void chrdev_show(struct seq_file *,off_t); 1529extern void chrdev_show(struct seq_file *,off_t);
1524 1530
1525/* fs/block_dev.c */ 1531/* fs/block_dev.c */
1526#define BLKDEV_MAJOR_HASH_SIZE 255
1527#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ 1532#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */
1533
1534#ifdef CONFIG_BLOCK
1535#define BLKDEV_MAJOR_HASH_SIZE 255
1528extern const char *__bdevname(dev_t, char *buffer); 1536extern const char *__bdevname(dev_t, char *buffer);
1529extern const char *bdevname(struct block_device *bdev, char *buffer); 1537extern const char *bdevname(struct block_device *bdev, char *buffer);
1530extern struct block_device *lookup_bdev(const char *); 1538extern struct block_device *lookup_bdev(const char *);
1531extern struct block_device *open_bdev_excl(const char *, int, void *); 1539extern struct block_device *open_bdev_excl(const char *, int, void *);
1532extern void close_bdev_excl(struct block_device *); 1540extern void close_bdev_excl(struct block_device *);
1533extern void blkdev_show(struct seq_file *,off_t); 1541extern void blkdev_show(struct seq_file *,off_t);
1542#else
1543#define BLKDEV_MAJOR_HASH_SIZE 0
1544#endif
1534 1545
1535extern void init_special_inode(struct inode *, umode_t, dev_t); 1546extern void init_special_inode(struct inode *, umode_t, dev_t);
1536 1547
@@ -1544,6 +1555,7 @@ extern const struct file_operations rdwr_fifo_fops;
1544 1555
1545extern int fs_may_remount_ro(struct super_block *); 1556extern int fs_may_remount_ro(struct super_block *);
1546 1557
1558#ifdef CONFIG_BLOCK
1547/* 1559/*
1548 * return READ, READA, or WRITE 1560 * return READ, READA, or WRITE
1549 */ 1561 */
@@ -1555,9 +1567,10 @@ extern int fs_may_remount_ro(struct super_block *);
1555#define bio_data_dir(bio) ((bio)->bi_rw & 1) 1567#define bio_data_dir(bio) ((bio)->bi_rw & 1)
1556 1568
1557extern int check_disk_change(struct block_device *); 1569extern int check_disk_change(struct block_device *);
1558extern int invalidate_inodes(struct super_block *);
1559extern int __invalidate_device(struct block_device *); 1570extern int __invalidate_device(struct block_device *);
1560extern int invalidate_partition(struct gendisk *, int); 1571extern int invalidate_partition(struct gendisk *, int);
1572#endif
1573extern int invalidate_inodes(struct super_block *);
1561unsigned long invalidate_mapping_pages(struct address_space *mapping, 1574unsigned long invalidate_mapping_pages(struct address_space *mapping,
1562 pgoff_t start, pgoff_t end); 1575 pgoff_t start, pgoff_t end);
1563unsigned long invalidate_inode_pages(struct address_space *mapping); 1576unsigned long invalidate_inode_pages(struct address_space *mapping);
@@ -1590,7 +1603,9 @@ extern void emergency_sync(void);
1590extern void emergency_remount(void); 1603extern void emergency_remount(void);
1591extern int do_remount_sb(struct super_block *sb, int flags, 1604extern int do_remount_sb(struct super_block *sb, int flags,
1592 void *data, int force); 1605 void *data, int force);
1606#ifdef CONFIG_BLOCK
1593extern sector_t bmap(struct inode *, sector_t); 1607extern sector_t bmap(struct inode *, sector_t);
1608#endif
1594extern int notify_change(struct dentry *, struct iattr *); 1609extern int notify_change(struct dentry *, struct iattr *);
1595extern int permission(struct inode *, int, struct nameidata *); 1610extern int permission(struct inode *, int, struct nameidata *);
1596extern int generic_permission(struct inode *, int, 1611extern int generic_permission(struct inode *, int,
@@ -1673,9 +1688,11 @@ static inline void insert_inode_hash(struct inode *inode) {
1673extern struct file * get_empty_filp(void); 1688extern struct file * get_empty_filp(void);
1674extern void file_move(struct file *f, struct list_head *list); 1689extern void file_move(struct file *f, struct list_head *list);
1675extern void file_kill(struct file *f); 1690extern void file_kill(struct file *f);
1691#ifdef CONFIG_BLOCK
1676struct bio; 1692struct bio;
1677extern void submit_bio(int, struct bio *); 1693extern void submit_bio(int, struct bio *);
1678extern int bdev_read_only(struct block_device *); 1694extern int bdev_read_only(struct block_device *);
1695#endif
1679extern int set_blocksize(struct block_device *, int); 1696extern int set_blocksize(struct block_device *, int);
1680extern int sb_set_blocksize(struct super_block *, int); 1697extern int sb_set_blocksize(struct super_block *, int);
1681extern int sb_min_blocksize(struct super_block *, int); 1698extern int sb_min_blocksize(struct super_block *, int);
@@ -1756,6 +1773,7 @@ static inline void do_generic_file_read(struct file * filp, loff_t *ppos,
1756 actor); 1773 actor);
1757} 1774}
1758 1775
1776#ifdef CONFIG_BLOCK
1759ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, 1777ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1760 struct block_device *bdev, const struct iovec *iov, loff_t offset, 1778 struct block_device *bdev, const struct iovec *iov, loff_t offset,
1761 unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io, 1779 unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io,
@@ -1793,6 +1811,7 @@ static inline ssize_t blockdev_direct_IO_own_locking(int rw, struct kiocb *iocb,
1793 return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset, 1811 return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
1794 nr_segs, get_block, end_io, DIO_OWN_LOCKING); 1812 nr_segs, get_block, end_io, DIO_OWN_LOCKING);
1795} 1813}
1814#endif
1796 1815
1797extern const struct file_operations generic_ro_fops; 1816extern const struct file_operations generic_ro_fops;
1798 1817
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index e4af57e87c17..41f276fdd185 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -11,6 +11,8 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13 13
14#ifdef CONFIG_BLOCK
15
14enum { 16enum {
15/* These three have identical behaviour; use the second one if DOS FDISK gets 17/* These three have identical behaviour; use the second one if DOS FDISK gets
16 confused about extended/logical partitions starting past cylinder 1023. */ 18 confused about extended/logical partitions starting past cylinder 1023. */
@@ -420,3 +422,5 @@ static inline struct block_device *bdget_disk(struct gendisk *disk, int index)
420#endif 422#endif
421 423
422#endif 424#endif
425
426#endif
diff --git a/include/linux/mpage.h b/include/linux/mpage.h
index 517c098fde20..cc5fb75af78a 100644
--- a/include/linux/mpage.h
+++ b/include/linux/mpage.h
@@ -9,6 +9,7 @@
9 * (And no, it doesn't do the #ifdef __MPAGE_H thing, and it doesn't do 9 * (And no, it doesn't do the #ifdef __MPAGE_H thing, and it doesn't do
10 * nested includes. Get it right in the .c file). 10 * nested includes. Get it right in the .c file).
11 */ 11 */
12#ifdef CONFIG_BLOCK
12 13
13struct writeback_control; 14struct writeback_control;
14typedef int (writepage_t)(struct page *page, struct writeback_control *wbc); 15typedef int (writepage_t)(struct page *page, struct writeback_control *wbc);
@@ -20,3 +21,5 @@ int mpage_writepages(struct address_space *mapping,
20 struct writeback_control *wbc, get_block_t get_block); 21 struct writeback_control *wbc, get_block_t get_block);
21int mpage_writepage(struct page *page, get_block_t *get_block, 22int mpage_writepage(struct page *page, get_block_t *get_block,
22 struct writeback_control *wbc); 23 struct writeback_control *wbc);
24
25#endif
diff --git a/include/linux/raid/md.h b/include/linux/raid/md.h
index eb3e547c8fee..c588709acbbc 100644
--- a/include/linux/raid/md.h
+++ b/include/linux/raid/md.h
@@ -53,6 +53,8 @@
53#include <linux/raid/md_u.h> 53#include <linux/raid/md_u.h>
54#include <linux/raid/md_k.h> 54#include <linux/raid/md_k.h>
55 55
56#ifdef CONFIG_MD
57
56/* 58/*
57 * Different major versions are not compatible. 59 * Different major versions are not compatible.
58 * Different minor versions are only downward compatible. 60 * Different minor versions are only downward compatible.
@@ -95,5 +97,6 @@ extern void md_new_event(mddev_t *mddev);
95 97
96extern void md_update_sb(mddev_t * mddev); 98extern void md_update_sb(mddev_t * mddev);
97 99
100#endif /* CONFIG_MD */
98#endif 101#endif
99 102
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index d28890295852..920b94fe31fa 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -18,6 +18,8 @@
18/* and dm-bio-list.h is not under include/linux because.... ??? */ 18/* and dm-bio-list.h is not under include/linux because.... ??? */
19#include "../../../drivers/md/dm-bio-list.h" 19#include "../../../drivers/md/dm-bio-list.h"
20 20
21#ifdef CONFIG_BLOCK
22
21#define LEVEL_MULTIPATH (-4) 23#define LEVEL_MULTIPATH (-4)
22#define LEVEL_LINEAR (-1) 24#define LEVEL_LINEAR (-1)
23#define LEVEL_FAULTY (-5) 25#define LEVEL_FAULTY (-5)
@@ -362,5 +364,6 @@ static inline void safe_put_page(struct page *p)
362 if (p) put_page(p); 364 if (p) put_page(p);
363} 365}
364 366
367#endif /* CONFIG_BLOCK */
365#endif 368#endif
366 369