aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-alpha/io.h13
-rw-r--r--include/asm-arm/arch-versatile/hardware.h4
-rw-r--r--include/asm-arm/io.h17
-rw-r--r--include/asm-arm/uaccess.h2
-rw-r--r--include/asm-avr32/irq_regs.h1
-rw-r--r--include/asm-frv/io.h21
-rw-r--r--include/asm-generic/bitops/sched.h2
-rw-r--r--include/asm-i386/io.h27
-rw-r--r--include/asm-i386/uaccess.h67
-rw-r--r--include/asm-i386/unistd.h3
-rw-r--r--include/asm-m32r/io.h32
-rw-r--r--include/asm-m68k/uaccess.h16
-rw-r--r--include/asm-mips/io.h26
-rw-r--r--include/asm-powerpc/io.h26
-rw-r--r--include/asm-ppc/io.h16
-rw-r--r--include/asm-sh/io.h16
-rw-r--r--include/asm-sh64/io.h16
-rw-r--r--include/asm-sparc64/io.h15
-rw-r--r--include/asm-x86_64/io.h27
-rw-r--r--include/linux/bitmap.h13
-rw-r--r--include/linux/carta_random32.h29
-rw-r--r--include/linux/compat_ioctl.h24
-rw-r--r--include/linux/cpumask.h14
-rw-r--r--include/linux/dcache.h1
-rw-r--r--include/linux/ext4_fs.h994
-rw-r--r--include/linux/ext4_fs_extents.h198
-rw-r--r--include/linux/ext4_fs_i.h158
-rw-r--r--include/linux/ext4_fs_sb.h94
-rw-r--r--include/linux/ext4_jbd2.h273
-rw-r--r--include/linux/hugetlb.h1
-rw-r--r--include/linux/io.h27
-rw-r--r--include/linux/jbd2.h1107
-rw-r--r--include/linux/magic.h1
-rw-r--r--include/linux/mm.h7
-rw-r--r--include/linux/module.h3
-rw-r--r--include/linux/nbd.h2
-rw-r--r--include/linux/nodemask.h14
-rw-r--r--include/linux/syscalls.h4
38 files changed, 2979 insertions, 332 deletions
diff --git a/include/asm-alpha/io.h b/include/asm-alpha/io.h
index f5ae98c25d1f..5d15af24573b 100644
--- a/include/asm-alpha/io.h
+++ b/include/asm-alpha/io.h
@@ -533,19 +533,6 @@ extern void outsl (unsigned long port, const void *src, unsigned long count);
533#define eth_io_copy_and_sum(skb,src,len,unused) \ 533#define eth_io_copy_and_sum(skb,src,len,unused) \
534 memcpy_fromio((skb)->data,src,len) 534 memcpy_fromio((skb)->data,src,len)
535 535
536static inline int
537check_signature(const volatile void __iomem *io_addr,
538 const unsigned char *signature, int length)
539{
540 do {
541 if (readb(io_addr) != *signature)
542 return 0;
543 io_addr++;
544 signature++;
545 } while (--length);
546 return 1;
547}
548
549/* 536/*
550 * The Alpha Jensen hardware for some rather strange reason puts 537 * The Alpha Jensen hardware for some rather strange reason puts
551 * the RTC clock at 0x170 instead of 0x70. Probably due to some 538 * the RTC clock at 0x170 instead of 0x70. Probably due to some
diff --git a/include/asm-arm/arch-versatile/hardware.h b/include/asm-arm/arch-versatile/hardware.h
index 41c1bee342ad..edc06598d187 100644
--- a/include/asm-arm/arch-versatile/hardware.h
+++ b/include/asm-arm/arch-versatile/hardware.h
@@ -28,8 +28,8 @@
28/* 28/*
29 * PCI space virtual addresses 29 * PCI space virtual addresses
30 */ 30 */
31#define VERSATILE_PCI_VIRT_BASE 0xe8000000 31#define VERSATILE_PCI_VIRT_BASE (void __iomem *)0xe8000000ul
32#define VERSATILE_PCI_CFG_VIRT_BASE 0xe9000000 32#define VERSATILE_PCI_CFG_VIRT_BASE (void __iomem *)0xe9000000ul
33 33
34#if 0 34#if 0
35#define VERSATILE_PCI_VIRT_MEM_BASE0 0xf4000000 35#define VERSATILE_PCI_VIRT_MEM_BASE0 0xf4000000
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index 34aaaac4f617..ae999fd5dc67 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -193,23 +193,6 @@ extern void _memset_io(volatile void __iomem *, int, size_t);
193#define eth_io_copy_and_sum(s,c,l,b) \ 193#define eth_io_copy_and_sum(s,c,l,b) \
194 eth_copy_and_sum((s),__mem_pci(c),(l),(b)) 194 eth_copy_and_sum((s),__mem_pci(c),(l),(b))
195 195
196static inline int
197check_signature(void __iomem *io_addr, const unsigned char *signature,
198 int length)
199{
200 int retval = 0;
201 do {
202 if (readb(io_addr) != *signature)
203 goto out;
204 io_addr++;
205 signature++;
206 length--;
207 } while (length);
208 retval = 1;
209out:
210 return retval;
211}
212
213#elif !defined(readb) 196#elif !defined(readb)
214 197
215#define readb(c) (__readwrite_bug("readb"),0) 198#define readb(c) (__readwrite_bug("readb"),0)
diff --git a/include/asm-arm/uaccess.h b/include/asm-arm/uaccess.h
index 87aba57a66c4..09ad0cab9014 100644
--- a/include/asm-arm/uaccess.h
+++ b/include/asm-arm/uaccess.h
@@ -110,7 +110,7 @@ extern int __get_user_4(void *);
110#define get_user(x,p) \ 110#define get_user(x,p) \
111 ({ \ 111 ({ \
112 const register typeof(*(p)) __user *__p asm("r0") = (p);\ 112 const register typeof(*(p)) __user *__p asm("r0") = (p);\
113 register unsigned int __r2 asm("r2"); \ 113 register unsigned long __r2 asm("r2"); \
114 register int __e asm("r0"); \ 114 register int __e asm("r0"); \
115 switch (sizeof(*(__p))) { \ 115 switch (sizeof(*(__p))) { \
116 case 1: \ 116 case 1: \
diff --git a/include/asm-avr32/irq_regs.h b/include/asm-avr32/irq_regs.h
new file mode 100644
index 000000000000..3dd9c0b70270
--- /dev/null
+++ b/include/asm-avr32/irq_regs.h
@@ -0,0 +1 @@
#include <asm-generic/irq_regs.h>
diff --git a/include/asm-frv/io.h b/include/asm-frv/io.h
index 7765f5528894..20e44fe00abf 100644
--- a/include/asm-frv/io.h
+++ b/include/asm-frv/io.h
@@ -385,27 +385,6 @@ static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
385 */ 385 */
386#define xlate_dev_kmem_ptr(p) p 386#define xlate_dev_kmem_ptr(p) p
387 387
388/*
389 * Check BIOS signature
390 */
391static inline int check_signature(volatile void __iomem *io_addr,
392 const unsigned char *signature, int length)
393{
394 int retval = 0;
395
396 do {
397 if (readb(io_addr) != *signature)
398 goto out;
399 io_addr++;
400 signature++;
401 length--;
402 } while (length);
403
404 retval = 1;
405out:
406 return retval;
407}
408
409#endif /* __KERNEL__ */ 388#endif /* __KERNEL__ */
410 389
411#endif /* _ASM_IO_H */ 390#endif /* _ASM_IO_H */
diff --git a/include/asm-generic/bitops/sched.h b/include/asm-generic/bitops/sched.h
index 5ef93a4d009f..815bb0148060 100644
--- a/include/asm-generic/bitops/sched.h
+++ b/include/asm-generic/bitops/sched.h
@@ -15,7 +15,7 @@ static inline int sched_find_first_bit(const unsigned long *b)
15#if BITS_PER_LONG == 64 15#if BITS_PER_LONG == 64
16 if (unlikely(b[0])) 16 if (unlikely(b[0]))
17 return __ffs(b[0]); 17 return __ffs(b[0]);
18 if (unlikely(b[1])) 18 if (likely(b[1]))
19 return __ffs(b[1]) + 64; 19 return __ffs(b[1]) + 64;
20 return __ffs(b[2]) + 128; 20 return __ffs(b[2]) + 128;
21#elif BITS_PER_LONG == 32 21#elif BITS_PER_LONG == 32
diff --git a/include/asm-i386/io.h b/include/asm-i386/io.h
index b3724fe93ff1..68df0dc3ab8f 100644
--- a/include/asm-i386/io.h
+++ b/include/asm-i386/io.h
@@ -224,33 +224,6 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int
224 224
225#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(b),(c),(d)) 225#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(b),(c),(d))
226 226
227/**
228 * check_signature - find BIOS signatures
229 * @io_addr: mmio address to check
230 * @signature: signature block
231 * @length: length of signature
232 *
233 * Perform a signature comparison with the mmio address io_addr. This
234 * address should have been obtained by ioremap.
235 * Returns 1 on a match.
236 */
237
238static inline int check_signature(volatile void __iomem * io_addr,
239 const unsigned char *signature, int length)
240{
241 int retval = 0;
242 do {
243 if (readb(io_addr) != *signature)
244 goto out;
245 io_addr++;
246 signature++;
247 length--;
248 } while (length);
249 retval = 1;
250out:
251 return retval;
252}
253
254/* 227/*
255 * Cache management 228 * Cache management
256 * 229 *
diff --git a/include/asm-i386/uaccess.h b/include/asm-i386/uaccess.h
index 54d905ebc63d..eef5133b9ce2 100644
--- a/include/asm-i386/uaccess.h
+++ b/include/asm-i386/uaccess.h
@@ -404,20 +404,6 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero(void *to,
404 * anything, so this is accurate. 404 * anything, so this is accurate.
405 */ 405 */
406 406
407/**
408 * __copy_to_user: - Copy a block of data into user space, with less checking.
409 * @to: Destination address, in user space.
410 * @from: Source address, in kernel space.
411 * @n: Number of bytes to copy.
412 *
413 * Context: User context only. This function may sleep.
414 *
415 * Copy data from kernel space to user space. Caller must check
416 * the specified block with access_ok() before calling this function.
417 *
418 * Returns number of bytes that could not be copied.
419 * On success, this will be zero.
420 */
421static __always_inline unsigned long __must_check 407static __always_inline unsigned long __must_check
422__copy_to_user_inatomic(void __user *to, const void *from, unsigned long n) 408__copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
423{ 409{
@@ -439,35 +425,27 @@ __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
439 return __copy_to_user_ll(to, from, n); 425 return __copy_to_user_ll(to, from, n);
440} 426}
441 427
442static __always_inline unsigned long __must_check
443__copy_to_user(void __user *to, const void *from, unsigned long n)
444{
445 might_sleep();
446 return __copy_to_user_inatomic(to, from, n);
447}
448
449/** 428/**
450 * __copy_from_user: - Copy a block of data from user space, with less checking. 429 * __copy_to_user: - Copy a block of data into user space, with less checking.
451 * @to: Destination address, in kernel space. 430 * @to: Destination address, in user space.
452 * @from: Source address, in user space. 431 * @from: Source address, in kernel space.
453 * @n: Number of bytes to copy. 432 * @n: Number of bytes to copy.
454 * 433 *
455 * Context: User context only. This function may sleep. 434 * Context: User context only. This function may sleep.
456 * 435 *
457 * Copy data from user space to kernel space. Caller must check 436 * Copy data from kernel space to user space. Caller must check
458 * the specified block with access_ok() before calling this function. 437 * the specified block with access_ok() before calling this function.
459 * 438 *
460 * Returns number of bytes that could not be copied. 439 * Returns number of bytes that could not be copied.
461 * On success, this will be zero. 440 * On success, this will be zero.
462 *
463 * If some data could not be copied, this function will pad the copied
464 * data to the requested size using zero bytes.
465 *
466 * An alternate version - __copy_from_user_inatomic() - may be called from
467 * atomic context and will fail rather than sleep. In this case the
468 * uncopied bytes will *NOT* be padded with zeros. See fs/filemap.h
469 * for explanation of why this is needed.
470 */ 441 */
442static __always_inline unsigned long __must_check
443__copy_to_user(void __user *to, const void *from, unsigned long n)
444{
445 might_sleep();
446 return __copy_to_user_inatomic(to, from, n);
447}
448
471static __always_inline unsigned long 449static __always_inline unsigned long
472__copy_from_user_inatomic(void *to, const void __user *from, unsigned long n) 450__copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
473{ 451{
@@ -493,6 +471,29 @@ __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
493 } 471 }
494 return __copy_from_user_ll_nozero(to, from, n); 472 return __copy_from_user_ll_nozero(to, from, n);
495} 473}
474
475/**
476 * __copy_from_user: - Copy a block of data from user space, with less checking.
477 * @to: Destination address, in kernel space.
478 * @from: Source address, in user space.
479 * @n: Number of bytes to copy.
480 *
481 * Context: User context only. This function may sleep.
482 *
483 * Copy data from user space to kernel space. Caller must check
484 * the specified block with access_ok() before calling this function.
485 *
486 * Returns number of bytes that could not be copied.
487 * On success, this will be zero.
488 *
489 * If some data could not be copied, this function will pad the copied
490 * data to the requested size using zero bytes.
491 *
492 * An alternate version - __copy_from_user_inatomic() - may be called from
493 * atomic context and will fail rather than sleep. In this case the
494 * uncopied bytes will *NOT* be padded with zeros. See fs/filemap.h
495 * for explanation of why this is needed.
496 */
496static __always_inline unsigned long 497static __always_inline unsigned long
497__copy_from_user(void *to, const void __user *from, unsigned long n) 498__copy_from_user(void *to, const void __user *from, unsigned long n)
498{ 499{
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index 3ca7ab963d7d..beeeaf6b054a 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -324,10 +324,11 @@
324#define __NR_vmsplice 316 324#define __NR_vmsplice 316
325#define __NR_move_pages 317 325#define __NR_move_pages 317
326#define __NR_getcpu 318 326#define __NR_getcpu 318
327#define __NR_epoll_pwait 319
327 328
328#ifdef __KERNEL__ 329#ifdef __KERNEL__
329 330
330#define NR_syscalls 319 331#define NR_syscalls 320
331#include <linux/err.h> 332#include <linux/err.h>
332 333
333/* 334/*
diff --git a/include/asm-m32r/io.h b/include/asm-m32r/io.h
index 70ad1c949c2b..d06933bd6318 100644
--- a/include/asm-m32r/io.h
+++ b/include/asm-m32r/io.h
@@ -166,38 +166,6 @@ static inline void _writel(unsigned long l, unsigned long addr)
166 166
167#define flush_write_buffers() do { } while (0) /* M32R_FIXME */ 167#define flush_write_buffers() do { } while (0) /* M32R_FIXME */
168 168
169/**
170 * check_signature - find BIOS signatures
171 * @io_addr: mmio address to check
172 * @signature: signature block
173 * @length: length of signature
174 *
175 * Perform a signature comparison with the ISA mmio address io_addr.
176 * Returns 1 on a match.
177 *
178 * This function is deprecated. New drivers should use ioremap and
179 * check_signature.
180 */
181
182static inline int check_signature(void __iomem *io_addr,
183 const unsigned char *signature, int length)
184{
185 int retval = 0;
186#if 0
187printk("check_signature\n");
188 do {
189 if (readb(io_addr) != *signature)
190 goto out;
191 io_addr++;
192 signature++;
193 length--;
194 } while (length);
195 retval = 1;
196out:
197#endif
198 return retval;
199}
200
201static inline void 169static inline void
202memset_io(volatile void __iomem *addr, unsigned char val, int count) 170memset_io(volatile void __iomem *addr, unsigned char val, int count)
203{ 171{
diff --git a/include/asm-m68k/uaccess.h b/include/asm-m68k/uaccess.h
index 88b1f47400e1..e4c9f080ff20 100644
--- a/include/asm-m68k/uaccess.h
+++ b/include/asm-m68k/uaccess.h
@@ -76,7 +76,7 @@ asm volatile ("\n" \
76 break; \ 76 break; \
77 case 8: \ 77 case 8: \
78 { \ 78 { \
79 const void *__pu_ptr = (ptr); \ 79 const void __user *__pu_ptr = (ptr); \
80 asm volatile ("\n" \ 80 asm volatile ("\n" \
81 "1: moves.l %2,(%1)+\n" \ 81 "1: moves.l %2,(%1)+\n" \
82 "2: moves.l %R2,(%1)\n" \ 82 "2: moves.l %R2,(%1)\n" \
@@ -125,7 +125,7 @@ asm volatile ("\n" \
125 " .previous" \ 125 " .previous" \
126 : "+d" (res), "=&" #reg (__gu_val) \ 126 : "+d" (res), "=&" #reg (__gu_val) \
127 : "m" (*(ptr)), "i" (err)); \ 127 : "m" (*(ptr)), "i" (err)); \
128 (x) = (typeof(*(ptr)))(long)__gu_val; \ 128 (x) = (typeof(*(ptr)))(unsigned long)__gu_val; \
129}) 129})
130 130
131#define __get_user(x, ptr) \ 131#define __get_user(x, ptr) \
@@ -221,16 +221,16 @@ __constant_copy_from_user(void *to, const void __user *from, unsigned long n)
221 221
222 switch (n) { 222 switch (n) {
223 case 1: 223 case 1:
224 __get_user_asm(res, *(u8 *)to, (u8 *)from, u8, b, d, 1); 224 __get_user_asm(res, *(u8 *)to, (u8 __user *)from, u8, b, d, 1);
225 break; 225 break;
226 case 2: 226 case 2:
227 __get_user_asm(res, *(u16 *)to, (u16 *)from, u16, w, d, 2); 227 __get_user_asm(res, *(u16 *)to, (u16 __user *)from, u16, w, d, 2);
228 break; 228 break;
229 case 3: 229 case 3:
230 __constant_copy_from_user_asm(res, to, from, tmp, 3, w, b,); 230 __constant_copy_from_user_asm(res, to, from, tmp, 3, w, b,);
231 break; 231 break;
232 case 4: 232 case 4:
233 __get_user_asm(res, *(u32 *)to, (u32 *)from, u32, l, r, 4); 233 __get_user_asm(res, *(u32 *)to, (u32 __user *)from, u32, l, r, 4);
234 break; 234 break;
235 case 5: 235 case 5:
236 __constant_copy_from_user_asm(res, to, from, tmp, 5, l, b,); 236 __constant_copy_from_user_asm(res, to, from, tmp, 5, l, b,);
@@ -302,16 +302,16 @@ __constant_copy_to_user(void __user *to, const void *from, unsigned long n)
302 302
303 switch (n) { 303 switch (n) {
304 case 1: 304 case 1:
305 __put_user_asm(res, *(u8 *)from, (u8 *)to, b, d, 1); 305 __put_user_asm(res, *(u8 *)from, (u8 __user *)to, b, d, 1);
306 break; 306 break;
307 case 2: 307 case 2:
308 __put_user_asm(res, *(u16 *)from, (u16 *)to, w, d, 2); 308 __put_user_asm(res, *(u16 *)from, (u16 __user *)to, w, d, 2);
309 break; 309 break;
310 case 3: 310 case 3:
311 __constant_copy_to_user_asm(res, to, from, tmp, 3, w, b,); 311 __constant_copy_to_user_asm(res, to, from, tmp, 3, w, b,);
312 break; 312 break;
313 case 4: 313 case 4:
314 __put_user_asm(res, *(u32 *)from, (u32 *)to, l, r, 4); 314 __put_user_asm(res, *(u32 *)from, (u32 __user *)to, l, r, 4);
315 break; 315 break;
316 case 5: 316 case 5:
317 __constant_copy_to_user_asm(res, to, from, tmp, 5, l, b,); 317 __constant_copy_to_user_asm(res, to, from, tmp, 5, l, b,);
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index df624e1ee6e2..c2d124badbe5 100644
--- a/include/asm-mips/io.h
+++ b/include/asm-mips/io.h
@@ -562,32 +562,6 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
562#define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len)) 562#define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
563 563
564/* 564/*
565 * check_signature - find BIOS signatures
566 * @io_addr: mmio address to check
567 * @signature: signature block
568 * @length: length of signature
569 *
570 * Perform a signature comparison with the mmio address io_addr. This
571 * address should have been obtained by ioremap.
572 * Returns 1 on a match.
573 */
574static inline int check_signature(char __iomem *io_addr,
575 const unsigned char *signature, int length)
576{
577 int retval = 0;
578 do {
579 if (readb(io_addr) != *signature)
580 goto out;
581 io_addr++;
582 signature++;
583 length--;
584 } while (length);
585 retval = 1;
586out:
587 return retval;
588}
589
590/*
591 * The caches on some architectures aren't dma-coherent and have need to 565 * The caches on some architectures aren't dma-coherent and have need to
592 * handle this in software. There are three types of operations that 566 * handle this in software. There are three types of operations that
593 * can be applied to dma buffers. 567 * can be applied to dma buffers.
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index cbbd8c648df1..3baff8b0fd5a 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -404,32 +404,6 @@ static inline void __out_be64(volatile unsigned long __iomem *addr, unsigned lon
404 404
405#include <asm/eeh.h> 405#include <asm/eeh.h>
406 406
407/**
408 * check_signature - find BIOS signatures
409 * @io_addr: mmio address to check
410 * @signature: signature block
411 * @length: length of signature
412 *
413 * Perform a signature comparison with the mmio address io_addr. This
414 * address should have been obtained by ioremap.
415 * Returns 1 on a match.
416 */
417static inline int check_signature(const volatile void __iomem * io_addr,
418 const unsigned char *signature, int length)
419{
420 int retval = 0;
421 do {
422 if (readb(io_addr) != *signature)
423 goto out;
424 io_addr++;
425 signature++;
426 length--;
427 } while (length);
428 retval = 1;
429out:
430 return retval;
431}
432
433/* Nothing to do */ 407/* Nothing to do */
434 408
435#define dma_cache_inv(_start,_size) do { } while (0) 409#define dma_cache_inv(_start,_size) do { } while (0)
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index 3d9a9e6f3321..a4c411b753ef 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -439,22 +439,6 @@ extern inline void * phys_to_virt(unsigned long address)
439#define iobarrier_r() eieio() 439#define iobarrier_r() eieio()
440#define iobarrier_w() eieio() 440#define iobarrier_w() eieio()
441 441
442static inline int check_signature(volatile void __iomem * io_addr,
443 const unsigned char *signature, int length)
444{
445 int retval = 0;
446 do {
447 if (readb(io_addr) != *signature)
448 goto out;
449 io_addr++;
450 signature++;
451 length--;
452 } while (length);
453 retval = 1;
454out:
455 return retval;
456}
457
458/* 442/*
459 * Here comes the ppc implementation of the IOMAP 443 * Here comes the ppc implementation of the IOMAP
460 * interfaces. 444 * interfaces.
diff --git a/include/asm-sh/io.h b/include/asm-sh/io.h
index ed12d38e8c00..a0e55b09e4fd 100644
--- a/include/asm-sh/io.h
+++ b/include/asm-sh/io.h
@@ -304,22 +304,6 @@ __ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
304#define iounmap(addr) \ 304#define iounmap(addr) \
305 __iounmap((addr)) 305 __iounmap((addr))
306 306
307static inline int check_signature(char __iomem *io_addr,
308 const unsigned char *signature, int length)
309{
310 int retval = 0;
311 do {
312 if (readb(io_addr) != *signature)
313 goto out;
314 io_addr++;
315 signature++;
316 length--;
317 } while (length);
318 retval = 1;
319out:
320 return retval;
321}
322
323/* 307/*
324 * The caches on some architectures aren't dma-coherent and have need to 308 * The caches on some architectures aren't dma-coherent and have need to
325 * handle this in software. There are three types of operations that 309 * handle this in software. There are three types of operations that
diff --git a/include/asm-sh64/io.h b/include/asm-sh64/io.h
index 252fedbb6621..14d8e7b4bf4b 100644
--- a/include/asm-sh64/io.h
+++ b/include/asm-sh64/io.h
@@ -178,22 +178,6 @@ extern void iounmap(void *addr);
178unsigned long onchip_remap(unsigned long addr, unsigned long size, const char* name); 178unsigned long onchip_remap(unsigned long addr, unsigned long size, const char* name);
179extern void onchip_unmap(unsigned long vaddr); 179extern void onchip_unmap(unsigned long vaddr);
180 180
181static __inline__ int check_signature(volatile void __iomem *io_addr,
182 const unsigned char *signature, int length)
183{
184 int retval = 0;
185 do {
186 if (readb(io_addr) != *signature)
187 goto out;
188 io_addr++;
189 signature++;
190 length--;
191 } while (length);
192 retval = 1;
193out:
194 return retval;
195}
196
197/* 181/*
198 * The caches on some architectures aren't dma-coherent and have need to 182 * The caches on some architectures aren't dma-coherent and have need to
199 * handle this in software. There are three types of operations that 183 * handle this in software. There are three types of operations that
diff --git a/include/asm-sparc64/io.h b/include/asm-sparc64/io.h
index 0056770e83ad..30b912d8e8bc 100644
--- a/include/asm-sparc64/io.h
+++ b/include/asm-sparc64/io.h
@@ -440,21 +440,6 @@ _memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n)
440 440
441#define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz) 441#define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz)
442 442
443static inline int check_signature(void __iomem *io_addr,
444 const unsigned char *signature,
445 int length)
446{
447 int retval = 0;
448 do {
449 if (readb(io_addr) != *signature++)
450 goto out;
451 io_addr++;
452 } while (--length);
453 retval = 1;
454out:
455 return retval;
456}
457
458#define mmiowb() 443#define mmiowb()
459 444
460#ifdef __KERNEL__ 445#ifdef __KERNEL__
diff --git a/include/asm-x86_64/io.h b/include/asm-x86_64/io.h
index 70e91fe76344..6ee9fadaaacb 100644
--- a/include/asm-x86_64/io.h
+++ b/include/asm-x86_64/io.h
@@ -254,33 +254,6 @@ void memset_io(volatile void __iomem *a, int b, size_t c);
254 254
255#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(b),(c),(d)) 255#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(b),(c),(d))
256 256
257/**
258 * check_signature - find BIOS signatures
259 * @io_addr: mmio address to check
260 * @signature: signature block
261 * @length: length of signature
262 *
263 * Perform a signature comparison with the mmio address io_addr. This
264 * address should have been obtained by ioremap.
265 * Returns 1 on a match.
266 */
267
268static inline int check_signature(void __iomem *io_addr,
269 const unsigned char *signature, int length)
270{
271 int retval = 0;
272 do {
273 if (readb(io_addr) != *signature)
274 goto out;
275 io_addr++;
276 signature++;
277 length--;
278 } while (length);
279 retval = 1;
280out:
281 return retval;
282}
283
284/* Nothing to do */ 257/* Nothing to do */
285 258
286#define dma_cache_inv(_start,_size) do { } while (0) 259#define dma_cache_inv(_start,_size) do { } while (0)
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index dcc5de7cc487..64b4641904fe 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -46,7 +46,8 @@
46 * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src) 46 * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src)
47 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit) 47 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit)
48 * bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf 48 * bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf
49 * bitmap_parse(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf 49 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf
50 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
50 * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf 51 * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf
51 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from list 52 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from list
52 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region 53 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region
@@ -106,7 +107,9 @@ extern int __bitmap_weight(const unsigned long *bitmap, int bits);
106 107
107extern int bitmap_scnprintf(char *buf, unsigned int len, 108extern int bitmap_scnprintf(char *buf, unsigned int len,
108 const unsigned long *src, int nbits); 109 const unsigned long *src, int nbits);
109extern int bitmap_parse(const char __user *ubuf, unsigned int ulen, 110extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user,
111 unsigned long *dst, int nbits);
112extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen,
110 unsigned long *dst, int nbits); 113 unsigned long *dst, int nbits);
111extern int bitmap_scnlistprintf(char *buf, unsigned int len, 114extern int bitmap_scnlistprintf(char *buf, unsigned int len,
112 const unsigned long *src, int nbits); 115 const unsigned long *src, int nbits);
@@ -270,6 +273,12 @@ static inline void bitmap_shift_left(unsigned long *dst,
270 __bitmap_shift_left(dst, src, n, nbits); 273 __bitmap_shift_left(dst, src, n, nbits);
271} 274}
272 275
276static inline int bitmap_parse(const char *buf, unsigned int buflen,
277 unsigned long *maskp, int nmaskbits)
278{
279 return __bitmap_parse(buf, buflen, 0, maskp, nmaskbits);
280}
281
273#endif /* __ASSEMBLY__ */ 282#endif /* __ASSEMBLY__ */
274 283
275#endif /* __LINUX_BITMAP_H */ 284#endif /* __LINUX_BITMAP_H */
diff --git a/include/linux/carta_random32.h b/include/linux/carta_random32.h
new file mode 100644
index 000000000000..f6f3bd9f20b5
--- /dev/null
+++ b/include/linux/carta_random32.h
@@ -0,0 +1,29 @@
1/*
2 * Fast, simple, yet decent quality random number generator based on
3 * a paper by David G. Carta ("Two Fast Implementations of the
4 * `Minimal Standard' Random Number Generator," Communications of the
5 * ACM, January, 1990).
6 *
7 * Copyright (c) 2002-2006 Hewlett-Packard Development Company, L.P.
8 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */
24#ifndef _LINUX_CARTA_RANDOM32_H_
25#define _LINUX_CARTA_RANDOM32_H_
26
27u64 carta_random32(u64 seed);
28
29#endif /* _LINUX_CARTA_RANDOM32_H_ */
diff --git a/include/linux/compat_ioctl.h b/include/linux/compat_ioctl.h
index 4e1663d7691e..cfdb4f6a89d4 100644
--- a/include/linux/compat_ioctl.h
+++ b/include/linux/compat_ioctl.h
@@ -61,17 +61,23 @@ COMPATIBLE_IOCTL(FIGETBSZ)
61 * Some need translations, these do not. 61 * Some need translations, these do not.
62 */ 62 */
63COMPATIBLE_IOCTL(HDIO_GET_IDENTITY) 63COMPATIBLE_IOCTL(HDIO_GET_IDENTITY)
64COMPATIBLE_IOCTL(HDIO_SET_DMA)
65COMPATIBLE_IOCTL(HDIO_SET_UNMASKINTR)
66COMPATIBLE_IOCTL(HDIO_SET_NOWERR)
67COMPATIBLE_IOCTL(HDIO_SET_32BIT)
68COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
69COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
70COMPATIBLE_IOCTL(HDIO_DRIVE_TASK) 64COMPATIBLE_IOCTL(HDIO_DRIVE_TASK)
71COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE) 65COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
72COMPATIBLE_IOCTL(HDIO_SET_NICE) 66ULONG_IOCTL(HDIO_SET_MULTCOUNT)
73COMPATIBLE_IOCTL(HDIO_SET_KEEPSETTINGS) 67ULONG_IOCTL(HDIO_SET_UNMASKINTR)
68ULONG_IOCTL(HDIO_SET_KEEPSETTINGS)
69ULONG_IOCTL(HDIO_SET_32BIT)
70ULONG_IOCTL(HDIO_SET_NOWERR)
71ULONG_IOCTL(HDIO_SET_DMA)
72ULONG_IOCTL(HDIO_SET_PIO_MODE)
73ULONG_IOCTL(HDIO_SET_NICE)
74ULONG_IOCTL(HDIO_SET_WCACHE)
75ULONG_IOCTL(HDIO_SET_ACOUSTIC)
76ULONG_IOCTL(HDIO_SET_BUSSTATE)
77ULONG_IOCTL(HDIO_SET_ADDRESS)
74COMPATIBLE_IOCTL(HDIO_SCAN_HWIF) 78COMPATIBLE_IOCTL(HDIO_SCAN_HWIF)
79/* 0x330 is reserved -- it used to be HDIO_GETGEO_BIG */
80COMPATIBLE_IOCTL(0x330)
75/* 0x02 -- Floppy ioctls */ 81/* 0x02 -- Floppy ioctls */
76COMPATIBLE_IOCTL(FDMSGON) 82COMPATIBLE_IOCTL(FDMSGON)
77COMPATIBLE_IOCTL(FDMSGOFF) 83COMPATIBLE_IOCTL(FDMSGOFF)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index b268a3c0c376..d0e8c8b0e34d 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -8,8 +8,8 @@
8 * See detailed comments in the file linux/bitmap.h describing the 8 * See detailed comments in the file linux/bitmap.h describing the
9 * data type on which these cpumasks are based. 9 * data type on which these cpumasks are based.
10 * 10 *
11 * For details of cpumask_scnprintf() and cpumask_parse(), 11 * For details of cpumask_scnprintf() and cpumask_parse_user(),
12 * see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c. 12 * see bitmap_scnprintf() and bitmap_parse_user() in lib/bitmap.c.
13 * For details of cpulist_scnprintf() and cpulist_parse(), see 13 * For details of cpulist_scnprintf() and cpulist_parse(), see
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c. 14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15 * For details of cpu_remap(), see bitmap_bitremap in lib/bitmap.c 15 * For details of cpu_remap(), see bitmap_bitremap in lib/bitmap.c
@@ -49,7 +49,7 @@
49 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask 49 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask
50 * 50 *
51 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing 51 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
52 * int cpumask_parse(ubuf, ulen, mask) Parse ascii string as cpumask 52 * int cpumask_parse_user(ubuf, ulen, mask) Parse ascii string as cpumask
53 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing 53 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
54 * int cpulist_parse(buf, map) Parse ascii string as cpulist 54 * int cpulist_parse(buf, map) Parse ascii string as cpulist
55 * int cpu_remap(oldbit, old, new) newbit = map(old, new)(oldbit) 55 * int cpu_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
@@ -273,12 +273,12 @@ static inline int __cpumask_scnprintf(char *buf, int len,
273 return bitmap_scnprintf(buf, len, srcp->bits, nbits); 273 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
274} 274}
275 275
276#define cpumask_parse(ubuf, ulen, dst) \ 276#define cpumask_parse_user(ubuf, ulen, dst) \
277 __cpumask_parse((ubuf), (ulen), &(dst), NR_CPUS) 277 __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS)
278static inline int __cpumask_parse(const char __user *buf, int len, 278static inline int __cpumask_parse_user(const char __user *buf, int len,
279 cpumask_t *dstp, int nbits) 279 cpumask_t *dstp, int nbits)
280{ 280{
281 return bitmap_parse(buf, len, dstp->bits, nbits); 281 return bitmap_parse_user(buf, len, dstp->bits, nbits);
282} 282}
283 283
284#define cpulist_scnprintf(buf, len, src) \ 284#define cpulist_scnprintf(buf, len, src) \
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 44605be59409..63f64a9a5bf7 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -230,6 +230,7 @@ extern struct dentry * d_alloc_anon(struct inode *);
230extern struct dentry * d_splice_alias(struct inode *, struct dentry *); 230extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
231extern void shrink_dcache_sb(struct super_block *); 231extern void shrink_dcache_sb(struct super_block *);
232extern void shrink_dcache_parent(struct dentry *); 232extern void shrink_dcache_parent(struct dentry *);
233extern void shrink_dcache_for_umount(struct super_block *);
233extern int d_invalidate(struct dentry *); 234extern int d_invalidate(struct dentry *);
234 235
235/* only used at mount-time */ 236/* only used at mount-time */
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
new file mode 100644
index 000000000000..498503ee613d
--- /dev/null
+++ b/include/linux/ext4_fs.h
@@ -0,0 +1,994 @@
1/*
2 * linux/include/linux/ext4_fs.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT4_FS_H
17#define _LINUX_EXT4_FS_H
18
19#include <linux/types.h>
20#include <linux/blkdev.h>
21#include <linux/magic.h>
22
23/*
24 * The second extended filesystem constants/structures
25 */
26
27/*
28 * Define EXT4FS_DEBUG to produce debug messages
29 */
30#undef EXT4FS_DEBUG
31
32/*
33 * Define EXT4_RESERVATION to reserve data blocks for expanding files
34 */
35#define EXT4_DEFAULT_RESERVE_BLOCKS 8
36/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */
37#define EXT4_MAX_RESERVE_BLOCKS 1027
38#define EXT4_RESERVE_WINDOW_NOT_ALLOCATED 0
39/*
40 * Always enable hashed directories
41 */
42#define CONFIG_EXT4_INDEX
43
44/*
45 * Debug code
46 */
47#ifdef EXT4FS_DEBUG
48#define ext4_debug(f, a...) \
49 do { \
50 printk (KERN_DEBUG "EXT4-fs DEBUG (%s, %d): %s:", \
51 __FILE__, __LINE__, __FUNCTION__); \
52 printk (KERN_DEBUG f, ## a); \
53 } while (0)
54#else
55#define ext4_debug(f, a...) do {} while (0)
56#endif
57
58/*
59 * Special inodes numbers
60 */
61#define EXT4_BAD_INO 1 /* Bad blocks inode */
62#define EXT4_ROOT_INO 2 /* Root inode */
63#define EXT4_BOOT_LOADER_INO 5 /* Boot loader inode */
64#define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */
65#define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */
66#define EXT4_JOURNAL_INO 8 /* Journal inode */
67
68/* First non-reserved inode for old ext4 filesystems */
69#define EXT4_GOOD_OLD_FIRST_INO 11
70
71/*
72 * Maximal count of links to a file
73 */
74#define EXT4_LINK_MAX 32000
75
76/*
77 * Macro-instructions used to manage several block sizes
78 */
79#define EXT4_MIN_BLOCK_SIZE 1024
80#define EXT4_MAX_BLOCK_SIZE 4096
81#define EXT4_MIN_BLOCK_LOG_SIZE 10
82#ifdef __KERNEL__
83# define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
84#else
85# define EXT4_BLOCK_SIZE(s) (EXT4_MIN_BLOCK_SIZE << (s)->s_log_block_size)
86#endif
87#define EXT4_ADDR_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / sizeof (__u32))
88#ifdef __KERNEL__
89# define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
90#else
91# define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
92#endif
93#ifdef __KERNEL__
94#define EXT4_ADDR_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_addr_per_block_bits)
95#define EXT4_INODE_SIZE(s) (EXT4_SB(s)->s_inode_size)
96#define EXT4_FIRST_INO(s) (EXT4_SB(s)->s_first_ino)
97#else
98#define EXT4_INODE_SIZE(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
99 EXT4_GOOD_OLD_INODE_SIZE : \
100 (s)->s_inode_size)
101#define EXT4_FIRST_INO(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
102 EXT4_GOOD_OLD_FIRST_INO : \
103 (s)->s_first_ino)
104#endif
105
106/*
107 * Macro-instructions used to manage fragments
108 */
109#define EXT4_MIN_FRAG_SIZE 1024
110#define EXT4_MAX_FRAG_SIZE 4096
111#define EXT4_MIN_FRAG_LOG_SIZE 10
112#ifdef __KERNEL__
113# define EXT4_FRAG_SIZE(s) (EXT4_SB(s)->s_frag_size)
114# define EXT4_FRAGS_PER_BLOCK(s) (EXT4_SB(s)->s_frags_per_block)
115#else
116# define EXT4_FRAG_SIZE(s) (EXT4_MIN_FRAG_SIZE << (s)->s_log_frag_size)
117# define EXT4_FRAGS_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_FRAG_SIZE(s))
118#endif
119
120/*
121 * Structure of a blocks group descriptor
122 */
123struct ext4_group_desc
124{
125 __le32 bg_block_bitmap; /* Blocks bitmap block */
126 __le32 bg_inode_bitmap; /* Inodes bitmap block */
127 __le32 bg_inode_table; /* Inodes table block */
128 __le16 bg_free_blocks_count; /* Free blocks count */
129 __le16 bg_free_inodes_count; /* Free inodes count */
130 __le16 bg_used_dirs_count; /* Directories count */
131 __u16 bg_flags;
132 __u32 bg_reserved[3];
133 __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
134 __le32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */
135 __le32 bg_inode_table_hi; /* Inodes table block MSB */
136};
137
138#ifdef __KERNEL__
139#include <linux/ext4_fs_i.h>
140#include <linux/ext4_fs_sb.h>
141#endif
142/*
143 * Macro-instructions used to manage group descriptors
144 */
145#define EXT4_MIN_DESC_SIZE 32
146#define EXT4_MIN_DESC_SIZE_64BIT 64
147#define EXT4_MAX_DESC_SIZE EXT4_MIN_BLOCK_SIZE
148#define EXT4_DESC_SIZE(s) (EXT4_SB(s)->s_desc_size)
149#ifdef __KERNEL__
150# define EXT4_BLOCKS_PER_GROUP(s) (EXT4_SB(s)->s_blocks_per_group)
151# define EXT4_DESC_PER_BLOCK(s) (EXT4_SB(s)->s_desc_per_block)
152# define EXT4_INODES_PER_GROUP(s) (EXT4_SB(s)->s_inodes_per_group)
153# define EXT4_DESC_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_desc_per_block_bits)
154#else
155# define EXT4_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
156# define EXT4_DESC_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_DESC_SIZE(s))
157# define EXT4_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
158#endif
159
160/*
161 * Constants relative to the data blocks
162 */
163#define EXT4_NDIR_BLOCKS 12
164#define EXT4_IND_BLOCK EXT4_NDIR_BLOCKS
165#define EXT4_DIND_BLOCK (EXT4_IND_BLOCK + 1)
166#define EXT4_TIND_BLOCK (EXT4_DIND_BLOCK + 1)
167#define EXT4_N_BLOCKS (EXT4_TIND_BLOCK + 1)
168
169/*
170 * Inode flags
171 */
172#define EXT4_SECRM_FL 0x00000001 /* Secure deletion */
173#define EXT4_UNRM_FL 0x00000002 /* Undelete */
174#define EXT4_COMPR_FL 0x00000004 /* Compress file */
175#define EXT4_SYNC_FL 0x00000008 /* Synchronous updates */
176#define EXT4_IMMUTABLE_FL 0x00000010 /* Immutable file */
177#define EXT4_APPEND_FL 0x00000020 /* writes to file may only append */
178#define EXT4_NODUMP_FL 0x00000040 /* do not dump file */
179#define EXT4_NOATIME_FL 0x00000080 /* do not update atime */
180/* Reserved for compression usage... */
181#define EXT4_DIRTY_FL 0x00000100
182#define EXT4_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
183#define EXT4_NOCOMPR_FL 0x00000400 /* Don't compress */
184#define EXT4_ECOMPR_FL 0x00000800 /* Compression error */
185/* End compression flags --- maybe not all used */
186#define EXT4_INDEX_FL 0x00001000 /* hash-indexed directory */
187#define EXT4_IMAGIC_FL 0x00002000 /* AFS directory */
188#define EXT4_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
189#define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
190#define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
191#define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
192#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
193#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
194
195#define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
196#define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
197
198/*
199 * Inode dynamic state flags
200 */
201#define EXT4_STATE_JDATA 0x00000001 /* journaled data exists */
202#define EXT4_STATE_NEW 0x00000002 /* inode is newly created */
203#define EXT4_STATE_XATTR 0x00000004 /* has in-inode xattrs */
204
205/* Used to pass group descriptor data when online resize is done */
206struct ext4_new_group_input {
207 __u32 group; /* Group number for this data */
208 __u64 block_bitmap; /* Absolute block number of block bitmap */
209 __u64 inode_bitmap; /* Absolute block number of inode bitmap */
210 __u64 inode_table; /* Absolute block number of inode table start */
211 __u32 blocks_count; /* Total number of blocks in this group */
212 __u16 reserved_blocks; /* Number of reserved blocks in this group */
213 __u16 unused;
214};
215
216/* The struct ext4_new_group_input in kernel space, with free_blocks_count */
217struct ext4_new_group_data {
218 __u32 group;
219 __u64 block_bitmap;
220 __u64 inode_bitmap;
221 __u64 inode_table;
222 __u32 blocks_count;
223 __u16 reserved_blocks;
224 __u16 unused;
225 __u32 free_blocks_count;
226};
227
228
229/*
230 * ioctl commands
231 */
232#define EXT4_IOC_GETFLAGS FS_IOC_GETFLAGS
233#define EXT4_IOC_SETFLAGS FS_IOC_SETFLAGS
234#define EXT4_IOC_GETVERSION _IOR('f', 3, long)
235#define EXT4_IOC_SETVERSION _IOW('f', 4, long)
236#define EXT4_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
237#define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input)
238#define EXT4_IOC_GETVERSION_OLD FS_IOC_GETVERSION
239#define EXT4_IOC_SETVERSION_OLD FS_IOC_SETVERSION
240#ifdef CONFIG_JBD_DEBUG
241#define EXT4_IOC_WAIT_FOR_READONLY _IOR('f', 99, long)
242#endif
243#define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
244#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
245
246/*
247 * ioctl commands in 32 bit emulation
248 */
249#define EXT4_IOC32_GETFLAGS FS_IOC32_GETFLAGS
250#define EXT4_IOC32_SETFLAGS FS_IOC32_SETFLAGS
251#define EXT4_IOC32_GETVERSION _IOR('f', 3, int)
252#define EXT4_IOC32_SETVERSION _IOW('f', 4, int)
253#define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int)
254#define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int)
255#define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
256#ifdef CONFIG_JBD_DEBUG
257#define EXT4_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
258#endif
259#define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION
260#define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
261
262
263/*
264 * Mount options
265 */
266struct ext4_mount_options {
267 unsigned long s_mount_opt;
268 uid_t s_resuid;
269 gid_t s_resgid;
270 unsigned long s_commit_interval;
271#ifdef CONFIG_QUOTA
272 int s_jquota_fmt;
273 char *s_qf_names[MAXQUOTAS];
274#endif
275};
276
277/*
278 * Structure of an inode on the disk
279 */
280struct ext4_inode {
281 __le16 i_mode; /* File mode */
282 __le16 i_uid; /* Low 16 bits of Owner Uid */
283 __le32 i_size; /* Size in bytes */
284 __le32 i_atime; /* Access time */
285 __le32 i_ctime; /* Creation time */
286 __le32 i_mtime; /* Modification time */
287 __le32 i_dtime; /* Deletion Time */
288 __le16 i_gid; /* Low 16 bits of Group Id */
289 __le16 i_links_count; /* Links count */
290 __le32 i_blocks; /* Blocks count */
291 __le32 i_flags; /* File flags */
292 union {
293 struct {
294 __u32 l_i_reserved1;
295 } linux1;
296 struct {
297 __u32 h_i_translator;
298 } hurd1;
299 struct {
300 __u32 m_i_reserved1;
301 } masix1;
302 } osd1; /* OS dependent 1 */
303 __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
304 __le32 i_generation; /* File version (for NFS) */
305 __le32 i_file_acl; /* File ACL */
306 __le32 i_dir_acl; /* Directory ACL */
307 __le32 i_faddr; /* Fragment address */
308 union {
309 struct {
310 __u8 l_i_frag; /* Fragment number */
311 __u8 l_i_fsize; /* Fragment size */
312 __le16 l_i_file_acl_high;
313 __le16 l_i_uid_high; /* these 2 fields */
314 __le16 l_i_gid_high; /* were reserved2[0] */
315 __u32 l_i_reserved2;
316 } linux2;
317 struct {
318 __u8 h_i_frag; /* Fragment number */
319 __u8 h_i_fsize; /* Fragment size */
320 __u16 h_i_mode_high;
321 __u16 h_i_uid_high;
322 __u16 h_i_gid_high;
323 __u32 h_i_author;
324 } hurd2;
325 struct {
326 __u8 m_i_frag; /* Fragment number */
327 __u8 m_i_fsize; /* Fragment size */
328 __le16 m_i_file_acl_high;
329 __u32 m_i_reserved2[2];
330 } masix2;
331 } osd2; /* OS dependent 2 */
332 __le16 i_extra_isize;
333 __le16 i_pad1;
334};
335
336#define i_size_high i_dir_acl
337
338#if defined(__KERNEL__) || defined(__linux__)
339#define i_reserved1 osd1.linux1.l_i_reserved1
340#define i_frag osd2.linux2.l_i_frag
341#define i_fsize osd2.linux2.l_i_fsize
342#define i_file_acl_high osd2.linux2.l_i_file_acl_high
343#define i_uid_low i_uid
344#define i_gid_low i_gid
345#define i_uid_high osd2.linux2.l_i_uid_high
346#define i_gid_high osd2.linux2.l_i_gid_high
347#define i_reserved2 osd2.linux2.l_i_reserved2
348
349#elif defined(__GNU__)
350
351#define i_translator osd1.hurd1.h_i_translator
352#define i_frag osd2.hurd2.h_i_frag;
353#define i_fsize osd2.hurd2.h_i_fsize;
354#define i_uid_high osd2.hurd2.h_i_uid_high
355#define i_gid_high osd2.hurd2.h_i_gid_high
356#define i_author osd2.hurd2.h_i_author
357
358#elif defined(__masix__)
359
360#define i_reserved1 osd1.masix1.m_i_reserved1
361#define i_frag osd2.masix2.m_i_frag
362#define i_fsize osd2.masix2.m_i_fsize
363#define i_file_acl_high osd2.masix2.m_i_file_acl_high
364#define i_reserved2 osd2.masix2.m_i_reserved2
365
366#endif /* defined(__KERNEL__) || defined(__linux__) */
367
368/*
369 * File system states
370 */
371#define EXT4_VALID_FS 0x0001 /* Unmounted cleanly */
372#define EXT4_ERROR_FS 0x0002 /* Errors detected */
373#define EXT4_ORPHAN_FS 0x0004 /* Orphans being recovered */
374
375/*
376 * Mount flags
377 */
378#define EXT4_MOUNT_CHECK 0x00001 /* Do mount-time checks */
379#define EXT4_MOUNT_OLDALLOC 0x00002 /* Don't use the new Orlov allocator */
380#define EXT4_MOUNT_GRPID 0x00004 /* Create files with directory's group */
381#define EXT4_MOUNT_DEBUG 0x00008 /* Some debugging messages */
382#define EXT4_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */
383#define EXT4_MOUNT_ERRORS_RO 0x00020 /* Remount fs ro on errors */
384#define EXT4_MOUNT_ERRORS_PANIC 0x00040 /* Panic on errors */
385#define EXT4_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */
386#define EXT4_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/
387#define EXT4_MOUNT_ABORT 0x00200 /* Fatal error detected */
388#define EXT4_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */
389#define EXT4_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */
390#define EXT4_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */
391#define EXT4_MOUNT_WRITEBACK_DATA 0x00C00 /* No data ordering */
392#define EXT4_MOUNT_UPDATE_JOURNAL 0x01000 /* Update the journal format */
393#define EXT4_MOUNT_NO_UID32 0x02000 /* Disable 32-bit UIDs */
394#define EXT4_MOUNT_XATTR_USER 0x04000 /* Extended user attributes */
395#define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
396#define EXT4_MOUNT_RESERVATION 0x10000 /* Preallocation */
397#define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
398#define EXT4_MOUNT_NOBH 0x40000 /* No bufferheads */
399#define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
400#define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
401#define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
402#define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
403
404/* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
405#ifndef _LINUX_EXT2_FS_H
406#define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
407#define set_opt(o, opt) o |= EXT4_MOUNT_##opt
408#define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt & \
409 EXT4_MOUNT_##opt)
410#else
411#define EXT2_MOUNT_NOLOAD EXT4_MOUNT_NOLOAD
412#define EXT2_MOUNT_ABORT EXT4_MOUNT_ABORT
413#define EXT2_MOUNT_DATA_FLAGS EXT4_MOUNT_DATA_FLAGS
414#endif
415
416#define ext4_set_bit ext2_set_bit
417#define ext4_set_bit_atomic ext2_set_bit_atomic
418#define ext4_clear_bit ext2_clear_bit
419#define ext4_clear_bit_atomic ext2_clear_bit_atomic
420#define ext4_test_bit ext2_test_bit
421#define ext4_find_first_zero_bit ext2_find_first_zero_bit
422#define ext4_find_next_zero_bit ext2_find_next_zero_bit
423
424/*
425 * Maximal mount counts between two filesystem checks
426 */
427#define EXT4_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
428#define EXT4_DFL_CHECKINTERVAL 0 /* Don't use interval check */
429
430/*
431 * Behaviour when detecting errors
432 */
433#define EXT4_ERRORS_CONTINUE 1 /* Continue execution */
434#define EXT4_ERRORS_RO 2 /* Remount fs read-only */
435#define EXT4_ERRORS_PANIC 3 /* Panic */
436#define EXT4_ERRORS_DEFAULT EXT4_ERRORS_CONTINUE
437
438/*
439 * Structure of the super block
440 */
441struct ext4_super_block {
442/*00*/ __le32 s_inodes_count; /* Inodes count */
443 __le32 s_blocks_count; /* Blocks count */
444 __le32 s_r_blocks_count; /* Reserved blocks count */
445 __le32 s_free_blocks_count; /* Free blocks count */
446/*10*/ __le32 s_free_inodes_count; /* Free inodes count */
447 __le32 s_first_data_block; /* First Data Block */
448 __le32 s_log_block_size; /* Block size */
449 __le32 s_log_frag_size; /* Fragment size */
450/*20*/ __le32 s_blocks_per_group; /* # Blocks per group */
451 __le32 s_frags_per_group; /* # Fragments per group */
452 __le32 s_inodes_per_group; /* # Inodes per group */
453 __le32 s_mtime; /* Mount time */
454/*30*/ __le32 s_wtime; /* Write time */
455 __le16 s_mnt_count; /* Mount count */
456 __le16 s_max_mnt_count; /* Maximal mount count */
457 __le16 s_magic; /* Magic signature */
458 __le16 s_state; /* File system state */
459 __le16 s_errors; /* Behaviour when detecting errors */
460 __le16 s_minor_rev_level; /* minor revision level */
461/*40*/ __le32 s_lastcheck; /* time of last check */
462 __le32 s_checkinterval; /* max. time between checks */
463 __le32 s_creator_os; /* OS */
464 __le32 s_rev_level; /* Revision level */
465/*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */
466 __le16 s_def_resgid; /* Default gid for reserved blocks */
467 /*
468 * These fields are for EXT4_DYNAMIC_REV superblocks only.
469 *
470 * Note: the difference between the compatible feature set and
471 * the incompatible feature set is that if there is a bit set
472 * in the incompatible feature set that the kernel doesn't
473 * know about, it should refuse to mount the filesystem.
474 *
475 * e2fsck's requirements are more strict; if it doesn't know
476 * about a feature in either the compatible or incompatible
477 * feature set, it must abort and not try to meddle with
478 * things it doesn't understand...
479 */
480 __le32 s_first_ino; /* First non-reserved inode */
481 __le16 s_inode_size; /* size of inode structure */
482 __le16 s_block_group_nr; /* block group # of this superblock */
483 __le32 s_feature_compat; /* compatible feature set */
484/*60*/ __le32 s_feature_incompat; /* incompatible feature set */
485 __le32 s_feature_ro_compat; /* readonly-compatible feature set */
486/*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
487/*78*/ char s_volume_name[16]; /* volume name */
488/*88*/ char s_last_mounted[64]; /* directory where last mounted */
489/*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
490 /*
491 * Performance hints. Directory preallocation should only
492 * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
493 */
494 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
495 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
496 __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
497 /*
498 * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
499 */
500/*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
501/*E0*/ __le32 s_journal_inum; /* inode number of journal file */
502 __le32 s_journal_dev; /* device number of journal file */
503 __le32 s_last_orphan; /* start of list of inodes to delete */
504 __le32 s_hash_seed[4]; /* HTREE hash seed */
505 __u8 s_def_hash_version; /* Default hash version to use */
506 __u8 s_reserved_char_pad;
507 __le16 s_desc_size; /* size of group descriptor */
508/*100*/ __le32 s_default_mount_opts;
509 __le32 s_first_meta_bg; /* First metablock block group */
510 __le32 s_mkfs_time; /* When the filesystem was created */
511 __le32 s_jnl_blocks[17]; /* Backup of the journal inode */
512 /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
513/*150*/ __le32 s_blocks_count_hi; /* Blocks count */
514 __le32 s_r_blocks_count_hi; /* Reserved blocks count */
515 __le32 s_free_blocks_count_hi; /* Free blocks count */
516 __u32 s_reserved[169]; /* Padding to the end of the block */
517};
518
519#ifdef __KERNEL__
520static inline struct ext4_sb_info * EXT4_SB(struct super_block *sb)
521{
522 return sb->s_fs_info;
523}
524static inline struct ext4_inode_info *EXT4_I(struct inode *inode)
525{
526 return container_of(inode, struct ext4_inode_info, vfs_inode);
527}
528
529static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
530{
531 return ino == EXT4_ROOT_INO ||
532 ino == EXT4_JOURNAL_INO ||
533 ino == EXT4_RESIZE_INO ||
534 (ino >= EXT4_FIRST_INO(sb) &&
535 ino <= le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count));
536}
537#else
538/* Assume that user mode programs are passing in an ext4fs superblock, not
539 * a kernel struct super_block. This will allow us to call the feature-test
540 * macros from user land. */
541#define EXT4_SB(sb) (sb)
542#endif
543
544#define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
545
546/*
547 * Codes for operating systems
548 */
549#define EXT4_OS_LINUX 0
550#define EXT4_OS_HURD 1
551#define EXT4_OS_MASIX 2
552#define EXT4_OS_FREEBSD 3
553#define EXT4_OS_LITES 4
554
555/*
556 * Revision levels
557 */
558#define EXT4_GOOD_OLD_REV 0 /* The good old (original) format */
559#define EXT4_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
560
561#define EXT4_CURRENT_REV EXT4_GOOD_OLD_REV
562#define EXT4_MAX_SUPP_REV EXT4_DYNAMIC_REV
563
564#define EXT4_GOOD_OLD_INODE_SIZE 128
565
566/*
567 * Feature set definitions
568 */
569
570#define EXT4_HAS_COMPAT_FEATURE(sb,mask) \
571 ( EXT4_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
572#define EXT4_HAS_RO_COMPAT_FEATURE(sb,mask) \
573 ( EXT4_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
574#define EXT4_HAS_INCOMPAT_FEATURE(sb,mask) \
575 ( EXT4_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
576#define EXT4_SET_COMPAT_FEATURE(sb,mask) \
577 EXT4_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
578#define EXT4_SET_RO_COMPAT_FEATURE(sb,mask) \
579 EXT4_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
580#define EXT4_SET_INCOMPAT_FEATURE(sb,mask) \
581 EXT4_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
582#define EXT4_CLEAR_COMPAT_FEATURE(sb,mask) \
583 EXT4_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
584#define EXT4_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
585 EXT4_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
586#define EXT4_CLEAR_INCOMPAT_FEATURE(sb,mask) \
587 EXT4_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
588
589#define EXT4_FEATURE_COMPAT_DIR_PREALLOC 0x0001
590#define EXT4_FEATURE_COMPAT_IMAGIC_INODES 0x0002
591#define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004
592#define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008
593#define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
594#define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
595
596#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
597#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
598#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
599
600#define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
601#define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
602#define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
603#define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
604#define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
605#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
606#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
607
608#define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
609#define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
610 EXT4_FEATURE_INCOMPAT_RECOVER| \
611 EXT4_FEATURE_INCOMPAT_META_BG| \
612 EXT4_FEATURE_INCOMPAT_EXTENTS| \
613 EXT4_FEATURE_INCOMPAT_64BIT)
614#define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
615 EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
616 EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
617
618/*
619 * Default values for user and/or group using reserved blocks
620 */
621#define EXT4_DEF_RESUID 0
622#define EXT4_DEF_RESGID 0
623
624/*
625 * Default mount options
626 */
627#define EXT4_DEFM_DEBUG 0x0001
628#define EXT4_DEFM_BSDGROUPS 0x0002
629#define EXT4_DEFM_XATTR_USER 0x0004
630#define EXT4_DEFM_ACL 0x0008
631#define EXT4_DEFM_UID16 0x0010
632#define EXT4_DEFM_JMODE 0x0060
633#define EXT4_DEFM_JMODE_DATA 0x0020
634#define EXT4_DEFM_JMODE_ORDERED 0x0040
635#define EXT4_DEFM_JMODE_WBACK 0x0060
636
637/*
638 * Structure of a directory entry
639 */
640#define EXT4_NAME_LEN 255
641
642struct ext4_dir_entry {
643 __le32 inode; /* Inode number */
644 __le16 rec_len; /* Directory entry length */
645 __le16 name_len; /* Name length */
646 char name[EXT4_NAME_LEN]; /* File name */
647};
648
649/*
650 * The new version of the directory entry. Since EXT4 structures are
651 * stored in intel byte order, and the name_len field could never be
652 * bigger than 255 chars, it's safe to reclaim the extra byte for the
653 * file_type field.
654 */
655struct ext4_dir_entry_2 {
656 __le32 inode; /* Inode number */
657 __le16 rec_len; /* Directory entry length */
658 __u8 name_len; /* Name length */
659 __u8 file_type;
660 char name[EXT4_NAME_LEN]; /* File name */
661};
662
663/*
664 * Ext4 directory file types. Only the low 3 bits are used. The
665 * other bits are reserved for now.
666 */
667#define EXT4_FT_UNKNOWN 0
668#define EXT4_FT_REG_FILE 1
669#define EXT4_FT_DIR 2
670#define EXT4_FT_CHRDEV 3
671#define EXT4_FT_BLKDEV 4
672#define EXT4_FT_FIFO 5
673#define EXT4_FT_SOCK 6
674#define EXT4_FT_SYMLINK 7
675
676#define EXT4_FT_MAX 8
677
678/*
679 * EXT4_DIR_PAD defines the directory entries boundaries
680 *
681 * NOTE: It must be a multiple of 4
682 */
683#define EXT4_DIR_PAD 4
684#define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
685#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \
686 ~EXT4_DIR_ROUND)
687/*
688 * Hash Tree Directory indexing
689 * (c) Daniel Phillips, 2001
690 */
691
692#ifdef CONFIG_EXT4_INDEX
693 #define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \
694 EXT4_FEATURE_COMPAT_DIR_INDEX) && \
695 (EXT4_I(dir)->i_flags & EXT4_INDEX_FL))
696#define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)
697#define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
698#else
699 #define is_dx(dir) 0
700#define EXT4_DIR_LINK_MAX(dir) ((dir)->i_nlink >= EXT4_LINK_MAX)
701#define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2)
702#endif
703
704/* Legal values for the dx_root hash_version field: */
705
706#define DX_HASH_LEGACY 0
707#define DX_HASH_HALF_MD4 1
708#define DX_HASH_TEA 2
709
710#ifdef __KERNEL__
711
712/* hash info structure used by the directory hash */
713struct dx_hash_info
714{
715 u32 hash;
716 u32 minor_hash;
717 int hash_version;
718 u32 *seed;
719};
720
721#define EXT4_HTREE_EOF 0x7fffffff
722
723/*
724 * Control parameters used by ext4_htree_next_block
725 */
726#define HASH_NB_ALWAYS 1
727
728
729/*
730 * Describe an inode's exact location on disk and in memory
731 */
732struct ext4_iloc
733{
734 struct buffer_head *bh;
735 unsigned long offset;
736 unsigned long block_group;
737};
738
739static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc)
740{
741 return (struct ext4_inode *) (iloc->bh->b_data + iloc->offset);
742}
743
744/*
745 * This structure is stuffed into the struct file's private_data field
746 * for directories. It is where we put information so that we can do
747 * readdir operations in hash tree order.
748 */
749struct dir_private_info {
750 struct rb_root root;
751 struct rb_node *curr_node;
752 struct fname *extra_fname;
753 loff_t last_pos;
754 __u32 curr_hash;
755 __u32 curr_minor_hash;
756 __u32 next_hash;
757};
758
759/* calculate the first block number of the group */
760static inline ext4_fsblk_t
761ext4_group_first_block_no(struct super_block *sb, unsigned long group_no)
762{
763 return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
764 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
765}
766
767/*
768 * Special error return code only used by dx_probe() and its callers.
769 */
770#define ERR_BAD_DX_DIR -75000
771
772void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
773 unsigned long *blockgrpp, ext4_grpblk_t *offsetp);
774
775/*
776 * Function prototypes
777 */
778
779/*
780 * Ok, these declarations are also in <linux/kernel.h> but none of the
781 * ext4 source programs needs to include it so they are duplicated here.
782 */
783# define NORET_TYPE /**/
784# define ATTRIB_NORET __attribute__((noreturn))
785# define NORET_AND noreturn,
786
787/* balloc.c */
788extern unsigned int ext4_block_group(struct super_block *sb,
789 ext4_fsblk_t blocknr);
790extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,
791 ext4_fsblk_t blocknr);
792extern int ext4_bg_has_super(struct super_block *sb, int group);
793extern unsigned long ext4_bg_num_gdb(struct super_block *sb, int group);
794extern ext4_fsblk_t ext4_new_block (handle_t *handle, struct inode *inode,
795 ext4_fsblk_t goal, int *errp);
796extern ext4_fsblk_t ext4_new_blocks (handle_t *handle, struct inode *inode,
797 ext4_fsblk_t goal, unsigned long *count, int *errp);
798extern void ext4_free_blocks (handle_t *handle, struct inode *inode,
799 ext4_fsblk_t block, unsigned long count);
800extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb,
801 ext4_fsblk_t block, unsigned long count,
802 unsigned long *pdquot_freed_blocks);
803extern ext4_fsblk_t ext4_count_free_blocks (struct super_block *);
804extern void ext4_check_blocks_bitmap (struct super_block *);
805extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
806 unsigned int block_group,
807 struct buffer_head ** bh);
808extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
809extern void ext4_init_block_alloc_info(struct inode *);
810extern void ext4_rsv_window_add(struct super_block *sb, struct ext4_reserve_window_node *rsv);
811
812/* dir.c */
813extern int ext4_check_dir_entry(const char *, struct inode *,
814 struct ext4_dir_entry_2 *,
815 struct buffer_head *, unsigned long);
816extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
817 __u32 minor_hash,
818 struct ext4_dir_entry_2 *dirent);
819extern void ext4_htree_free_dir_info(struct dir_private_info *p);
820
821/* fsync.c */
822extern int ext4_sync_file (struct file *, struct dentry *, int);
823
824/* hash.c */
825extern int ext4fs_dirhash(const char *name, int len, struct
826 dx_hash_info *hinfo);
827
828/* ialloc.c */
829extern struct inode * ext4_new_inode (handle_t *, struct inode *, int);
830extern void ext4_free_inode (handle_t *, struct inode *);
831extern struct inode * ext4_orphan_get (struct super_block *, unsigned long);
832extern unsigned long ext4_count_free_inodes (struct super_block *);
833extern unsigned long ext4_count_dirs (struct super_block *);
834extern void ext4_check_inodes_bitmap (struct super_block *);
835extern unsigned long ext4_count_free (struct buffer_head *, unsigned);
836
837
838/* inode.c */
839int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
840 struct buffer_head *bh, ext4_fsblk_t blocknr);
841struct buffer_head * ext4_getblk (handle_t *, struct inode *, long, int, int *);
842struct buffer_head * ext4_bread (handle_t *, struct inode *, int, int, int *);
843int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
844 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
845 int create, int extend_disksize);
846
847extern void ext4_read_inode (struct inode *);
848extern int ext4_write_inode (struct inode *, int);
849extern int ext4_setattr (struct dentry *, struct iattr *);
850extern void ext4_delete_inode (struct inode *);
851extern int ext4_sync_inode (handle_t *, struct inode *);
852extern void ext4_discard_reservation (struct inode *);
853extern void ext4_dirty_inode(struct inode *);
854extern int ext4_change_inode_journal_flag(struct inode *, int);
855extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
856extern void ext4_truncate (struct inode *);
857extern void ext4_set_inode_flags(struct inode *);
858extern void ext4_set_aops(struct inode *inode);
859extern int ext4_writepage_trans_blocks(struct inode *);
860extern int ext4_block_truncate_page(handle_t *handle, struct page *page,
861 struct address_space *mapping, loff_t from);
862
863/* ioctl.c */
864extern int ext4_ioctl (struct inode *, struct file *, unsigned int,
865 unsigned long);
866extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long);
867
868/* namei.c */
869extern int ext4_orphan_add(handle_t *, struct inode *);
870extern int ext4_orphan_del(handle_t *, struct inode *);
871extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
872 __u32 start_minor_hash, __u32 *next_hash);
873
874/* resize.c */
875extern int ext4_group_add(struct super_block *sb,
876 struct ext4_new_group_data *input);
877extern int ext4_group_extend(struct super_block *sb,
878 struct ext4_super_block *es,
879 ext4_fsblk_t n_blocks_count);
880
881/* super.c */
882extern void ext4_error (struct super_block *, const char *, const char *, ...)
883 __attribute__ ((format (printf, 3, 4)));
884extern void __ext4_std_error (struct super_block *, const char *, int);
885extern void ext4_abort (struct super_block *, const char *, const char *, ...)
886 __attribute__ ((format (printf, 3, 4)));
887extern void ext4_warning (struct super_block *, const char *, const char *, ...)
888 __attribute__ ((format (printf, 3, 4)));
889extern void ext4_update_dynamic_rev (struct super_block *sb);
890extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
891 struct ext4_group_desc *bg);
892extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
893 struct ext4_group_desc *bg);
894extern ext4_fsblk_t ext4_inode_table(struct super_block *sb,
895 struct ext4_group_desc *bg);
896extern void ext4_block_bitmap_set(struct super_block *sb,
897 struct ext4_group_desc *bg, ext4_fsblk_t blk);
898extern void ext4_inode_bitmap_set(struct super_block *sb,
899 struct ext4_group_desc *bg, ext4_fsblk_t blk);
900extern void ext4_inode_table_set(struct super_block *sb,
901 struct ext4_group_desc *bg, ext4_fsblk_t blk);
902
903static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)
904{
905 return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
906 le32_to_cpu(es->s_blocks_count);
907}
908
909static inline ext4_fsblk_t ext4_r_blocks_count(struct ext4_super_block *es)
910{
911 return ((ext4_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
912 le32_to_cpu(es->s_r_blocks_count);
913}
914
915static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es)
916{
917 return ((ext4_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) |
918 le32_to_cpu(es->s_free_blocks_count);
919}
920
921static inline void ext4_blocks_count_set(struct ext4_super_block *es,
922 ext4_fsblk_t blk)
923{
924 es->s_blocks_count = cpu_to_le32((u32)blk);
925 es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
926}
927
928static inline void ext4_free_blocks_count_set(struct ext4_super_block *es,
929 ext4_fsblk_t blk)
930{
931 es->s_free_blocks_count = cpu_to_le32((u32)blk);
932 es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
933}
934
935static inline void ext4_r_blocks_count_set(struct ext4_super_block *es,
936 ext4_fsblk_t blk)
937{
938 es->s_r_blocks_count = cpu_to_le32((u32)blk);
939 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
940}
941
942
943
944#define ext4_std_error(sb, errno) \
945do { \
946 if ((errno)) \
947 __ext4_std_error((sb), __FUNCTION__, (errno)); \
948} while (0)
949
950/*
951 * Inodes and files operations
952 */
953
954/* dir.c */
955extern const struct file_operations ext4_dir_operations;
956
957/* file.c */
958extern struct inode_operations ext4_file_inode_operations;
959extern const struct file_operations ext4_file_operations;
960
961/* namei.c */
962extern struct inode_operations ext4_dir_inode_operations;
963extern struct inode_operations ext4_special_inode_operations;
964
965/* symlink.c */
966extern struct inode_operations ext4_symlink_inode_operations;
967extern struct inode_operations ext4_fast_symlink_inode_operations;
968
969/* extents.c */
970extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
971extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
972extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
973 ext4_fsblk_t iblock,
974 unsigned long max_blocks, struct buffer_head *bh_result,
975 int create, int extend_disksize);
976extern void ext4_ext_truncate(struct inode *, struct page *);
977extern void ext4_ext_init(struct super_block *);
978extern void ext4_ext_release(struct super_block *);
979static inline int
980ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
981 unsigned long max_blocks, struct buffer_head *bh,
982 int create, int extend_disksize)
983{
984 if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)
985 return ext4_ext_get_blocks(handle, inode, block, max_blocks,
986 bh, create, extend_disksize);
987 return ext4_get_blocks_handle(handle, inode, block, max_blocks, bh,
988 create, extend_disksize);
989}
990
991
992#endif /* __KERNEL__ */
993
994#endif /* _LINUX_EXT4_FS_H */
diff --git a/include/linux/ext4_fs_extents.h b/include/linux/ext4_fs_extents.h
new file mode 100644
index 000000000000..a41cc24568ca
--- /dev/null
+++ b/include/linux/ext4_fs_extents.h
@@ -0,0 +1,198 @@
1/*
2 * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
3 * Written by Alex Tomas <alex@clusterfs.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public Licens
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
17 */
18
19#ifndef _LINUX_EXT4_EXTENTS
20#define _LINUX_EXT4_EXTENTS
21
22#include <linux/ext4_fs.h>
23
24/*
25 * With AGRESSIVE_TEST defined, the capacity of index/leaf blocks
26 * becomes very small, so index split, in-depth growing and
27 * other hard changes happen much more often.
28 * This is for debug purposes only.
29 */
30#define AGRESSIVE_TEST_
31
32/*
33 * With EXTENTS_STATS defined, the number of blocks and extents
34 * are collected in the truncate path. They'll be shown at
35 * umount time.
36 */
37#define EXTENTS_STATS__
38
39/*
40 * If CHECK_BINSEARCH is defined, then the results of the binary search
41 * will also be checked by linear search.
42 */
43#define CHECK_BINSEARCH__
44
45/*
46 * If EXT_DEBUG is defined you can use the 'extdebug' mount option
47 * to get lots of info about what's going on.
48 */
49#define EXT_DEBUG__
50#ifdef EXT_DEBUG
51#define ext_debug(a...) printk(a)
52#else
53#define ext_debug(a...)
54#endif
55
56/*
57 * If EXT_STATS is defined then stats numbers are collected.
58 * These number will be displayed at umount time.
59 */
60#define EXT_STATS_
61
62
63/*
64 * ext4_inode has i_block array (60 bytes total).
65 * The first 12 bytes store ext4_extent_header;
66 * the remainder stores an array of ext4_extent.
67 */
68
69/*
70 * This is the extent on-disk structure.
71 * It's used at the bottom of the tree.
72 */
73struct ext4_extent {
74 __le32 ee_block; /* first logical block extent covers */
75 __le16 ee_len; /* number of blocks covered by extent */
76 __le16 ee_start_hi; /* high 16 bits of physical block */
77 __le32 ee_start; /* low 32 bits of physical block */
78};
79
80/*
81 * This is index on-disk structure.
82 * It's used at all the levels except the bottom.
83 */
84struct ext4_extent_idx {
85 __le32 ei_block; /* index covers logical blocks from 'block' */
86 __le32 ei_leaf; /* pointer to the physical block of the next *
87 * level. leaf or next index could be there */
88 __le16 ei_leaf_hi; /* high 16 bits of physical block */
89 __u16 ei_unused;
90};
91
92/*
93 * Each block (leaves and indexes), even inode-stored has header.
94 */
95struct ext4_extent_header {
96 __le16 eh_magic; /* probably will support different formats */
97 __le16 eh_entries; /* number of valid entries */
98 __le16 eh_max; /* capacity of store in entries */
99 __le16 eh_depth; /* has tree real underlying blocks? */
100 __le32 eh_generation; /* generation of the tree */
101};
102
103#define EXT4_EXT_MAGIC cpu_to_le16(0xf30a)
104
105/*
106 * Array of ext4_ext_path contains path to some extent.
107 * Creation/lookup routines use it for traversal/splitting/etc.
108 * Truncate uses it to simulate recursive walking.
109 */
110struct ext4_ext_path {
111 ext4_fsblk_t p_block;
112 __u16 p_depth;
113 struct ext4_extent *p_ext;
114 struct ext4_extent_idx *p_idx;
115 struct ext4_extent_header *p_hdr;
116 struct buffer_head *p_bh;
117};
118
119/*
120 * structure for external API
121 */
122
123#define EXT4_EXT_CACHE_NO 0
124#define EXT4_EXT_CACHE_GAP 1
125#define EXT4_EXT_CACHE_EXTENT 2
126
127/*
128 * to be called by ext4_ext_walk_space()
129 * negative retcode - error
130 * positive retcode - signal for ext4_ext_walk_space(), see below
131 * callback must return valid extent (passed or newly created)
132 */
133typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
134 struct ext4_ext_cache *,
135 void *);
136
137#define EXT_CONTINUE 0
138#define EXT_BREAK 1
139#define EXT_REPEAT 2
140
141
142#define EXT_MAX_BLOCK 0xffffffff
143
144#define EXT_MAX_LEN ((1UL << 15) - 1)
145
146
147#define EXT_FIRST_EXTENT(__hdr__) \
148 ((struct ext4_extent *) (((char *) (__hdr__)) + \
149 sizeof(struct ext4_extent_header)))
150#define EXT_FIRST_INDEX(__hdr__) \
151 ((struct ext4_extent_idx *) (((char *) (__hdr__)) + \
152 sizeof(struct ext4_extent_header)))
153#define EXT_HAS_FREE_INDEX(__path__) \
154 (le16_to_cpu((__path__)->p_hdr->eh_entries) \
155 < le16_to_cpu((__path__)->p_hdr->eh_max))
156#define EXT_LAST_EXTENT(__hdr__) \
157 (EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
158#define EXT_LAST_INDEX(__hdr__) \
159 (EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
160#define EXT_MAX_EXTENT(__hdr__) \
161 (EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
162#define EXT_MAX_INDEX(__hdr__) \
163 (EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
164
165static inline struct ext4_extent_header *ext_inode_hdr(struct inode *inode)
166{
167 return (struct ext4_extent_header *) EXT4_I(inode)->i_data;
168}
169
170static inline struct ext4_extent_header *ext_block_hdr(struct buffer_head *bh)
171{
172 return (struct ext4_extent_header *) bh->b_data;
173}
174
175static inline unsigned short ext_depth(struct inode *inode)
176{
177 return le16_to_cpu(ext_inode_hdr(inode)->eh_depth);
178}
179
180static inline void ext4_ext_tree_changed(struct inode *inode)
181{
182 EXT4_I(inode)->i_ext_generation++;
183}
184
185static inline void
186ext4_ext_invalidate_cache(struct inode *inode)
187{
188 EXT4_I(inode)->i_cached_extent.ec_type = EXT4_EXT_CACHE_NO;
189}
190
191extern int ext4_extent_tree_init(handle_t *, struct inode *);
192extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *);
193extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *);
194extern int ext4_ext_walk_space(struct inode *, unsigned long, unsigned long, ext_prepare_callback, void *);
195extern struct ext4_ext_path * ext4_ext_find_extent(struct inode *, int, struct ext4_ext_path *);
196
197#endif /* _LINUX_EXT4_EXTENTS */
198
diff --git a/include/linux/ext4_fs_i.h b/include/linux/ext4_fs_i.h
new file mode 100644
index 000000000000..bb42379cb7fd
--- /dev/null
+++ b/include/linux/ext4_fs_i.h
@@ -0,0 +1,158 @@
1/*
2 * linux/include/linux/ext4_fs_i.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs_i.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT4_FS_I
17#define _LINUX_EXT4_FS_I
18
19#include <linux/rwsem.h>
20#include <linux/rbtree.h>
21#include <linux/seqlock.h>
22#include <linux/mutex.h>
23
24/* data type for block offset of block group */
25typedef int ext4_grpblk_t;
26
27/* data type for filesystem-wide blocks number */
28typedef unsigned long long ext4_fsblk_t;
29
30struct ext4_reserve_window {
31 ext4_fsblk_t _rsv_start; /* First byte reserved */
32 ext4_fsblk_t _rsv_end; /* Last byte reserved or 0 */
33};
34
35struct ext4_reserve_window_node {
36 struct rb_node rsv_node;
37 __u32 rsv_goal_size;
38 __u32 rsv_alloc_hit;
39 struct ext4_reserve_window rsv_window;
40};
41
42struct ext4_block_alloc_info {
43 /* information about reservation window */
44 struct ext4_reserve_window_node rsv_window_node;
45 /*
46 * was i_next_alloc_block in ext4_inode_info
47 * is the logical (file-relative) number of the
48 * most-recently-allocated block in this file.
49 * We use this for detecting linearly ascending allocation requests.
50 */
51 __u32 last_alloc_logical_block;
52 /*
53 * Was i_next_alloc_goal in ext4_inode_info
54 * is the *physical* companion to i_next_alloc_block.
55 * it the the physical block number of the block which was most-recentl
56 * allocated to this file. This give us the goal (target) for the next
57 * allocation when we detect linearly ascending requests.
58 */
59 ext4_fsblk_t last_alloc_physical_block;
60};
61
62#define rsv_start rsv_window._rsv_start
63#define rsv_end rsv_window._rsv_end
64
65/*
66 * storage for cached extent
67 */
68struct ext4_ext_cache {
69 ext4_fsblk_t ec_start;
70 __u32 ec_block;
71 __u32 ec_len; /* must be 32bit to return holes */
72 __u32 ec_type;
73};
74
75/*
76 * third extended file system inode data in memory
77 */
78struct ext4_inode_info {
79 __le32 i_data[15]; /* unconverted */
80 __u32 i_flags;
81#ifdef EXT4_FRAGMENTS
82 __u32 i_faddr;
83 __u8 i_frag_no;
84 __u8 i_frag_size;
85#endif
86 ext4_fsblk_t i_file_acl;
87 __u32 i_dir_acl;
88 __u32 i_dtime;
89
90 /*
91 * i_block_group is the number of the block group which contains
92 * this file's inode. Constant across the lifetime of the inode,
93 * it is ued for making block allocation decisions - we try to
94 * place a file's data blocks near its inode block, and new inodes
95 * near to their parent directory's inode.
96 */
97 __u32 i_block_group;
98 __u32 i_state; /* Dynamic state flags for ext4 */
99
100 /* block reservation info */
101 struct ext4_block_alloc_info *i_block_alloc_info;
102
103 __u32 i_dir_start_lookup;
104#ifdef CONFIG_EXT4DEV_FS_XATTR
105 /*
106 * Extended attributes can be read independently of the main file
107 * data. Taking i_mutex even when reading would cause contention
108 * between readers of EAs and writers of regular file data, so
109 * instead we synchronize on xattr_sem when reading or changing
110 * EAs.
111 */
112 struct rw_semaphore xattr_sem;
113#endif
114#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
115 struct posix_acl *i_acl;
116 struct posix_acl *i_default_acl;
117#endif
118
119 struct list_head i_orphan; /* unlinked but open inodes */
120
121 /*
122 * i_disksize keeps track of what the inode size is ON DISK, not
123 * in memory. During truncate, i_size is set to the new size by
124 * the VFS prior to calling ext4_truncate(), but the filesystem won't
125 * set i_disksize to 0 until the truncate is actually under way.
126 *
127 * The intent is that i_disksize always represents the blocks which
128 * are used by this file. This allows recovery to restart truncate
129 * on orphans if we crash during truncate. We actually write i_disksize
130 * into the on-disk inode when writing inodes out, instead of i_size.
131 *
132 * The only time when i_disksize and i_size may be different is when
133 * a truncate is in progress. The only things which change i_disksize
134 * are ext4_get_block (growth) and ext4_truncate (shrinkth).
135 */
136 loff_t i_disksize;
137
138 /* on-disk additional length */
139 __u16 i_extra_isize;
140
141 /*
142 * truncate_mutex is for serialising ext4_truncate() against
143 * ext4_getblock(). In the 2.4 ext2 design, great chunks of inode's
144 * data tree are chopped off during truncate. We can't do that in
145 * ext4 because whenever we perform intermediate commits during
146 * truncate, the inode and all the metadata blocks *must* be in a
147 * consistent state which allows truncation of the orphans to restart
148 * during recovery. Hence we must fix the get_block-vs-truncate race
149 * by other means, so we have truncate_mutex.
150 */
151 struct mutex truncate_mutex;
152 struct inode vfs_inode;
153
154 unsigned long i_ext_generation;
155 struct ext4_ext_cache i_cached_extent;
156};
157
158#endif /* _LINUX_EXT4_FS_I */
diff --git a/include/linux/ext4_fs_sb.h b/include/linux/ext4_fs_sb.h
new file mode 100644
index 000000000000..691a713139ce
--- /dev/null
+++ b/include/linux/ext4_fs_sb.h
@@ -0,0 +1,94 @@
1/*
2 * linux/include/linux/ext4_fs_sb.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs_sb.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT4_FS_SB
17#define _LINUX_EXT4_FS_SB
18
19#ifdef __KERNEL__
20#include <linux/timer.h>
21#include <linux/wait.h>
22#include <linux/blockgroup_lock.h>
23#include <linux/percpu_counter.h>
24#endif
25#include <linux/rbtree.h>
26
27/*
28 * third extended-fs super-block data in memory
29 */
30struct ext4_sb_info {
31 unsigned long s_frag_size; /* Size of a fragment in bytes */
32 unsigned long s_desc_size; /* Size of a group descriptor in bytes */
33 unsigned long s_frags_per_block;/* Number of fragments per block */
34 unsigned long s_inodes_per_block;/* Number of inodes per block */
35 unsigned long s_frags_per_group;/* Number of fragments in a group */
36 unsigned long s_blocks_per_group;/* Number of blocks in a group */
37 unsigned long s_inodes_per_group;/* Number of inodes in a group */
38 unsigned long s_itb_per_group; /* Number of inode table blocks per group */
39 unsigned long s_gdb_count; /* Number of group descriptor blocks */
40 unsigned long s_desc_per_block; /* Number of group descriptors per block */
41 unsigned long s_groups_count; /* Number of groups in the fs */
42 struct buffer_head * s_sbh; /* Buffer containing the super block */
43 struct ext4_super_block * s_es; /* Pointer to the super block in the buffer */
44 struct buffer_head ** s_group_desc;
45 unsigned long s_mount_opt;
46 uid_t s_resuid;
47 gid_t s_resgid;
48 unsigned short s_mount_state;
49 unsigned short s_pad;
50 int s_addr_per_block_bits;
51 int s_desc_per_block_bits;
52 int s_inode_size;
53 int s_first_ino;
54 spinlock_t s_next_gen_lock;
55 u32 s_next_generation;
56 u32 s_hash_seed[4];
57 int s_def_hash_version;
58 struct percpu_counter s_freeblocks_counter;
59 struct percpu_counter s_freeinodes_counter;
60 struct percpu_counter s_dirs_counter;
61 struct blockgroup_lock s_blockgroup_lock;
62
63 /* root of the per fs reservation window tree */
64 spinlock_t s_rsv_window_lock;
65 struct rb_root s_rsv_window_root;
66 struct ext4_reserve_window_node s_rsv_window_head;
67
68 /* Journaling */
69 struct inode * s_journal_inode;
70 struct journal_s * s_journal;
71 struct list_head s_orphan;
72 unsigned long s_commit_interval;
73 struct block_device *journal_bdev;
74#ifdef CONFIG_JBD_DEBUG
75 struct timer_list turn_ro_timer; /* For turning read-only (crash simulation) */
76 wait_queue_head_t ro_wait_queue; /* For people waiting for the fs to go read-only */
77#endif
78#ifdef CONFIG_QUOTA
79 char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */
80 int s_jquota_fmt; /* Format of quota to use */
81#endif
82
83#ifdef EXTENTS_STATS
84 /* ext4 extents stats */
85 unsigned long s_ext_min;
86 unsigned long s_ext_max;
87 unsigned long s_depth_max;
88 spinlock_t s_ext_stats_lock;
89 unsigned long s_ext_blocks;
90 unsigned long s_ext_extents;
91#endif
92};
93
94#endif /* _LINUX_EXT4_FS_SB */
diff --git a/include/linux/ext4_jbd2.h b/include/linux/ext4_jbd2.h
new file mode 100644
index 000000000000..72dd631912e4
--- /dev/null
+++ b/include/linux/ext4_jbd2.h
@@ -0,0 +1,273 @@
1/*
2 * linux/include/linux/ext4_jbd2.h
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
5 *
6 * Copyright 1998--1999 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Ext4-specific journaling extensions.
13 */
14
15#ifndef _LINUX_EXT4_JBD_H
16#define _LINUX_EXT4_JBD_H
17
18#include <linux/fs.h>
19#include <linux/jbd2.h>
20#include <linux/ext4_fs.h>
21
22#define EXT4_JOURNAL(inode) (EXT4_SB((inode)->i_sb)->s_journal)
23
24/* Define the number of blocks we need to account to a transaction to
25 * modify one block of data.
26 *
27 * We may have to touch one inode, one bitmap buffer, up to three
28 * indirection blocks, the group and superblock summaries, and the data
29 * block to complete the transaction.
30 *
31 * For extents-enabled fs we may have to allocate and modify up to
32 * 5 levels of tree + root which are stored in the inode. */
33
34#define EXT4_SINGLEDATA_TRANS_BLOCKS(sb) \
35 (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \
36 || test_opt(sb, EXTENTS) ? 27U : 8U)
37
38/* Extended attribute operations touch at most two data buffers,
39 * two bitmap buffers, and two group summaries, in addition to the inode
40 * and the superblock, which are already accounted for. */
41
42#define EXT4_XATTR_TRANS_BLOCKS 6U
43
44/* Define the minimum size for a transaction which modifies data. This
45 * needs to take into account the fact that we may end up modifying two
46 * quota files too (one for the group, one for the user quota). The
47 * superblock only gets updated once, of course, so don't bother
48 * counting that again for the quota updates. */
49
50#define EXT4_DATA_TRANS_BLOCKS(sb) (EXT4_SINGLEDATA_TRANS_BLOCKS(sb) + \
51 EXT4_XATTR_TRANS_BLOCKS - 2 + \
52 2*EXT4_QUOTA_TRANS_BLOCKS(sb))
53
54/* Delete operations potentially hit one directory's namespace plus an
55 * entire inode, plus arbitrary amounts of bitmap/indirection data. Be
56 * generous. We can grow the delete transaction later if necessary. */
57
58#define EXT4_DELETE_TRANS_BLOCKS(sb) (2 * EXT4_DATA_TRANS_BLOCKS(sb) + 64)
59
60/* Define an arbitrary limit for the amount of data we will anticipate
61 * writing to any given transaction. For unbounded transactions such as
62 * write(2) and truncate(2) we can write more than this, but we always
63 * start off at the maximum transaction size and grow the transaction
64 * optimistically as we go. */
65
66#define EXT4_MAX_TRANS_DATA 64U
67
68/* We break up a large truncate or write transaction once the handle's
69 * buffer credits gets this low, we need either to extend the
70 * transaction or to start a new one. Reserve enough space here for
71 * inode, bitmap, superblock, group and indirection updates for at least
72 * one block, plus two quota updates. Quota allocations are not
73 * needed. */
74
75#define EXT4_RESERVE_TRANS_BLOCKS 12U
76
77#define EXT4_INDEX_EXTRA_TRANS_BLOCKS 8
78
79#ifdef CONFIG_QUOTA
80/* Amount of blocks needed for quota update - we know that the structure was
81 * allocated so we need to update only inode+data */
82#define EXT4_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 2 : 0)
83/* Amount of blocks needed for quota insert/delete - we do some block writes
84 * but inode, sb and group updates are done only once */
85#define EXT4_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
86 (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_INIT_REWRITE) : 0)
87#define EXT4_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
88 (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_DEL_REWRITE) : 0)
89#else
90#define EXT4_QUOTA_TRANS_BLOCKS(sb) 0
91#define EXT4_QUOTA_INIT_BLOCKS(sb) 0
92#define EXT4_QUOTA_DEL_BLOCKS(sb) 0
93#endif
94
95int
96ext4_mark_iloc_dirty(handle_t *handle,
97 struct inode *inode,
98 struct ext4_iloc *iloc);
99
100/*
101 * On success, We end up with an outstanding reference count against
102 * iloc->bh. This _must_ be cleaned up later.
103 */
104
105int ext4_reserve_inode_write(handle_t *handle, struct inode *inode,
106 struct ext4_iloc *iloc);
107
108int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode);
109
110/*
111 * Wrapper functions with which ext4 calls into JBD. The intent here is
112 * to allow these to be turned into appropriate stubs so ext4 can control
113 * ext2 filesystems, so ext2+ext4 systems only nee one fs. This work hasn't
114 * been done yet.
115 */
116
117void ext4_journal_abort_handle(const char *caller, const char *err_fn,
118 struct buffer_head *bh, handle_t *handle, int err);
119
120static inline int
121__ext4_journal_get_undo_access(const char *where, handle_t *handle,
122 struct buffer_head *bh)
123{
124 int err = jbd2_journal_get_undo_access(handle, bh);
125 if (err)
126 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
127 return err;
128}
129
130static inline int
131__ext4_journal_get_write_access(const char *where, handle_t *handle,
132 struct buffer_head *bh)
133{
134 int err = jbd2_journal_get_write_access(handle, bh);
135 if (err)
136 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
137 return err;
138}
139
140static inline void
141ext4_journal_release_buffer(handle_t *handle, struct buffer_head *bh)
142{
143 jbd2_journal_release_buffer(handle, bh);
144}
145
146static inline int
147__ext4_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh)
148{
149 int err = jbd2_journal_forget(handle, bh);
150 if (err)
151 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
152 return err;
153}
154
155static inline int
156__ext4_journal_revoke(const char *where, handle_t *handle,
157 ext4_fsblk_t blocknr, struct buffer_head *bh)
158{
159 int err = jbd2_journal_revoke(handle, blocknr, bh);
160 if (err)
161 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
162 return err;
163}
164
165static inline int
166__ext4_journal_get_create_access(const char *where,
167 handle_t *handle, struct buffer_head *bh)
168{
169 int err = jbd2_journal_get_create_access(handle, bh);
170 if (err)
171 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
172 return err;
173}
174
175static inline int
176__ext4_journal_dirty_metadata(const char *where,
177 handle_t *handle, struct buffer_head *bh)
178{
179 int err = jbd2_journal_dirty_metadata(handle, bh);
180 if (err)
181 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
182 return err;
183}
184
185
186#define ext4_journal_get_undo_access(handle, bh) \
187 __ext4_journal_get_undo_access(__FUNCTION__, (handle), (bh))
188#define ext4_journal_get_write_access(handle, bh) \
189 __ext4_journal_get_write_access(__FUNCTION__, (handle), (bh))
190#define ext4_journal_revoke(handle, blocknr, bh) \
191 __ext4_journal_revoke(__FUNCTION__, (handle), (blocknr), (bh))
192#define ext4_journal_get_create_access(handle, bh) \
193 __ext4_journal_get_create_access(__FUNCTION__, (handle), (bh))
194#define ext4_journal_dirty_metadata(handle, bh) \
195 __ext4_journal_dirty_metadata(__FUNCTION__, (handle), (bh))
196#define ext4_journal_forget(handle, bh) \
197 __ext4_journal_forget(__FUNCTION__, (handle), (bh))
198
199int ext4_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
200
201handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks);
202int __ext4_journal_stop(const char *where, handle_t *handle);
203
204static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks)
205{
206 return ext4_journal_start_sb(inode->i_sb, nblocks);
207}
208
209#define ext4_journal_stop(handle) \
210 __ext4_journal_stop(__FUNCTION__, (handle))
211
212static inline handle_t *ext4_journal_current_handle(void)
213{
214 return journal_current_handle();
215}
216
217static inline int ext4_journal_extend(handle_t *handle, int nblocks)
218{
219 return jbd2_journal_extend(handle, nblocks);
220}
221
222static inline int ext4_journal_restart(handle_t *handle, int nblocks)
223{
224 return jbd2_journal_restart(handle, nblocks);
225}
226
227static inline int ext4_journal_blocks_per_page(struct inode *inode)
228{
229 return jbd2_journal_blocks_per_page(inode);
230}
231
232static inline int ext4_journal_force_commit(journal_t *journal)
233{
234 return jbd2_journal_force_commit(journal);
235}
236
237/* super.c */
238int ext4_force_commit(struct super_block *sb);
239
240static inline int ext4_should_journal_data(struct inode *inode)
241{
242 if (!S_ISREG(inode->i_mode))
243 return 1;
244 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
245 return 1;
246 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
247 return 1;
248 return 0;
249}
250
251static inline int ext4_should_order_data(struct inode *inode)
252{
253 if (!S_ISREG(inode->i_mode))
254 return 0;
255 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
256 return 0;
257 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA)
258 return 1;
259 return 0;
260}
261
262static inline int ext4_should_writeback_data(struct inode *inode)
263{
264 if (!S_ISREG(inode->i_mode))
265 return 0;
266 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
267 return 0;
268 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
269 return 1;
270 return 0;
271}
272
273#endif /* _LINUX_EXT4_JBD_H */
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index c25a38d8f600..5081d27bfa27 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -17,6 +17,7 @@ int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *
17int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *); 17int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
18int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int); 18int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int);
19void unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long); 19void unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long);
20void __unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long);
20int hugetlb_prefault(struct address_space *, struct vm_area_struct *); 21int hugetlb_prefault(struct address_space *, struct vm_area_struct *);
21int hugetlb_report_meminfo(char *); 22int hugetlb_report_meminfo(char *);
22int hugetlb_report_node_meminfo(int, char *); 23int hugetlb_report_node_meminfo(int, char *);
diff --git a/include/linux/io.h b/include/linux/io.h
index 2ad96c3f0e4e..81877ea39309 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -28,4 +28,31 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count);
28int ioremap_page_range(unsigned long addr, unsigned long end, 28int ioremap_page_range(unsigned long addr, unsigned long end,
29 unsigned long phys_addr, pgprot_t prot); 29 unsigned long phys_addr, pgprot_t prot);
30 30
31/**
32 * check_signature - find BIOS signatures
33 * @io_addr: mmio address to check
34 * @signature: signature block
35 * @length: length of signature
36 *
37 * Perform a signature comparison with the mmio address io_addr. This
38 * address should have been obtained by ioremap.
39 * Returns 1 on a match.
40 */
41
42static inline int check_signature(const volatile void __iomem *io_addr,
43 const unsigned char *signature, int length)
44{
45 int retval = 0;
46 do {
47 if (readb(io_addr) != *signature)
48 goto out;
49 io_addr++;
50 signature++;
51 length--;
52 } while (length);
53 retval = 1;
54out:
55 return retval;
56}
57
31#endif /* _LINUX_IO_H */ 58#endif /* _LINUX_IO_H */
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
new file mode 100644
index 000000000000..ddb128795781
--- /dev/null
+++ b/include/linux/jbd2.h
@@ -0,0 +1,1107 @@
1/*
2 * linux/include/linux/jbd2.h
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>
5 *
6 * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Definitions for transaction data structures for the buffer cache
13 * filesystem journaling support.
14 */
15
16#ifndef _LINUX_JBD_H
17#define _LINUX_JBD_H
18
19/* Allow this file to be included directly into e2fsprogs */
20#ifndef __KERNEL__
21#include "jfs_compat.h"
22#define JBD2_DEBUG
23#define jfs_debug jbd_debug
24#else
25
26#include <linux/types.h>
27#include <linux/buffer_head.h>
28#include <linux/journal-head.h>
29#include <linux/stddef.h>
30#include <linux/bit_spinlock.h>
31#include <linux/mutex.h>
32#include <linux/timer.h>
33
34#include <asm/semaphore.h>
35#endif
36
37#define journal_oom_retry 1
38
39/*
40 * Define JBD_PARANIOD_IOFAIL to cause a kernel BUG() if ext3 finds
41 * certain classes of error which can occur due to failed IOs. Under
42 * normal use we want ext3 to continue after such errors, because
43 * hardware _can_ fail, but for debugging purposes when running tests on
44 * known-good hardware we may want to trap these errors.
45 */
46#undef JBD_PARANOID_IOFAIL
47
48/*
49 * The default maximum commit age, in seconds.
50 */
51#define JBD_DEFAULT_MAX_COMMIT_AGE 5
52
53#ifdef CONFIG_JBD_DEBUG
54/*
55 * Define JBD_EXPENSIVE_CHECKING to enable more expensive internal
56 * consistency checks. By default we don't do this unless
57 * CONFIG_JBD_DEBUG is on.
58 */
59#define JBD_EXPENSIVE_CHECKING
60extern int jbd2_journal_enable_debug;
61
62#define jbd_debug(n, f, a...) \
63 do { \
64 if ((n) <= jbd2_journal_enable_debug) { \
65 printk (KERN_DEBUG "(%s, %d): %s: ", \
66 __FILE__, __LINE__, __FUNCTION__); \
67 printk (f, ## a); \
68 } \
69 } while (0)
70#else
71#define jbd_debug(f, a...) /**/
72#endif
73
74extern void * __jbd2_kmalloc (const char *where, size_t size, gfp_t flags, int retry);
75extern void * jbd2_slab_alloc(size_t size, gfp_t flags);
76extern void jbd2_slab_free(void *ptr, size_t size);
77
78#define jbd_kmalloc(size, flags) \
79 __jbd2_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
80#define jbd_rep_kmalloc(size, flags) \
81 __jbd2_kmalloc(__FUNCTION__, (size), (flags), 1)
82
83#define JBD2_MIN_JOURNAL_BLOCKS 1024
84
85#ifdef __KERNEL__
86
87/**
88 * typedef handle_t - The handle_t type represents a single atomic update being performed by some process.
89 *
90 * All filesystem modifications made by the process go
91 * through this handle. Recursive operations (such as quota operations)
92 * are gathered into a single update.
93 *
94 * The buffer credits field is used to account for journaled buffers
95 * being modified by the running process. To ensure that there is
96 * enough log space for all outstanding operations, we need to limit the
97 * number of outstanding buffers possible at any time. When the
98 * operation completes, any buffer credits not used are credited back to
99 * the transaction, so that at all times we know how many buffers the
100 * outstanding updates on a transaction might possibly touch.
101 *
102 * This is an opaque datatype.
103 **/
104typedef struct handle_s handle_t; /* Atomic operation type */
105
106
107/**
108 * typedef journal_t - The journal_t maintains all of the journaling state information for a single filesystem.
109 *
110 * journal_t is linked to from the fs superblock structure.
111 *
112 * We use the journal_t to keep track of all outstanding transaction
113 * activity on the filesystem, and to manage the state of the log
114 * writing process.
115 *
116 * This is an opaque datatype.
117 **/
118typedef struct journal_s journal_t; /* Journal control structure */
119#endif
120
121/*
122 * Internal structures used by the logging mechanism:
123 */
124
125#define JBD2_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
126
127/*
128 * On-disk structures
129 */
130
131/*
132 * Descriptor block types:
133 */
134
135#define JBD2_DESCRIPTOR_BLOCK 1
136#define JBD2_COMMIT_BLOCK 2
137#define JBD2_SUPERBLOCK_V1 3
138#define JBD2_SUPERBLOCK_V2 4
139#define JBD2_REVOKE_BLOCK 5
140
141/*
142 * Standard header for all descriptor blocks:
143 */
144typedef struct journal_header_s
145{
146 __be32 h_magic;
147 __be32 h_blocktype;
148 __be32 h_sequence;
149} journal_header_t;
150
151
152/*
153 * The block tag: used to describe a single buffer in the journal.
154 * t_blocknr_high is only used if INCOMPAT_64BIT is set, so this
155 * raw struct shouldn't be used for pointer math or sizeof() - use
156 * journal_tag_bytes(journal) instead to compute this.
157 */
158typedef struct journal_block_tag_s
159{
160 __be32 t_blocknr; /* The on-disk block number */
161 __be32 t_flags; /* See below */
162 __be32 t_blocknr_high; /* most-significant high 32bits. */
163} journal_block_tag_t;
164
165#define JBD_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high))
166#define JBD_TAG_SIZE64 (sizeof(journal_block_tag_t))
167
168/*
169 * The revoke descriptor: used on disk to describe a series of blocks to
170 * be revoked from the log
171 */
172typedef struct jbd2_journal_revoke_header_s
173{
174 journal_header_t r_header;
175 __be32 r_count; /* Count of bytes used in the block */
176} jbd2_journal_revoke_header_t;
177
178
179/* Definitions for the journal tag flags word: */
180#define JBD2_FLAG_ESCAPE 1 /* on-disk block is escaped */
181#define JBD2_FLAG_SAME_UUID 2 /* block has same uuid as previous */
182#define JBD2_FLAG_DELETED 4 /* block deleted by this transaction */
183#define JBD2_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
184
185
186/*
187 * The journal superblock. All fields are in big-endian byte order.
188 */
189typedef struct journal_superblock_s
190{
191/* 0x0000 */
192 journal_header_t s_header;
193
194/* 0x000C */
195 /* Static information describing the journal */
196 __be32 s_blocksize; /* journal device blocksize */
197 __be32 s_maxlen; /* total blocks in journal file */
198 __be32 s_first; /* first block of log information */
199
200/* 0x0018 */
201 /* Dynamic information describing the current state of the log */
202 __be32 s_sequence; /* first commit ID expected in log */
203 __be32 s_start; /* blocknr of start of log */
204
205/* 0x0020 */
206 /* Error value, as set by jbd2_journal_abort(). */
207 __be32 s_errno;
208
209/* 0x0024 */
210 /* Remaining fields are only valid in a version-2 superblock */
211 __be32 s_feature_compat; /* compatible feature set */
212 __be32 s_feature_incompat; /* incompatible feature set */
213 __be32 s_feature_ro_compat; /* readonly-compatible feature set */
214/* 0x0030 */
215 __u8 s_uuid[16]; /* 128-bit uuid for journal */
216
217/* 0x0040 */
218 __be32 s_nr_users; /* Nr of filesystems sharing log */
219
220 __be32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
221
222/* 0x0048 */
223 __be32 s_max_transaction; /* Limit of journal blocks per trans.*/
224 __be32 s_max_trans_data; /* Limit of data blocks per trans. */
225
226/* 0x0050 */
227 __u32 s_padding[44];
228
229/* 0x0100 */
230 __u8 s_users[16*48]; /* ids of all fs'es sharing the log */
231/* 0x0400 */
232} journal_superblock_t;
233
234#define JBD2_HAS_COMPAT_FEATURE(j,mask) \
235 ((j)->j_format_version >= 2 && \
236 ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
237#define JBD2_HAS_RO_COMPAT_FEATURE(j,mask) \
238 ((j)->j_format_version >= 2 && \
239 ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))
240#define JBD2_HAS_INCOMPAT_FEATURE(j,mask) \
241 ((j)->j_format_version >= 2 && \
242 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
243
244#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
245#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
246
247/* Features known to this kernel version: */
248#define JBD2_KNOWN_COMPAT_FEATURES 0
249#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
250#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \
251 JBD2_FEATURE_INCOMPAT_64BIT)
252
253#ifdef __KERNEL__
254
255#include <linux/fs.h>
256#include <linux/sched.h>
257
258#define JBD_ASSERTIONS
259#ifdef JBD_ASSERTIONS
260#define J_ASSERT(assert) \
261do { \
262 if (!(assert)) { \
263 printk (KERN_EMERG \
264 "Assertion failure in %s() at %s:%d: \"%s\"\n", \
265 __FUNCTION__, __FILE__, __LINE__, # assert); \
266 BUG(); \
267 } \
268} while (0)
269
270#if defined(CONFIG_BUFFER_DEBUG)
271void buffer_assertion_failure(struct buffer_head *bh);
272#define J_ASSERT_BH(bh, expr) \
273 do { \
274 if (!(expr)) \
275 buffer_assertion_failure(bh); \
276 J_ASSERT(expr); \
277 } while (0)
278#define J_ASSERT_JH(jh, expr) J_ASSERT_BH(jh2bh(jh), expr)
279#else
280#define J_ASSERT_BH(bh, expr) J_ASSERT(expr)
281#define J_ASSERT_JH(jh, expr) J_ASSERT(expr)
282#endif
283
284#else
285#define J_ASSERT(assert) do { } while (0)
286#endif /* JBD_ASSERTIONS */
287
288#if defined(JBD_PARANOID_IOFAIL)
289#define J_EXPECT(expr, why...) J_ASSERT(expr)
290#define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr)
291#define J_EXPECT_JH(jh, expr, why...) J_ASSERT_JH(jh, expr)
292#else
293#define __journal_expect(expr, why...) \
294 ({ \
295 int val = (expr); \
296 if (!val) { \
297 printk(KERN_ERR \
298 "EXT3-fs unexpected failure: %s;\n",# expr); \
299 printk(KERN_ERR why "\n"); \
300 } \
301 val; \
302 })
303#define J_EXPECT(expr, why...) __journal_expect(expr, ## why)
304#define J_EXPECT_BH(bh, expr, why...) __journal_expect(expr, ## why)
305#define J_EXPECT_JH(jh, expr, why...) __journal_expect(expr, ## why)
306#endif
307
308enum jbd_state_bits {
309 BH_JBD /* Has an attached ext3 journal_head */
310 = BH_PrivateStart,
311 BH_JWrite, /* Being written to log (@@@ DEBUGGING) */
312 BH_Freed, /* Has been freed (truncated) */
313 BH_Revoked, /* Has been revoked from the log */
314 BH_RevokeValid, /* Revoked flag is valid */
315 BH_JBDDirty, /* Is dirty but journaled */
316 BH_State, /* Pins most journal_head state */
317 BH_JournalHead, /* Pins bh->b_private and jh->b_bh */
318 BH_Unshadow, /* Dummy bit, for BJ_Shadow wakeup filtering */
319};
320
321BUFFER_FNS(JBD, jbd)
322BUFFER_FNS(JWrite, jwrite)
323BUFFER_FNS(JBDDirty, jbddirty)
324TAS_BUFFER_FNS(JBDDirty, jbddirty)
325BUFFER_FNS(Revoked, revoked)
326TAS_BUFFER_FNS(Revoked, revoked)
327BUFFER_FNS(RevokeValid, revokevalid)
328TAS_BUFFER_FNS(RevokeValid, revokevalid)
329BUFFER_FNS(Freed, freed)
330
331static inline struct buffer_head *jh2bh(struct journal_head *jh)
332{
333 return jh->b_bh;
334}
335
336static inline struct journal_head *bh2jh(struct buffer_head *bh)
337{
338 return bh->b_private;
339}
340
341static inline void jbd_lock_bh_state(struct buffer_head *bh)
342{
343 bit_spin_lock(BH_State, &bh->b_state);
344}
345
346static inline int jbd_trylock_bh_state(struct buffer_head *bh)
347{
348 return bit_spin_trylock(BH_State, &bh->b_state);
349}
350
351static inline int jbd_is_locked_bh_state(struct buffer_head *bh)
352{
353 return bit_spin_is_locked(BH_State, &bh->b_state);
354}
355
356static inline void jbd_unlock_bh_state(struct buffer_head *bh)
357{
358 bit_spin_unlock(BH_State, &bh->b_state);
359}
360
361static inline void jbd_lock_bh_journal_head(struct buffer_head *bh)
362{
363 bit_spin_lock(BH_JournalHead, &bh->b_state);
364}
365
366static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
367{
368 bit_spin_unlock(BH_JournalHead, &bh->b_state);
369}
370
371struct jbd2_revoke_table_s;
372
373/**
374 * struct handle_s - The handle_s type is the concrete type associated with
375 * handle_t.
376 * @h_transaction: Which compound transaction is this update a part of?
377 * @h_buffer_credits: Number of remaining buffers we are allowed to dirty.
378 * @h_ref: Reference count on this handle
379 * @h_err: Field for caller's use to track errors through large fs operations
380 * @h_sync: flag for sync-on-close
381 * @h_jdata: flag to force data journaling
382 * @h_aborted: flag indicating fatal error on handle
383 **/
384
385/* Docbook can't yet cope with the bit fields, but will leave the documentation
386 * in so it can be fixed later.
387 */
388
389struct handle_s
390{
391 /* Which compound transaction is this update a part of? */
392 transaction_t *h_transaction;
393
394 /* Number of remaining buffers we are allowed to dirty: */
395 int h_buffer_credits;
396
397 /* Reference count on this handle */
398 int h_ref;
399
400 /* Field for caller's use to track errors through large fs */
401 /* operations */
402 int h_err;
403
404 /* Flags [no locking] */
405 unsigned int h_sync: 1; /* sync-on-close */
406 unsigned int h_jdata: 1; /* force data journaling */
407 unsigned int h_aborted: 1; /* fatal error on handle */
408};
409
410
411/* The transaction_t type is the guts of the journaling mechanism. It
412 * tracks a compound transaction through its various states:
413 *
414 * RUNNING: accepting new updates
415 * LOCKED: Updates still running but we don't accept new ones
416 * RUNDOWN: Updates are tidying up but have finished requesting
417 * new buffers to modify (state not used for now)
418 * FLUSH: All updates complete, but we are still writing to disk
419 * COMMIT: All data on disk, writing commit record
420 * FINISHED: We still have to keep the transaction for checkpointing.
421 *
422 * The transaction keeps track of all of the buffers modified by a
423 * running transaction, and all of the buffers committed but not yet
424 * flushed to home for finished transactions.
425 */
426
427/*
428 * Lock ranking:
429 *
430 * j_list_lock
431 * ->jbd_lock_bh_journal_head() (This is "innermost")
432 *
433 * j_state_lock
434 * ->jbd_lock_bh_state()
435 *
436 * jbd_lock_bh_state()
437 * ->j_list_lock
438 *
439 * j_state_lock
440 * ->t_handle_lock
441 *
442 * j_state_lock
443 * ->j_list_lock (journal_unmap_buffer)
444 *
445 */
446
447struct transaction_s
448{
449 /* Pointer to the journal for this transaction. [no locking] */
450 journal_t *t_journal;
451
452 /* Sequence number for this transaction [no locking] */
453 tid_t t_tid;
454
455 /*
456 * Transaction's current state
457 * [no locking - only kjournald2 alters this]
458 * FIXME: needs barriers
459 * KLUDGE: [use j_state_lock]
460 */
461 enum {
462 T_RUNNING,
463 T_LOCKED,
464 T_RUNDOWN,
465 T_FLUSH,
466 T_COMMIT,
467 T_FINISHED
468 } t_state;
469
470 /*
471 * Where in the log does this transaction's commit start? [no locking]
472 */
473 unsigned long t_log_start;
474
475 /* Number of buffers on the t_buffers list [j_list_lock] */
476 int t_nr_buffers;
477
478 /*
479 * Doubly-linked circular list of all buffers reserved but not yet
480 * modified by this transaction [j_list_lock]
481 */
482 struct journal_head *t_reserved_list;
483
484 /*
485 * Doubly-linked circular list of all buffers under writeout during
486 * commit [j_list_lock]
487 */
488 struct journal_head *t_locked_list;
489
490 /*
491 * Doubly-linked circular list of all metadata buffers owned by this
492 * transaction [j_list_lock]
493 */
494 struct journal_head *t_buffers;
495
496 /*
497 * Doubly-linked circular list of all data buffers still to be
498 * flushed before this transaction can be committed [j_list_lock]
499 */
500 struct journal_head *t_sync_datalist;
501
502 /*
503 * Doubly-linked circular list of all forget buffers (superseded
504 * buffers which we can un-checkpoint once this transaction commits)
505 * [j_list_lock]
506 */
507 struct journal_head *t_forget;
508
509 /*
510 * Doubly-linked circular list of all buffers still to be flushed before
511 * this transaction can be checkpointed. [j_list_lock]
512 */
513 struct journal_head *t_checkpoint_list;
514
515 /*
516 * Doubly-linked circular list of all buffers submitted for IO while
517 * checkpointing. [j_list_lock]
518 */
519 struct journal_head *t_checkpoint_io_list;
520
521 /*
522 * Doubly-linked circular list of temporary buffers currently undergoing
523 * IO in the log [j_list_lock]
524 */
525 struct journal_head *t_iobuf_list;
526
527 /*
528 * Doubly-linked circular list of metadata buffers being shadowed by log
529 * IO. The IO buffers on the iobuf list and the shadow buffers on this
530 * list match each other one for one at all times. [j_list_lock]
531 */
532 struct journal_head *t_shadow_list;
533
534 /*
535 * Doubly-linked circular list of control buffers being written to the
536 * log. [j_list_lock]
537 */
538 struct journal_head *t_log_list;
539
540 /*
541 * Protects info related to handles
542 */
543 spinlock_t t_handle_lock;
544
545 /*
546 * Number of outstanding updates running on this transaction
547 * [t_handle_lock]
548 */
549 int t_updates;
550
551 /*
552 * Number of buffers reserved for use by all handles in this transaction
553 * handle but not yet modified. [t_handle_lock]
554 */
555 int t_outstanding_credits;
556
557 /*
558 * Forward and backward links for the circular list of all transactions
559 * awaiting checkpoint. [j_list_lock]
560 */
561 transaction_t *t_cpnext, *t_cpprev;
562
563 /*
564 * When will the transaction expire (become due for commit), in jiffies?
565 * [no locking]
566 */
567 unsigned long t_expires;
568
569 /*
570 * How many handles used this transaction? [t_handle_lock]
571 */
572 int t_handle_count;
573
574};
575
576/**
577 * struct journal_s - The journal_s type is the concrete type associated with
578 * journal_t.
579 * @j_flags: General journaling state flags
580 * @j_errno: Is there an outstanding uncleared error on the journal (from a
581 * prior abort)?
582 * @j_sb_buffer: First part of superblock buffer
583 * @j_superblock: Second part of superblock buffer
584 * @j_format_version: Version of the superblock format
585 * @j_state_lock: Protect the various scalars in the journal
586 * @j_barrier_count: Number of processes waiting to create a barrier lock
587 * @j_barrier: The barrier lock itself
588 * @j_running_transaction: The current running transaction..
589 * @j_committing_transaction: the transaction we are pushing to disk
590 * @j_checkpoint_transactions: a linked circular list of all transactions
591 * waiting for checkpointing
592 * @j_wait_transaction_locked: Wait queue for waiting for a locked transaction
593 * to start committing, or for a barrier lock to be released
594 * @j_wait_logspace: Wait queue for waiting for checkpointing to complete
595 * @j_wait_done_commit: Wait queue for waiting for commit to complete
596 * @j_wait_checkpoint: Wait queue to trigger checkpointing
597 * @j_wait_commit: Wait queue to trigger commit
598 * @j_wait_updates: Wait queue to wait for updates to complete
599 * @j_checkpoint_mutex: Mutex for locking against concurrent checkpoints
600 * @j_head: Journal head - identifies the first unused block in the journal
601 * @j_tail: Journal tail - identifies the oldest still-used block in the
602 * journal.
603 * @j_free: Journal free - how many free blocks are there in the journal?
604 * @j_first: The block number of the first usable block
605 * @j_last: The block number one beyond the last usable block
606 * @j_dev: Device where we store the journal
607 * @j_blocksize: blocksize for the location where we store the journal.
608 * @j_blk_offset: starting block offset for into the device where we store the
609 * journal
610 * @j_fs_dev: Device which holds the client fs. For internal journal this will
611 * be equal to j_dev
612 * @j_maxlen: Total maximum capacity of the journal region on disk.
613 * @j_list_lock: Protects the buffer lists and internal buffer state.
614 * @j_inode: Optional inode where we store the journal. If present, all journal
615 * block numbers are mapped into this inode via bmap().
616 * @j_tail_sequence: Sequence number of the oldest transaction in the log
617 * @j_transaction_sequence: Sequence number of the next transaction to grant
618 * @j_commit_sequence: Sequence number of the most recently committed
619 * transaction
620 * @j_commit_request: Sequence number of the most recent transaction wanting
621 * commit
622 * @j_uuid: Uuid of client object.
623 * @j_task: Pointer to the current commit thread for this journal
624 * @j_max_transaction_buffers: Maximum number of metadata buffers to allow in a
625 * single compound commit transaction
626 * @j_commit_interval: What is the maximum transaction lifetime before we begin
627 * a commit?
628 * @j_commit_timer: The timer used to wakeup the commit thread
629 * @j_revoke_lock: Protect the revoke table
630 * @j_revoke: The revoke table - maintains the list of revoked blocks in the
631 * current transaction.
632 * @j_revoke_table: alternate revoke tables for j_revoke
633 * @j_wbuf: array of buffer_heads for jbd2_journal_commit_transaction
634 * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the
635 * number that will fit in j_blocksize
636 * @j_last_sync_writer: most recent pid which did a synchronous write
637 * @j_private: An opaque pointer to fs-private information.
638 */
639
640struct journal_s
641{
642 /* General journaling state flags [j_state_lock] */
643 unsigned long j_flags;
644
645 /*
646 * Is there an outstanding uncleared error on the journal (from a prior
647 * abort)? [j_state_lock]
648 */
649 int j_errno;
650
651 /* The superblock buffer */
652 struct buffer_head *j_sb_buffer;
653 journal_superblock_t *j_superblock;
654
655 /* Version of the superblock format */
656 int j_format_version;
657
658 /*
659 * Protect the various scalars in the journal
660 */
661 spinlock_t j_state_lock;
662
663 /*
664 * Number of processes waiting to create a barrier lock [j_state_lock]
665 */
666 int j_barrier_count;
667
668 /* The barrier lock itself */
669 struct mutex j_barrier;
670
671 /*
672 * Transactions: The current running transaction...
673 * [j_state_lock] [caller holding open handle]
674 */
675 transaction_t *j_running_transaction;
676
677 /*
678 * the transaction we are pushing to disk
679 * [j_state_lock] [caller holding open handle]
680 */
681 transaction_t *j_committing_transaction;
682
683 /*
684 * ... and a linked circular list of all transactions waiting for
685 * checkpointing. [j_list_lock]
686 */
687 transaction_t *j_checkpoint_transactions;
688
689 /*
690 * Wait queue for waiting for a locked transaction to start committing,
691 * or for a barrier lock to be released
692 */
693 wait_queue_head_t j_wait_transaction_locked;
694
695 /* Wait queue for waiting for checkpointing to complete */
696 wait_queue_head_t j_wait_logspace;
697
698 /* Wait queue for waiting for commit to complete */
699 wait_queue_head_t j_wait_done_commit;
700
701 /* Wait queue to trigger checkpointing */
702 wait_queue_head_t j_wait_checkpoint;
703
704 /* Wait queue to trigger commit */
705 wait_queue_head_t j_wait_commit;
706
707 /* Wait queue to wait for updates to complete */
708 wait_queue_head_t j_wait_updates;
709
710 /* Semaphore for locking against concurrent checkpoints */
711 struct mutex j_checkpoint_mutex;
712
713 /*
714 * Journal head: identifies the first unused block in the journal.
715 * [j_state_lock]
716 */
717 unsigned long j_head;
718
719 /*
720 * Journal tail: identifies the oldest still-used block in the journal.
721 * [j_state_lock]
722 */
723 unsigned long j_tail;
724
725 /*
726 * Journal free: how many free blocks are there in the journal?
727 * [j_state_lock]
728 */
729 unsigned long j_free;
730
731 /*
732 * Journal start and end: the block numbers of the first usable block
733 * and one beyond the last usable block in the journal. [j_state_lock]
734 */
735 unsigned long j_first;
736 unsigned long j_last;
737
738 /*
739 * Device, blocksize and starting block offset for the location where we
740 * store the journal.
741 */
742 struct block_device *j_dev;
743 int j_blocksize;
744 unsigned long long j_blk_offset;
745
746 /*
747 * Device which holds the client fs. For internal journal this will be
748 * equal to j_dev.
749 */
750 struct block_device *j_fs_dev;
751
752 /* Total maximum capacity of the journal region on disk. */
753 unsigned int j_maxlen;
754
755 /*
756 * Protects the buffer lists and internal buffer state.
757 */
758 spinlock_t j_list_lock;
759
760 /* Optional inode where we store the journal. If present, all */
761 /* journal block numbers are mapped into this inode via */
762 /* bmap(). */
763 struct inode *j_inode;
764
765 /*
766 * Sequence number of the oldest transaction in the log [j_state_lock]
767 */
768 tid_t j_tail_sequence;
769
770 /*
771 * Sequence number of the next transaction to grant [j_state_lock]
772 */
773 tid_t j_transaction_sequence;
774
775 /*
776 * Sequence number of the most recently committed transaction
777 * [j_state_lock].
778 */
779 tid_t j_commit_sequence;
780
781 /*
782 * Sequence number of the most recent transaction wanting commit
783 * [j_state_lock]
784 */
785 tid_t j_commit_request;
786
787 /*
788 * Journal uuid: identifies the object (filesystem, LVM volume etc)
789 * backed by this journal. This will eventually be replaced by an array
790 * of uuids, allowing us to index multiple devices within a single
791 * journal and to perform atomic updates across them.
792 */
793 __u8 j_uuid[16];
794
795 /* Pointer to the current commit thread for this journal */
796 struct task_struct *j_task;
797
798 /*
799 * Maximum number of metadata buffers to allow in a single compound
800 * commit transaction
801 */
802 int j_max_transaction_buffers;
803
804 /*
805 * What is the maximum transaction lifetime before we begin a commit?
806 */
807 unsigned long j_commit_interval;
808
809 /* The timer used to wakeup the commit thread: */
810 struct timer_list j_commit_timer;
811
812 /*
813 * The revoke table: maintains the list of revoked blocks in the
814 * current transaction. [j_revoke_lock]
815 */
816 spinlock_t j_revoke_lock;
817 struct jbd2_revoke_table_s *j_revoke;
818 struct jbd2_revoke_table_s *j_revoke_table[2];
819
820 /*
821 * array of bhs for jbd2_journal_commit_transaction
822 */
823 struct buffer_head **j_wbuf;
824 int j_wbufsize;
825
826 pid_t j_last_sync_writer;
827
828 /*
829 * An opaque pointer to fs-private information. ext3 puts its
830 * superblock pointer here
831 */
832 void *j_private;
833};
834
835/*
836 * Journal flag definitions
837 */
838#define JBD2_UNMOUNT 0x001 /* Journal thread is being destroyed */
839#define JBD2_ABORT 0x002 /* Journaling has been aborted for errors. */
840#define JBD2_ACK_ERR 0x004 /* The errno in the sb has been acked */
841#define JBD2_FLUSHED 0x008 /* The journal superblock has been flushed */
842#define JBD2_LOADED 0x010 /* The journal superblock has been loaded */
843#define JBD2_BARRIER 0x020 /* Use IDE barriers */
844
845/*
846 * Function declarations for the journaling transaction and buffer
847 * management
848 */
849
850/* Filing buffers */
851extern void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
852extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *);
853extern void __jbd2_journal_unfile_buffer(struct journal_head *);
854extern void __jbd2_journal_refile_buffer(struct journal_head *);
855extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *);
856extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
857extern void __journal_free_buffer(struct journal_head *bh);
858extern void jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
859extern void __journal_clean_data_list(transaction_t *transaction);
860
861/* Log buffer allocation */
862extern struct journal_head * jbd2_journal_get_descriptor_buffer(journal_t *);
863int jbd2_journal_next_log_block(journal_t *, unsigned long long *);
864
865/* Commit management */
866extern void jbd2_journal_commit_transaction(journal_t *);
867
868/* Checkpoint list management */
869int __jbd2_journal_clean_checkpoint_list(journal_t *journal);
870int __jbd2_journal_remove_checkpoint(struct journal_head *);
871void __jbd2_journal_insert_checkpoint(struct journal_head *, transaction_t *);
872
873/* Buffer IO */
874extern int
875jbd2_journal_write_metadata_buffer(transaction_t *transaction,
876 struct journal_head *jh_in,
877 struct journal_head **jh_out,
878 unsigned long long blocknr);
879
880/* Transaction locking */
881extern void __wait_on_journal (journal_t *);
882
883/*
884 * Journal locking.
885 *
886 * We need to lock the journal during transaction state changes so that nobody
887 * ever tries to take a handle on the running transaction while we are in the
888 * middle of moving it to the commit phase. j_state_lock does this.
889 *
890 * Note that the locking is completely interrupt unsafe. We never touch
891 * journal structures from interrupts.
892 */
893
894static inline handle_t *journal_current_handle(void)
895{
896 return current->journal_info;
897}
898
899/* The journaling code user interface:
900 *
901 * Create and destroy handles
902 * Register buffer modifications against the current transaction.
903 */
904
905extern handle_t *jbd2_journal_start(journal_t *, int nblocks);
906extern int jbd2_journal_restart (handle_t *, int nblocks);
907extern int jbd2_journal_extend (handle_t *, int nblocks);
908extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *);
909extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *);
910extern int jbd2_journal_get_undo_access(handle_t *, struct buffer_head *);
911extern int jbd2_journal_dirty_data (handle_t *, struct buffer_head *);
912extern int jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *);
913extern void jbd2_journal_release_buffer (handle_t *, struct buffer_head *);
914extern int jbd2_journal_forget (handle_t *, struct buffer_head *);
915extern void journal_sync_buffer (struct buffer_head *);
916extern void jbd2_journal_invalidatepage(journal_t *,
917 struct page *, unsigned long);
918extern int jbd2_journal_try_to_free_buffers(journal_t *, struct page *, gfp_t);
919extern int jbd2_journal_stop(handle_t *);
920extern int jbd2_journal_flush (journal_t *);
921extern void jbd2_journal_lock_updates (journal_t *);
922extern void jbd2_journal_unlock_updates (journal_t *);
923
924extern journal_t * jbd2_journal_init_dev(struct block_device *bdev,
925 struct block_device *fs_dev,
926 unsigned long long start, int len, int bsize);
927extern journal_t * jbd2_journal_init_inode (struct inode *);
928extern int jbd2_journal_update_format (journal_t *);
929extern int jbd2_journal_check_used_features
930 (journal_t *, unsigned long, unsigned long, unsigned long);
931extern int jbd2_journal_check_available_features
932 (journal_t *, unsigned long, unsigned long, unsigned long);
933extern int jbd2_journal_set_features
934 (journal_t *, unsigned long, unsigned long, unsigned long);
935extern int jbd2_journal_create (journal_t *);
936extern int jbd2_journal_load (journal_t *journal);
937extern void jbd2_journal_destroy (journal_t *);
938extern int jbd2_journal_recover (journal_t *journal);
939extern int jbd2_journal_wipe (journal_t *, int);
940extern int jbd2_journal_skip_recovery (journal_t *);
941extern void jbd2_journal_update_superblock (journal_t *, int);
942extern void __jbd2_journal_abort_hard (journal_t *);
943extern void jbd2_journal_abort (journal_t *, int);
944extern int jbd2_journal_errno (journal_t *);
945extern void jbd2_journal_ack_err (journal_t *);
946extern int jbd2_journal_clear_err (journal_t *);
947extern int jbd2_journal_bmap(journal_t *, unsigned long, unsigned long long *);
948extern int jbd2_journal_force_commit(journal_t *);
949
950/*
951 * journal_head management
952 */
953struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh);
954struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh);
955void jbd2_journal_remove_journal_head(struct buffer_head *bh);
956void jbd2_journal_put_journal_head(struct journal_head *jh);
957
958/*
959 * handle management
960 */
961extern kmem_cache_t *jbd2_handle_cache;
962
963static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
964{
965 return kmem_cache_alloc(jbd2_handle_cache, gfp_flags);
966}
967
968static inline void jbd_free_handle(handle_t *handle)
969{
970 kmem_cache_free(jbd2_handle_cache, handle);
971}
972
973/* Primary revoke support */
974#define JOURNAL_REVOKE_DEFAULT_HASH 256
975extern int jbd2_journal_init_revoke(journal_t *, int);
976extern void jbd2_journal_destroy_revoke_caches(void);
977extern int jbd2_journal_init_revoke_caches(void);
978
979extern void jbd2_journal_destroy_revoke(journal_t *);
980extern int jbd2_journal_revoke (handle_t *, unsigned long long, struct buffer_head *);
981extern int jbd2_journal_cancel_revoke(handle_t *, struct journal_head *);
982extern void jbd2_journal_write_revoke_records(journal_t *, transaction_t *);
983
984/* Recovery revoke support */
985extern int jbd2_journal_set_revoke(journal_t *, unsigned long long, tid_t);
986extern int jbd2_journal_test_revoke(journal_t *, unsigned long long, tid_t);
987extern void jbd2_journal_clear_revoke(journal_t *);
988extern void jbd2_journal_switch_revoke_table(journal_t *journal);
989
990/*
991 * The log thread user interface:
992 *
993 * Request space in the current transaction, and force transaction commit
994 * transitions on demand.
995 */
996
997int __jbd2_log_space_left(journal_t *); /* Called with journal locked */
998int jbd2_log_start_commit(journal_t *journal, tid_t tid);
999int __jbd2_log_start_commit(journal_t *journal, tid_t tid);
1000int jbd2_journal_start_commit(journal_t *journal, tid_t *tid);
1001int jbd2_journal_force_commit_nested(journal_t *journal);
1002int jbd2_log_wait_commit(journal_t *journal, tid_t tid);
1003int jbd2_log_do_checkpoint(journal_t *journal);
1004
1005void __jbd2_log_wait_for_space(journal_t *journal);
1006extern void __jbd2_journal_drop_transaction(journal_t *, transaction_t *);
1007extern int jbd2_cleanup_journal_tail(journal_t *);
1008
1009/* Debugging code only: */
1010
1011#define jbd_ENOSYS() \
1012do { \
1013 printk (KERN_ERR "JBD unimplemented function %s\n", __FUNCTION__); \
1014 current->state = TASK_UNINTERRUPTIBLE; \
1015 schedule(); \
1016} while (1)
1017
1018/*
1019 * is_journal_abort
1020 *
1021 * Simple test wrapper function to test the JBD2_ABORT state flag. This
1022 * bit, when set, indicates that we have had a fatal error somewhere,
1023 * either inside the journaling layer or indicated to us by the client
1024 * (eg. ext3), and that we and should not commit any further
1025 * transactions.
1026 */
1027
1028static inline int is_journal_aborted(journal_t *journal)
1029{
1030 return journal->j_flags & JBD2_ABORT;
1031}
1032
1033static inline int is_handle_aborted(handle_t *handle)
1034{
1035 if (handle->h_aborted)
1036 return 1;
1037 return is_journal_aborted(handle->h_transaction->t_journal);
1038}
1039
1040static inline void jbd2_journal_abort_handle(handle_t *handle)
1041{
1042 handle->h_aborted = 1;
1043}
1044
1045#endif /* __KERNEL__ */
1046
1047/* Comparison functions for transaction IDs: perform comparisons using
1048 * modulo arithmetic so that they work over sequence number wraps. */
1049
1050static inline int tid_gt(tid_t x, tid_t y)
1051{
1052 int difference = (x - y);
1053 return (difference > 0);
1054}
1055
1056static inline int tid_geq(tid_t x, tid_t y)
1057{
1058 int difference = (x - y);
1059 return (difference >= 0);
1060}
1061
1062extern int jbd2_journal_blocks_per_page(struct inode *inode);
1063extern size_t journal_tag_bytes(journal_t *journal);
1064
1065/*
1066 * Return the minimum number of blocks which must be free in the journal
1067 * before a new transaction may be started. Must be called under j_state_lock.
1068 */
1069static inline int jbd_space_needed(journal_t *journal)
1070{
1071 int nblocks = journal->j_max_transaction_buffers;
1072 if (journal->j_committing_transaction)
1073 nblocks += journal->j_committing_transaction->
1074 t_outstanding_credits;
1075 return nblocks;
1076}
1077
1078/*
1079 * Definitions which augment the buffer_head layer
1080 */
1081
1082/* journaling buffer types */
1083#define BJ_None 0 /* Not journaled */
1084#define BJ_SyncData 1 /* Normal data: flush before commit */
1085#define BJ_Metadata 2 /* Normal journaled metadata */
1086#define BJ_Forget 3 /* Buffer superseded by this transaction */
1087#define BJ_IO 4 /* Buffer is for temporary IO use */
1088#define BJ_Shadow 5 /* Buffer contents being shadowed to the log */
1089#define BJ_LogCtl 6 /* Buffer contains log descriptors */
1090#define BJ_Reserved 7 /* Buffer is reserved for access by journal */
1091#define BJ_Locked 8 /* Locked for I/O during commit */
1092#define BJ_Types 9
1093
1094extern int jbd_blocks_per_page(struct inode *inode);
1095
1096#ifdef __KERNEL__
1097
1098#define buffer_trace_init(bh) do {} while (0)
1099#define print_buffer_fields(bh) do {} while (0)
1100#define print_buffer_trace(bh) do {} while (0)
1101#define BUFFER_TRACE(bh, info) do {} while (0)
1102#define BUFFER_TRACE2(bh, bh2, info) do {} while (0)
1103#define JBUFFER_TRACE(jh, info) do {} while (0)
1104
1105#endif /* __KERNEL__ */
1106
1107#endif /* _LINUX_JBD_H */
diff --git a/include/linux/magic.h b/include/linux/magic.h
index 22036dd2ba36..156c40fc664e 100644
--- a/include/linux/magic.h
+++ b/include/linux/magic.h
@@ -8,6 +8,7 @@
8#define EFS_SUPER_MAGIC 0x414A53 8#define EFS_SUPER_MAGIC 0x414A53
9#define EXT2_SUPER_MAGIC 0xEF53 9#define EXT2_SUPER_MAGIC 0xEF53
10#define EXT3_SUPER_MAGIC 0xEF53 10#define EXT3_SUPER_MAGIC 0xEF53
11#define EXT4_SUPER_MAGIC 0xEF53
11#define HPFS_SUPER_MAGIC 0xf995e849 12#define HPFS_SUPER_MAGIC 0xf995e849
12#define ISOFS_SUPER_MAGIC 0x9660 13#define ISOFS_SUPER_MAGIC 0x9660
13#define JFFS2_SUPER_MAGIC 0x72b6 14#define JFFS2_SUPER_MAGIC 0x72b6
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 26146623be2f..5a6068ff5556 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1103,12 +1103,7 @@ static inline void vm_stat_account(struct mm_struct *mm,
1103 1103
1104#ifndef CONFIG_DEBUG_PAGEALLOC 1104#ifndef CONFIG_DEBUG_PAGEALLOC
1105static inline void 1105static inline void
1106kernel_map_pages(struct page *page, int numpages, int enable) 1106kernel_map_pages(struct page *page, int numpages, int enable) {}
1107{
1108 if (!PageHighMem(page) && !enable)
1109 debug_check_no_locks_freed(page_address(page),
1110 numpages * PAGE_SIZE);
1111}
1112#endif 1107#endif
1113 1108
1114extern struct vm_area_struct *get_gate_vma(struct task_struct *tsk); 1109extern struct vm_area_struct *get_gate_vma(struct task_struct *tsk);
diff --git a/include/linux/module.h b/include/linux/module.h
index 4b2d8091a410..d1d00ce8f4ed 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -317,9 +317,6 @@ struct module
317 /* Am I unsafe to unload? */ 317 /* Am I unsafe to unload? */
318 int unsafe; 318 int unsafe;
319 319
320 /* Am I GPL-compatible */
321 int license_gplok;
322
323 unsigned int taints; /* same bits as kernel:tainted */ 320 unsigned int taints; /* same bits as kernel:tainted */
324 321
325#ifdef CONFIG_MODULE_UNLOAD 322#ifdef CONFIG_MODULE_UNLOAD
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index e712e7d47cc2..d6b6dc09ad97 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
@@ -15,6 +15,8 @@
15#ifndef LINUX_NBD_H 15#ifndef LINUX_NBD_H
16#define LINUX_NBD_H 16#define LINUX_NBD_H
17 17
18#include <linux/types.h>
19
18#define NBD_SET_SOCK _IO( 0xab, 0 ) 20#define NBD_SET_SOCK _IO( 0xab, 0 )
19#define NBD_SET_BLKSIZE _IO( 0xab, 1 ) 21#define NBD_SET_BLKSIZE _IO( 0xab, 1 )
20#define NBD_SET_SIZE _IO( 0xab, 2 ) 22#define NBD_SET_SIZE _IO( 0xab, 2 )
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 5dce5c21822c..b1063e9cdb1b 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -8,8 +8,8 @@
8 * See detailed comments in the file linux/bitmap.h describing the 8 * See detailed comments in the file linux/bitmap.h describing the
9 * data type on which these nodemasks are based. 9 * data type on which these nodemasks are based.
10 * 10 *
11 * For details of nodemask_scnprintf() and nodemask_parse(), 11 * For details of nodemask_scnprintf() and nodemask_parse_user(),
12 * see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c. 12 * see bitmap_scnprintf() and bitmap_parse_user() in lib/bitmap.c.
13 * For details of nodelist_scnprintf() and nodelist_parse(), see 13 * For details of nodelist_scnprintf() and nodelist_parse(), see
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c. 14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15 * For details of node_remap(), see bitmap_bitremap in lib/bitmap.c. 15 * For details of node_remap(), see bitmap_bitremap in lib/bitmap.c.
@@ -51,7 +51,7 @@
51 * unsigned long *nodes_addr(mask) Array of unsigned long's in mask 51 * unsigned long *nodes_addr(mask) Array of unsigned long's in mask
52 * 52 *
53 * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing 53 * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing
54 * int nodemask_parse(ubuf, ulen, mask) Parse ascii string as nodemask 54 * int nodemask_parse_user(ubuf, ulen, mask) Parse ascii string as nodemask
55 * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing 55 * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing
56 * int nodelist_parse(buf, map) Parse ascii string as nodelist 56 * int nodelist_parse(buf, map) Parse ascii string as nodelist
57 * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit) 57 * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
@@ -288,12 +288,12 @@ static inline int __nodemask_scnprintf(char *buf, int len,
288 return bitmap_scnprintf(buf, len, srcp->bits, nbits); 288 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
289} 289}
290 290
291#define nodemask_parse(ubuf, ulen, dst) \ 291#define nodemask_parse_user(ubuf, ulen, dst) \
292 __nodemask_parse((ubuf), (ulen), &(dst), MAX_NUMNODES) 292 __nodemask_parse_user((ubuf), (ulen), &(dst), MAX_NUMNODES)
293static inline int __nodemask_parse(const char __user *buf, int len, 293static inline int __nodemask_parse_user(const char __user *buf, int len,
294 nodemask_t *dstp, int nbits) 294 nodemask_t *dstp, int nbits)
295{ 295{
296 return bitmap_parse(buf, len, dstp->bits, nbits); 296 return bitmap_parse_user(buf, len, dstp->bits, nbits);
297} 297}
298 298
299#define nodelist_scnprintf(buf, len, src) \ 299#define nodelist_scnprintf(buf, len, src) \
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index b0ace3fd7eb9..1912c6cbef55 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -431,6 +431,10 @@ asmlinkage long sys_epoll_ctl(int epfd, int op, int fd,
431 struct epoll_event __user *event); 431 struct epoll_event __user *event);
432asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events, 432asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events,
433 int maxevents, int timeout); 433 int maxevents, int timeout);
434asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events,
435 int maxevents, int timeout,
436 const sigset_t __user *sigmask,
437 size_t sigsetsize);
434asmlinkage long sys_gethostname(char __user *name, int len); 438asmlinkage long sys_gethostname(char __user *name, int len);
435asmlinkage long sys_sethostname(char __user *name, int len); 439asmlinkage long sys_sethostname(char __user *name, int len);
436asmlinkage long sys_setdomainname(char __user *name, int len); 440asmlinkage long sys_setdomainname(char __user *name, int len);