diff options
Diffstat (limited to 'include/linux')
45 files changed, 1312 insertions, 821 deletions
diff --git a/include/linux/bfs_fs.h b/include/linux/bfs_fs.h index f7f0913cd110..c1237aa92e38 100644 --- a/include/linux/bfs_fs.h +++ b/include/linux/bfs_fs.h | |||
@@ -14,8 +14,9 @@ | |||
14 | #define BFS_INODES_PER_BLOCK 8 | 14 | #define BFS_INODES_PER_BLOCK 8 |
15 | 15 | ||
16 | /* SVR4 vnode type values (bfs_inode->i_vtype) */ | 16 | /* SVR4 vnode type values (bfs_inode->i_vtype) */ |
17 | #define BFS_VDIR 2 | 17 | #define BFS_VDIR 2L |
18 | #define BFS_VREG 1 | 18 | #define BFS_VREG 1L |
19 | |||
19 | 20 | ||
20 | /* BFS inode layout on disk */ | 21 | /* BFS inode layout on disk */ |
21 | struct bfs_inode { | 22 | struct bfs_inode { |
@@ -58,22 +59,22 @@ struct bfs_super_block { | |||
58 | __u32 s_padding[118]; | 59 | __u32 s_padding[118]; |
59 | }; | 60 | }; |
60 | 61 | ||
61 | #define BFS_NZFILESIZE(ip) \ | ||
62 | (((ip)->i_eoffset + 1) - (ip)->i_sblock * BFS_BSIZE) | ||
63 | |||
64 | #define BFS_FILESIZE(ip) \ | ||
65 | ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip)) | ||
66 | |||
67 | #define BFS_FILEBLOCKS(ip) \ | ||
68 | ((ip)->i_sblock == 0 ? 0 : ((ip)->i_eblock + 1) - (ip)->i_sblock) | ||
69 | 62 | ||
70 | #define BFS_OFF2INO(offset) \ | 63 | #define BFS_OFF2INO(offset) \ |
71 | ((((offset) - BFS_BSIZE) / sizeof(struct bfs_inode)) + BFS_ROOT_INO) | 64 | ((((offset) - BFS_BSIZE) / sizeof(struct bfs_inode)) + BFS_ROOT_INO) |
72 | 65 | ||
73 | #define BFS_INO2OFF(ino) \ | 66 | #define BFS_INO2OFF(ino) \ |
74 | ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE) | 67 | ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE) |
68 | #define BFS_NZFILESIZE(ip) \ | ||
69 | ((cpu_to_le32((ip)->i_eoffset) + 1) - cpu_to_le32((ip)->i_sblock) * BFS_BSIZE) | ||
70 | |||
71 | #define BFS_FILESIZE(ip) \ | ||
72 | ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip)) | ||
75 | 73 | ||
74 | #define BFS_FILEBLOCKS(ip) \ | ||
75 | ((ip)->i_sblock == 0 ? 0 : (cpu_to_le32((ip)->i_eblock) + 1) - cpu_to_le32((ip)->i_sblock)) | ||
76 | #define BFS_UNCLEAN(bfs_sb, sb) \ | 76 | #define BFS_UNCLEAN(bfs_sb, sb) \ |
77 | ((bfs_sb->s_from != -1) && (bfs_sb->s_to != -1) && !(sb->s_flags & MS_RDONLY)) | 77 | ((cpu_to_le32(bfs_sb->s_from) != -1) && (cpu_to_le32(bfs_sb->s_to) != -1) && !(sb->s_flags & MS_RDONLY)) |
78 | |||
78 | 79 | ||
79 | #endif /* _LINUX_BFS_FS_H */ | 80 | #endif /* _LINUX_BFS_FS_H */ |
diff --git a/include/linux/bio.h b/include/linux/bio.h index cdaf03a14a51..6e1c79c8b6bf 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -314,9 +314,8 @@ void zero_fill_bio(struct bio *bio); | |||
314 | * bvec_kmap_irq and bvec_kunmap_irq!! | 314 | * bvec_kmap_irq and bvec_kunmap_irq!! |
315 | * | 315 | * |
316 | * This function MUST be inlined - it plays with the CPU interrupt flags. | 316 | * This function MUST be inlined - it plays with the CPU interrupt flags. |
317 | * Hence the `extern inline'. | ||
318 | */ | 317 | */ |
319 | extern inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags) | 318 | static inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags) |
320 | { | 319 | { |
321 | unsigned long addr; | 320 | unsigned long addr; |
322 | 321 | ||
@@ -332,7 +331,7 @@ extern inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags) | |||
332 | return (char *) addr + bvec->bv_offset; | 331 | return (char *) addr + bvec->bv_offset; |
333 | } | 332 | } |
334 | 333 | ||
335 | extern inline void bvec_kunmap_irq(char *buffer, unsigned long *flags) | 334 | static inline void bvec_kunmap_irq(char *buffer, unsigned long *flags) |
336 | { | 335 | { |
337 | unsigned long ptr = (unsigned long) buffer & PAGE_MASK; | 336 | unsigned long ptr = (unsigned long) buffer & PAGE_MASK; |
338 | 337 | ||
@@ -345,7 +344,7 @@ extern inline void bvec_kunmap_irq(char *buffer, unsigned long *flags) | |||
345 | #define bvec_kunmap_irq(buf, flags) do { *(flags) = 0; } while (0) | 344 | #define bvec_kunmap_irq(buf, flags) do { *(flags) = 0; } while (0) |
346 | #endif | 345 | #endif |
347 | 346 | ||
348 | extern inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx, | 347 | static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx, |
349 | unsigned long *flags) | 348 | unsigned long *flags) |
350 | { | 349 | { |
351 | return bvec_kmap_irq(bio_iovec_idx(bio, idx), flags); | 350 | return bvec_kmap_irq(bio_iovec_idx(bio, idx), flags); |
diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h new file mode 100644 index 000000000000..6b20af0bbb79 --- /dev/null +++ b/include/linux/bit_spinlock.h | |||
@@ -0,0 +1,77 @@ | |||
1 | #ifndef __LINUX_BIT_SPINLOCK_H | ||
2 | #define __LINUX_BIT_SPINLOCK_H | ||
3 | |||
4 | /* | ||
5 | * bit-based spin_lock() | ||
6 | * | ||
7 | * Don't use this unless you really need to: spin_lock() and spin_unlock() | ||
8 | * are significantly faster. | ||
9 | */ | ||
10 | static inline void bit_spin_lock(int bitnum, unsigned long *addr) | ||
11 | { | ||
12 | /* | ||
13 | * Assuming the lock is uncontended, this never enters | ||
14 | * the body of the outer loop. If it is contended, then | ||
15 | * within the inner loop a non-atomic test is used to | ||
16 | * busywait with less bus contention for a good time to | ||
17 | * attempt to acquire the lock bit. | ||
18 | */ | ||
19 | preempt_disable(); | ||
20 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
21 | while (test_and_set_bit(bitnum, addr)) { | ||
22 | while (test_bit(bitnum, addr)) { | ||
23 | preempt_enable(); | ||
24 | cpu_relax(); | ||
25 | preempt_disable(); | ||
26 | } | ||
27 | } | ||
28 | #endif | ||
29 | __acquire(bitlock); | ||
30 | } | ||
31 | |||
32 | /* | ||
33 | * Return true if it was acquired | ||
34 | */ | ||
35 | static inline int bit_spin_trylock(int bitnum, unsigned long *addr) | ||
36 | { | ||
37 | preempt_disable(); | ||
38 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
39 | if (test_and_set_bit(bitnum, addr)) { | ||
40 | preempt_enable(); | ||
41 | return 0; | ||
42 | } | ||
43 | #endif | ||
44 | __acquire(bitlock); | ||
45 | return 1; | ||
46 | } | ||
47 | |||
48 | /* | ||
49 | * bit-based spin_unlock() | ||
50 | */ | ||
51 | static inline void bit_spin_unlock(int bitnum, unsigned long *addr) | ||
52 | { | ||
53 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
54 | BUG_ON(!test_bit(bitnum, addr)); | ||
55 | smp_mb__before_clear_bit(); | ||
56 | clear_bit(bitnum, addr); | ||
57 | #endif | ||
58 | preempt_enable(); | ||
59 | __release(bitlock); | ||
60 | } | ||
61 | |||
62 | /* | ||
63 | * Return true if the lock is held. | ||
64 | */ | ||
65 | static inline int bit_spin_is_locked(int bitnum, unsigned long *addr) | ||
66 | { | ||
67 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
68 | return test_bit(bitnum, addr); | ||
69 | #elif defined CONFIG_PREEMPT | ||
70 | return preempt_count(); | ||
71 | #else | ||
72 | return 1; | ||
73 | #endif | ||
74 | } | ||
75 | |||
76 | #endif /* __LINUX_BIT_SPINLOCK_H */ | ||
77 | |||
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index aefa26fbae8a..efdc9b5bc05c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -728,7 +728,7 @@ static inline unsigned int blksize_bits(unsigned int size) | |||
728 | return bits; | 728 | return bits; |
729 | } | 729 | } |
730 | 730 | ||
731 | extern inline unsigned int block_size(struct block_device *bdev) | 731 | static inline unsigned int block_size(struct block_device *bdev) |
732 | { | 732 | { |
733 | return bdev->bd_block_size; | 733 | return bdev->bd_block_size; |
734 | } | 734 | } |
diff --git a/include/linux/chio.h b/include/linux/chio.h index 63035ae67e63..a404c111c937 100644 --- a/include/linux/chio.h +++ b/include/linux/chio.h | |||
@@ -96,7 +96,7 @@ struct changer_position { | |||
96 | */ | 96 | */ |
97 | struct changer_element_status { | 97 | struct changer_element_status { |
98 | int ces_type; | 98 | int ces_type; |
99 | unsigned char *ces_data; | 99 | unsigned char __user *ces_data; |
100 | }; | 100 | }; |
101 | #define CESTATUS_FULL 0x01 /* full */ | 101 | #define CESTATUS_FULL 0x01 /* full */ |
102 | #define CESTATUS_IMPEXP 0x02 /* media was imported (inserted by sysop) */ | 102 | #define CESTATUS_IMPEXP 0x02 /* media was imported (inserted by sysop) */ |
diff --git a/include/linux/dccp.h b/include/linux/dccp.h index 007c290f74d4..8bf4bacb5051 100644 --- a/include/linux/dccp.h +++ b/include/linux/dccp.h | |||
@@ -432,7 +432,10 @@ struct dccp_sock { | |||
432 | struct ccid *dccps_hc_rx_ccid; | 432 | struct ccid *dccps_hc_rx_ccid; |
433 | struct ccid *dccps_hc_tx_ccid; | 433 | struct ccid *dccps_hc_tx_ccid; |
434 | struct dccp_options_received dccps_options_received; | 434 | struct dccp_options_received dccps_options_received; |
435 | struct timeval dccps_epoch; | ||
435 | enum dccp_role dccps_role:2; | 436 | enum dccp_role dccps_role:2; |
437 | __u8 dccps_hc_rx_insert_options:1; | ||
438 | __u8 dccps_hc_tx_insert_options:1; | ||
436 | }; | 439 | }; |
437 | 440 | ||
438 | static inline struct dccp_sock *dccp_sk(const struct sock *sk) | 441 | static inline struct dccp_sock *dccp_sk(const struct sock *sk) |
diff --git a/include/linux/dmapool.h b/include/linux/dmapool.h index e60bfdac348d..4932ee5c77f0 100644 --- a/include/linux/dmapool.h +++ b/include/linux/dmapool.h | |||
@@ -19,7 +19,8 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev, | |||
19 | 19 | ||
20 | void dma_pool_destroy(struct dma_pool *pool); | 20 | void dma_pool_destroy(struct dma_pool *pool); |
21 | 21 | ||
22 | void *dma_pool_alloc(struct dma_pool *pool, int mem_flags, dma_addr_t *handle); | 22 | void *dma_pool_alloc(struct dma_pool *pool, unsigned int __nocast mem_flags, |
23 | dma_addr_t *handle); | ||
23 | 24 | ||
24 | void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr); | 25 | void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr); |
25 | 26 | ||
diff --git a/include/linux/dmi.h b/include/linux/dmi.h index c30175e8dec6..a415f1d93e9a 100644 --- a/include/linux/dmi.h +++ b/include/linux/dmi.h | |||
@@ -70,7 +70,7 @@ extern struct dmi_device * dmi_find_device(int type, const char *name, | |||
70 | 70 | ||
71 | static inline int dmi_check_system(struct dmi_system_id *list) { return 0; } | 71 | static inline int dmi_check_system(struct dmi_system_id *list) { return 0; } |
72 | static inline char * dmi_get_system_info(int field) { return NULL; } | 72 | static inline char * dmi_get_system_info(int field) { return NULL; } |
73 | static struct dmi_device * dmi_find_device(int type, const char *name, | 73 | static inline struct dmi_device * dmi_find_device(int type, const char *name, |
74 | struct dmi_device *from) { return NULL; } | 74 | struct dmi_device *from) { return NULL; } |
75 | 75 | ||
76 | #endif | 76 | #endif |
diff --git a/include/linux/fb.h b/include/linux/fb.h index bc24beeed971..82e39cd0c4fb 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h | |||
@@ -107,6 +107,8 @@ | |||
107 | #define FB_ACCEL_NV_20 44 /* nVidia Arch 20 */ | 107 | #define FB_ACCEL_NV_20 44 /* nVidia Arch 20 */ |
108 | #define FB_ACCEL_NV_30 45 /* nVidia Arch 30 */ | 108 | #define FB_ACCEL_NV_30 45 /* nVidia Arch 30 */ |
109 | #define FB_ACCEL_NV_40 46 /* nVidia Arch 40 */ | 109 | #define FB_ACCEL_NV_40 46 /* nVidia Arch 40 */ |
110 | #define FB_ACCEL_XGI_VOLARI_V 47 /* XGI Volari V3XT, V5, V8 */ | ||
111 | #define FB_ACCEL_XGI_VOLARI_Z 48 /* XGI Volari Z7 */ | ||
110 | #define FB_ACCEL_NEOMAGIC_NM2070 90 /* NeoMagic NM2070 */ | 112 | #define FB_ACCEL_NEOMAGIC_NM2070 90 /* NeoMagic NM2070 */ |
111 | #define FB_ACCEL_NEOMAGIC_NM2090 91 /* NeoMagic NM2090 */ | 113 | #define FB_ACCEL_NEOMAGIC_NM2090 91 /* NeoMagic NM2090 */ |
112 | #define FB_ACCEL_NEOMAGIC_NM2093 92 /* NeoMagic NM2093 */ | 114 | #define FB_ACCEL_NEOMAGIC_NM2093 92 /* NeoMagic NM2093 */ |
@@ -495,6 +497,9 @@ struct fb_cursor_user { | |||
495 | #define FB_EVENT_BLANK 0x08 | 497 | #define FB_EVENT_BLANK 0x08 |
496 | /* Private modelist is to be replaced */ | 498 | /* Private modelist is to be replaced */ |
497 | #define FB_EVENT_NEW_MODELIST 0x09 | 499 | #define FB_EVENT_NEW_MODELIST 0x09 |
500 | /* The resolution of the passed in fb_info about to change and | ||
501 | all vc's should be changed */ | ||
502 | #define FB_EVENT_MODE_CHANGE_ALL 0x0A | ||
498 | 503 | ||
499 | struct fb_event { | 504 | struct fb_event { |
500 | struct fb_info *info; | 505 | struct fb_info *info; |
@@ -820,13 +825,29 @@ extern void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, | |||
820 | u32 height, u32 shift_high, u32 shift_low, u32 mod); | 825 | u32 height, u32 shift_high, u32 shift_low, u32 mod); |
821 | extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height); | 826 | extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height); |
822 | extern void fb_set_suspend(struct fb_info *info, int state); | 827 | extern void fb_set_suspend(struct fb_info *info, int state); |
823 | extern int fb_get_color_depth(struct fb_var_screeninfo *var); | 828 | extern int fb_get_color_depth(struct fb_var_screeninfo *var, |
829 | struct fb_fix_screeninfo *fix); | ||
824 | extern int fb_get_options(char *name, char **option); | 830 | extern int fb_get_options(char *name, char **option); |
825 | extern int fb_new_modelist(struct fb_info *info); | 831 | extern int fb_new_modelist(struct fb_info *info); |
826 | 832 | ||
827 | extern struct fb_info *registered_fb[FB_MAX]; | 833 | extern struct fb_info *registered_fb[FB_MAX]; |
828 | extern int num_registered_fb; | 834 | extern int num_registered_fb; |
829 | 835 | ||
836 | static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, | ||
837 | u8 *src, u32 s_pitch, u32 height) | ||
838 | { | ||
839 | int i, j; | ||
840 | |||
841 | d_pitch -= s_pitch; | ||
842 | |||
843 | for (i = height; i--; ) { | ||
844 | /* s_pitch is a few bytes at the most, memcpy is suboptimal */ | ||
845 | for (j = 0; j < s_pitch; j++) | ||
846 | *dst++ = *src++; | ||
847 | dst += d_pitch; | ||
848 | } | ||
849 | } | ||
850 | |||
830 | /* drivers/video/fbsysfs.c */ | 851 | /* drivers/video/fbsysfs.c */ |
831 | extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev); | 852 | extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev); |
832 | extern void framebuffer_release(struct fb_info *info); | 853 | extern void framebuffer_release(struct fb_info *info); |
@@ -856,8 +877,11 @@ extern int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var, | |||
856 | extern int fb_validate_mode(const struct fb_var_screeninfo *var, | 877 | extern int fb_validate_mode(const struct fb_var_screeninfo *var, |
857 | struct fb_info *info); | 878 | struct fb_info *info); |
858 | extern int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var); | 879 | extern int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var); |
859 | extern void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs); | 880 | extern const unsigned char *fb_firmware_edid(struct device *device); |
881 | extern void fb_edid_to_monspecs(unsigned char *edid, | ||
882 | struct fb_monspecs *specs); | ||
860 | extern void fb_destroy_modedb(struct fb_videomode *modedb); | 883 | extern void fb_destroy_modedb(struct fb_videomode *modedb); |
884 | extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb); | ||
861 | 885 | ||
862 | /* drivers/video/modedb.c */ | 886 | /* drivers/video/modedb.c */ |
863 | #define VESA_MODEDB_SIZE 34 | 887 | #define VESA_MODEDB_SIZE 34 |
diff --git a/include/linux/file.h b/include/linux/file.h index 5206beb9a80e..f5bbd4c508b3 100644 --- a/include/linux/file.h +++ b/include/linux/file.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/posix_types.h> | 9 | #include <linux/posix_types.h> |
10 | #include <linux/compiler.h> | 10 | #include <linux/compiler.h> |
11 | #include <linux/spinlock.h> | 11 | #include <linux/spinlock.h> |
12 | #include <linux/rcupdate.h> | ||
12 | 13 | ||
13 | /* | 14 | /* |
14 | * The default fd array needs to be at least BITS_PER_LONG, | 15 | * The default fd array needs to be at least BITS_PER_LONG, |
@@ -16,23 +17,33 @@ | |||
16 | */ | 17 | */ |
17 | #define NR_OPEN_DEFAULT BITS_PER_LONG | 18 | #define NR_OPEN_DEFAULT BITS_PER_LONG |
18 | 19 | ||
20 | struct fdtable { | ||
21 | unsigned int max_fds; | ||
22 | int max_fdset; | ||
23 | int next_fd; | ||
24 | struct file ** fd; /* current fd array */ | ||
25 | fd_set *close_on_exec; | ||
26 | fd_set *open_fds; | ||
27 | struct rcu_head rcu; | ||
28 | struct files_struct *free_files; | ||
29 | struct fdtable *next; | ||
30 | }; | ||
31 | |||
19 | /* | 32 | /* |
20 | * Open file table structure | 33 | * Open file table structure |
21 | */ | 34 | */ |
22 | struct files_struct { | 35 | struct files_struct { |
23 | atomic_t count; | 36 | atomic_t count; |
24 | spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */ | 37 | spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */ |
25 | int max_fds; | 38 | struct fdtable *fdt; |
26 | int max_fdset; | 39 | struct fdtable fdtab; |
27 | int next_fd; | ||
28 | struct file ** fd; /* current fd array */ | ||
29 | fd_set *close_on_exec; | ||
30 | fd_set *open_fds; | ||
31 | fd_set close_on_exec_init; | 40 | fd_set close_on_exec_init; |
32 | fd_set open_fds_init; | 41 | fd_set open_fds_init; |
33 | struct file * fd_array[NR_OPEN_DEFAULT]; | 42 | struct file * fd_array[NR_OPEN_DEFAULT]; |
34 | }; | 43 | }; |
35 | 44 | ||
45 | #define files_fdtable(files) (rcu_dereference((files)->fdt)) | ||
46 | |||
36 | extern void FASTCALL(__fput(struct file *)); | 47 | extern void FASTCALL(__fput(struct file *)); |
37 | extern void FASTCALL(fput(struct file *)); | 48 | extern void FASTCALL(fput(struct file *)); |
38 | 49 | ||
@@ -59,13 +70,16 @@ extern fd_set *alloc_fdset(int); | |||
59 | extern void free_fdset(fd_set *, int); | 70 | extern void free_fdset(fd_set *, int); |
60 | 71 | ||
61 | extern int expand_files(struct files_struct *, int nr); | 72 | extern int expand_files(struct files_struct *, int nr); |
73 | extern void free_fdtable(struct fdtable *fdt); | ||
74 | extern void __init files_defer_init(void); | ||
62 | 75 | ||
63 | static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) | 76 | static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) |
64 | { | 77 | { |
65 | struct file * file = NULL; | 78 | struct file * file = NULL; |
79 | struct fdtable *fdt = files_fdtable(files); | ||
66 | 80 | ||
67 | if (fd < files->max_fds) | 81 | if (fd < fdt->max_fds) |
68 | file = files->fd[fd]; | 82 | file = rcu_dereference(fdt->fd[fd]); |
69 | return file; | 83 | return file; |
70 | } | 84 | } |
71 | 85 | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index fd93ab7da905..e0b77c5af9a0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/config.h> | 9 | #include <linux/config.h> |
10 | #include <linux/limits.h> | 10 | #include <linux/limits.h> |
11 | #include <linux/ioctl.h> | 11 | #include <linux/ioctl.h> |
12 | #include <linux/rcuref.h> | ||
12 | 13 | ||
13 | /* | 14 | /* |
14 | * It's silly to have NR_OPEN bigger than NR_FILE, but you can change | 15 | * It's silly to have NR_OPEN bigger than NR_FILE, but you can change |
@@ -597,12 +598,13 @@ struct file { | |||
597 | spinlock_t f_ep_lock; | 598 | spinlock_t f_ep_lock; |
598 | #endif /* #ifdef CONFIG_EPOLL */ | 599 | #endif /* #ifdef CONFIG_EPOLL */ |
599 | struct address_space *f_mapping; | 600 | struct address_space *f_mapping; |
601 | struct rcu_head f_rcuhead; | ||
600 | }; | 602 | }; |
601 | extern spinlock_t files_lock; | 603 | extern spinlock_t files_lock; |
602 | #define file_list_lock() spin_lock(&files_lock); | 604 | #define file_list_lock() spin_lock(&files_lock); |
603 | #define file_list_unlock() spin_unlock(&files_lock); | 605 | #define file_list_unlock() spin_unlock(&files_lock); |
604 | 606 | ||
605 | #define get_file(x) atomic_inc(&(x)->f_count) | 607 | #define get_file(x) rcuref_inc(&(x)->f_count) |
606 | #define file_count(x) atomic_read(&(x)->f_count) | 608 | #define file_count(x) atomic_read(&(x)->f_count) |
607 | 609 | ||
608 | #define MAX_NON_LFS ((1UL<<31) - 1) | 610 | #define MAX_NON_LFS ((1UL<<31) - 1) |
@@ -1507,8 +1509,6 @@ extern void do_generic_mapping_read(struct address_space *mapping, | |||
1507 | loff_t *, read_descriptor_t *, read_actor_t); | 1509 | loff_t *, read_descriptor_t *, read_actor_t); |
1508 | extern void | 1510 | extern void |
1509 | file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); | 1511 | file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); |
1510 | extern ssize_t generic_file_direct_IO(int rw, struct kiocb *iocb, | ||
1511 | const struct iovec *iov, loff_t offset, unsigned long nr_segs); | ||
1512 | extern ssize_t generic_file_readv(struct file *filp, const struct iovec *iov, | 1512 | extern ssize_t generic_file_readv(struct file *filp, const struct iovec *iov, |
1513 | unsigned long nr_segs, loff_t *ppos); | 1513 | unsigned long nr_segs, loff_t *ppos); |
1514 | ssize_t generic_file_writev(struct file *filp, const struct iovec *iov, | 1514 | ssize_t generic_file_writev(struct file *filp, const struct iovec *iov, |
diff --git a/include/linux/fuse.h b/include/linux/fuse.h new file mode 100644 index 000000000000..acbeb96a3353 --- /dev/null +++ b/include/linux/fuse.h | |||
@@ -0,0 +1,259 @@ | |||
1 | /* | ||
2 | FUSE: Filesystem in Userspace | ||
3 | Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu> | ||
4 | |||
5 | This program can be distributed under the terms of the GNU GPL. | ||
6 | See the file COPYING. | ||
7 | */ | ||
8 | |||
9 | /* This file defines the kernel interface of FUSE */ | ||
10 | |||
11 | #include <asm/types.h> | ||
12 | |||
13 | /** Version number of this interface */ | ||
14 | #define FUSE_KERNEL_VERSION 7 | ||
15 | |||
16 | /** Minor version number of this interface */ | ||
17 | #define FUSE_KERNEL_MINOR_VERSION 2 | ||
18 | |||
19 | /** The node ID of the root inode */ | ||
20 | #define FUSE_ROOT_ID 1 | ||
21 | |||
22 | /** The major number of the fuse character device */ | ||
23 | #define FUSE_MAJOR 10 | ||
24 | |||
25 | /** The minor number of the fuse character device */ | ||
26 | #define FUSE_MINOR 229 | ||
27 | |||
28 | /* Make sure all structures are padded to 64bit boundary, so 32bit | ||
29 | userspace works under 64bit kernels */ | ||
30 | |||
31 | struct fuse_attr { | ||
32 | __u64 ino; | ||
33 | __u64 size; | ||
34 | __u64 blocks; | ||
35 | __u64 atime; | ||
36 | __u64 mtime; | ||
37 | __u64 ctime; | ||
38 | __u32 atimensec; | ||
39 | __u32 mtimensec; | ||
40 | __u32 ctimensec; | ||
41 | __u32 mode; | ||
42 | __u32 nlink; | ||
43 | __u32 uid; | ||
44 | __u32 gid; | ||
45 | __u32 rdev; | ||
46 | }; | ||
47 | |||
48 | struct fuse_kstatfs { | ||
49 | __u64 blocks; | ||
50 | __u64 bfree; | ||
51 | __u64 bavail; | ||
52 | __u64 files; | ||
53 | __u64 ffree; | ||
54 | __u32 bsize; | ||
55 | __u32 namelen; | ||
56 | }; | ||
57 | |||
58 | #define FATTR_MODE (1 << 0) | ||
59 | #define FATTR_UID (1 << 1) | ||
60 | #define FATTR_GID (1 << 2) | ||
61 | #define FATTR_SIZE (1 << 3) | ||
62 | #define FATTR_ATIME (1 << 4) | ||
63 | #define FATTR_MTIME (1 << 5) | ||
64 | #define FATTR_CTIME (1 << 6) | ||
65 | |||
66 | /** | ||
67 | * Flags returned by the OPEN request | ||
68 | * | ||
69 | * FOPEN_DIRECT_IO: bypass page cache for this open file | ||
70 | * FOPEN_KEEP_CACHE: don't invalidate the data cache on open | ||
71 | */ | ||
72 | #define FOPEN_DIRECT_IO (1 << 0) | ||
73 | #define FOPEN_KEEP_CACHE (1 << 1) | ||
74 | |||
75 | enum fuse_opcode { | ||
76 | FUSE_LOOKUP = 1, | ||
77 | FUSE_FORGET = 2, /* no reply */ | ||
78 | FUSE_GETATTR = 3, | ||
79 | FUSE_SETATTR = 4, | ||
80 | FUSE_READLINK = 5, | ||
81 | FUSE_SYMLINK = 6, | ||
82 | FUSE_MKNOD = 8, | ||
83 | FUSE_MKDIR = 9, | ||
84 | FUSE_UNLINK = 10, | ||
85 | FUSE_RMDIR = 11, | ||
86 | FUSE_RENAME = 12, | ||
87 | FUSE_LINK = 13, | ||
88 | FUSE_OPEN = 14, | ||
89 | FUSE_READ = 15, | ||
90 | FUSE_WRITE = 16, | ||
91 | FUSE_STATFS = 17, | ||
92 | FUSE_RELEASE = 18, | ||
93 | FUSE_FSYNC = 20, | ||
94 | FUSE_SETXATTR = 21, | ||
95 | FUSE_GETXATTR = 22, | ||
96 | FUSE_LISTXATTR = 23, | ||
97 | FUSE_REMOVEXATTR = 24, | ||
98 | FUSE_FLUSH = 25, | ||
99 | FUSE_INIT = 26, | ||
100 | FUSE_OPENDIR = 27, | ||
101 | FUSE_READDIR = 28, | ||
102 | FUSE_RELEASEDIR = 29, | ||
103 | FUSE_FSYNCDIR = 30 | ||
104 | }; | ||
105 | |||
106 | /* Conservative buffer size for the client */ | ||
107 | #define FUSE_MAX_IN 8192 | ||
108 | |||
109 | #define FUSE_NAME_MAX 1024 | ||
110 | #define FUSE_SYMLINK_MAX 4096 | ||
111 | #define FUSE_XATTR_SIZE_MAX 4096 | ||
112 | |||
113 | struct fuse_entry_out { | ||
114 | __u64 nodeid; /* Inode ID */ | ||
115 | __u64 generation; /* Inode generation: nodeid:gen must | ||
116 | be unique for the fs's lifetime */ | ||
117 | __u64 entry_valid; /* Cache timeout for the name */ | ||
118 | __u64 attr_valid; /* Cache timeout for the attributes */ | ||
119 | __u32 entry_valid_nsec; | ||
120 | __u32 attr_valid_nsec; | ||
121 | struct fuse_attr attr; | ||
122 | }; | ||
123 | |||
124 | struct fuse_forget_in { | ||
125 | __u64 nlookup; | ||
126 | }; | ||
127 | |||
128 | struct fuse_attr_out { | ||
129 | __u64 attr_valid; /* Cache timeout for the attributes */ | ||
130 | __u32 attr_valid_nsec; | ||
131 | __u32 dummy; | ||
132 | struct fuse_attr attr; | ||
133 | }; | ||
134 | |||
135 | struct fuse_mknod_in { | ||
136 | __u32 mode; | ||
137 | __u32 rdev; | ||
138 | }; | ||
139 | |||
140 | struct fuse_mkdir_in { | ||
141 | __u32 mode; | ||
142 | __u32 padding; | ||
143 | }; | ||
144 | |||
145 | struct fuse_rename_in { | ||
146 | __u64 newdir; | ||
147 | }; | ||
148 | |||
149 | struct fuse_link_in { | ||
150 | __u64 oldnodeid; | ||
151 | }; | ||
152 | |||
153 | struct fuse_setattr_in { | ||
154 | __u32 valid; | ||
155 | __u32 padding; | ||
156 | struct fuse_attr attr; | ||
157 | }; | ||
158 | |||
159 | struct fuse_open_in { | ||
160 | __u32 flags; | ||
161 | __u32 padding; | ||
162 | }; | ||
163 | |||
164 | struct fuse_open_out { | ||
165 | __u64 fh; | ||
166 | __u32 open_flags; | ||
167 | __u32 padding; | ||
168 | }; | ||
169 | |||
170 | struct fuse_release_in { | ||
171 | __u64 fh; | ||
172 | __u32 flags; | ||
173 | __u32 padding; | ||
174 | }; | ||
175 | |||
176 | struct fuse_flush_in { | ||
177 | __u64 fh; | ||
178 | __u32 flush_flags; | ||
179 | __u32 padding; | ||
180 | }; | ||
181 | |||
182 | struct fuse_read_in { | ||
183 | __u64 fh; | ||
184 | __u64 offset; | ||
185 | __u32 size; | ||
186 | __u32 padding; | ||
187 | }; | ||
188 | |||
189 | struct fuse_write_in { | ||
190 | __u64 fh; | ||
191 | __u64 offset; | ||
192 | __u32 size; | ||
193 | __u32 write_flags; | ||
194 | }; | ||
195 | |||
196 | struct fuse_write_out { | ||
197 | __u32 size; | ||
198 | __u32 padding; | ||
199 | }; | ||
200 | |||
201 | struct fuse_statfs_out { | ||
202 | struct fuse_kstatfs st; | ||
203 | }; | ||
204 | |||
205 | struct fuse_fsync_in { | ||
206 | __u64 fh; | ||
207 | __u32 fsync_flags; | ||
208 | __u32 padding; | ||
209 | }; | ||
210 | |||
211 | struct fuse_setxattr_in { | ||
212 | __u32 size; | ||
213 | __u32 flags; | ||
214 | }; | ||
215 | |||
216 | struct fuse_getxattr_in { | ||
217 | __u32 size; | ||
218 | __u32 padding; | ||
219 | }; | ||
220 | |||
221 | struct fuse_getxattr_out { | ||
222 | __u32 size; | ||
223 | __u32 padding; | ||
224 | }; | ||
225 | |||
226 | struct fuse_init_in_out { | ||
227 | __u32 major; | ||
228 | __u32 minor; | ||
229 | }; | ||
230 | |||
231 | struct fuse_in_header { | ||
232 | __u32 len; | ||
233 | __u32 opcode; | ||
234 | __u64 unique; | ||
235 | __u64 nodeid; | ||
236 | __u32 uid; | ||
237 | __u32 gid; | ||
238 | __u32 pid; | ||
239 | __u32 padding; | ||
240 | }; | ||
241 | |||
242 | struct fuse_out_header { | ||
243 | __u32 len; | ||
244 | __s32 error; | ||
245 | __u64 unique; | ||
246 | }; | ||
247 | |||
248 | struct fuse_dirent { | ||
249 | __u64 ino; | ||
250 | __u64 off; | ||
251 | __u32 namelen; | ||
252 | __u32 type; | ||
253 | char name[0]; | ||
254 | }; | ||
255 | |||
256 | #define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name) | ||
257 | #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1)) | ||
258 | #define FUSE_DIRENT_SIZE(d) \ | ||
259 | FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) | ||
diff --git a/include/linux/in6.h b/include/linux/in6.h index bd32b79d6295..304aaedea305 100644 --- a/include/linux/in6.h +++ b/include/linux/in6.h | |||
@@ -198,27 +198,43 @@ struct in6_flowlabel_req | |||
198 | * MCAST_MSFILTER 48 | 198 | * MCAST_MSFILTER 48 |
199 | */ | 199 | */ |
200 | 200 | ||
201 | /* RFC3542 advanced socket options (50-67) */ | 201 | /* |
202 | #define IPV6_RECVPKTINFO 50 | 202 | * Advanced API (RFC3542) (1) |
203 | #define IPV6_PKTINFO 51 | 203 | * |
204 | #if 0 | 204 | * Note: IPV6_RECVRTHDRDSTOPTS does not exist. see net/ipv6/datagram.c. |
205 | #define IPV6_RECVPATHMTU 52 | 205 | */ |
206 | #define IPV6_PATHMTU 53 | 206 | |
207 | #define IPV6_DONTFRAG 54 | 207 | #define IPV6_RECVPKTINFO 49 |
208 | #define IPV6_USE_MIN_MTU 55 | 208 | #define IPV6_PKTINFO 50 |
209 | #endif | 209 | #define IPV6_RECVHOPLIMIT 51 |
210 | #define IPV6_RECVHOPOPTS 56 | 210 | #define IPV6_HOPLIMIT 52 |
211 | #define IPV6_HOPOPTS 57 | 211 | #define IPV6_RECVHOPOPTS 53 |
212 | #if 0 | 212 | #define IPV6_HOPOPTS 54 |
213 | #define IPV6_RECVRTHDRDSTOPTS 58 /* Unused, see net/ipv6/datagram.c */ | 213 | #define IPV6_RTHDRDSTOPTS 55 |
214 | #define IPV6_RECVRTHDR 56 | ||
215 | #define IPV6_RTHDR 57 | ||
216 | #define IPV6_RECVDSTOPTS 58 | ||
217 | #define IPV6_DSTOPTS 59 | ||
218 | #if 0 /* not yet */ | ||
219 | #define IPV6_RECVPATHMTU 60 | ||
220 | #define IPV6_PATHMTU 61 | ||
221 | #define IPV6_DONTFRAG 62 | ||
222 | #define IPV6_USE_MIN_MTU 63 | ||
214 | #endif | 223 | #endif |
215 | #define IPV6_RTHDRDSTOPTS 59 | 224 | |
216 | #define IPV6_RECVRTHDR 60 | 225 | /* |
217 | #define IPV6_RTHDR 61 | 226 | * Netfilter |
218 | #define IPV6_RECVDSTOPTS 62 | 227 | * |
219 | #define IPV6_DSTOPTS 63 | 228 | * Following socket options are used in ip6_tables; |
220 | #define IPV6_RECVHOPLIMIT 64 | 229 | * see include/linux/netfilter_ipv6/ip6_tables.h. |
221 | #define IPV6_HOPLIMIT 65 | 230 | * |
231 | * IP6T_SO_SET_REPLACE / IP6T_SO_GET_INFO 64 | ||
232 | * IP6T_SO_SET_ADD_COUNTERS / IP6T_SO_GET_ENTRIES 65 | ||
233 | */ | ||
234 | |||
235 | /* | ||
236 | * Advanced API (RFC3542) (2) | ||
237 | */ | ||
222 | #define IPV6_RECVTCLASS 66 | 238 | #define IPV6_RECVTCLASS 66 |
223 | #define IPV6_TCLASS 67 | 239 | #define IPV6_TCLASS 67 |
224 | 240 | ||
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index c727c195a91a..68ab5f2ab9cd 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
@@ -2,17 +2,27 @@ | |||
2 | #define _LINUX__INIT_TASK_H | 2 | #define _LINUX__INIT_TASK_H |
3 | 3 | ||
4 | #include <linux/file.h> | 4 | #include <linux/file.h> |
5 | #include <linux/rcupdate.h> | ||
5 | 6 | ||
6 | #define INIT_FILES \ | 7 | #define INIT_FDTABLE \ |
7 | { \ | 8 | { \ |
8 | .count = ATOMIC_INIT(1), \ | ||
9 | .file_lock = SPIN_LOCK_UNLOCKED, \ | ||
10 | .max_fds = NR_OPEN_DEFAULT, \ | 9 | .max_fds = NR_OPEN_DEFAULT, \ |
11 | .max_fdset = __FD_SETSIZE, \ | 10 | .max_fdset = __FD_SETSIZE, \ |
12 | .next_fd = 0, \ | 11 | .next_fd = 0, \ |
13 | .fd = &init_files.fd_array[0], \ | 12 | .fd = &init_files.fd_array[0], \ |
14 | .close_on_exec = &init_files.close_on_exec_init, \ | 13 | .close_on_exec = &init_files.close_on_exec_init, \ |
15 | .open_fds = &init_files.open_fds_init, \ | 14 | .open_fds = &init_files.open_fds_init, \ |
15 | .rcu = RCU_HEAD_INIT, \ | ||
16 | .free_files = NULL, \ | ||
17 | .next = NULL, \ | ||
18 | } | ||
19 | |||
20 | #define INIT_FILES \ | ||
21 | { \ | ||
22 | .count = ATOMIC_INIT(1), \ | ||
23 | .file_lock = SPIN_LOCK_UNLOCKED, \ | ||
24 | .fdt = &init_files.fdtab, \ | ||
25 | .fdtab = INIT_FDTABLE, \ | ||
16 | .close_on_exec_init = { { 0, } }, \ | 26 | .close_on_exec_init = { { 0, } }, \ |
17 | .open_fds_init = { { 0, } }, \ | 27 | .open_fds_init = { { 0, } }, \ |
18 | .fd_array = { NULL, } \ | 28 | .fd_array = { NULL, } \ |
diff --git a/include/linux/input.h b/include/linux/input.h index 4767e5429534..e8c296ff6257 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
@@ -289,6 +289,8 @@ struct input_absinfo { | |||
289 | #define KEY_SCROLLDOWN 178 | 289 | #define KEY_SCROLLDOWN 178 |
290 | #define KEY_KPLEFTPAREN 179 | 290 | #define KEY_KPLEFTPAREN 179 |
291 | #define KEY_KPRIGHTPAREN 180 | 291 | #define KEY_KPRIGHTPAREN 180 |
292 | #define KEY_NEW 181 | ||
293 | #define KEY_REDO 182 | ||
292 | 294 | ||
293 | #define KEY_F13 183 | 295 | #define KEY_F13 183 |
294 | #define KEY_F14 184 | 296 | #define KEY_F14 184 |
@@ -335,6 +337,12 @@ struct input_absinfo { | |||
335 | #define KEY_KBDILLUMDOWN 229 | 337 | #define KEY_KBDILLUMDOWN 229 |
336 | #define KEY_KBDILLUMUP 230 | 338 | #define KEY_KBDILLUMUP 230 |
337 | 339 | ||
340 | #define KEY_SEND 231 | ||
341 | #define KEY_REPLY 232 | ||
342 | #define KEY_FORWARDMAIL 233 | ||
343 | #define KEY_SAVE 234 | ||
344 | #define KEY_DOCUMENTS 235 | ||
345 | |||
338 | #define KEY_UNKNOWN 240 | 346 | #define KEY_UNKNOWN 240 |
339 | 347 | ||
340 | #define BTN_MISC 0x100 | 348 | #define BTN_MISC 0x100 |
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index d99e7aeb7d33..0a90205184b0 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h | |||
@@ -57,6 +57,11 @@ extern void disable_irq(unsigned int irq); | |||
57 | extern void enable_irq(unsigned int irq); | 57 | extern void enable_irq(unsigned int irq); |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #ifndef __ARCH_SET_SOFTIRQ_PENDING | ||
61 | #define set_softirq_pending(x) (local_softirq_pending() = (x)) | ||
62 | #define or_softirq_pending(x) (local_softirq_pending() |= (x)) | ||
63 | #endif | ||
64 | |||
60 | /* | 65 | /* |
61 | * Temporary defines for UP kernels, until all code gets fixed. | 66 | * Temporary defines for UP kernels, until all code gets fixed. |
62 | */ | 67 | */ |
@@ -123,7 +128,7 @@ struct softirq_action | |||
123 | asmlinkage void do_softirq(void); | 128 | asmlinkage void do_softirq(void); |
124 | extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data); | 129 | extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data); |
125 | extern void softirq_init(void); | 130 | extern void softirq_init(void); |
126 | #define __raise_softirq_irqoff(nr) do { local_softirq_pending() |= 1UL << (nr); } while (0) | 131 | #define __raise_softirq_irqoff(nr) do { or_softirq_pending(1UL << (nr)); } while (0) |
127 | extern void FASTCALL(raise_softirq_irqoff(unsigned int nr)); | 132 | extern void FASTCALL(raise_softirq_irqoff(unsigned int nr)); |
128 | extern void FASTCALL(raise_softirq(unsigned int nr)); | 133 | extern void FASTCALL(raise_softirq(unsigned int nr)); |
129 | 134 | ||
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 6c5f7b39a4b0..bb6f88e14061 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h | |||
@@ -68,7 +68,7 @@ struct ipv6_opt_hdr { | |||
68 | 68 | ||
69 | struct rt0_hdr { | 69 | struct rt0_hdr { |
70 | struct ipv6_rt_hdr rt_hdr; | 70 | struct ipv6_rt_hdr rt_hdr; |
71 | __u32 bitmap; /* strict/loose bit map */ | 71 | __u32 reserved; |
72 | struct in6_addr addr[0]; | 72 | struct in6_addr addr[0]; |
73 | 73 | ||
74 | #define rt0_type rt_hdr.type | 74 | #define rt0_type rt_hdr.type |
diff --git a/include/linux/jbd.h b/include/linux/jbd.h index 84321a4cac93..de097269bd7f 100644 --- a/include/linux/jbd.h +++ b/include/linux/jbd.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/buffer_head.h> | 28 | #include <linux/buffer_head.h> |
29 | #include <linux/journal-head.h> | 29 | #include <linux/journal-head.h> |
30 | #include <linux/stddef.h> | 30 | #include <linux/stddef.h> |
31 | #include <linux/bit_spinlock.h> | ||
31 | #include <asm/semaphore.h> | 32 | #include <asm/semaphore.h> |
32 | #endif | 33 | #endif |
33 | 34 | ||
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index d7a2555a886c..6acfdbba734b 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h | |||
@@ -254,23 +254,23 @@ static inline u64 get_jiffies_64(void) | |||
254 | */ | 254 | */ |
255 | static inline unsigned int jiffies_to_msecs(const unsigned long j) | 255 | static inline unsigned int jiffies_to_msecs(const unsigned long j) |
256 | { | 256 | { |
257 | #if HZ <= 1000 && !(1000 % HZ) | 257 | #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) |
258 | return (1000 / HZ) * j; | 258 | return (MSEC_PER_SEC / HZ) * j; |
259 | #elif HZ > 1000 && !(HZ % 1000) | 259 | #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) |
260 | return (j + (HZ / 1000) - 1)/(HZ / 1000); | 260 | return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); |
261 | #else | 261 | #else |
262 | return (j * 1000) / HZ; | 262 | return (j * MSEC_PER_SEC) / HZ; |
263 | #endif | 263 | #endif |
264 | } | 264 | } |
265 | 265 | ||
266 | static inline unsigned int jiffies_to_usecs(const unsigned long j) | 266 | static inline unsigned int jiffies_to_usecs(const unsigned long j) |
267 | { | 267 | { |
268 | #if HZ <= 1000000 && !(1000000 % HZ) | 268 | #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) |
269 | return (1000000 / HZ) * j; | 269 | return (USEC_PER_SEC / HZ) * j; |
270 | #elif HZ > 1000000 && !(HZ % 1000000) | 270 | #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) |
271 | return (j + (HZ / 1000000) - 1)/(HZ / 1000000); | 271 | return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); |
272 | #else | 272 | #else |
273 | return (j * 1000000) / HZ; | 273 | return (j * USEC_PER_SEC) / HZ; |
274 | #endif | 274 | #endif |
275 | } | 275 | } |
276 | 276 | ||
@@ -278,12 +278,12 @@ static inline unsigned long msecs_to_jiffies(const unsigned int m) | |||
278 | { | 278 | { |
279 | if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) | 279 | if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) |
280 | return MAX_JIFFY_OFFSET; | 280 | return MAX_JIFFY_OFFSET; |
281 | #if HZ <= 1000 && !(1000 % HZ) | 281 | #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) |
282 | return (m + (1000 / HZ) - 1) / (1000 / HZ); | 282 | return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ); |
283 | #elif HZ > 1000 && !(HZ % 1000) | 283 | #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) |
284 | return m * (HZ / 1000); | 284 | return m * (HZ / MSEC_PER_SEC); |
285 | #else | 285 | #else |
286 | return (m * HZ + 999) / 1000; | 286 | return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC; |
287 | #endif | 287 | #endif |
288 | } | 288 | } |
289 | 289 | ||
@@ -291,12 +291,12 @@ static inline unsigned long usecs_to_jiffies(const unsigned int u) | |||
291 | { | 291 | { |
292 | if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) | 292 | if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) |
293 | return MAX_JIFFY_OFFSET; | 293 | return MAX_JIFFY_OFFSET; |
294 | #if HZ <= 1000000 && !(1000000 % HZ) | 294 | #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) |
295 | return (u + (1000000 / HZ) - 1) / (1000000 / HZ); | 295 | return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ); |
296 | #elif HZ > 1000000 && !(HZ % 1000000) | 296 | #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) |
297 | return u * (HZ / 1000000); | 297 | return u * (HZ / USEC_PER_SEC); |
298 | #else | 298 | #else |
299 | return (u * HZ + 999999) / 1000000; | 299 | return (u * HZ + USEC_PER_SEC - 1) / USEC_PER_SEC; |
300 | #endif | 300 | #endif |
301 | } | 301 | } |
302 | 302 | ||
diff --git a/include/linux/pci.h b/include/linux/pci.h index 6caaba0af469..7349058ed778 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -315,8 +315,11 @@ static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *s | |||
315 | pci_bus_add_devices(root_bus); | 315 | pci_bus_add_devices(root_bus); |
316 | return root_bus; | 316 | return root_bus; |
317 | } | 317 | } |
318 | struct pci_bus *pci_create_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); | ||
319 | struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); | ||
318 | int pci_scan_slot(struct pci_bus *bus, int devfn); | 320 | int pci_scan_slot(struct pci_bus *bus, int devfn); |
319 | struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); | 321 | struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); |
322 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); | ||
320 | unsigned int pci_scan_child_bus(struct pci_bus *bus); | 323 | unsigned int pci_scan_child_bus(struct pci_bus *bus); |
321 | void pci_bus_add_device(struct pci_dev *dev); | 324 | void pci_bus_add_device(struct pci_dev *dev); |
322 | void pci_read_bridge_bases(struct pci_bus *child); | 325 | void pci_read_bridge_bases(struct pci_bus *child); |
@@ -326,6 +329,7 @@ extern struct pci_dev *pci_dev_get(struct pci_dev *dev); | |||
326 | extern void pci_dev_put(struct pci_dev *dev); | 329 | extern void pci_dev_put(struct pci_dev *dev); |
327 | extern void pci_remove_bus(struct pci_bus *b); | 330 | extern void pci_remove_bus(struct pci_bus *b); |
328 | extern void pci_remove_bus_device(struct pci_dev *dev); | 331 | extern void pci_remove_bus_device(struct pci_dev *dev); |
332 | void pci_setup_cardbus(struct pci_bus *bus); | ||
329 | 333 | ||
330 | /* Generic PCI functions exported to card drivers */ | 334 | /* Generic PCI functions exported to card drivers */ |
331 | 335 | ||
@@ -391,8 +395,8 @@ int pci_assign_resource(struct pci_dev *dev, int i); | |||
391 | void pci_restore_bars(struct pci_dev *dev); | 395 | void pci_restore_bars(struct pci_dev *dev); |
392 | 396 | ||
393 | /* ROM control related routines */ | 397 | /* ROM control related routines */ |
394 | void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size); | 398 | void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); |
395 | void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size); | 399 | void __iomem __must_check *pci_map_rom_copy(struct pci_dev *pdev, size_t *size); |
396 | void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); | 400 | void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); |
397 | void pci_remove_rom(struct pci_dev *pdev); | 401 | void pci_remove_rom(struct pci_dev *pdev); |
398 | 402 | ||
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h index 8081a281fa5e..9c51917b1cce 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | struct radix_tree_root { | 25 | struct radix_tree_root { |
26 | unsigned int height; | 26 | unsigned int height; |
27 | int gfp_mask; | 27 | unsigned int gfp_mask; |
28 | struct radix_tree_node *rnode; | 28 | struct radix_tree_node *rnode; |
29 | }; | 29 | }; |
30 | 30 | ||
@@ -50,7 +50,7 @@ void *radix_tree_delete(struct radix_tree_root *, unsigned long); | |||
50 | unsigned int | 50 | unsigned int |
51 | radix_tree_gang_lookup(struct radix_tree_root *root, void **results, | 51 | radix_tree_gang_lookup(struct radix_tree_root *root, void **results, |
52 | unsigned long first_index, unsigned int max_items); | 52 | unsigned long first_index, unsigned int max_items); |
53 | int radix_tree_preload(int gfp_mask); | 53 | int radix_tree_preload(unsigned int __nocast gfp_mask); |
54 | void radix_tree_init(void); | 54 | void radix_tree_init(void); |
55 | void *radix_tree_tag_set(struct radix_tree_root *root, | 55 | void *radix_tree_tag_set(struct radix_tree_root *root, |
56 | unsigned long index, int tag); | 56 | unsigned long index, int tag); |
diff --git a/include/linux/raid/bitmap.h b/include/linux/raid/bitmap.h index 4bf1659f8aa8..9de99198caf1 100644 --- a/include/linux/raid/bitmap.h +++ b/include/linux/raid/bitmap.h | |||
@@ -7,7 +7,7 @@ | |||
7 | #define BITMAP_H 1 | 7 | #define BITMAP_H 1 |
8 | 8 | ||
9 | #define BITMAP_MAJOR 3 | 9 | #define BITMAP_MAJOR 3 |
10 | #define BITMAP_MINOR 38 | 10 | #define BITMAP_MINOR 39 |
11 | 11 | ||
12 | /* | 12 | /* |
13 | * in-memory bitmap: | 13 | * in-memory bitmap: |
@@ -147,8 +147,9 @@ typedef struct bitmap_super_s { | |||
147 | __u32 state; /* 48 bitmap state information */ | 147 | __u32 state; /* 48 bitmap state information */ |
148 | __u32 chunksize; /* 52 the bitmap chunk size in bytes */ | 148 | __u32 chunksize; /* 52 the bitmap chunk size in bytes */ |
149 | __u32 daemon_sleep; /* 56 seconds between disk flushes */ | 149 | __u32 daemon_sleep; /* 56 seconds between disk flushes */ |
150 | __u32 write_behind; /* 60 number of outstanding write-behind writes */ | ||
150 | 151 | ||
151 | __u8 pad[256 - 60]; /* set to zero */ | 152 | __u8 pad[256 - 64]; /* set to zero */ |
152 | } bitmap_super_t; | 153 | } bitmap_super_t; |
153 | 154 | ||
154 | /* notes: | 155 | /* notes: |
@@ -226,6 +227,9 @@ struct bitmap { | |||
226 | 227 | ||
227 | unsigned long flags; | 228 | unsigned long flags; |
228 | 229 | ||
230 | unsigned long max_write_behind; /* write-behind mode */ | ||
231 | atomic_t behind_writes; | ||
232 | |||
229 | /* | 233 | /* |
230 | * the bitmap daemon - periodically wakes up and sweeps the bitmap | 234 | * the bitmap daemon - periodically wakes up and sweeps the bitmap |
231 | * file, cleaning up bits and flushing out pages to disk as necessary | 235 | * file, cleaning up bits and flushing out pages to disk as necessary |
@@ -260,9 +264,10 @@ int bitmap_setallbits(struct bitmap *bitmap); | |||
260 | void bitmap_write_all(struct bitmap *bitmap); | 264 | void bitmap_write_all(struct bitmap *bitmap); |
261 | 265 | ||
262 | /* these are exported */ | 266 | /* these are exported */ |
263 | int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors); | 267 | int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, |
264 | void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, | 268 | unsigned long sectors, int behind); |
265 | int success); | 269 | void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, |
270 | unsigned long sectors, int success, int behind); | ||
266 | int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int degraded); | 271 | int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int degraded); |
267 | void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted); | 272 | void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted); |
268 | void bitmap_close_sync(struct bitmap *bitmap); | 273 | void bitmap_close_sync(struct bitmap *bitmap); |
diff --git a/include/linux/raid/linear.h b/include/linux/raid/linear.h index e04c4fe45b53..7eaf290e10e7 100644 --- a/include/linux/raid/linear.h +++ b/include/linux/raid/linear.h | |||
@@ -14,8 +14,8 @@ typedef struct dev_info dev_info_t; | |||
14 | struct linear_private_data | 14 | struct linear_private_data |
15 | { | 15 | { |
16 | dev_info_t **hash_table; | 16 | dev_info_t **hash_table; |
17 | dev_info_t *smallest; | 17 | sector_t hash_spacing; |
18 | int nr_zones; | 18 | int preshift; /* shift before dividing by hash_spacing */ |
19 | dev_info_t disks[0]; | 19 | dev_info_t disks[0]; |
20 | }; | 20 | }; |
21 | 21 | ||
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index 8c14ba565a45..ebce949b1443 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h | |||
@@ -86,70 +86,6 @@ typedef struct mdk_rdev_s mdk_rdev_t; | |||
86 | #define MAX_CHUNK_SIZE (4096*1024) | 86 | #define MAX_CHUNK_SIZE (4096*1024) |
87 | 87 | ||
88 | /* | 88 | /* |
89 | * default readahead | ||
90 | */ | ||
91 | |||
92 | static inline int disk_faulty(mdp_disk_t * d) | ||
93 | { | ||
94 | return d->state & (1 << MD_DISK_FAULTY); | ||
95 | } | ||
96 | |||
97 | static inline int disk_active(mdp_disk_t * d) | ||
98 | { | ||
99 | return d->state & (1 << MD_DISK_ACTIVE); | ||
100 | } | ||
101 | |||
102 | static inline int disk_sync(mdp_disk_t * d) | ||
103 | { | ||
104 | return d->state & (1 << MD_DISK_SYNC); | ||
105 | } | ||
106 | |||
107 | static inline int disk_spare(mdp_disk_t * d) | ||
108 | { | ||
109 | return !disk_sync(d) && !disk_active(d) && !disk_faulty(d); | ||
110 | } | ||
111 | |||
112 | static inline int disk_removed(mdp_disk_t * d) | ||
113 | { | ||
114 | return d->state & (1 << MD_DISK_REMOVED); | ||
115 | } | ||
116 | |||
117 | static inline void mark_disk_faulty(mdp_disk_t * d) | ||
118 | { | ||
119 | d->state |= (1 << MD_DISK_FAULTY); | ||
120 | } | ||
121 | |||
122 | static inline void mark_disk_active(mdp_disk_t * d) | ||
123 | { | ||
124 | d->state |= (1 << MD_DISK_ACTIVE); | ||
125 | } | ||
126 | |||
127 | static inline void mark_disk_sync(mdp_disk_t * d) | ||
128 | { | ||
129 | d->state |= (1 << MD_DISK_SYNC); | ||
130 | } | ||
131 | |||
132 | static inline void mark_disk_spare(mdp_disk_t * d) | ||
133 | { | ||
134 | d->state = 0; | ||
135 | } | ||
136 | |||
137 | static inline void mark_disk_removed(mdp_disk_t * d) | ||
138 | { | ||
139 | d->state = (1 << MD_DISK_FAULTY) | (1 << MD_DISK_REMOVED); | ||
140 | } | ||
141 | |||
142 | static inline void mark_disk_inactive(mdp_disk_t * d) | ||
143 | { | ||
144 | d->state &= ~(1 << MD_DISK_ACTIVE); | ||
145 | } | ||
146 | |||
147 | static inline void mark_disk_nonsync(mdp_disk_t * d) | ||
148 | { | ||
149 | d->state &= ~(1 << MD_DISK_SYNC); | ||
150 | } | ||
151 | |||
152 | /* | ||
153 | * MD's 'extended' device | 89 | * MD's 'extended' device |
154 | */ | 90 | */ |
155 | struct mdk_rdev_s | 91 | struct mdk_rdev_s |
@@ -166,6 +102,7 @@ struct mdk_rdev_s | |||
166 | int sb_loaded; | 102 | int sb_loaded; |
167 | sector_t data_offset; /* start of data in array */ | 103 | sector_t data_offset; /* start of data in array */ |
168 | sector_t sb_offset; | 104 | sector_t sb_offset; |
105 | int sb_size; /* bytes in the superblock */ | ||
169 | int preferred_minor; /* autorun support */ | 106 | int preferred_minor; /* autorun support */ |
170 | 107 | ||
171 | /* A device can be in one of three states based on two flags: | 108 | /* A device can be in one of three states based on two flags: |
@@ -181,6 +118,9 @@ struct mdk_rdev_s | |||
181 | int faulty; /* if faulty do not issue IO requests */ | 118 | int faulty; /* if faulty do not issue IO requests */ |
182 | int in_sync; /* device is a full member of the array */ | 119 | int in_sync; /* device is a full member of the array */ |
183 | 120 | ||
121 | unsigned long flags; /* Should include faulty and in_sync here. */ | ||
122 | #define WriteMostly 4 /* Avoid reading if at all possible */ | ||
123 | |||
184 | int desc_nr; /* descriptor index in the superblock */ | 124 | int desc_nr; /* descriptor index in the superblock */ |
185 | int raid_disk; /* role of device in array */ | 125 | int raid_disk; /* role of device in array */ |
186 | int saved_raid_disk; /* role that device used to have in the | 126 | int saved_raid_disk; /* role that device used to have in the |
@@ -272,12 +212,19 @@ struct mddev_s | |||
272 | atomic_t writes_pending; | 212 | atomic_t writes_pending; |
273 | request_queue_t *queue; /* for plugging ... */ | 213 | request_queue_t *queue; /* for plugging ... */ |
274 | 214 | ||
215 | atomic_t write_behind; /* outstanding async IO */ | ||
216 | unsigned int max_write_behind; /* 0 = sync */ | ||
217 | |||
275 | struct bitmap *bitmap; /* the bitmap for the device */ | 218 | struct bitmap *bitmap; /* the bitmap for the device */ |
276 | struct file *bitmap_file; /* the bitmap file */ | 219 | struct file *bitmap_file; /* the bitmap file */ |
277 | long bitmap_offset; /* offset from superblock of | 220 | long bitmap_offset; /* offset from superblock of |
278 | * start of bitmap. May be | 221 | * start of bitmap. May be |
279 | * negative, but not '0' | 222 | * negative, but not '0' |
280 | */ | 223 | */ |
224 | long default_bitmap_offset; /* this is the offset to use when | ||
225 | * hot-adding a bitmap. It should | ||
226 | * eventually be settable by sysfs. | ||
227 | */ | ||
281 | 228 | ||
282 | struct list_head all_mddevs; | 229 | struct list_head all_mddevs; |
283 | }; | 230 | }; |
@@ -314,6 +261,12 @@ struct mdk_personality_s | |||
314 | int (*resize) (mddev_t *mddev, sector_t sectors); | 261 | int (*resize) (mddev_t *mddev, sector_t sectors); |
315 | int (*reshape) (mddev_t *mddev, int raid_disks); | 262 | int (*reshape) (mddev_t *mddev, int raid_disks); |
316 | int (*reconfig) (mddev_t *mddev, int layout, int chunk_size); | 263 | int (*reconfig) (mddev_t *mddev, int layout, int chunk_size); |
264 | /* quiesce moves between quiescence states | ||
265 | * 0 - fully active | ||
266 | * 1 - no new requests allowed | ||
267 | * others - reserved | ||
268 | */ | ||
269 | void (*quiesce) (mddev_t *mddev, int state); | ||
317 | }; | 270 | }; |
318 | 271 | ||
319 | 272 | ||
diff --git a/include/linux/raid/md_p.h b/include/linux/raid/md_p.h index dc65cd435494..c100fa5d4bfa 100644 --- a/include/linux/raid/md_p.h +++ b/include/linux/raid/md_p.h | |||
@@ -79,6 +79,11 @@ | |||
79 | #define MD_DISK_SYNC 2 /* disk is in sync with the raid set */ | 79 | #define MD_DISK_SYNC 2 /* disk is in sync with the raid set */ |
80 | #define MD_DISK_REMOVED 3 /* disk is in sync with the raid set */ | 80 | #define MD_DISK_REMOVED 3 /* disk is in sync with the raid set */ |
81 | 81 | ||
82 | #define MD_DISK_WRITEMOSTLY 9 /* disk is "write-mostly" is RAID1 config. | ||
83 | * read requests will only be sent here in | ||
84 | * dire need | ||
85 | */ | ||
86 | |||
82 | typedef struct mdp_device_descriptor_s { | 87 | typedef struct mdp_device_descriptor_s { |
83 | __u32 number; /* 0 Device number in the entire set */ | 88 | __u32 number; /* 0 Device number in the entire set */ |
84 | __u32 major; /* 1 Device major number */ | 89 | __u32 major; /* 1 Device major number */ |
@@ -193,7 +198,7 @@ struct mdp_superblock_1 { | |||
193 | 198 | ||
194 | __u64 ctime; /* lo 40 bits are seconds, top 24 are microseconds or 0*/ | 199 | __u64 ctime; /* lo 40 bits are seconds, top 24 are microseconds or 0*/ |
195 | __u32 level; /* -4 (multipath), -1 (linear), 0,1,4,5 */ | 200 | __u32 level; /* -4 (multipath), -1 (linear), 0,1,4,5 */ |
196 | __u32 layout; /* only for raid5 currently */ | 201 | __u32 layout; /* only for raid5 and raid10 currently */ |
197 | __u64 size; /* used size of component devices, in 512byte sectors */ | 202 | __u64 size; /* used size of component devices, in 512byte sectors */ |
198 | 203 | ||
199 | __u32 chunksize; /* in 512byte sectors */ | 204 | __u32 chunksize; /* in 512byte sectors */ |
@@ -212,7 +217,9 @@ struct mdp_superblock_1 { | |||
212 | __u32 dev_number; /* permanent identifier of this device - not role in raid */ | 217 | __u32 dev_number; /* permanent identifier of this device - not role in raid */ |
213 | __u32 cnt_corrected_read; /* number of read errors that were corrected by re-writing */ | 218 | __u32 cnt_corrected_read; /* number of read errors that were corrected by re-writing */ |
214 | __u8 device_uuid[16]; /* user-space setable, ignored by kernel */ | 219 | __u8 device_uuid[16]; /* user-space setable, ignored by kernel */ |
215 | __u8 pad2[64-56]; /* set to 0 when writing */ | 220 | __u8 devflags; /* per-device flags. Only one defined...*/ |
221 | #define WriteMostly1 1 /* mask for writemostly flag in above */ | ||
222 | __u8 pad2[64-57]; /* set to 0 when writing */ | ||
216 | 223 | ||
217 | /* array state information - 64 bytes */ | 224 | /* array state information - 64 bytes */ |
218 | __u64 utime; /* 40 bits second, 24 btes microseconds */ | 225 | __u64 utime; /* 40 bits second, 24 btes microseconds */ |
@@ -231,5 +238,10 @@ struct mdp_superblock_1 { | |||
231 | __u16 dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */ | 238 | __u16 dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */ |
232 | }; | 239 | }; |
233 | 240 | ||
241 | /* feature_map bits */ | ||
242 | #define MD_FEATURE_BITMAP_OFFSET 1 | ||
243 | |||
244 | #define MD_FEATURE_ALL 1 | ||
245 | |||
234 | #endif | 246 | #endif |
235 | 247 | ||
diff --git a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h index 9d93cf12e890..60e19b667548 100644 --- a/include/linux/raid/raid1.h +++ b/include/linux/raid/raid1.h | |||
@@ -80,6 +80,9 @@ struct r1bio_s { | |||
80 | atomic_t remaining; /* 'have we finished' count, | 80 | atomic_t remaining; /* 'have we finished' count, |
81 | * used from IRQ handlers | 81 | * used from IRQ handlers |
82 | */ | 82 | */ |
83 | atomic_t behind_remaining; /* number of write-behind ios remaining | ||
84 | * in this BehindIO request | ||
85 | */ | ||
83 | sector_t sector; | 86 | sector_t sector; |
84 | int sectors; | 87 | int sectors; |
85 | unsigned long state; | 88 | unsigned long state; |
@@ -107,4 +110,14 @@ struct r1bio_s { | |||
107 | #define R1BIO_Uptodate 0 | 110 | #define R1BIO_Uptodate 0 |
108 | #define R1BIO_IsSync 1 | 111 | #define R1BIO_IsSync 1 |
109 | #define R1BIO_Degraded 2 | 112 | #define R1BIO_Degraded 2 |
113 | #define R1BIO_BehindIO 3 | ||
114 | /* For write-behind requests, we call bi_end_io when | ||
115 | * the last non-write-behind device completes, providing | ||
116 | * any write was successful. Otherwise we call when | ||
117 | * any write-behind write succeeds, otherwise we call | ||
118 | * with failure when last write completes (and all failed). | ||
119 | * Record that bi_end_io was called with this flag... | ||
120 | */ | ||
121 | #define R1BIO_Returned 4 | ||
122 | |||
110 | #endif | 123 | #endif |
diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h index d63ddcb4afad..176fc653c284 100644 --- a/include/linux/raid/raid5.h +++ b/include/linux/raid/raid5.h | |||
@@ -134,6 +134,7 @@ struct stripe_head { | |||
134 | unsigned long state; /* state flags */ | 134 | unsigned long state; /* state flags */ |
135 | atomic_t count; /* nr of active thread/requests */ | 135 | atomic_t count; /* nr of active thread/requests */ |
136 | spinlock_t lock; | 136 | spinlock_t lock; |
137 | int bm_seq; /* sequence number for bitmap flushes */ | ||
137 | struct r5dev { | 138 | struct r5dev { |
138 | struct bio req; | 139 | struct bio req; |
139 | struct bio_vec vec; | 140 | struct bio_vec vec; |
@@ -165,12 +166,13 @@ struct stripe_head { | |||
165 | /* | 166 | /* |
166 | * Stripe state | 167 | * Stripe state |
167 | */ | 168 | */ |
168 | #define STRIPE_ERROR 1 | ||
169 | #define STRIPE_HANDLE 2 | 169 | #define STRIPE_HANDLE 2 |
170 | #define STRIPE_SYNCING 3 | 170 | #define STRIPE_SYNCING 3 |
171 | #define STRIPE_INSYNC 4 | 171 | #define STRIPE_INSYNC 4 |
172 | #define STRIPE_PREREAD_ACTIVE 5 | 172 | #define STRIPE_PREREAD_ACTIVE 5 |
173 | #define STRIPE_DELAYED 6 | 173 | #define STRIPE_DELAYED 6 |
174 | #define STRIPE_DEGRADED 7 | ||
175 | #define STRIPE_BIT_DELAY 8 | ||
174 | 176 | ||
175 | /* | 177 | /* |
176 | * Plugging: | 178 | * Plugging: |
@@ -210,10 +212,20 @@ struct raid5_private_data { | |||
210 | 212 | ||
211 | struct list_head handle_list; /* stripes needing handling */ | 213 | struct list_head handle_list; /* stripes needing handling */ |
212 | struct list_head delayed_list; /* stripes that have plugged requests */ | 214 | struct list_head delayed_list; /* stripes that have plugged requests */ |
215 | struct list_head bitmap_list; /* stripes delaying awaiting bitmap update */ | ||
213 | atomic_t preread_active_stripes; /* stripes with scheduled io */ | 216 | atomic_t preread_active_stripes; /* stripes with scheduled io */ |
214 | 217 | ||
215 | char cache_name[20]; | 218 | char cache_name[20]; |
216 | kmem_cache_t *slab_cache; /* for allocating stripes */ | 219 | kmem_cache_t *slab_cache; /* for allocating stripes */ |
220 | |||
221 | int seq_flush, seq_write; | ||
222 | int quiesce; | ||
223 | |||
224 | int fullsync; /* set to 1 if a full sync is needed, | ||
225 | * (fresh device added). | ||
226 | * Cleared when a sync completes. | ||
227 | */ | ||
228 | |||
217 | /* | 229 | /* |
218 | * Free stripes pool | 230 | * Free stripes pool |
219 | */ | 231 | */ |
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index fd276adf0fd5..4e65eb44adfd 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
@@ -52,8 +52,8 @@ struct rcu_head { | |||
52 | void (*func)(struct rcu_head *head); | 52 | void (*func)(struct rcu_head *head); |
53 | }; | 53 | }; |
54 | 54 | ||
55 | #define RCU_HEAD_INIT(head) { .next = NULL, .func = NULL } | 55 | #define RCU_HEAD_INIT { .next = NULL, .func = NULL } |
56 | #define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT(head) | 56 | #define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT |
57 | #define INIT_RCU_HEAD(ptr) do { \ | 57 | #define INIT_RCU_HEAD(ptr) do { \ |
58 | (ptr)->next = NULL; (ptr)->func = NULL; \ | 58 | (ptr)->next = NULL; (ptr)->func = NULL; \ |
59 | } while (0) | 59 | } while (0) |
diff --git a/include/linux/rcuref.h b/include/linux/rcuref.h new file mode 100644 index 000000000000..e1adbba14b67 --- /dev/null +++ b/include/linux/rcuref.h | |||
@@ -0,0 +1,220 @@ | |||
1 | /* | ||
2 | * rcuref.h | ||
3 | * | ||
4 | * Reference counting for elements of lists/arrays protected by | ||
5 | * RCU. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | * | ||
21 | * Copyright (C) IBM Corporation, 2005 | ||
22 | * | ||
23 | * Author: Dipankar Sarma <dipankar@in.ibm.com> | ||
24 | * Ravikiran Thirumalai <kiran_th@gmail.com> | ||
25 | * | ||
26 | * See Documentation/RCU/rcuref.txt for detailed user guide. | ||
27 | * | ||
28 | */ | ||
29 | |||
30 | #ifndef _RCUREF_H_ | ||
31 | #define _RCUREF_H_ | ||
32 | |||
33 | #ifdef __KERNEL__ | ||
34 | |||
35 | #include <linux/types.h> | ||
36 | #include <linux/interrupt.h> | ||
37 | #include <linux/spinlock.h> | ||
38 | #include <asm/atomic.h> | ||
39 | |||
40 | /* | ||
41 | * These APIs work on traditional atomic_t counters used in the | ||
42 | * kernel for reference counting. Under special circumstances | ||
43 | * where a lock-free get() operation races with a put() operation | ||
44 | * these APIs can be used. See Documentation/RCU/rcuref.txt. | ||
45 | */ | ||
46 | |||
47 | #ifdef __HAVE_ARCH_CMPXCHG | ||
48 | |||
49 | /** | ||
50 | * rcuref_inc - increment refcount for object. | ||
51 | * @rcuref: reference counter in the object in question. | ||
52 | * | ||
53 | * This should be used only for objects where we use RCU and | ||
54 | * use the rcuref_inc_lf() api to acquire a reference | ||
55 | * in a lock-free reader-side critical section. | ||
56 | */ | ||
57 | static inline void rcuref_inc(atomic_t *rcuref) | ||
58 | { | ||
59 | atomic_inc(rcuref); | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * rcuref_dec - decrement refcount for object. | ||
64 | * @rcuref: reference counter in the object in question. | ||
65 | * | ||
66 | * This should be used only for objects where we use RCU and | ||
67 | * use the rcuref_inc_lf() api to acquire a reference | ||
68 | * in a lock-free reader-side critical section. | ||
69 | */ | ||
70 | static inline void rcuref_dec(atomic_t *rcuref) | ||
71 | { | ||
72 | atomic_dec(rcuref); | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * rcuref_dec_and_test - decrement refcount for object and test | ||
77 | * @rcuref: reference counter in the object. | ||
78 | * @release: pointer to the function that will clean up the object | ||
79 | * when the last reference to the object is released. | ||
80 | * This pointer is required. | ||
81 | * | ||
82 | * Decrement the refcount, and if 0, return 1. Else return 0. | ||
83 | * | ||
84 | * This should be used only for objects where we use RCU and | ||
85 | * use the rcuref_inc_lf() api to acquire a reference | ||
86 | * in a lock-free reader-side critical section. | ||
87 | */ | ||
88 | static inline int rcuref_dec_and_test(atomic_t *rcuref) | ||
89 | { | ||
90 | return atomic_dec_and_test(rcuref); | ||
91 | } | ||
92 | |||
93 | /* | ||
94 | * cmpxchg is needed on UP too, if deletions to the list/array can happen | ||
95 | * in interrupt context. | ||
96 | */ | ||
97 | |||
98 | /** | ||
99 | * rcuref_inc_lf - Take reference to an object in a read-side | ||
100 | * critical section protected by RCU. | ||
101 | * @rcuref: reference counter in the object in question. | ||
102 | * | ||
103 | * Try and increment the refcount by 1. The increment might fail if | ||
104 | * the reference counter has been through a 1 to 0 transition and | ||
105 | * is no longer part of the lock-free list. | ||
106 | * Returns non-zero on successful increment and zero otherwise. | ||
107 | */ | ||
108 | static inline int rcuref_inc_lf(atomic_t *rcuref) | ||
109 | { | ||
110 | int c, old; | ||
111 | c = atomic_read(rcuref); | ||
112 | while (c && (old = cmpxchg(&rcuref->counter, c, c + 1)) != c) | ||
113 | c = old; | ||
114 | return c; | ||
115 | } | ||
116 | |||
117 | #else /* !__HAVE_ARCH_CMPXCHG */ | ||
118 | |||
119 | extern spinlock_t __rcuref_hash[]; | ||
120 | |||
121 | /* | ||
122 | * Use a hash table of locks to protect the reference count | ||
123 | * since cmpxchg is not available in this arch. | ||
124 | */ | ||
125 | #ifdef CONFIG_SMP | ||
126 | #define RCUREF_HASH_SIZE 4 | ||
127 | #define RCUREF_HASH(k) \ | ||
128 | (&__rcuref_hash[(((unsigned long)k)>>8) & (RCUREF_HASH_SIZE-1)]) | ||
129 | #else | ||
130 | #define RCUREF_HASH_SIZE 1 | ||
131 | #define RCUREF_HASH(k) &__rcuref_hash[0] | ||
132 | #endif /* CONFIG_SMP */ | ||
133 | |||
134 | /** | ||
135 | * rcuref_inc - increment refcount for object. | ||
136 | * @rcuref: reference counter in the object in question. | ||
137 | * | ||
138 | * This should be used only for objects where we use RCU and | ||
139 | * use the rcuref_inc_lf() api to acquire a reference in a lock-free | ||
140 | * reader-side critical section. | ||
141 | */ | ||
142 | static inline void rcuref_inc(atomic_t *rcuref) | ||
143 | { | ||
144 | unsigned long flags; | ||
145 | spin_lock_irqsave(RCUREF_HASH(rcuref), flags); | ||
146 | rcuref->counter += 1; | ||
147 | spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * rcuref_dec - decrement refcount for object. | ||
152 | * @rcuref: reference counter in the object in question. | ||
153 | * | ||
154 | * This should be used only for objects where we use RCU and | ||
155 | * use the rcuref_inc_lf() api to acquire a reference in a lock-free | ||
156 | * reader-side critical section. | ||
157 | */ | ||
158 | static inline void rcuref_dec(atomic_t *rcuref) | ||
159 | { | ||
160 | unsigned long flags; | ||
161 | spin_lock_irqsave(RCUREF_HASH(rcuref), flags); | ||
162 | rcuref->counter -= 1; | ||
163 | spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * rcuref_dec_and_test - decrement refcount for object and test | ||
168 | * @rcuref: reference counter in the object. | ||
169 | * @release: pointer to the function that will clean up the object | ||
170 | * when the last reference to the object is released. | ||
171 | * This pointer is required. | ||
172 | * | ||
173 | * Decrement the refcount, and if 0, return 1. Else return 0. | ||
174 | * | ||
175 | * This should be used only for objects where we use RCU and | ||
176 | * use the rcuref_inc_lf() api to acquire a reference in a lock-free | ||
177 | * reader-side critical section. | ||
178 | */ | ||
179 | static inline int rcuref_dec_and_test(atomic_t *rcuref) | ||
180 | { | ||
181 | unsigned long flags; | ||
182 | spin_lock_irqsave(RCUREF_HASH(rcuref), flags); | ||
183 | rcuref->counter--; | ||
184 | if (!rcuref->counter) { | ||
185 | spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); | ||
186 | return 1; | ||
187 | } else { | ||
188 | spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); | ||
189 | return 0; | ||
190 | } | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * rcuref_inc_lf - Take reference to an object of a lock-free collection | ||
195 | * by traversing a lock-free list/array. | ||
196 | * @rcuref: reference counter in the object in question. | ||
197 | * | ||
198 | * Try and increment the refcount by 1. The increment might fail if | ||
199 | * the reference counter has been through a 1 to 0 transition and | ||
200 | * object is no longer part of the lock-free list. | ||
201 | * Returns non-zero on successful increment and zero otherwise. | ||
202 | */ | ||
203 | static inline int rcuref_inc_lf(atomic_t *rcuref) | ||
204 | { | ||
205 | int ret; | ||
206 | unsigned long flags; | ||
207 | spin_lock_irqsave(RCUREF_HASH(rcuref), flags); | ||
208 | if (rcuref->counter) | ||
209 | ret = rcuref->counter++; | ||
210 | else | ||
211 | ret = 0; | ||
212 | spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); | ||
213 | return ret; | ||
214 | } | ||
215 | |||
216 | |||
217 | #endif /* !__HAVE_ARCH_CMPXCHG */ | ||
218 | |||
219 | #endif /* __KERNEL__ */ | ||
220 | #endif /* _RCUREF_H_ */ | ||
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h index 17e458e17e2b..af00b10294cd 100644 --- a/include/linux/reiserfs_fs.h +++ b/include/linux/reiserfs_fs.h | |||
@@ -2097,7 +2097,7 @@ void reiserfs_free_block(struct reiserfs_transaction_handle *th, struct inode *, | |||
2097 | b_blocknr_t, int for_unformatted); | 2097 | b_blocknr_t, int for_unformatted); |
2098 | int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t *, int, | 2098 | int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t *, int, |
2099 | int); | 2099 | int); |
2100 | extern inline int reiserfs_new_form_blocknrs(struct tree_balance *tb, | 2100 | static inline int reiserfs_new_form_blocknrs(struct tree_balance *tb, |
2101 | b_blocknr_t * new_blocknrs, | 2101 | b_blocknr_t * new_blocknrs, |
2102 | int amount_needed) | 2102 | int amount_needed) |
2103 | { | 2103 | { |
@@ -2113,7 +2113,7 @@ extern inline int reiserfs_new_form_blocknrs(struct tree_balance *tb, | |||
2113 | 0); | 2113 | 0); |
2114 | } | 2114 | } |
2115 | 2115 | ||
2116 | extern inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle | 2116 | static inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle |
2117 | *th, struct inode *inode, | 2117 | *th, struct inode *inode, |
2118 | b_blocknr_t * new_blocknrs, | 2118 | b_blocknr_t * new_blocknrs, |
2119 | struct path *path, long block) | 2119 | struct path *path, long block) |
@@ -2130,7 +2130,7 @@ extern inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle | |||
2130 | } | 2130 | } |
2131 | 2131 | ||
2132 | #ifdef REISERFS_PREALLOCATE | 2132 | #ifdef REISERFS_PREALLOCATE |
2133 | extern inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle | 2133 | static inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle |
2134 | *th, struct inode *inode, | 2134 | *th, struct inode *inode, |
2135 | b_blocknr_t * new_blocknrs, | 2135 | b_blocknr_t * new_blocknrs, |
2136 | struct path *path, long block) | 2136 | struct path *path, long block) |
diff --git a/include/linux/sched.h b/include/linux/sched.h index ea1b5f32ec5c..38c8654aaa96 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -114,6 +114,7 @@ extern unsigned long nr_iowait(void); | |||
114 | #define TASK_TRACED 8 | 114 | #define TASK_TRACED 8 |
115 | #define EXIT_ZOMBIE 16 | 115 | #define EXIT_ZOMBIE 16 |
116 | #define EXIT_DEAD 32 | 116 | #define EXIT_DEAD 32 |
117 | #define TASK_NONINTERACTIVE 64 | ||
117 | 118 | ||
118 | #define __set_task_state(tsk, state_value) \ | 119 | #define __set_task_state(tsk, state_value) \ |
119 | do { (tsk)->state = (state_value); } while (0) | 120 | do { (tsk)->state = (state_value); } while (0) |
@@ -202,6 +203,8 @@ extern int in_sched_functions(unsigned long addr); | |||
202 | 203 | ||
203 | #define MAX_SCHEDULE_TIMEOUT LONG_MAX | 204 | #define MAX_SCHEDULE_TIMEOUT LONG_MAX |
204 | extern signed long FASTCALL(schedule_timeout(signed long timeout)); | 205 | extern signed long FASTCALL(schedule_timeout(signed long timeout)); |
206 | extern signed long schedule_timeout_interruptible(signed long timeout); | ||
207 | extern signed long schedule_timeout_uninterruptible(signed long timeout); | ||
205 | asmlinkage void schedule(void); | 208 | asmlinkage void schedule(void); |
206 | 209 | ||
207 | struct namespace; | 210 | struct namespace; |
@@ -604,6 +607,11 @@ extern int groups_search(struct group_info *group_info, gid_t grp); | |||
604 | #define GROUP_AT(gi, i) \ | 607 | #define GROUP_AT(gi, i) \ |
605 | ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK]) | 608 | ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK]) |
606 | 609 | ||
610 | #ifdef ARCH_HAS_PREFETCH_SWITCH_STACK | ||
611 | extern void prefetch_stack(struct task_struct*); | ||
612 | #else | ||
613 | static inline void prefetch_stack(struct task_struct *t) { } | ||
614 | #endif | ||
607 | 615 | ||
608 | struct audit_context; /* See audit.c */ | 616 | struct audit_context; /* See audit.c */ |
609 | struct mempolicy; | 617 | struct mempolicy; |
@@ -895,6 +903,8 @@ extern int task_curr(const task_t *p); | |||
895 | extern int idle_cpu(int cpu); | 903 | extern int idle_cpu(int cpu); |
896 | extern int sched_setscheduler(struct task_struct *, int, struct sched_param *); | 904 | extern int sched_setscheduler(struct task_struct *, int, struct sched_param *); |
897 | extern task_t *idle_task(int cpu); | 905 | extern task_t *idle_task(int cpu); |
906 | extern task_t *curr_task(int cpu); | ||
907 | extern void set_curr_task(int cpu, task_t *p); | ||
898 | 908 | ||
899 | void yield(void); | 909 | void yield(void); |
900 | 910 | ||
diff --git a/include/linux/security.h b/include/linux/security.h index 7aab6ab7c57f..55b02e1c73f4 100644 --- a/include/linux/security.h +++ b/include/linux/security.h | |||
@@ -250,29 +250,37 @@ struct swap_info_struct; | |||
250 | * @inode contains the inode structure. | 250 | * @inode contains the inode structure. |
251 | * Deallocate the inode security structure and set @inode->i_security to | 251 | * Deallocate the inode security structure and set @inode->i_security to |
252 | * NULL. | 252 | * NULL. |
253 | * @inode_init_security: | ||
254 | * Obtain the security attribute name suffix and value to set on a newly | ||
255 | * created inode and set up the incore security field for the new inode. | ||
256 | * This hook is called by the fs code as part of the inode creation | ||
257 | * transaction and provides for atomic labeling of the inode, unlike | ||
258 | * the post_create/mkdir/... hooks called by the VFS. The hook function | ||
259 | * is expected to allocate the name and value via kmalloc, with the caller | ||
260 | * being responsible for calling kfree after using them. | ||
261 | * If the security module does not use security attributes or does | ||
262 | * not wish to put a security attribute on this particular inode, | ||
263 | * then it should return -EOPNOTSUPP to skip this processing. | ||
264 | * @inode contains the inode structure of the newly created inode. | ||
265 | * @dir contains the inode structure of the parent directory. | ||
266 | * @name will be set to the allocated name suffix (e.g. selinux). | ||
267 | * @value will be set to the allocated attribute value. | ||
268 | * @len will be set to the length of the value. | ||
269 | * Returns 0 if @name and @value have been successfully set, | ||
270 | * -EOPNOTSUPP if no security attribute is needed, or | ||
271 | * -ENOMEM on memory allocation failure. | ||
253 | * @inode_create: | 272 | * @inode_create: |
254 | * Check permission to create a regular file. | 273 | * Check permission to create a regular file. |
255 | * @dir contains inode structure of the parent of the new file. | 274 | * @dir contains inode structure of the parent of the new file. |
256 | * @dentry contains the dentry structure for the file to be created. | 275 | * @dentry contains the dentry structure for the file to be created. |
257 | * @mode contains the file mode of the file to be created. | 276 | * @mode contains the file mode of the file to be created. |
258 | * Return 0 if permission is granted. | 277 | * Return 0 if permission is granted. |
259 | * @inode_post_create: | ||
260 | * Set the security attributes on a newly created regular file. This hook | ||
261 | * is called after a file has been successfully created. | ||
262 | * @dir contains the inode structure of the parent directory of the new file. | ||
263 | * @dentry contains the the dentry structure for the newly created file. | ||
264 | * @mode contains the file mode. | ||
265 | * @inode_link: | 278 | * @inode_link: |
266 | * Check permission before creating a new hard link to a file. | 279 | * Check permission before creating a new hard link to a file. |
267 | * @old_dentry contains the dentry structure for an existing link to the file. | 280 | * @old_dentry contains the dentry structure for an existing link to the file. |
268 | * @dir contains the inode structure of the parent directory of the new link. | 281 | * @dir contains the inode structure of the parent directory of the new link. |
269 | * @new_dentry contains the dentry structure for the new link. | 282 | * @new_dentry contains the dentry structure for the new link. |
270 | * Return 0 if permission is granted. | 283 | * Return 0 if permission is granted. |
271 | * @inode_post_link: | ||
272 | * Set security attributes for a new hard link to a file. | ||
273 | * @old_dentry contains the dentry structure for the existing link. | ||
274 | * @dir contains the inode structure of the parent directory of the new file. | ||
275 | * @new_dentry contains the dentry structure for the new file link. | ||
276 | * @inode_unlink: | 284 | * @inode_unlink: |
277 | * Check the permission to remove a hard link to a file. | 285 | * Check the permission to remove a hard link to a file. |
278 | * @dir contains the inode structure of parent directory of the file. | 286 | * @dir contains the inode structure of parent directory of the file. |
@@ -284,13 +292,6 @@ struct swap_info_struct; | |||
284 | * @dentry contains the dentry structure of the symbolic link. | 292 | * @dentry contains the dentry structure of the symbolic link. |
285 | * @old_name contains the pathname of file. | 293 | * @old_name contains the pathname of file. |
286 | * Return 0 if permission is granted. | 294 | * Return 0 if permission is granted. |
287 | * @inode_post_symlink: | ||
288 | * @dir contains the inode structure of the parent directory of the new link. | ||
289 | * @dentry contains the dentry structure of new symbolic link. | ||
290 | * @old_name contains the pathname of file. | ||
291 | * Set security attributes for a newly created symbolic link. Note that | ||
292 | * @dentry->d_inode may be NULL, since the filesystem might not | ||
293 | * instantiate the dentry (e.g. NFS). | ||
294 | * @inode_mkdir: | 295 | * @inode_mkdir: |
295 | * Check permissions to create a new directory in the existing directory | 296 | * Check permissions to create a new directory in the existing directory |
296 | * associated with inode strcture @dir. | 297 | * associated with inode strcture @dir. |
@@ -298,11 +299,6 @@ struct swap_info_struct; | |||
298 | * @dentry contains the dentry structure of new directory. | 299 | * @dentry contains the dentry structure of new directory. |
299 | * @mode contains the mode of new directory. | 300 | * @mode contains the mode of new directory. |
300 | * Return 0 if permission is granted. | 301 | * Return 0 if permission is granted. |
301 | * @inode_post_mkdir: | ||
302 | * Set security attributes on a newly created directory. | ||
303 | * @dir contains the inode structure of parent of the directory to be created. | ||
304 | * @dentry contains the dentry structure of new directory. | ||
305 | * @mode contains the mode of new directory. | ||
306 | * @inode_rmdir: | 302 | * @inode_rmdir: |
307 | * Check the permission to remove a directory. | 303 | * Check the permission to remove a directory. |
308 | * @dir contains the inode structure of parent of the directory to be removed. | 304 | * @dir contains the inode structure of parent of the directory to be removed. |
@@ -318,13 +314,6 @@ struct swap_info_struct; | |||
318 | * @mode contains the mode of the new file. | 314 | * @mode contains the mode of the new file. |
319 | * @dev contains the the device number. | 315 | * @dev contains the the device number. |
320 | * Return 0 if permission is granted. | 316 | * Return 0 if permission is granted. |
321 | * @inode_post_mknod: | ||
322 | * Set security attributes on a newly created special file (or socket or | ||
323 | * fifo file created via the mknod system call). | ||
324 | * @dir contains the inode structure of parent of the new node. | ||
325 | * @dentry contains the dentry structure of the new node. | ||
326 | * @mode contains the mode of the new node. | ||
327 | * @dev contains the the device number. | ||
328 | * @inode_rename: | 317 | * @inode_rename: |
329 | * Check for permission to rename a file or directory. | 318 | * Check for permission to rename a file or directory. |
330 | * @old_dir contains the inode structure for parent of the old link. | 319 | * @old_dir contains the inode structure for parent of the old link. |
@@ -332,12 +321,6 @@ struct swap_info_struct; | |||
332 | * @new_dir contains the inode structure for parent of the new link. | 321 | * @new_dir contains the inode structure for parent of the new link. |
333 | * @new_dentry contains the dentry structure of the new link. | 322 | * @new_dentry contains the dentry structure of the new link. |
334 | * Return 0 if permission is granted. | 323 | * Return 0 if permission is granted. |
335 | * @inode_post_rename: | ||
336 | * Set security attributes on a renamed file or directory. | ||
337 | * @old_dir contains the inode structure for parent of the old link. | ||
338 | * @old_dentry contains the dentry structure of the old link. | ||
339 | * @new_dir contains the inode structure for parent of the new link. | ||
340 | * @new_dentry contains the dentry structure of the new link. | ||
341 | * @inode_readlink: | 324 | * @inode_readlink: |
342 | * Check the permission to read the symbolic link. | 325 | * Check the permission to read the symbolic link. |
343 | * @dentry contains the dentry structure for the file link. | 326 | * @dentry contains the dentry structure for the file link. |
@@ -1080,34 +1063,21 @@ struct security_operations { | |||
1080 | 1063 | ||
1081 | int (*inode_alloc_security) (struct inode *inode); | 1064 | int (*inode_alloc_security) (struct inode *inode); |
1082 | void (*inode_free_security) (struct inode *inode); | 1065 | void (*inode_free_security) (struct inode *inode); |
1066 | int (*inode_init_security) (struct inode *inode, struct inode *dir, | ||
1067 | char **name, void **value, size_t *len); | ||
1083 | int (*inode_create) (struct inode *dir, | 1068 | int (*inode_create) (struct inode *dir, |
1084 | struct dentry *dentry, int mode); | 1069 | struct dentry *dentry, int mode); |
1085 | void (*inode_post_create) (struct inode *dir, | ||
1086 | struct dentry *dentry, int mode); | ||
1087 | int (*inode_link) (struct dentry *old_dentry, | 1070 | int (*inode_link) (struct dentry *old_dentry, |
1088 | struct inode *dir, struct dentry *new_dentry); | 1071 | struct inode *dir, struct dentry *new_dentry); |
1089 | void (*inode_post_link) (struct dentry *old_dentry, | ||
1090 | struct inode *dir, struct dentry *new_dentry); | ||
1091 | int (*inode_unlink) (struct inode *dir, struct dentry *dentry); | 1072 | int (*inode_unlink) (struct inode *dir, struct dentry *dentry); |
1092 | int (*inode_symlink) (struct inode *dir, | 1073 | int (*inode_symlink) (struct inode *dir, |
1093 | struct dentry *dentry, const char *old_name); | 1074 | struct dentry *dentry, const char *old_name); |
1094 | void (*inode_post_symlink) (struct inode *dir, | ||
1095 | struct dentry *dentry, | ||
1096 | const char *old_name); | ||
1097 | int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode); | 1075 | int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode); |
1098 | void (*inode_post_mkdir) (struct inode *dir, struct dentry *dentry, | ||
1099 | int mode); | ||
1100 | int (*inode_rmdir) (struct inode *dir, struct dentry *dentry); | 1076 | int (*inode_rmdir) (struct inode *dir, struct dentry *dentry); |
1101 | int (*inode_mknod) (struct inode *dir, struct dentry *dentry, | 1077 | int (*inode_mknod) (struct inode *dir, struct dentry *dentry, |
1102 | int mode, dev_t dev); | 1078 | int mode, dev_t dev); |
1103 | void (*inode_post_mknod) (struct inode *dir, struct dentry *dentry, | ||
1104 | int mode, dev_t dev); | ||
1105 | int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry, | 1079 | int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry, |
1106 | struct inode *new_dir, struct dentry *new_dentry); | 1080 | struct inode *new_dir, struct dentry *new_dentry); |
1107 | void (*inode_post_rename) (struct inode *old_dir, | ||
1108 | struct dentry *old_dentry, | ||
1109 | struct inode *new_dir, | ||
1110 | struct dentry *new_dentry); | ||
1111 | int (*inode_readlink) (struct dentry *dentry); | 1081 | int (*inode_readlink) (struct dentry *dentry); |
1112 | int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd); | 1082 | int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd); |
1113 | int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd); | 1083 | int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd); |
@@ -1442,6 +1412,17 @@ static inline void security_inode_free (struct inode *inode) | |||
1442 | return; | 1412 | return; |
1443 | security_ops->inode_free_security (inode); | 1413 | security_ops->inode_free_security (inode); |
1444 | } | 1414 | } |
1415 | |||
1416 | static inline int security_inode_init_security (struct inode *inode, | ||
1417 | struct inode *dir, | ||
1418 | char **name, | ||
1419 | void **value, | ||
1420 | size_t *len) | ||
1421 | { | ||
1422 | if (unlikely (IS_PRIVATE (inode))) | ||
1423 | return -EOPNOTSUPP; | ||
1424 | return security_ops->inode_init_security (inode, dir, name, value, len); | ||
1425 | } | ||
1445 | 1426 | ||
1446 | static inline int security_inode_create (struct inode *dir, | 1427 | static inline int security_inode_create (struct inode *dir, |
1447 | struct dentry *dentry, | 1428 | struct dentry *dentry, |
@@ -1452,15 +1433,6 @@ static inline int security_inode_create (struct inode *dir, | |||
1452 | return security_ops->inode_create (dir, dentry, mode); | 1433 | return security_ops->inode_create (dir, dentry, mode); |
1453 | } | 1434 | } |
1454 | 1435 | ||
1455 | static inline void security_inode_post_create (struct inode *dir, | ||
1456 | struct dentry *dentry, | ||
1457 | int mode) | ||
1458 | { | ||
1459 | if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1460 | return; | ||
1461 | security_ops->inode_post_create (dir, dentry, mode); | ||
1462 | } | ||
1463 | |||
1464 | static inline int security_inode_link (struct dentry *old_dentry, | 1436 | static inline int security_inode_link (struct dentry *old_dentry, |
1465 | struct inode *dir, | 1437 | struct inode *dir, |
1466 | struct dentry *new_dentry) | 1438 | struct dentry *new_dentry) |
@@ -1470,15 +1442,6 @@ static inline int security_inode_link (struct dentry *old_dentry, | |||
1470 | return security_ops->inode_link (old_dentry, dir, new_dentry); | 1442 | return security_ops->inode_link (old_dentry, dir, new_dentry); |
1471 | } | 1443 | } |
1472 | 1444 | ||
1473 | static inline void security_inode_post_link (struct dentry *old_dentry, | ||
1474 | struct inode *dir, | ||
1475 | struct dentry *new_dentry) | ||
1476 | { | ||
1477 | if (new_dentry->d_inode && unlikely (IS_PRIVATE (new_dentry->d_inode))) | ||
1478 | return; | ||
1479 | security_ops->inode_post_link (old_dentry, dir, new_dentry); | ||
1480 | } | ||
1481 | |||
1482 | static inline int security_inode_unlink (struct inode *dir, | 1445 | static inline int security_inode_unlink (struct inode *dir, |
1483 | struct dentry *dentry) | 1446 | struct dentry *dentry) |
1484 | { | 1447 | { |
@@ -1496,15 +1459,6 @@ static inline int security_inode_symlink (struct inode *dir, | |||
1496 | return security_ops->inode_symlink (dir, dentry, old_name); | 1459 | return security_ops->inode_symlink (dir, dentry, old_name); |
1497 | } | 1460 | } |
1498 | 1461 | ||
1499 | static inline void security_inode_post_symlink (struct inode *dir, | ||
1500 | struct dentry *dentry, | ||
1501 | const char *old_name) | ||
1502 | { | ||
1503 | if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1504 | return; | ||
1505 | security_ops->inode_post_symlink (dir, dentry, old_name); | ||
1506 | } | ||
1507 | |||
1508 | static inline int security_inode_mkdir (struct inode *dir, | 1462 | static inline int security_inode_mkdir (struct inode *dir, |
1509 | struct dentry *dentry, | 1463 | struct dentry *dentry, |
1510 | int mode) | 1464 | int mode) |
@@ -1514,15 +1468,6 @@ static inline int security_inode_mkdir (struct inode *dir, | |||
1514 | return security_ops->inode_mkdir (dir, dentry, mode); | 1468 | return security_ops->inode_mkdir (dir, dentry, mode); |
1515 | } | 1469 | } |
1516 | 1470 | ||
1517 | static inline void security_inode_post_mkdir (struct inode *dir, | ||
1518 | struct dentry *dentry, | ||
1519 | int mode) | ||
1520 | { | ||
1521 | if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1522 | return; | ||
1523 | security_ops->inode_post_mkdir (dir, dentry, mode); | ||
1524 | } | ||
1525 | |||
1526 | static inline int security_inode_rmdir (struct inode *dir, | 1471 | static inline int security_inode_rmdir (struct inode *dir, |
1527 | struct dentry *dentry) | 1472 | struct dentry *dentry) |
1528 | { | 1473 | { |
@@ -1540,15 +1485,6 @@ static inline int security_inode_mknod (struct inode *dir, | |||
1540 | return security_ops->inode_mknod (dir, dentry, mode, dev); | 1485 | return security_ops->inode_mknod (dir, dentry, mode, dev); |
1541 | } | 1486 | } |
1542 | 1487 | ||
1543 | static inline void security_inode_post_mknod (struct inode *dir, | ||
1544 | struct dentry *dentry, | ||
1545 | int mode, dev_t dev) | ||
1546 | { | ||
1547 | if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1548 | return; | ||
1549 | security_ops->inode_post_mknod (dir, dentry, mode, dev); | ||
1550 | } | ||
1551 | |||
1552 | static inline int security_inode_rename (struct inode *old_dir, | 1488 | static inline int security_inode_rename (struct inode *old_dir, |
1553 | struct dentry *old_dentry, | 1489 | struct dentry *old_dentry, |
1554 | struct inode *new_dir, | 1490 | struct inode *new_dir, |
@@ -1561,18 +1497,6 @@ static inline int security_inode_rename (struct inode *old_dir, | |||
1561 | new_dir, new_dentry); | 1497 | new_dir, new_dentry); |
1562 | } | 1498 | } |
1563 | 1499 | ||
1564 | static inline void security_inode_post_rename (struct inode *old_dir, | ||
1565 | struct dentry *old_dentry, | ||
1566 | struct inode *new_dir, | ||
1567 | struct dentry *new_dentry) | ||
1568 | { | ||
1569 | if (unlikely (IS_PRIVATE (old_dentry->d_inode) || | ||
1570 | (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode)))) | ||
1571 | return; | ||
1572 | security_ops->inode_post_rename (old_dir, old_dentry, | ||
1573 | new_dir, new_dentry); | ||
1574 | } | ||
1575 | |||
1576 | static inline int security_inode_readlink (struct dentry *dentry) | 1500 | static inline int security_inode_readlink (struct dentry *dentry) |
1577 | { | 1501 | { |
1578 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | 1502 | if (unlikely (IS_PRIVATE (dentry->d_inode))) |
@@ -2171,6 +2095,15 @@ static inline int security_inode_alloc (struct inode *inode) | |||
2171 | 2095 | ||
2172 | static inline void security_inode_free (struct inode *inode) | 2096 | static inline void security_inode_free (struct inode *inode) |
2173 | { } | 2097 | { } |
2098 | |||
2099 | static inline int security_inode_init_security (struct inode *inode, | ||
2100 | struct inode *dir, | ||
2101 | char **name, | ||
2102 | void **value, | ||
2103 | size_t *len) | ||
2104 | { | ||
2105 | return -EOPNOTSUPP; | ||
2106 | } | ||
2174 | 2107 | ||
2175 | static inline int security_inode_create (struct inode *dir, | 2108 | static inline int security_inode_create (struct inode *dir, |
2176 | struct dentry *dentry, | 2109 | struct dentry *dentry, |
@@ -2179,11 +2112,6 @@ static inline int security_inode_create (struct inode *dir, | |||
2179 | return 0; | 2112 | return 0; |
2180 | } | 2113 | } |
2181 | 2114 | ||
2182 | static inline void security_inode_post_create (struct inode *dir, | ||
2183 | struct dentry *dentry, | ||
2184 | int mode) | ||
2185 | { } | ||
2186 | |||
2187 | static inline int security_inode_link (struct dentry *old_dentry, | 2115 | static inline int security_inode_link (struct dentry *old_dentry, |
2188 | struct inode *dir, | 2116 | struct inode *dir, |
2189 | struct dentry *new_dentry) | 2117 | struct dentry *new_dentry) |
@@ -2191,11 +2119,6 @@ static inline int security_inode_link (struct dentry *old_dentry, | |||
2191 | return 0; | 2119 | return 0; |
2192 | } | 2120 | } |
2193 | 2121 | ||
2194 | static inline void security_inode_post_link (struct dentry *old_dentry, | ||
2195 | struct inode *dir, | ||
2196 | struct dentry *new_dentry) | ||
2197 | { } | ||
2198 | |||
2199 | static inline int security_inode_unlink (struct inode *dir, | 2122 | static inline int security_inode_unlink (struct inode *dir, |
2200 | struct dentry *dentry) | 2123 | struct dentry *dentry) |
2201 | { | 2124 | { |
@@ -2209,11 +2132,6 @@ static inline int security_inode_symlink (struct inode *dir, | |||
2209 | return 0; | 2132 | return 0; |
2210 | } | 2133 | } |
2211 | 2134 | ||
2212 | static inline void security_inode_post_symlink (struct inode *dir, | ||
2213 | struct dentry *dentry, | ||
2214 | const char *old_name) | ||
2215 | { } | ||
2216 | |||
2217 | static inline int security_inode_mkdir (struct inode *dir, | 2135 | static inline int security_inode_mkdir (struct inode *dir, |
2218 | struct dentry *dentry, | 2136 | struct dentry *dentry, |
2219 | int mode) | 2137 | int mode) |
@@ -2221,11 +2139,6 @@ static inline int security_inode_mkdir (struct inode *dir, | |||
2221 | return 0; | 2139 | return 0; |
2222 | } | 2140 | } |
2223 | 2141 | ||
2224 | static inline void security_inode_post_mkdir (struct inode *dir, | ||
2225 | struct dentry *dentry, | ||
2226 | int mode) | ||
2227 | { } | ||
2228 | |||
2229 | static inline int security_inode_rmdir (struct inode *dir, | 2142 | static inline int security_inode_rmdir (struct inode *dir, |
2230 | struct dentry *dentry) | 2143 | struct dentry *dentry) |
2231 | { | 2144 | { |
@@ -2239,11 +2152,6 @@ static inline int security_inode_mknod (struct inode *dir, | |||
2239 | return 0; | 2152 | return 0; |
2240 | } | 2153 | } |
2241 | 2154 | ||
2242 | static inline void security_inode_post_mknod (struct inode *dir, | ||
2243 | struct dentry *dentry, | ||
2244 | int mode, dev_t dev) | ||
2245 | { } | ||
2246 | |||
2247 | static inline int security_inode_rename (struct inode *old_dir, | 2155 | static inline int security_inode_rename (struct inode *old_dir, |
2248 | struct dentry *old_dentry, | 2156 | struct dentry *old_dentry, |
2249 | struct inode *new_dir, | 2157 | struct inode *new_dir, |
@@ -2252,12 +2160,6 @@ static inline int security_inode_rename (struct inode *old_dir, | |||
2252 | return 0; | 2160 | return 0; |
2253 | } | 2161 | } |
2254 | 2162 | ||
2255 | static inline void security_inode_post_rename (struct inode *old_dir, | ||
2256 | struct dentry *old_dentry, | ||
2257 | struct inode *new_dir, | ||
2258 | struct dentry *new_dentry) | ||
2259 | { } | ||
2260 | |||
2261 | static inline int security_inode_readlink (struct dentry *dentry) | 2163 | static inline int security_inode_readlink (struct dentry *dentry) |
2262 | { | 2164 | { |
2263 | return 0; | 2165 | return 0; |
diff --git a/include/linux/slab.h b/include/linux/slab.h index 42a6bea58af3..1f356f3bbc64 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -118,7 +118,8 @@ extern void kfree(const void *); | |||
118 | extern unsigned int ksize(const void *); | 118 | extern unsigned int ksize(const void *); |
119 | 119 | ||
120 | #ifdef CONFIG_NUMA | 120 | #ifdef CONFIG_NUMA |
121 | extern void *kmem_cache_alloc_node(kmem_cache_t *, int flags, int node); | 121 | extern void *kmem_cache_alloc_node(kmem_cache_t *, |
122 | unsigned int __nocast flags, int node); | ||
122 | extern void *kmalloc_node(size_t size, unsigned int __nocast flags, int node); | 123 | extern void *kmalloc_node(size_t size, unsigned int __nocast flags, int node); |
123 | #else | 124 | #else |
124 | static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int node) | 125 | static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int node) |
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index d6ba068719b6..cdc99a27840d 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h | |||
@@ -2,7 +2,48 @@ | |||
2 | #define __LINUX_SPINLOCK_H | 2 | #define __LINUX_SPINLOCK_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | * include/linux/spinlock.h - generic locking declarations | 5 | * include/linux/spinlock.h - generic spinlock/rwlock declarations |
6 | * | ||
7 | * here's the role of the various spinlock/rwlock related include files: | ||
8 | * | ||
9 | * on SMP builds: | ||
10 | * | ||
11 | * asm/spinlock_types.h: contains the raw_spinlock_t/raw_rwlock_t and the | ||
12 | * initializers | ||
13 | * | ||
14 | * linux/spinlock_types.h: | ||
15 | * defines the generic type and initializers | ||
16 | * | ||
17 | * asm/spinlock.h: contains the __raw_spin_*()/etc. lowlevel | ||
18 | * implementations, mostly inline assembly code | ||
19 | * | ||
20 | * (also included on UP-debug builds:) | ||
21 | * | ||
22 | * linux/spinlock_api_smp.h: | ||
23 | * contains the prototypes for the _spin_*() APIs. | ||
24 | * | ||
25 | * linux/spinlock.h: builds the final spin_*() APIs. | ||
26 | * | ||
27 | * on UP builds: | ||
28 | * | ||
29 | * linux/spinlock_type_up.h: | ||
30 | * contains the generic, simplified UP spinlock type. | ||
31 | * (which is an empty structure on non-debug builds) | ||
32 | * | ||
33 | * linux/spinlock_types.h: | ||
34 | * defines the generic type and initializers | ||
35 | * | ||
36 | * linux/spinlock_up.h: | ||
37 | * contains the __raw_spin_*()/etc. version of UP | ||
38 | * builds. (which are NOPs on non-debug, non-preempt | ||
39 | * builds) | ||
40 | * | ||
41 | * (included on UP-non-debug builds:) | ||
42 | * | ||
43 | * linux/spinlock_api_up.h: | ||
44 | * builds the _spin_*() APIs. | ||
45 | * | ||
46 | * linux/spinlock.h: builds the final spin_*() APIs. | ||
6 | */ | 47 | */ |
7 | 48 | ||
8 | #include <linux/config.h> | 49 | #include <linux/config.h> |
@@ -13,7 +54,6 @@ | |||
13 | #include <linux/kernel.h> | 54 | #include <linux/kernel.h> |
14 | #include <linux/stringify.h> | 55 | #include <linux/stringify.h> |
15 | 56 | ||
16 | #include <asm/processor.h> /* for cpu relax */ | ||
17 | #include <asm/system.h> | 57 | #include <asm/system.h> |
18 | 58 | ||
19 | /* | 59 | /* |
@@ -35,423 +75,84 @@ | |||
35 | #define __lockfunc fastcall __attribute__((section(".spinlock.text"))) | 75 | #define __lockfunc fastcall __attribute__((section(".spinlock.text"))) |
36 | 76 | ||
37 | /* | 77 | /* |
38 | * If CONFIG_SMP is set, pull in the _raw_* definitions | 78 | * Pull the raw_spinlock_t and raw_rwlock_t definitions: |
39 | */ | 79 | */ |
40 | #ifdef CONFIG_SMP | 80 | #include <linux/spinlock_types.h> |
41 | |||
42 | #define assert_spin_locked(x) BUG_ON(!spin_is_locked(x)) | ||
43 | #include <asm/spinlock.h> | ||
44 | |||
45 | int __lockfunc _spin_trylock(spinlock_t *lock); | ||
46 | int __lockfunc _read_trylock(rwlock_t *lock); | ||
47 | int __lockfunc _write_trylock(rwlock_t *lock); | ||
48 | |||
49 | void __lockfunc _spin_lock(spinlock_t *lock) __acquires(spinlock_t); | ||
50 | void __lockfunc _read_lock(rwlock_t *lock) __acquires(rwlock_t); | ||
51 | void __lockfunc _write_lock(rwlock_t *lock) __acquires(rwlock_t); | ||
52 | |||
53 | void __lockfunc _spin_unlock(spinlock_t *lock) __releases(spinlock_t); | ||
54 | void __lockfunc _read_unlock(rwlock_t *lock) __releases(rwlock_t); | ||
55 | void __lockfunc _write_unlock(rwlock_t *lock) __releases(rwlock_t); | ||
56 | |||
57 | unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock) __acquires(spinlock_t); | ||
58 | unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock) __acquires(rwlock_t); | ||
59 | unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock) __acquires(rwlock_t); | ||
60 | |||
61 | void __lockfunc _spin_lock_irq(spinlock_t *lock) __acquires(spinlock_t); | ||
62 | void __lockfunc _spin_lock_bh(spinlock_t *lock) __acquires(spinlock_t); | ||
63 | void __lockfunc _read_lock_irq(rwlock_t *lock) __acquires(rwlock_t); | ||
64 | void __lockfunc _read_lock_bh(rwlock_t *lock) __acquires(rwlock_t); | ||
65 | void __lockfunc _write_lock_irq(rwlock_t *lock) __acquires(rwlock_t); | ||
66 | void __lockfunc _write_lock_bh(rwlock_t *lock) __acquires(rwlock_t); | ||
67 | |||
68 | void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) __releases(spinlock_t); | ||
69 | void __lockfunc _spin_unlock_irq(spinlock_t *lock) __releases(spinlock_t); | ||
70 | void __lockfunc _spin_unlock_bh(spinlock_t *lock) __releases(spinlock_t); | ||
71 | void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) __releases(rwlock_t); | ||
72 | void __lockfunc _read_unlock_irq(rwlock_t *lock) __releases(rwlock_t); | ||
73 | void __lockfunc _read_unlock_bh(rwlock_t *lock) __releases(rwlock_t); | ||
74 | void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) __releases(rwlock_t); | ||
75 | void __lockfunc _write_unlock_irq(rwlock_t *lock) __releases(rwlock_t); | ||
76 | void __lockfunc _write_unlock_bh(rwlock_t *lock) __releases(rwlock_t); | ||
77 | |||
78 | int __lockfunc _spin_trylock_bh(spinlock_t *lock); | ||
79 | int __lockfunc generic_raw_read_trylock(rwlock_t *lock); | ||
80 | int in_lock_functions(unsigned long addr); | ||
81 | |||
82 | #else | ||
83 | 81 | ||
84 | #define in_lock_functions(ADDR) 0 | 82 | extern int __lockfunc generic__raw_read_trylock(raw_rwlock_t *lock); |
85 | 83 | ||
86 | #if !defined(CONFIG_PREEMPT) && !defined(CONFIG_DEBUG_SPINLOCK) | ||
87 | # define _atomic_dec_and_lock(atomic,lock) atomic_dec_and_test(atomic) | ||
88 | # define ATOMIC_DEC_AND_LOCK | ||
89 | #endif | ||
90 | |||
91 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
92 | |||
93 | #define SPINLOCK_MAGIC 0x1D244B3C | ||
94 | typedef struct { | ||
95 | unsigned long magic; | ||
96 | volatile unsigned long lock; | ||
97 | volatile unsigned int babble; | ||
98 | const char *module; | ||
99 | char *owner; | ||
100 | int oline; | ||
101 | } spinlock_t; | ||
102 | #define SPIN_LOCK_UNLOCKED (spinlock_t) { SPINLOCK_MAGIC, 0, 10, __FILE__ , NULL, 0} | ||
103 | |||
104 | #define spin_lock_init(x) \ | ||
105 | do { \ | ||
106 | (x)->magic = SPINLOCK_MAGIC; \ | ||
107 | (x)->lock = 0; \ | ||
108 | (x)->babble = 5; \ | ||
109 | (x)->module = __FILE__; \ | ||
110 | (x)->owner = NULL; \ | ||
111 | (x)->oline = 0; \ | ||
112 | } while (0) | ||
113 | |||
114 | #define CHECK_LOCK(x) \ | ||
115 | do { \ | ||
116 | if ((x)->magic != SPINLOCK_MAGIC) { \ | ||
117 | printk(KERN_ERR "%s:%d: spin_is_locked on uninitialized spinlock %p.\n", \ | ||
118 | __FILE__, __LINE__, (x)); \ | ||
119 | } \ | ||
120 | } while(0) | ||
121 | |||
122 | #define _raw_spin_lock(x) \ | ||
123 | do { \ | ||
124 | CHECK_LOCK(x); \ | ||
125 | if ((x)->lock&&(x)->babble) { \ | ||
126 | (x)->babble--; \ | ||
127 | printk("%s:%d: spin_lock(%s:%p) already locked by %s/%d\n", \ | ||
128 | __FILE__,__LINE__, (x)->module, \ | ||
129 | (x), (x)->owner, (x)->oline); \ | ||
130 | } \ | ||
131 | (x)->lock = 1; \ | ||
132 | (x)->owner = __FILE__; \ | ||
133 | (x)->oline = __LINE__; \ | ||
134 | } while (0) | ||
135 | |||
136 | /* without debugging, spin_is_locked on UP always says | ||
137 | * FALSE. --> printk if already locked. */ | ||
138 | #define spin_is_locked(x) \ | ||
139 | ({ \ | ||
140 | CHECK_LOCK(x); \ | ||
141 | if ((x)->lock&&(x)->babble) { \ | ||
142 | (x)->babble--; \ | ||
143 | printk("%s:%d: spin_is_locked(%s:%p) already locked by %s/%d\n", \ | ||
144 | __FILE__,__LINE__, (x)->module, \ | ||
145 | (x), (x)->owner, (x)->oline); \ | ||
146 | } \ | ||
147 | 0; \ | ||
148 | }) | ||
149 | |||
150 | /* with debugging, assert_spin_locked() on UP does check | ||
151 | * the lock value properly */ | ||
152 | #define assert_spin_locked(x) \ | ||
153 | ({ \ | ||
154 | CHECK_LOCK(x); \ | ||
155 | BUG_ON(!(x)->lock); \ | ||
156 | }) | ||
157 | |||
158 | /* without debugging, spin_trylock on UP always says | ||
159 | * TRUE. --> printk if already locked. */ | ||
160 | #define _raw_spin_trylock(x) \ | ||
161 | ({ \ | ||
162 | CHECK_LOCK(x); \ | ||
163 | if ((x)->lock&&(x)->babble) { \ | ||
164 | (x)->babble--; \ | ||
165 | printk("%s:%d: spin_trylock(%s:%p) already locked by %s/%d\n", \ | ||
166 | __FILE__,__LINE__, (x)->module, \ | ||
167 | (x), (x)->owner, (x)->oline); \ | ||
168 | } \ | ||
169 | (x)->lock = 1; \ | ||
170 | (x)->owner = __FILE__; \ | ||
171 | (x)->oline = __LINE__; \ | ||
172 | 1; \ | ||
173 | }) | ||
174 | |||
175 | #define spin_unlock_wait(x) \ | ||
176 | do { \ | ||
177 | CHECK_LOCK(x); \ | ||
178 | if ((x)->lock&&(x)->babble) { \ | ||
179 | (x)->babble--; \ | ||
180 | printk("%s:%d: spin_unlock_wait(%s:%p) owned by %s/%d\n", \ | ||
181 | __FILE__,__LINE__, (x)->module, (x), \ | ||
182 | (x)->owner, (x)->oline); \ | ||
183 | }\ | ||
184 | } while (0) | ||
185 | |||
186 | #define _raw_spin_unlock(x) \ | ||
187 | do { \ | ||
188 | CHECK_LOCK(x); \ | ||
189 | if (!(x)->lock&&(x)->babble) { \ | ||
190 | (x)->babble--; \ | ||
191 | printk("%s:%d: spin_unlock(%s:%p) not locked\n", \ | ||
192 | __FILE__,__LINE__, (x)->module, (x));\ | ||
193 | } \ | ||
194 | (x)->lock = 0; \ | ||
195 | } while (0) | ||
196 | #else | ||
197 | /* | 84 | /* |
198 | * gcc versions before ~2.95 have a nasty bug with empty initializers. | 85 | * Pull the __raw*() functions/declarations (UP-nondebug doesnt need them): |
199 | */ | 86 | */ |
200 | #if (__GNUC__ > 2) | 87 | #if defined(CONFIG_SMP) |
201 | typedef struct { } spinlock_t; | 88 | # include <asm/spinlock.h> |
202 | #define SPIN_LOCK_UNLOCKED (spinlock_t) { } | ||
203 | #else | 89 | #else |
204 | typedef struct { int gcc_is_buggy; } spinlock_t; | 90 | # include <linux/spinlock_up.h> |
205 | #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 } | ||
206 | #endif | 91 | #endif |
207 | 92 | ||
93 | #define spin_lock_init(lock) do { *(lock) = SPIN_LOCK_UNLOCKED; } while (0) | ||
94 | #define rwlock_init(lock) do { *(lock) = RW_LOCK_UNLOCKED; } while (0) | ||
95 | |||
96 | #define spin_is_locked(lock) __raw_spin_is_locked(&(lock)->raw_lock) | ||
97 | |||
98 | /** | ||
99 | * spin_unlock_wait - wait until the spinlock gets unlocked | ||
100 | * @lock: the spinlock in question. | ||
101 | */ | ||
102 | #define spin_unlock_wait(lock) __raw_spin_unlock_wait(&(lock)->raw_lock) | ||
103 | |||
208 | /* | 104 | /* |
209 | * If CONFIG_SMP is unset, declare the _raw_* definitions as nops | 105 | * Pull the _spin_*()/_read_*()/_write_*() functions/declarations: |
210 | */ | 106 | */ |
211 | #define spin_lock_init(lock) do { (void)(lock); } while(0) | 107 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) |
212 | #define _raw_spin_lock(lock) do { (void)(lock); } while(0) | 108 | # include <linux/spinlock_api_smp.h> |
213 | #define spin_is_locked(lock) ((void)(lock), 0) | ||
214 | #define assert_spin_locked(lock) do { (void)(lock); } while(0) | ||
215 | #define _raw_spin_trylock(lock) (((void)(lock), 1)) | ||
216 | #define spin_unlock_wait(lock) (void)(lock) | ||
217 | #define _raw_spin_unlock(lock) do { (void)(lock); } while(0) | ||
218 | #endif /* CONFIG_DEBUG_SPINLOCK */ | ||
219 | |||
220 | /* RW spinlocks: No debug version */ | ||
221 | |||
222 | #if (__GNUC__ > 2) | ||
223 | typedef struct { } rwlock_t; | ||
224 | #define RW_LOCK_UNLOCKED (rwlock_t) { } | ||
225 | #else | 109 | #else |
226 | typedef struct { int gcc_is_buggy; } rwlock_t; | 110 | # include <linux/spinlock_api_up.h> |
227 | #define RW_LOCK_UNLOCKED (rwlock_t) { 0 } | ||
228 | #endif | 111 | #endif |
229 | 112 | ||
230 | #define rwlock_init(lock) do { (void)(lock); } while(0) | 113 | #ifdef CONFIG_DEBUG_SPINLOCK |
231 | #define _raw_read_lock(lock) do { (void)(lock); } while(0) | 114 | extern void _raw_spin_lock(spinlock_t *lock); |
232 | #define _raw_read_unlock(lock) do { (void)(lock); } while(0) | 115 | #define _raw_spin_lock_flags(lock, flags) _raw_spin_lock(lock) |
233 | #define _raw_write_lock(lock) do { (void)(lock); } while(0) | 116 | extern int _raw_spin_trylock(spinlock_t *lock); |
234 | #define _raw_write_unlock(lock) do { (void)(lock); } while(0) | 117 | extern void _raw_spin_unlock(spinlock_t *lock); |
235 | #define read_can_lock(lock) (((void)(lock), 1)) | 118 | |
236 | #define write_can_lock(lock) (((void)(lock), 1)) | 119 | extern void _raw_read_lock(rwlock_t *lock); |
237 | #define _raw_read_trylock(lock) ({ (void)(lock); (1); }) | 120 | extern int _raw_read_trylock(rwlock_t *lock); |
238 | #define _raw_write_trylock(lock) ({ (void)(lock); (1); }) | 121 | extern void _raw_read_unlock(rwlock_t *lock); |
239 | 122 | extern void _raw_write_lock(rwlock_t *lock); | |
240 | #define _spin_trylock(lock) ({preempt_disable(); _raw_spin_trylock(lock) ? \ | 123 | extern int _raw_write_trylock(rwlock_t *lock); |
241 | 1 : ({preempt_enable(); 0;});}) | 124 | extern void _raw_write_unlock(rwlock_t *lock); |
242 | 125 | #else | |
243 | #define _read_trylock(lock) ({preempt_disable();_raw_read_trylock(lock) ? \ | 126 | # define _raw_spin_unlock(lock) __raw_spin_unlock(&(lock)->raw_lock) |
244 | 1 : ({preempt_enable(); 0;});}) | 127 | # define _raw_spin_trylock(lock) __raw_spin_trylock(&(lock)->raw_lock) |
245 | 128 | # define _raw_spin_lock(lock) __raw_spin_lock(&(lock)->raw_lock) | |
246 | #define _write_trylock(lock) ({preempt_disable(); _raw_write_trylock(lock) ? \ | 129 | # define _raw_spin_lock_flags(lock, flags) \ |
247 | 1 : ({preempt_enable(); 0;});}) | 130 | __raw_spin_lock_flags(&(lock)->raw_lock, *(flags)) |
248 | 131 | # define _raw_read_lock(rwlock) __raw_read_lock(&(rwlock)->raw_lock) | |
249 | #define _spin_trylock_bh(lock) ({preempt_disable(); local_bh_disable(); \ | 132 | # define _raw_write_lock(rwlock) __raw_write_lock(&(rwlock)->raw_lock) |
250 | _raw_spin_trylock(lock) ? \ | 133 | # define _raw_read_unlock(rwlock) __raw_read_unlock(&(rwlock)->raw_lock) |
251 | 1 : ({preempt_enable_no_resched(); local_bh_enable(); 0;});}) | 134 | # define _raw_write_unlock(rwlock) __raw_write_unlock(&(rwlock)->raw_lock) |
252 | 135 | # define _raw_read_trylock(rwlock) __raw_read_trylock(&(rwlock)->raw_lock) | |
253 | #define _spin_lock(lock) \ | 136 | # define _raw_write_trylock(rwlock) __raw_write_trylock(&(rwlock)->raw_lock) |
254 | do { \ | 137 | #endif |
255 | preempt_disable(); \ | ||
256 | _raw_spin_lock(lock); \ | ||
257 | __acquire(lock); \ | ||
258 | } while(0) | ||
259 | |||
260 | #define _write_lock(lock) \ | ||
261 | do { \ | ||
262 | preempt_disable(); \ | ||
263 | _raw_write_lock(lock); \ | ||
264 | __acquire(lock); \ | ||
265 | } while(0) | ||
266 | |||
267 | #define _read_lock(lock) \ | ||
268 | do { \ | ||
269 | preempt_disable(); \ | ||
270 | _raw_read_lock(lock); \ | ||
271 | __acquire(lock); \ | ||
272 | } while(0) | ||
273 | |||
274 | #define _spin_unlock(lock) \ | ||
275 | do { \ | ||
276 | _raw_spin_unlock(lock); \ | ||
277 | preempt_enable(); \ | ||
278 | __release(lock); \ | ||
279 | } while (0) | ||
280 | |||
281 | #define _write_unlock(lock) \ | ||
282 | do { \ | ||
283 | _raw_write_unlock(lock); \ | ||
284 | preempt_enable(); \ | ||
285 | __release(lock); \ | ||
286 | } while(0) | ||
287 | |||
288 | #define _read_unlock(lock) \ | ||
289 | do { \ | ||
290 | _raw_read_unlock(lock); \ | ||
291 | preempt_enable(); \ | ||
292 | __release(lock); \ | ||
293 | } while(0) | ||
294 | |||
295 | #define _spin_lock_irqsave(lock, flags) \ | ||
296 | do { \ | ||
297 | local_irq_save(flags); \ | ||
298 | preempt_disable(); \ | ||
299 | _raw_spin_lock(lock); \ | ||
300 | __acquire(lock); \ | ||
301 | } while (0) | ||
302 | |||
303 | #define _spin_lock_irq(lock) \ | ||
304 | do { \ | ||
305 | local_irq_disable(); \ | ||
306 | preempt_disable(); \ | ||
307 | _raw_spin_lock(lock); \ | ||
308 | __acquire(lock); \ | ||
309 | } while (0) | ||
310 | |||
311 | #define _spin_lock_bh(lock) \ | ||
312 | do { \ | ||
313 | local_bh_disable(); \ | ||
314 | preempt_disable(); \ | ||
315 | _raw_spin_lock(lock); \ | ||
316 | __acquire(lock); \ | ||
317 | } while (0) | ||
318 | |||
319 | #define _read_lock_irqsave(lock, flags) \ | ||
320 | do { \ | ||
321 | local_irq_save(flags); \ | ||
322 | preempt_disable(); \ | ||
323 | _raw_read_lock(lock); \ | ||
324 | __acquire(lock); \ | ||
325 | } while (0) | ||
326 | |||
327 | #define _read_lock_irq(lock) \ | ||
328 | do { \ | ||
329 | local_irq_disable(); \ | ||
330 | preempt_disable(); \ | ||
331 | _raw_read_lock(lock); \ | ||
332 | __acquire(lock); \ | ||
333 | } while (0) | ||
334 | |||
335 | #define _read_lock_bh(lock) \ | ||
336 | do { \ | ||
337 | local_bh_disable(); \ | ||
338 | preempt_disable(); \ | ||
339 | _raw_read_lock(lock); \ | ||
340 | __acquire(lock); \ | ||
341 | } while (0) | ||
342 | |||
343 | #define _write_lock_irqsave(lock, flags) \ | ||
344 | do { \ | ||
345 | local_irq_save(flags); \ | ||
346 | preempt_disable(); \ | ||
347 | _raw_write_lock(lock); \ | ||
348 | __acquire(lock); \ | ||
349 | } while (0) | ||
350 | 138 | ||
351 | #define _write_lock_irq(lock) \ | 139 | #define read_can_lock(rwlock) __raw_read_can_lock(&(rwlock)->raw_lock) |
352 | do { \ | 140 | #define write_can_lock(rwlock) __raw_write_can_lock(&(rwlock)->raw_lock) |
353 | local_irq_disable(); \ | ||
354 | preempt_disable(); \ | ||
355 | _raw_write_lock(lock); \ | ||
356 | __acquire(lock); \ | ||
357 | } while (0) | ||
358 | |||
359 | #define _write_lock_bh(lock) \ | ||
360 | do { \ | ||
361 | local_bh_disable(); \ | ||
362 | preempt_disable(); \ | ||
363 | _raw_write_lock(lock); \ | ||
364 | __acquire(lock); \ | ||
365 | } while (0) | ||
366 | |||
367 | #define _spin_unlock_irqrestore(lock, flags) \ | ||
368 | do { \ | ||
369 | _raw_spin_unlock(lock); \ | ||
370 | local_irq_restore(flags); \ | ||
371 | preempt_enable(); \ | ||
372 | __release(lock); \ | ||
373 | } while (0) | ||
374 | |||
375 | #define _spin_unlock_irq(lock) \ | ||
376 | do { \ | ||
377 | _raw_spin_unlock(lock); \ | ||
378 | local_irq_enable(); \ | ||
379 | preempt_enable(); \ | ||
380 | __release(lock); \ | ||
381 | } while (0) | ||
382 | |||
383 | #define _spin_unlock_bh(lock) \ | ||
384 | do { \ | ||
385 | _raw_spin_unlock(lock); \ | ||
386 | preempt_enable_no_resched(); \ | ||
387 | local_bh_enable(); \ | ||
388 | __release(lock); \ | ||
389 | } while (0) | ||
390 | |||
391 | #define _write_unlock_bh(lock) \ | ||
392 | do { \ | ||
393 | _raw_write_unlock(lock); \ | ||
394 | preempt_enable_no_resched(); \ | ||
395 | local_bh_enable(); \ | ||
396 | __release(lock); \ | ||
397 | } while (0) | ||
398 | |||
399 | #define _read_unlock_irqrestore(lock, flags) \ | ||
400 | do { \ | ||
401 | _raw_read_unlock(lock); \ | ||
402 | local_irq_restore(flags); \ | ||
403 | preempt_enable(); \ | ||
404 | __release(lock); \ | ||
405 | } while (0) | ||
406 | |||
407 | #define _write_unlock_irqrestore(lock, flags) \ | ||
408 | do { \ | ||
409 | _raw_write_unlock(lock); \ | ||
410 | local_irq_restore(flags); \ | ||
411 | preempt_enable(); \ | ||
412 | __release(lock); \ | ||
413 | } while (0) | ||
414 | |||
415 | #define _read_unlock_irq(lock) \ | ||
416 | do { \ | ||
417 | _raw_read_unlock(lock); \ | ||
418 | local_irq_enable(); \ | ||
419 | preempt_enable(); \ | ||
420 | __release(lock); \ | ||
421 | } while (0) | ||
422 | |||
423 | #define _read_unlock_bh(lock) \ | ||
424 | do { \ | ||
425 | _raw_read_unlock(lock); \ | ||
426 | preempt_enable_no_resched(); \ | ||
427 | local_bh_enable(); \ | ||
428 | __release(lock); \ | ||
429 | } while (0) | ||
430 | |||
431 | #define _write_unlock_irq(lock) \ | ||
432 | do { \ | ||
433 | _raw_write_unlock(lock); \ | ||
434 | local_irq_enable(); \ | ||
435 | preempt_enable(); \ | ||
436 | __release(lock); \ | ||
437 | } while (0) | ||
438 | |||
439 | #endif /* !SMP */ | ||
440 | 141 | ||
441 | /* | 142 | /* |
442 | * Define the various spin_lock and rw_lock methods. Note we define these | 143 | * Define the various spin_lock and rw_lock methods. Note we define these |
443 | * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various | 144 | * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various |
444 | * methods are defined as nops in the case they are not required. | 145 | * methods are defined as nops in the case they are not required. |
445 | */ | 146 | */ |
446 | #define spin_trylock(lock) __cond_lock(_spin_trylock(lock)) | 147 | #define spin_trylock(lock) __cond_lock(_spin_trylock(lock)) |
447 | #define read_trylock(lock) __cond_lock(_read_trylock(lock)) | 148 | #define read_trylock(lock) __cond_lock(_read_trylock(lock)) |
448 | #define write_trylock(lock) __cond_lock(_write_trylock(lock)) | 149 | #define write_trylock(lock) __cond_lock(_write_trylock(lock)) |
449 | 150 | ||
450 | #define spin_lock(lock) _spin_lock(lock) | 151 | #define spin_lock(lock) _spin_lock(lock) |
451 | #define write_lock(lock) _write_lock(lock) | 152 | #define write_lock(lock) _write_lock(lock) |
452 | #define read_lock(lock) _read_lock(lock) | 153 | #define read_lock(lock) _read_lock(lock) |
453 | 154 | ||
454 | #ifdef CONFIG_SMP | 155 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) |
455 | #define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock) | 156 | #define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock) |
456 | #define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock) | 157 | #define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock) |
457 | #define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock) | 158 | #define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock) |
@@ -470,137 +171,59 @@ do { \ | |||
470 | #define write_lock_irq(lock) _write_lock_irq(lock) | 171 | #define write_lock_irq(lock) _write_lock_irq(lock) |
471 | #define write_lock_bh(lock) _write_lock_bh(lock) | 172 | #define write_lock_bh(lock) _write_lock_bh(lock) |
472 | 173 | ||
473 | #define spin_unlock(lock) _spin_unlock(lock) | 174 | #define spin_unlock(lock) _spin_unlock(lock) |
474 | #define write_unlock(lock) _write_unlock(lock) | 175 | #define write_unlock(lock) _write_unlock(lock) |
475 | #define read_unlock(lock) _read_unlock(lock) | 176 | #define read_unlock(lock) _read_unlock(lock) |
476 | 177 | ||
477 | #define spin_unlock_irqrestore(lock, flags) _spin_unlock_irqrestore(lock, flags) | 178 | #define spin_unlock_irqrestore(lock, flags) \ |
179 | _spin_unlock_irqrestore(lock, flags) | ||
478 | #define spin_unlock_irq(lock) _spin_unlock_irq(lock) | 180 | #define spin_unlock_irq(lock) _spin_unlock_irq(lock) |
479 | #define spin_unlock_bh(lock) _spin_unlock_bh(lock) | 181 | #define spin_unlock_bh(lock) _spin_unlock_bh(lock) |
480 | 182 | ||
481 | #define read_unlock_irqrestore(lock, flags) _read_unlock_irqrestore(lock, flags) | 183 | #define read_unlock_irqrestore(lock, flags) \ |
482 | #define read_unlock_irq(lock) _read_unlock_irq(lock) | 184 | _read_unlock_irqrestore(lock, flags) |
483 | #define read_unlock_bh(lock) _read_unlock_bh(lock) | 185 | #define read_unlock_irq(lock) _read_unlock_irq(lock) |
186 | #define read_unlock_bh(lock) _read_unlock_bh(lock) | ||
484 | 187 | ||
485 | #define write_unlock_irqrestore(lock, flags) _write_unlock_irqrestore(lock, flags) | 188 | #define write_unlock_irqrestore(lock, flags) \ |
486 | #define write_unlock_irq(lock) _write_unlock_irq(lock) | 189 | _write_unlock_irqrestore(lock, flags) |
487 | #define write_unlock_bh(lock) _write_unlock_bh(lock) | 190 | #define write_unlock_irq(lock) _write_unlock_irq(lock) |
191 | #define write_unlock_bh(lock) _write_unlock_bh(lock) | ||
488 | 192 | ||
489 | #define spin_trylock_bh(lock) __cond_lock(_spin_trylock_bh(lock)) | 193 | #define spin_trylock_bh(lock) __cond_lock(_spin_trylock_bh(lock)) |
490 | 194 | ||
491 | #define spin_trylock_irq(lock) \ | 195 | #define spin_trylock_irq(lock) \ |
492 | ({ \ | 196 | ({ \ |
493 | local_irq_disable(); \ | 197 | local_irq_disable(); \ |
494 | _spin_trylock(lock) ? \ | 198 | _spin_trylock(lock) ? \ |
495 | 1 : ({local_irq_enable(); 0; }); \ | 199 | 1 : ({ local_irq_enable(); 0; }); \ |
496 | }) | 200 | }) |
497 | 201 | ||
498 | #define spin_trylock_irqsave(lock, flags) \ | 202 | #define spin_trylock_irqsave(lock, flags) \ |
499 | ({ \ | 203 | ({ \ |
500 | local_irq_save(flags); \ | 204 | local_irq_save(flags); \ |
501 | _spin_trylock(lock) ? \ | 205 | _spin_trylock(lock) ? \ |
502 | 1 : ({local_irq_restore(flags); 0;}); \ | 206 | 1 : ({ local_irq_restore(flags); 0; }); \ |
503 | }) | 207 | }) |
504 | 208 | ||
505 | #ifdef CONFIG_LOCKMETER | ||
506 | extern void _metered_spin_lock (spinlock_t *lock); | ||
507 | extern void _metered_spin_unlock (spinlock_t *lock); | ||
508 | extern int _metered_spin_trylock(spinlock_t *lock); | ||
509 | extern void _metered_read_lock (rwlock_t *lock); | ||
510 | extern void _metered_read_unlock (rwlock_t *lock); | ||
511 | extern void _metered_write_lock (rwlock_t *lock); | ||
512 | extern void _metered_write_unlock (rwlock_t *lock); | ||
513 | extern int _metered_read_trylock (rwlock_t *lock); | ||
514 | extern int _metered_write_trylock(rwlock_t *lock); | ||
515 | #endif | ||
516 | |||
517 | /* "lock on reference count zero" */ | ||
518 | #ifndef ATOMIC_DEC_AND_LOCK | ||
519 | #include <asm/atomic.h> | ||
520 | extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); | ||
521 | #endif | ||
522 | |||
523 | #define atomic_dec_and_lock(atomic,lock) __cond_lock(_atomic_dec_and_lock(atomic,lock)) | ||
524 | |||
525 | /* | ||
526 | * bit-based spin_lock() | ||
527 | * | ||
528 | * Don't use this unless you really need to: spin_lock() and spin_unlock() | ||
529 | * are significantly faster. | ||
530 | */ | ||
531 | static inline void bit_spin_lock(int bitnum, unsigned long *addr) | ||
532 | { | ||
533 | /* | ||
534 | * Assuming the lock is uncontended, this never enters | ||
535 | * the body of the outer loop. If it is contended, then | ||
536 | * within the inner loop a non-atomic test is used to | ||
537 | * busywait with less bus contention for a good time to | ||
538 | * attempt to acquire the lock bit. | ||
539 | */ | ||
540 | preempt_disable(); | ||
541 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
542 | while (test_and_set_bit(bitnum, addr)) { | ||
543 | while (test_bit(bitnum, addr)) { | ||
544 | preempt_enable(); | ||
545 | cpu_relax(); | ||
546 | preempt_disable(); | ||
547 | } | ||
548 | } | ||
549 | #endif | ||
550 | __acquire(bitlock); | ||
551 | } | ||
552 | |||
553 | /* | 209 | /* |
554 | * Return true if it was acquired | 210 | * Pull the atomic_t declaration: |
211 | * (asm-mips/atomic.h needs above definitions) | ||
555 | */ | 212 | */ |
556 | static inline int bit_spin_trylock(int bitnum, unsigned long *addr) | 213 | #include <asm/atomic.h> |
557 | { | 214 | /** |
558 | preempt_disable(); | 215 | * atomic_dec_and_lock - lock on reaching reference count zero |
559 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | 216 | * @atomic: the atomic counter |
560 | if (test_and_set_bit(bitnum, addr)) { | 217 | * @lock: the spinlock in question |
561 | preempt_enable(); | ||
562 | return 0; | ||
563 | } | ||
564 | #endif | ||
565 | __acquire(bitlock); | ||
566 | return 1; | ||
567 | } | ||
568 | |||
569 | /* | ||
570 | * bit-based spin_unlock() | ||
571 | */ | ||
572 | static inline void bit_spin_unlock(int bitnum, unsigned long *addr) | ||
573 | { | ||
574 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
575 | BUG_ON(!test_bit(bitnum, addr)); | ||
576 | smp_mb__before_clear_bit(); | ||
577 | clear_bit(bitnum, addr); | ||
578 | #endif | ||
579 | preempt_enable(); | ||
580 | __release(bitlock); | ||
581 | } | ||
582 | |||
583 | /* | ||
584 | * Return true if the lock is held. | ||
585 | */ | 218 | */ |
586 | static inline int bit_spin_is_locked(int bitnum, unsigned long *addr) | 219 | extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); |
587 | { | 220 | #define atomic_dec_and_lock(atomic, lock) \ |
588 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | 221 | __cond_lock(_atomic_dec_and_lock(atomic, lock)) |
589 | return test_bit(bitnum, addr); | ||
590 | #elif defined CONFIG_PREEMPT | ||
591 | return preempt_count(); | ||
592 | #else | ||
593 | return 1; | ||
594 | #endif | ||
595 | } | ||
596 | |||
597 | #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED | ||
598 | #define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED | ||
599 | 222 | ||
600 | /** | 223 | /** |
601 | * spin_can_lock - would spin_trylock() succeed? | 224 | * spin_can_lock - would spin_trylock() succeed? |
602 | * @lock: the spinlock in question. | 225 | * @lock: the spinlock in question. |
603 | */ | 226 | */ |
604 | #define spin_can_lock(lock) (!spin_is_locked(lock)) | 227 | #define spin_can_lock(lock) (!spin_is_locked(lock)) |
605 | 228 | ||
606 | #endif /* __LINUX_SPINLOCK_H */ | 229 | #endif /* __LINUX_SPINLOCK_H */ |
diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_smp.h new file mode 100644 index 000000000000..78e6989ffb54 --- /dev/null +++ b/include/linux/spinlock_api_smp.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #ifndef __LINUX_SPINLOCK_API_SMP_H | ||
2 | #define __LINUX_SPINLOCK_API_SMP_H | ||
3 | |||
4 | #ifndef __LINUX_SPINLOCK_H | ||
5 | # error "please don't include this file directly" | ||
6 | #endif | ||
7 | |||
8 | /* | ||
9 | * include/linux/spinlock_api_smp.h | ||
10 | * | ||
11 | * spinlock API declarations on SMP (and debug) | ||
12 | * (implemented in kernel/spinlock.c) | ||
13 | * | ||
14 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
15 | * Released under the General Public License (GPL). | ||
16 | */ | ||
17 | |||
18 | int in_lock_functions(unsigned long addr); | ||
19 | |||
20 | #define assert_spin_locked(x) BUG_ON(!spin_is_locked(x)) | ||
21 | |||
22 | void __lockfunc _spin_lock(spinlock_t *lock) __acquires(spinlock_t); | ||
23 | void __lockfunc _read_lock(rwlock_t *lock) __acquires(rwlock_t); | ||
24 | void __lockfunc _write_lock(rwlock_t *lock) __acquires(rwlock_t); | ||
25 | void __lockfunc _spin_lock_bh(spinlock_t *lock) __acquires(spinlock_t); | ||
26 | void __lockfunc _read_lock_bh(rwlock_t *lock) __acquires(rwlock_t); | ||
27 | void __lockfunc _write_lock_bh(rwlock_t *lock) __acquires(rwlock_t); | ||
28 | void __lockfunc _spin_lock_irq(spinlock_t *lock) __acquires(spinlock_t); | ||
29 | void __lockfunc _read_lock_irq(rwlock_t *lock) __acquires(rwlock_t); | ||
30 | void __lockfunc _write_lock_irq(rwlock_t *lock) __acquires(rwlock_t); | ||
31 | unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock) | ||
32 | __acquires(spinlock_t); | ||
33 | unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock) | ||
34 | __acquires(rwlock_t); | ||
35 | unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock) | ||
36 | __acquires(rwlock_t); | ||
37 | int __lockfunc _spin_trylock(spinlock_t *lock); | ||
38 | int __lockfunc _read_trylock(rwlock_t *lock); | ||
39 | int __lockfunc _write_trylock(rwlock_t *lock); | ||
40 | int __lockfunc _spin_trylock_bh(spinlock_t *lock); | ||
41 | void __lockfunc _spin_unlock(spinlock_t *lock) __releases(spinlock_t); | ||
42 | void __lockfunc _read_unlock(rwlock_t *lock) __releases(rwlock_t); | ||
43 | void __lockfunc _write_unlock(rwlock_t *lock) __releases(rwlock_t); | ||
44 | void __lockfunc _spin_unlock_bh(spinlock_t *lock) __releases(spinlock_t); | ||
45 | void __lockfunc _read_unlock_bh(rwlock_t *lock) __releases(rwlock_t); | ||
46 | void __lockfunc _write_unlock_bh(rwlock_t *lock) __releases(rwlock_t); | ||
47 | void __lockfunc _spin_unlock_irq(spinlock_t *lock) __releases(spinlock_t); | ||
48 | void __lockfunc _read_unlock_irq(rwlock_t *lock) __releases(rwlock_t); | ||
49 | void __lockfunc _write_unlock_irq(rwlock_t *lock) __releases(rwlock_t); | ||
50 | void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) | ||
51 | __releases(spinlock_t); | ||
52 | void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) | ||
53 | __releases(rwlock_t); | ||
54 | void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) | ||
55 | __releases(rwlock_t); | ||
56 | |||
57 | #endif /* __LINUX_SPINLOCK_API_SMP_H */ | ||
diff --git a/include/linux/spinlock_api_up.h b/include/linux/spinlock_api_up.h new file mode 100644 index 000000000000..cd81cee566f4 --- /dev/null +++ b/include/linux/spinlock_api_up.h | |||
@@ -0,0 +1,80 @@ | |||
1 | #ifndef __LINUX_SPINLOCK_API_UP_H | ||
2 | #define __LINUX_SPINLOCK_API_UP_H | ||
3 | |||
4 | #ifndef __LINUX_SPINLOCK_H | ||
5 | # error "please don't include this file directly" | ||
6 | #endif | ||
7 | |||
8 | /* | ||
9 | * include/linux/spinlock_api_up.h | ||
10 | * | ||
11 | * spinlock API implementation on UP-nondebug (inlined implementation) | ||
12 | * | ||
13 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
14 | * Released under the General Public License (GPL). | ||
15 | */ | ||
16 | |||
17 | #define in_lock_functions(ADDR) 0 | ||
18 | |||
19 | #define assert_spin_locked(lock) do { (void)(lock); } while (0) | ||
20 | |||
21 | /* | ||
22 | * In the UP-nondebug case there's no real locking going on, so the | ||
23 | * only thing we have to do is to keep the preempt counts and irq | ||
24 | * flags straight, to supress compiler warnings of unused lock | ||
25 | * variables, and to add the proper checker annotations: | ||
26 | */ | ||
27 | #define __LOCK(lock) \ | ||
28 | do { preempt_disable(); __acquire(lock); (void)(lock); } while (0) | ||
29 | |||
30 | #define __LOCK_BH(lock) \ | ||
31 | do { local_bh_disable(); __LOCK(lock); } while (0) | ||
32 | |||
33 | #define __LOCK_IRQ(lock) \ | ||
34 | do { local_irq_disable(); __LOCK(lock); } while (0) | ||
35 | |||
36 | #define __LOCK_IRQSAVE(lock, flags) \ | ||
37 | do { local_irq_save(flags); __LOCK(lock); } while (0) | ||
38 | |||
39 | #define __UNLOCK(lock) \ | ||
40 | do { preempt_enable(); __release(lock); (void)(lock); } while (0) | ||
41 | |||
42 | #define __UNLOCK_BH(lock) \ | ||
43 | do { preempt_enable_no_resched(); local_bh_enable(); __release(lock); (void)(lock); } while (0) | ||
44 | |||
45 | #define __UNLOCK_IRQ(lock) \ | ||
46 | do { local_irq_enable(); __UNLOCK(lock); } while (0) | ||
47 | |||
48 | #define __UNLOCK_IRQRESTORE(lock, flags) \ | ||
49 | do { local_irq_restore(flags); __UNLOCK(lock); } while (0) | ||
50 | |||
51 | #define _spin_lock(lock) __LOCK(lock) | ||
52 | #define _read_lock(lock) __LOCK(lock) | ||
53 | #define _write_lock(lock) __LOCK(lock) | ||
54 | #define _spin_lock_bh(lock) __LOCK_BH(lock) | ||
55 | #define _read_lock_bh(lock) __LOCK_BH(lock) | ||
56 | #define _write_lock_bh(lock) __LOCK_BH(lock) | ||
57 | #define _spin_lock_irq(lock) __LOCK_IRQ(lock) | ||
58 | #define _read_lock_irq(lock) __LOCK_IRQ(lock) | ||
59 | #define _write_lock_irq(lock) __LOCK_IRQ(lock) | ||
60 | #define _spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags) | ||
61 | #define _read_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags) | ||
62 | #define _write_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags) | ||
63 | #define _spin_trylock(lock) ({ __LOCK(lock); 1; }) | ||
64 | #define _read_trylock(lock) ({ __LOCK(lock); 1; }) | ||
65 | #define _write_trylock(lock) ({ __LOCK(lock); 1; }) | ||
66 | #define _spin_trylock_bh(lock) ({ __LOCK_BH(lock); 1; }) | ||
67 | #define _spin_unlock(lock) __UNLOCK(lock) | ||
68 | #define _read_unlock(lock) __UNLOCK(lock) | ||
69 | #define _write_unlock(lock) __UNLOCK(lock) | ||
70 | #define _spin_unlock_bh(lock) __UNLOCK_BH(lock) | ||
71 | #define _write_unlock_bh(lock) __UNLOCK_BH(lock) | ||
72 | #define _read_unlock_bh(lock) __UNLOCK_BH(lock) | ||
73 | #define _spin_unlock_irq(lock) __UNLOCK_IRQ(lock) | ||
74 | #define _read_unlock_irq(lock) __UNLOCK_IRQ(lock) | ||
75 | #define _write_unlock_irq(lock) __UNLOCK_IRQ(lock) | ||
76 | #define _spin_unlock_irqrestore(lock, flags) __UNLOCK_IRQRESTORE(lock, flags) | ||
77 | #define _read_unlock_irqrestore(lock, flags) __UNLOCK_IRQRESTORE(lock, flags) | ||
78 | #define _write_unlock_irqrestore(lock, flags) __UNLOCK_IRQRESTORE(lock, flags) | ||
79 | |||
80 | #endif /* __LINUX_SPINLOCK_API_UP_H */ | ||
diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h new file mode 100644 index 000000000000..9cb51e070390 --- /dev/null +++ b/include/linux/spinlock_types.h | |||
@@ -0,0 +1,67 @@ | |||
1 | #ifndef __LINUX_SPINLOCK_TYPES_H | ||
2 | #define __LINUX_SPINLOCK_TYPES_H | ||
3 | |||
4 | /* | ||
5 | * include/linux/spinlock_types.h - generic spinlock type definitions | ||
6 | * and initializers | ||
7 | * | ||
8 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
9 | * Released under the General Public License (GPL). | ||
10 | */ | ||
11 | |||
12 | #if defined(CONFIG_SMP) | ||
13 | # include <asm/spinlock_types.h> | ||
14 | #else | ||
15 | # include <linux/spinlock_types_up.h> | ||
16 | #endif | ||
17 | |||
18 | typedef struct { | ||
19 | raw_spinlock_t raw_lock; | ||
20 | #if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) | ||
21 | unsigned int break_lock; | ||
22 | #endif | ||
23 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
24 | unsigned int magic, owner_cpu; | ||
25 | void *owner; | ||
26 | #endif | ||
27 | } spinlock_t; | ||
28 | |||
29 | #define SPINLOCK_MAGIC 0xdead4ead | ||
30 | |||
31 | typedef struct { | ||
32 | raw_rwlock_t raw_lock; | ||
33 | #if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) | ||
34 | unsigned int break_lock; | ||
35 | #endif | ||
36 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
37 | unsigned int magic, owner_cpu; | ||
38 | void *owner; | ||
39 | #endif | ||
40 | } rwlock_t; | ||
41 | |||
42 | #define RWLOCK_MAGIC 0xdeaf1eed | ||
43 | |||
44 | #define SPINLOCK_OWNER_INIT ((void *)-1L) | ||
45 | |||
46 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
47 | # define SPIN_LOCK_UNLOCKED \ | ||
48 | (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \ | ||
49 | .magic = SPINLOCK_MAGIC, \ | ||
50 | .owner = SPINLOCK_OWNER_INIT, \ | ||
51 | .owner_cpu = -1 } | ||
52 | #define RW_LOCK_UNLOCKED \ | ||
53 | (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED, \ | ||
54 | .magic = RWLOCK_MAGIC, \ | ||
55 | .owner = SPINLOCK_OWNER_INIT, \ | ||
56 | .owner_cpu = -1 } | ||
57 | #else | ||
58 | # define SPIN_LOCK_UNLOCKED \ | ||
59 | (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED } | ||
60 | #define RW_LOCK_UNLOCKED \ | ||
61 | (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED } | ||
62 | #endif | ||
63 | |||
64 | #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED | ||
65 | #define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED | ||
66 | |||
67 | #endif /* __LINUX_SPINLOCK_TYPES_H */ | ||
diff --git a/include/linux/spinlock_types_up.h b/include/linux/spinlock_types_up.h new file mode 100644 index 000000000000..def2d173a8db --- /dev/null +++ b/include/linux/spinlock_types_up.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef __LINUX_SPINLOCK_TYPES_UP_H | ||
2 | #define __LINUX_SPINLOCK_TYPES_UP_H | ||
3 | |||
4 | #ifndef __LINUX_SPINLOCK_TYPES_H | ||
5 | # error "please don't include this file directly" | ||
6 | #endif | ||
7 | |||
8 | /* | ||
9 | * include/linux/spinlock_types_up.h - spinlock type definitions for UP | ||
10 | * | ||
11 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
12 | * Released under the General Public License (GPL). | ||
13 | */ | ||
14 | |||
15 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
16 | |||
17 | typedef struct { | ||
18 | volatile unsigned int slock; | ||
19 | } raw_spinlock_t; | ||
20 | |||
21 | #define __RAW_SPIN_LOCK_UNLOCKED { 1 } | ||
22 | |||
23 | #else | ||
24 | |||
25 | /* | ||
26 | * All gcc 2.95 versions and early versions of 2.96 have a nasty bug | ||
27 | * with empty initializers. | ||
28 | */ | ||
29 | #if (__GNUC__ > 2) | ||
30 | typedef struct { } raw_spinlock_t; | ||
31 | |||
32 | #define __RAW_SPIN_LOCK_UNLOCKED { } | ||
33 | #else | ||
34 | typedef struct { int gcc_is_buggy; } raw_spinlock_t; | ||
35 | #define __RAW_SPIN_LOCK_UNLOCKED (raw_spinlock_t) { 0 } | ||
36 | #endif | ||
37 | |||
38 | #endif | ||
39 | |||
40 | #if (__GNUC__ > 2) | ||
41 | typedef struct { | ||
42 | /* no debug version on UP */ | ||
43 | } raw_rwlock_t; | ||
44 | |||
45 | #define __RAW_RW_LOCK_UNLOCKED { } | ||
46 | #else | ||
47 | typedef struct { int gcc_is_buggy; } raw_rwlock_t; | ||
48 | #define __RAW_RW_LOCK_UNLOCKED (raw_rwlock_t) { 0 } | ||
49 | #endif | ||
50 | |||
51 | #endif /* __LINUX_SPINLOCK_TYPES_UP_H */ | ||
diff --git a/include/linux/spinlock_up.h b/include/linux/spinlock_up.h new file mode 100644 index 000000000000..31accf2f0b13 --- /dev/null +++ b/include/linux/spinlock_up.h | |||
@@ -0,0 +1,74 @@ | |||
1 | #ifndef __LINUX_SPINLOCK_UP_H | ||
2 | #define __LINUX_SPINLOCK_UP_H | ||
3 | |||
4 | #ifndef __LINUX_SPINLOCK_H | ||
5 | # error "please don't include this file directly" | ||
6 | #endif | ||
7 | |||
8 | /* | ||
9 | * include/linux/spinlock_up.h - UP-debug version of spinlocks. | ||
10 | * | ||
11 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
12 | * Released under the General Public License (GPL). | ||
13 | * | ||
14 | * In the debug case, 1 means unlocked, 0 means locked. (the values | ||
15 | * are inverted, to catch initialization bugs) | ||
16 | * | ||
17 | * No atomicity anywhere, we are on UP. | ||
18 | */ | ||
19 | |||
20 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
21 | |||
22 | #define __raw_spin_is_locked(x) ((x)->slock == 0) | ||
23 | |||
24 | static inline void __raw_spin_lock(raw_spinlock_t *lock) | ||
25 | { | ||
26 | lock->slock = 0; | ||
27 | } | ||
28 | |||
29 | static inline void | ||
30 | __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags) | ||
31 | { | ||
32 | local_irq_save(flags); | ||
33 | lock->slock = 0; | ||
34 | } | ||
35 | |||
36 | static inline int __raw_spin_trylock(raw_spinlock_t *lock) | ||
37 | { | ||
38 | char oldval = lock->slock; | ||
39 | |||
40 | lock->slock = 0; | ||
41 | |||
42 | return oldval > 0; | ||
43 | } | ||
44 | |||
45 | static inline void __raw_spin_unlock(raw_spinlock_t *lock) | ||
46 | { | ||
47 | lock->slock = 1; | ||
48 | } | ||
49 | |||
50 | /* | ||
51 | * Read-write spinlocks. No debug version. | ||
52 | */ | ||
53 | #define __raw_read_lock(lock) do { (void)(lock); } while (0) | ||
54 | #define __raw_write_lock(lock) do { (void)(lock); } while (0) | ||
55 | #define __raw_read_trylock(lock) ({ (void)(lock); 1; }) | ||
56 | #define __raw_write_trylock(lock) ({ (void)(lock); 1; }) | ||
57 | #define __raw_read_unlock(lock) do { (void)(lock); } while (0) | ||
58 | #define __raw_write_unlock(lock) do { (void)(lock); } while (0) | ||
59 | |||
60 | #else /* DEBUG_SPINLOCK */ | ||
61 | #define __raw_spin_is_locked(lock) ((void)(lock), 0) | ||
62 | /* for sched.c and kernel_lock.c: */ | ||
63 | # define __raw_spin_lock(lock) do { (void)(lock); } while (0) | ||
64 | # define __raw_spin_unlock(lock) do { (void)(lock); } while (0) | ||
65 | # define __raw_spin_trylock(lock) ({ (void)(lock); 1; }) | ||
66 | #endif /* DEBUG_SPINLOCK */ | ||
67 | |||
68 | #define __raw_read_can_lock(lock) (((void)(lock), 1)) | ||
69 | #define __raw_write_can_lock(lock) (((void)(lock), 1)) | ||
70 | |||
71 | #define __raw_spin_unlock_wait(lock) \ | ||
72 | do { cpu_relax(); } while (__raw_spin_is_locked(lock)) | ||
73 | |||
74 | #endif /* __LINUX_SPINLOCK_UP_H */ | ||
diff --git a/include/linux/time.h b/include/linux/time.h index c10d4c21c183..8e83f4e778bb 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -28,17 +28,10 @@ struct timezone { | |||
28 | #ifdef __KERNEL__ | 28 | #ifdef __KERNEL__ |
29 | 29 | ||
30 | /* Parameters used to convert the timespec values */ | 30 | /* Parameters used to convert the timespec values */ |
31 | #ifndef USEC_PER_SEC | 31 | #define MSEC_PER_SEC (1000L) |
32 | #define USEC_PER_SEC (1000000L) | 32 | #define USEC_PER_SEC (1000000L) |
33 | #endif | ||
34 | |||
35 | #ifndef NSEC_PER_SEC | ||
36 | #define NSEC_PER_SEC (1000000000L) | 33 | #define NSEC_PER_SEC (1000000000L) |
37 | #endif | ||
38 | |||
39 | #ifndef NSEC_PER_USEC | ||
40 | #define NSEC_PER_USEC (1000L) | 34 | #define NSEC_PER_USEC (1000L) |
41 | #endif | ||
42 | 35 | ||
43 | static __inline__ int timespec_equal(struct timespec *a, struct timespec *b) | 36 | static __inline__ int timespec_equal(struct timespec *a, struct timespec *b) |
44 | { | 37 | { |
diff --git a/include/linux/timer.h b/include/linux/timer.h index 221f81ac2002..3340f3bd135d 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h | |||
@@ -32,6 +32,10 @@ extern struct timer_base_s __init_timer_base; | |||
32 | .magic = TIMER_MAGIC, \ | 32 | .magic = TIMER_MAGIC, \ |
33 | } | 33 | } |
34 | 34 | ||
35 | #define DEFINE_TIMER(_name, _function, _expires, _data) \ | ||
36 | struct timer_list _name = \ | ||
37 | TIMER_INITIALIZER(_function, _expires, _data) | ||
38 | |||
35 | void fastcall init_timer(struct timer_list * timer); | 39 | void fastcall init_timer(struct timer_list * timer); |
36 | 40 | ||
37 | /*** | 41 | /*** |
diff --git a/include/linux/tty.h b/include/linux/tty.h index 59ff42c629ec..1267f88ece6e 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -74,7 +74,8 @@ struct screen_info { | |||
74 | u16 vesapm_off; /* 0x30 */ | 74 | u16 vesapm_off; /* 0x30 */ |
75 | u16 pages; /* 0x32 */ | 75 | u16 pages; /* 0x32 */ |
76 | u16 vesa_attributes; /* 0x34 */ | 76 | u16 vesa_attributes; /* 0x34 */ |
77 | /* 0x36 -- 0x3f reserved for future expansion */ | 77 | u32 capabilities; /* 0x36 */ |
78 | /* 0x3a -- 0x3f reserved for future expansion */ | ||
78 | }; | 79 | }; |
79 | 80 | ||
80 | extern struct screen_info screen_info; | 81 | extern struct screen_info screen_info; |
diff --git a/include/linux/videodev.h b/include/linux/videodev.h index 9d6fbde3d29c..1cc8c31b7988 100644 --- a/include/linux/videodev.h +++ b/include/linux/videodev.h | |||
@@ -3,7 +3,6 @@ | |||
3 | 3 | ||
4 | #include <linux/compiler.h> | 4 | #include <linux/compiler.h> |
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <linux/version.h> | ||
7 | 6 | ||
8 | #define HAVE_V4L2 1 | 7 | #define HAVE_V4L2 1 |
9 | #include <linux/videodev2.h> | 8 | #include <linux/videodev2.h> |
@@ -29,7 +28,6 @@ struct video_device | |||
29 | void (*release)(struct video_device *vfd); | 28 | void (*release)(struct video_device *vfd); |
30 | 29 | ||
31 | 30 | ||
32 | #if 1 /* to be removed in 2.7.x */ | ||
33 | /* obsolete -- fops->owner is used instead */ | 31 | /* obsolete -- fops->owner is used instead */ |
34 | struct module *owner; | 32 | struct module *owner; |
35 | /* dev->driver_data will be used instead some day. | 33 | /* dev->driver_data will be used instead some day. |
@@ -37,7 +35,6 @@ struct video_device | |||
37 | * so the switch over will be transparent for you. | 35 | * so the switch over will be transparent for you. |
38 | * Or use {pci|usb}_{get|set}_drvdata() directly. */ | 36 | * Or use {pci|usb}_{get|set}_drvdata() directly. */ |
39 | void *priv; | 37 | void *priv; |
40 | #endif | ||
41 | 38 | ||
42 | /* for videodev.c intenal usage -- please don't touch */ | 39 | /* for videodev.c intenal usage -- please don't touch */ |
43 | int users; /* video_exclusive_{open|close} ... */ | 40 | int users; /* video_exclusive_{open|close} ... */ |
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index acbfc525576d..f623a33b9abe 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h | |||
@@ -270,7 +270,6 @@ struct v4l2_timecode | |||
270 | /* The above is based on SMPTE timecodes */ | 270 | /* The above is based on SMPTE timecodes */ |
271 | 271 | ||
272 | 272 | ||
273 | #if 1 | ||
274 | /* | 273 | /* |
275 | * M P E G C O M P R E S S I O N P A R A M E T E R S | 274 | * M P E G C O M P R E S S I O N P A R A M E T E R S |
276 | * | 275 | * |
@@ -357,7 +356,6 @@ struct v4l2_mpeg_compression { | |||
357 | /* I don't expect the above being perfect yet ;) */ | 356 | /* I don't expect the above being perfect yet ;) */ |
358 | __u32 reserved_5[8]; | 357 | __u32 reserved_5[8]; |
359 | }; | 358 | }; |
360 | #endif | ||
361 | 359 | ||
362 | struct v4l2_jpegcompression | 360 | struct v4l2_jpegcompression |
363 | { | 361 | { |
@@ -871,10 +869,8 @@ struct v4l2_streamparm | |||
871 | #define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) | 869 | #define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) |
872 | #define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) | 870 | #define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) |
873 | #define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) | 871 | #define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) |
874 | #if 1 /* experimental */ | ||
875 | #define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression) | 872 | #define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression) |
876 | #define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression) | 873 | #define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression) |
877 | #endif | ||
878 | #define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) | 874 | #define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) |
879 | #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) | 875 | #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) |
880 | #define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) | 876 | #define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) |
diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 542dbaee6512..343d883d69c5 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h | |||
@@ -109,8 +109,6 @@ int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0); | |||
109 | int do_writepages(struct address_space *mapping, struct writeback_control *wbc); | 109 | int do_writepages(struct address_space *mapping, struct writeback_control *wbc); |
110 | int sync_page_range(struct inode *inode, struct address_space *mapping, | 110 | int sync_page_range(struct inode *inode, struct address_space *mapping, |
111 | loff_t pos, size_t count); | 111 | loff_t pos, size_t count); |
112 | int sync_page_range_nolock(struct inode *inode, struct address_space | ||
113 | *mapping, loff_t pos, size_t count); | ||
114 | 112 | ||
115 | /* pdflush.c */ | 113 | /* pdflush.c */ |
116 | extern int nr_pdflush_threads; /* Global so it can be exported to sysctl | 114 | extern int nr_pdflush_threads; /* Global so it can be exported to sysctl |