diff options
author | Paul Mackerras <paulus@samba.org> | 2005-11-01 23:20:55 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-11-01 23:20:55 -0500 |
commit | de2d3dbd17e6bb60bde4632ce1c7df063b073934 (patch) | |
tree | dfccb1a2717a8a042a87dbade509f894810ea1cd | |
parent | 104dd65fef378773ec0510c788bd4b5ad6ea1121 (diff) | |
parent | df70b17f88a4d1d8545d3569a1f6d28c6004f9e4 (diff) |
Merge ../linux-2.6
241 files changed, 4333 insertions, 1377 deletions
diff --git a/Documentation/filesystems/ntfs.txt b/Documentation/filesystems/ntfs.txt index a5fbc8e897fa..614de3124901 100644 --- a/Documentation/filesystems/ntfs.txt +++ b/Documentation/filesystems/ntfs.txt | |||
@@ -50,9 +50,14 @@ userspace utilities, etc. | |||
50 | Features | 50 | Features |
51 | ======== | 51 | ======== |
52 | 52 | ||
53 | - This is a complete rewrite of the NTFS driver that used to be in the kernel. | 53 | - This is a complete rewrite of the NTFS driver that used to be in the 2.4 and |
54 | This new driver implements NTFS read support and is functionally equivalent | 54 | earlier kernels. This new driver implements NTFS read support and is |
55 | to the old ntfs driver. | 55 | functionally equivalent to the old ntfs driver and it also implements limited |
56 | write support. The biggest limitation at present is that files/directories | ||
57 | cannot be created or deleted. See below for the list of write features that | ||
58 | are so far supported. Another limitation is that writing to compressed files | ||
59 | is not implemented at all. Also, neither read nor write access to encrypted | ||
60 | files is so far implemented. | ||
56 | - The new driver has full support for sparse files on NTFS 3.x volumes which | 61 | - The new driver has full support for sparse files on NTFS 3.x volumes which |
57 | the old driver isn't happy with. | 62 | the old driver isn't happy with. |
58 | - The new driver supports execution of binaries due to mmap() now being | 63 | - The new driver supports execution of binaries due to mmap() now being |
@@ -78,7 +83,20 @@ Features | |||
78 | - The new driver supports fsync(2), fdatasync(2), and msync(2). | 83 | - The new driver supports fsync(2), fdatasync(2), and msync(2). |
79 | - The new driver supports readv(2) and writev(2). | 84 | - The new driver supports readv(2) and writev(2). |
80 | - The new driver supports access time updates (including mtime and ctime). | 85 | - The new driver supports access time updates (including mtime and ctime). |
81 | 86 | - The new driver supports truncate(2) and open(2) with O_TRUNC. But at present | |
87 | only very limited support for highly fragmented files, i.e. ones which have | ||
88 | their data attribute split across multiple extents, is included. Another | ||
89 | limitation is that at present truncate(2) will never create sparse files, | ||
90 | since to mark a file sparse we need to modify the directory entry for the | ||
91 | file and we do not implement directory modifications yet. | ||
92 | - The new driver supports write(2) which can both overwrite existing data and | ||
93 | extend the file size so that you can write beyond the existing data. Also, | ||
94 | writing into sparse regions is supported and the holes are filled in with | ||
95 | clusters. But at present only limited support for highly fragmented files, | ||
96 | i.e. ones which have their data attribute split across multiple extents, is | ||
97 | included. Another limitation is that write(2) will never create sparse | ||
98 | files, since to mark a file sparse we need to modify the directory entry for | ||
99 | the file and we do not implement directory modifications yet. | ||
82 | 100 | ||
83 | Supported mount options | 101 | Supported mount options |
84 | ======================= | 102 | ======================= |
@@ -439,6 +457,22 @@ ChangeLog | |||
439 | 457 | ||
440 | Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog. | 458 | Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog. |
441 | 459 | ||
460 | 2.1.25: | ||
461 | - Write support is now extended with write(2) being able to both | ||
462 | overwrite existing file data and to extend files. Also, if a write | ||
463 | to a sparse region occurs, write(2) will fill in the hole. Note, | ||
464 | mmap(2) based writes still do not support writing into holes or | ||
465 | writing beyond the initialized size. | ||
466 | - Write support has a new feature and that is that truncate(2) and | ||
467 | open(2) with O_TRUNC are now implemented thus files can be both made | ||
468 | smaller and larger. | ||
469 | - Note: Both write(2) and truncate(2)/open(2) with O_TRUNC still have | ||
470 | limitations in that they | ||
471 | - only provide limited support for highly fragmented files. | ||
472 | - only work on regular, i.e. uncompressed and unencrypted files. | ||
473 | - never create sparse files although this will change once directory | ||
474 | operations are implemented. | ||
475 | - Lots of bug fixes and enhancements across the board. | ||
442 | 2.1.24: | 476 | 2.1.24: |
443 | - Support journals ($LogFile) which have been modified by chkdsk. This | 477 | - Support journals ($LogFile) which have been modified by chkdsk. This |
444 | means users can boot into Windows after we marked the volume dirty. | 478 | means users can boot into Windows after we marked the volume dirty. |
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c index 5cdb4122f057..ad55680726ed 100644 --- a/arch/arm/common/locomo.c +++ b/arch/arm/common/locomo.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
24 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
25 | #include <linux/device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
28 | 28 | ||
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index 21e2a518ad3a..174aa86ee816 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/ptrace.h> | 22 | #include <linux/ptrace.h> |
23 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
24 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
25 | #include <linux/device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
28 | #include <linux/dma-mapping.h> | 28 | #include <linux/dma-mapping.h> |
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c index 4af0cf5f3bfb..bb4eff614413 100644 --- a/arch/arm/common/scoop.c +++ b/arch/arm/common/scoop.c | |||
@@ -13,8 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/device.h> | 14 | #include <linux/device.h> |
15 | #include <linux/string.h> | 15 | #include <linux/string.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/platform_device.h> |
17 | |||
18 | #include <asm/io.h> | 17 | #include <asm/io.h> |
19 | #include <asm/hardware/scoop.h> | 18 | #include <asm/hardware/scoop.h> |
20 | 19 | ||
diff --git a/arch/arm/mach-aaec2000/core.c b/arch/arm/mach-aaec2000/core.c index 0c53dab80905..4e706d9ad368 100644 --- a/arch/arm/mach-aaec2000/core.c +++ b/arch/arm/mach-aaec2000/core.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
18 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
19 | #include <linux/dma-mapping.h> | 19 | #include <linux/dma-mapping.h> |
diff --git a/arch/arm/mach-h720x/h7202-eval.c b/arch/arm/mach-h720x/h7202-eval.c index db9078ad008c..d75c8221d2a5 100644 --- a/arch/arm/mach-h720x/h7202-eval.c +++ b/arch/arm/mach-h720x/h7202-eval.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
20 | #include <linux/string.h> | 20 | #include <linux/string.h> |
21 | #include <linux/device.h> | 21 | #include <linux/platform_device.h> |
22 | 22 | ||
23 | #include <asm/setup.h> | 23 | #include <asm/setup.h> |
24 | #include <asm/types.h> | 24 | #include <asm/types.h> |
diff --git a/arch/arm/mach-imx/generic.c b/arch/arm/mach-imx/generic.c index 837d7f0bda4c..37613ad68366 100644 --- a/arch/arm/mach-imx/generic.c +++ b/arch/arm/mach-imx/generic.c | |||
@@ -22,7 +22,7 @@ | |||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 | * | 23 | * |
24 | */ | 24 | */ |
25 | #include <linux/device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
diff --git a/arch/arm/mach-imx/mx1ads.c b/arch/arm/mach-imx/mx1ads.c index 4cbdc1fe04b1..708e1b3faa14 100644 --- a/arch/arm/mach-imx/mx1ads.c +++ b/arch/arm/mach-imx/mx1ads.c | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/device.h> | 15 | #include <linux/device.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/platform_device.h> | ||
17 | #include <asm/system.h> | 18 | #include <asm/system.h> |
18 | #include <asm/hardware.h> | 19 | #include <asm/hardware.h> |
19 | #include <asm/irq.h> | 20 | #include <asm/irq.h> |
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index 764ceb49470a..4c0f7c65facf 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/list.h> | 23 | #include <linux/list.h> |
24 | #include <linux/device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/string.h> | 26 | #include <linux/string.h> |
27 | #include <linux/sysdev.h> | 27 | #include <linux/sysdev.h> |
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c index aa34c58b96c4..93f7ccb22c27 100644 --- a/arch/arm/mach-integrator/integrator_cp.c +++ b/arch/arm/mach-integrator/integrator_cp.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/list.h> | 13 | #include <linux/list.h> |
14 | #include <linux/device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/dma-mapping.h> | 15 | #include <linux/dma-mapping.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
diff --git a/arch/arm/mach-iop3xx/iop321-setup.c b/arch/arm/mach-iop3xx/iop321-setup.c index bb5091223b63..80770233b8d4 100644 --- a/arch/arm/mach-iop3xx/iop321-setup.c +++ b/arch/arm/mach-iop3xx/iop321-setup.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/major.h> | 17 | #include <linux/major.h> |
18 | #include <linux/fs.h> | 18 | #include <linux/fs.h> |
19 | #include <linux/device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/serial.h> | 20 | #include <linux/serial.h> |
21 | #include <linux/tty.h> | 21 | #include <linux/tty.h> |
22 | #include <linux/serial_core.h> | 22 | #include <linux/serial_core.h> |
diff --git a/arch/arm/mach-iop3xx/iop331-setup.c b/arch/arm/mach-iop3xx/iop331-setup.c index a2533c3ab42f..53f60614498b 100644 --- a/arch/arm/mach-iop3xx/iop331-setup.c +++ b/arch/arm/mach-iop3xx/iop331-setup.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/major.h> | 16 | #include <linux/major.h> |
17 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
18 | #include <linux/device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/serial.h> | 19 | #include <linux/serial.h> |
20 | #include <linux/tty.h> | 20 | #include <linux/tty.h> |
21 | #include <linux/serial_core.h> | 21 | #include <linux/serial_core.h> |
diff --git a/arch/arm/mach-ixp2000/enp2611.c b/arch/arm/mach-ixp2000/enp2611.c index 9aa54de44740..643f5e1c3d93 100644 --- a/arch/arm/mach-ixp2000/enp2611.c +++ b/arch/arm/mach-ixp2000/enp2611.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/serial.h> | 32 | #include <linux/serial.h> |
33 | #include <linux/tty.h> | 33 | #include <linux/tty.h> |
34 | #include <linux/serial_core.h> | 34 | #include <linux/serial_core.h> |
35 | #include <linux/device.h> | 35 | #include <linux/platform_device.h> |
36 | 36 | ||
37 | #include <asm/io.h> | 37 | #include <asm/io.h> |
38 | #include <asm/irq.h> | 38 | #include <asm/irq.h> |
diff --git a/arch/arm/mach-ixp2000/ixdp2x00.c b/arch/arm/mach-ixp2000/ixdp2x00.c index 8b4a839b6279..05dfcb48c2b6 100644 --- a/arch/arm/mach-ixp2000/ixdp2x00.c +++ b/arch/arm/mach-ixp2000/ixdp2x00.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/mm.h> | 20 | #include <linux/mm.h> |
21 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
22 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
23 | #include <linux/device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/bitops.h> | 24 | #include <linux/bitops.h> |
25 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
26 | #include <linux/ioport.h> | 26 | #include <linux/ioport.h> |
diff --git a/arch/arm/mach-ixp2000/ixdp2x01.c b/arch/arm/mach-ixp2000/ixdp2x01.c index fee1d7b73503..b21249908ae4 100644 --- a/arch/arm/mach-ixp2000/ixdp2x01.c +++ b/arch/arm/mach-ixp2000/ixdp2x01.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/serial.h> | 29 | #include <linux/serial.h> |
30 | #include <linux/tty.h> | 30 | #include <linux/tty.h> |
31 | #include <linux/serial_core.h> | 31 | #include <linux/serial_core.h> |
32 | #include <linux/device.h> | 32 | #include <linux/platform_device.h> |
33 | 33 | ||
34 | #include <asm/io.h> | 34 | #include <asm/io.h> |
35 | #include <asm/irq.h> | 35 | #include <asm/irq.h> |
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c index 6c396447c4e0..f3c687cf0071 100644 --- a/arch/arm/mach-ixp4xx/common.c +++ b/arch/arm/mach-ixp4xx/common.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/serial.h> | 20 | #include <linux/serial.h> |
21 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
22 | #include <linux/tty.h> | 22 | #include <linux/tty.h> |
23 | #include <linux/platform_device.h> | ||
23 | #include <linux/serial_core.h> | 24 | #include <linux/serial_core.h> |
24 | #include <linux/bootmem.h> | 25 | #include <linux/bootmem.h> |
25 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
diff --git a/arch/arm/mach-lh7a40x/arch-lpd7a40x.c b/arch/arm/mach-lh7a40x/arch-lpd7a40x.c index a20eabc132b0..4eb962fdb3a8 100644 --- a/arch/arm/mach-lh7a40x/arch-lpd7a40x.c +++ b/arch/arm/mach-lh7a40x/arch-lpd7a40x.c | |||
@@ -10,7 +10,7 @@ | |||
10 | 10 | ||
11 | #include <linux/tty.h> | 11 | #include <linux/tty.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
15 | 15 | ||
16 | #include <asm/hardware.h> | 16 | #include <asm/hardware.h> |
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c index d46a70063b0c..4ee6bd8a50b8 100644 --- a/arch/arm/mach-omap1/board-h2.c +++ b/arch/arm/mach-omap1/board-h2.c | |||
@@ -21,7 +21,7 @@ | |||
21 | 21 | ||
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/mtd/mtd.h> | 26 | #include <linux/mtd/mtd.h> |
27 | #include <linux/mtd/partitions.h> | 27 | #include <linux/mtd/partitions.h> |
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c index 2798613696fa..fc824361430d 100644 --- a/arch/arm/mach-omap1/board-h3.c +++ b/arch/arm/mach-omap1/board-h3.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/major.h> | 20 | #include <linux/major.h> |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
24 | #include <linux/mtd/mtd.h> | 24 | #include <linux/mtd/mtd.h> |
25 | #include <linux/mtd/partitions.h> | 25 | #include <linux/mtd/partitions.h> |
diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c index fd9183ff2ed5..a2eac853b2da 100644 --- a/arch/arm/mach-omap1/board-innovator.c +++ b/arch/arm/mach-omap1/board-innovator.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/mtd/mtd.h> | 23 | #include <linux/mtd/mtd.h> |
24 | #include <linux/mtd/partitions.h> | 24 | #include <linux/mtd/partitions.h> |
diff --git a/arch/arm/mach-omap1/board-netstar.c b/arch/arm/mach-omap1/board-netstar.c index d904e643f5ec..c851c2e4dfcb 100644 --- a/arch/arm/mach-omap1/board-netstar.c +++ b/arch/arm/mach-omap1/board-netstar.c | |||
@@ -11,7 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c index 21103df50415..a88524e7c315 100644 --- a/arch/arm/mach-omap1/board-osk.c +++ b/arch/arm/mach-omap1/board-osk.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/device.h> | 31 | #include <linux/platform_device.h> |
32 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
33 | 33 | ||
34 | #include <linux/mtd/mtd.h> | 34 | #include <linux/mtd/mtd.h> |
diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c index 2ba26e239108..354b157acb3a 100644 --- a/arch/arm/mach-omap1/board-perseus2.c +++ b/arch/arm/mach-omap1/board-perseus2.c | |||
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/partitions.h> | 19 | #include <linux/mtd/partitions.h> |
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c index bf30b1acda0b..3f018b296861 100644 --- a/arch/arm/mach-omap1/board-voiceblue.c +++ b/arch/arm/mach-omap1/board-voiceblue.c | |||
@@ -13,7 +13,7 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c index e8b3981444cd..3c5d901efeaa 100644 --- a/arch/arm/mach-omap1/devices.c +++ b/arch/arm/mach-omap1/devices.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/device.h> | 16 | #include <linux/platform_device.h> |
17 | 17 | ||
18 | #include <asm/hardware.h> | 18 | #include <asm/hardware.h> |
19 | #include <asm/io.h> | 19 | #include <asm/io.h> |
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c index 656f73bbcb5a..eb5f6d744a4a 100644 --- a/arch/arm/mach-pxa/corgi.c +++ b/arch/arm/mach-pxa/corgi.c | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/major.h> | 18 | #include <linux/major.h> |
19 | #include <linux/fs.h> | 19 | #include <linux/fs.h> |
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
diff --git a/arch/arm/mach-pxa/corgi_lcd.c b/arch/arm/mach-pxa/corgi_lcd.c index 370df113dc06..54162ba95414 100644 --- a/arch/arm/mach-pxa/corgi_lcd.c +++ b/arch/arm/mach-pxa/corgi_lcd.c | |||
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <asm/arch/akita.h> | 22 | #include <asm/arch/akita.h> |
23 | #include <asm/arch/corgi.h> | 23 | #include <asm/arch/corgi.h> |
diff --git a/arch/arm/mach-pxa/corgi_ssp.c b/arch/arm/mach-pxa/corgi_ssp.c index 136c269db0b7..591e5f32dbec 100644 --- a/arch/arm/mach-pxa/corgi_ssp.c +++ b/arch/arm/mach-pxa/corgi_ssp.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <asm/hardware.h> | 19 | #include <asm/hardware.h> |
20 | #include <asm/mach-types.h> | 20 | #include <asm/mach-types.h> |
21 | 21 | ||
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c index 9c0289333301..9b48a90aefce 100644 --- a/arch/arm/mach-pxa/generic.c +++ b/arch/arm/mach-pxa/generic.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
25 | #include <linux/pm.h> | 25 | #include <linux/pm.h> |
26 | #include <linux/string.h> | 26 | #include <linux/string.h> |
diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c index 01a83ab09ac3..7de159e2ab42 100644 --- a/arch/arm/mach-pxa/idp.c +++ b/arch/arm/mach-pxa/idp.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/fb.h> | 22 | #include <linux/fb.h> |
23 | 23 | ||
24 | #include <asm/setup.h> | 24 | #include <asm/setup.h> |
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c index beccf455f796..1f6857d7747d 100644 --- a/arch/arm/mach-pxa/lubbock.c +++ b/arch/arm/mach-pxa/lubbock.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/sysdev.h> | 18 | #include <linux/sysdev.h> |
19 | #include <linux/major.h> | 19 | #include <linux/major.h> |
20 | #include <linux/fb.h> | 20 | #include <linux/fb.h> |
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c index a48c64026e1f..887a8cb7b721 100644 --- a/arch/arm/mach-pxa/mainstone.c +++ b/arch/arm/mach-pxa/mainstone.c | |||
@@ -14,7 +14,7 @@ | |||
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/sysdev.h> | 18 | #include <linux/sysdev.h> |
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c index 6d413f6701a7..ad6a13f95a62 100644 --- a/arch/arm/mach-pxa/poodle.c +++ b/arch/arm/mach-pxa/poodle.c | |||
@@ -16,7 +16,7 @@ | |||
16 | */ | 16 | */ |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/fb.h> | 20 | #include <linux/fb.h> |
21 | 21 | ||
22 | #include <asm/hardware.h> | 22 | #include <asm/hardware.h> |
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c index 09a5d593f04b..c722a9a91fcc 100644 --- a/arch/arm/mach-pxa/pxa27x.c +++ b/arch/arm/mach-pxa/pxa27x.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
19 | #include <linux/device.h> | 19 | #include <linux/platform_device.h> |
20 | 20 | ||
21 | #include <asm/hardware.h> | 21 | #include <asm/hardware.h> |
22 | #include <asm/irq.h> | 22 | #include <asm/irq.h> |
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index b838842b6a20..6c6878cd2207 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/major.h> | 19 | #include <linux/major.h> |
20 | #include <linux/fs.h> | 20 | #include <linux/fs.h> |
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c index 8b3d5dc35de5..82e8253b1fa0 100644 --- a/arch/arm/mach-s3c2410/clock.c +++ b/arch/arm/mach-s3c2410/clock.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/list.h> | 32 | #include <linux/list.h> |
33 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/device.h> | 35 | #include <linux/platform_device.h> |
36 | #include <linux/sysdev.h> | 36 | #include <linux/sysdev.h> |
37 | 37 | ||
38 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
diff --git a/arch/arm/mach-s3c2410/cpu.c b/arch/arm/mach-s3c2410/cpu.c index ca366e9e264d..687fe371369d 100644 --- a/arch/arm/mach-s3c2410/cpu.c +++ b/arch/arm/mach-s3c2410/cpu.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <linux/ioport.h> | 28 | #include <linux/ioport.h> |
29 | #include <linux/device.h> | 29 | #include <linux/platform_device.h> |
30 | 30 | ||
31 | #include <asm/hardware.h> | 31 | #include <asm/hardware.h> |
32 | #include <asm/irq.h> | 32 | #include <asm/irq.h> |
diff --git a/arch/arm/mach-s3c2410/devs.c b/arch/arm/mach-s3c2410/devs.c index 08bc7d95a45d..f58406e6ef5a 100644 --- a/arch/arm/mach-s3c2410/devs.c +++ b/arch/arm/mach-s3c2410/devs.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <linux/timer.h> | 25 | #include <linux/timer.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/device.h> | 27 | #include <linux/platform_device.h> |
28 | 28 | ||
29 | #include <asm/mach/arch.h> | 29 | #include <asm/mach/arch.h> |
30 | #include <asm/mach/map.h> | 30 | #include <asm/mach/map.h> |
diff --git a/arch/arm/mach-s3c2410/devs.h b/arch/arm/mach-s3c2410/devs.h index d6328f96728b..52c4bab5c761 100644 --- a/arch/arm/mach-s3c2410/devs.h +++ b/arch/arm/mach-s3c2410/devs.h | |||
@@ -15,6 +15,7 @@ | |||
15 | * 10-Feb-2005 BJD Added camera from guillaume.gourat@nexvision.tv | 15 | * 10-Feb-2005 BJD Added camera from guillaume.gourat@nexvision.tv |
16 | */ | 16 | */ |
17 | #include <linux/config.h> | 17 | #include <linux/config.h> |
18 | #include <linux/platform_device.h> | ||
18 | 19 | ||
19 | extern struct platform_device *s3c24xx_uart_devs[]; | 20 | extern struct platform_device *s3c24xx_uart_devs[]; |
20 | 21 | ||
diff --git a/arch/arm/mach-s3c2410/mach-anubis.c b/arch/arm/mach-s3c2410/mach-anubis.c index 5ae80f4e3e67..8390b685c2b6 100644 --- a/arch/arm/mach-s3c2410/mach-anubis.c +++ b/arch/arm/mach-s3c2410/mach-anubis.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
22 | #include <linux/timer.h> | 22 | #include <linux/timer.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/device.h> | 24 | #include <linux/platform_device.h> |
25 | 25 | ||
26 | #include <asm/mach/arch.h> | 26 | #include <asm/mach/arch.h> |
27 | #include <asm/mach/map.h> | 27 | #include <asm/mach/map.h> |
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c index c1b5c63ec24a..0b71c896bbd1 100644 --- a/arch/arm/mach-s3c2410/mach-bast.c +++ b/arch/arm/mach-s3c2410/mach-bast.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <linux/list.h> | 41 | #include <linux/list.h> |
42 | #include <linux/timer.h> | 42 | #include <linux/timer.h> |
43 | #include <linux/init.h> | 43 | #include <linux/init.h> |
44 | #include <linux/device.h> | 44 | #include <linux/platform_device.h> |
45 | #include <linux/dm9000.h> | 45 | #include <linux/dm9000.h> |
46 | 46 | ||
47 | #include <asm/mach/arch.h> | 47 | #include <asm/mach/arch.h> |
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c index 7efeaaad2361..0aa8760598f7 100644 --- a/arch/arm/mach-s3c2410/mach-h1940.c +++ b/arch/arm/mach-s3c2410/mach-h1940.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/list.h> | 34 | #include <linux/list.h> |
35 | #include <linux/timer.h> | 35 | #include <linux/timer.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/platform_device.h> | ||
37 | 38 | ||
38 | #include <asm/mach/arch.h> | 39 | #include <asm/mach/arch.h> |
39 | #include <asm/mach/map.h> | 40 | #include <asm/mach/map.h> |
diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c2410/mach-n30.c index 5c0f2b091f95..378d640ab00b 100644 --- a/arch/arm/mach-s3c2410/mach-n30.c +++ b/arch/arm/mach-s3c2410/mach-n30.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/timer.h> | 20 | #include <linux/timer.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
25 | 25 | ||
26 | #include <asm/mach/arch.h> | 26 | #include <asm/mach/arch.h> |
diff --git a/arch/arm/mach-s3c2410/mach-nexcoder.c b/arch/arm/mach-s3c2410/mach-nexcoder.c index c22f8216032d..42b0eeff2e0f 100644 --- a/arch/arm/mach-s3c2410/mach-nexcoder.c +++ b/arch/arm/mach-s3c2410/mach-nexcoder.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/timer.h> | 19 | #include <linux/timer.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
22 | #include <linux/device.h> | 22 | #include <linux/platform_device.h> |
23 | 23 | ||
24 | #include <linux/mtd/map.h> | 24 | #include <linux/mtd/map.h> |
25 | 25 | ||
diff --git a/arch/arm/mach-s3c2410/mach-otom.c b/arch/arm/mach-s3c2410/mach-otom.c index ad1459e402e2..a2eb9ed48fcd 100644 --- a/arch/arm/mach-s3c2410/mach-otom.c +++ b/arch/arm/mach-s3c2410/mach-otom.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/list.h> | 15 | #include <linux/list.h> |
16 | #include <linux/timer.h> | 16 | #include <linux/timer.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/device.h> | 18 | #include <linux/platform_device.h> |
19 | 19 | ||
20 | #include <asm/mach/arch.h> | 20 | #include <asm/mach/arch.h> |
21 | #include <asm/mach/map.h> | 21 | #include <asm/mach/map.h> |
diff --git a/arch/arm/mach-s3c2410/mach-rx3715.c b/arch/arm/mach-s3c2410/mach-rx3715.c index 22d9e070fd68..8f2a90bf940b 100644 --- a/arch/arm/mach-s3c2410/mach-rx3715.c +++ b/arch/arm/mach-s3c2410/mach-rx3715.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/tty.h> | 28 | #include <linux/tty.h> |
29 | #include <linux/console.h> | 29 | #include <linux/console.h> |
30 | #include <linux/platform_device.h> | ||
30 | #include <linux/serial_core.h> | 31 | #include <linux/serial_core.h> |
31 | #include <linux/serial.h> | 32 | #include <linux/serial.h> |
32 | 33 | ||
diff --git a/arch/arm/mach-s3c2410/mach-smdk2410.c b/arch/arm/mach-s3c2410/mach-smdk2410.c index 2eda55a6b678..2c91965ee1c8 100644 --- a/arch/arm/mach-s3c2410/mach-smdk2410.c +++ b/arch/arm/mach-s3c2410/mach-smdk2410.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/list.h> | 38 | #include <linux/list.h> |
39 | #include <linux/timer.h> | 39 | #include <linux/timer.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | #include <linux/platform_device.h> | ||
41 | 42 | ||
42 | #include <asm/mach/arch.h> | 43 | #include <asm/mach/arch.h> |
43 | #include <asm/mach/map.h> | 44 | #include <asm/mach/map.h> |
diff --git a/arch/arm/mach-s3c2410/mach-smdk2440.c b/arch/arm/mach-s3c2410/mach-smdk2440.c index 6950e61b7914..d666c621ad06 100644 --- a/arch/arm/mach-s3c2410/mach-smdk2440.c +++ b/arch/arm/mach-s3c2410/mach-smdk2440.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/list.h> | 28 | #include <linux/list.h> |
29 | #include <linux/timer.h> | 29 | #include <linux/timer.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/platform_device.h> | ||
31 | 32 | ||
32 | #include <asm/mach/arch.h> | 33 | #include <asm/mach/arch.h> |
33 | #include <asm/mach/map.h> | 34 | #include <asm/mach/map.h> |
diff --git a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c2410/s3c2410.c index a8bf5ec82602..0a2013a76549 100644 --- a/arch/arm/mach-s3c2410/s3c2410.c +++ b/arch/arm/mach-s3c2410/s3c2410.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/list.h> | 27 | #include <linux/list.h> |
28 | #include <linux/timer.h> | 28 | #include <linux/timer.h> |
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/device.h> | 30 | #include <linux/platform_device.h> |
31 | 31 | ||
32 | #include <asm/mach/arch.h> | 32 | #include <asm/mach/arch.h> |
33 | #include <asm/mach/map.h> | 33 | #include <asm/mach/map.h> |
diff --git a/arch/arm/mach-s3c2410/s3c2440.c b/arch/arm/mach-s3c2410/s3c2440.c index 833fa36bce05..4d63e7133b48 100644 --- a/arch/arm/mach-s3c2410/s3c2440.c +++ b/arch/arm/mach-s3c2410/s3c2440.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/list.h> | 26 | #include <linux/list.h> |
27 | #include <linux/timer.h> | 27 | #include <linux/timer.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/device.h> | 29 | #include <linux/platform_device.h> |
30 | #include <linux/sysdev.h> | 30 | #include <linux/sysdev.h> |
31 | 31 | ||
32 | #include <asm/mach/arch.h> | 32 | #include <asm/mach/arch.h> |
diff --git a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c index c92cebff7f8e..edccd5eb06be 100644 --- a/arch/arm/mach-sa1100/badge4.c +++ b/arch/arm/mach-sa1100/badge4.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/tty.h> | 21 | #include <linux/tty.h> |
22 | #include <linux/mtd/mtd.h> | 22 | #include <linux/mtd/mtd.h> |
diff --git a/arch/arm/mach-sa1100/cerf.c b/arch/arm/mach-sa1100/cerf.c index 23cb74885275..508593722bc7 100644 --- a/arch/arm/mach-sa1100/cerf.c +++ b/arch/arm/mach-sa1100/cerf.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/tty.h> | 16 | #include <linux/tty.h> |
17 | #include <linux/device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/partitions.h> | 19 | #include <linux/mtd/partitions.h> |
20 | 20 | ||
diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c index 7fd6e29c36b7..522abc036d3a 100644 --- a/arch/arm/mach-sa1100/collie.c +++ b/arch/arm/mach-sa1100/collie.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/tty.h> | 22 | #include <linux/tty.h> |
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/mtd/mtd.h> | 25 | #include <linux/mtd/mtd.h> |
26 | #include <linux/mtd/partitions.h> | 26 | #include <linux/mtd/partitions.h> |
27 | #include <linux/timer.h> | 27 | #include <linux/timer.h> |
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index 83eba8b54816..2abdc419e984 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/cpufreq.h> | 18 | #include <linux/cpufreq.h> |
19 | #include <linux/ioport.h> | 19 | #include <linux/ioport.h> |
20 | #include <linux/sched.h> /* just for sched_clock() - funny that */ | 20 | #include <linux/sched.h> /* just for sched_clock() - funny that */ |
21 | #include <linux/platform_device.h> | ||
21 | 22 | ||
22 | #include <asm/div64.h> | 23 | #include <asm/div64.h> |
23 | #include <asm/hardware.h> | 24 | #include <asm/hardware.h> |
diff --git a/arch/arm/mach-sa1100/jornada720.c b/arch/arm/mach-sa1100/jornada720.c index 89af0c831e8f..2f671cc3cb99 100644 --- a/arch/arm/mach-sa1100/jornada720.c +++ b/arch/arm/mach-sa1100/jornada720.c | |||
@@ -6,7 +6,7 @@ | |||
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
7 | #include <linux/tty.h> | 7 | #include <linux/tty.h> |
8 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
9 | #include <linux/device.h> | 9 | #include <linux/platform_device.h> |
10 | #include <linux/ioport.h> | 10 | #include <linux/ioport.h> |
11 | #include <linux/mtd/mtd.h> | 11 | #include <linux/mtd/mtd.h> |
12 | #include <linux/mtd/partitions.h> | 12 | #include <linux/mtd/partitions.h> |
diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 052e4caedb89..69f1970646c6 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <linux/tty.h> | 8 | #include <linux/tty.h> |
9 | #include <linux/ioport.h> | 9 | #include <linux/ioport.h> |
10 | #include <linux/serial_core.h> | 10 | #include <linux/serial_core.h> |
11 | #include <linux/device.h> | 11 | #include <linux/platform_device.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | 13 | ||
14 | #include <asm/hardware.h> | 14 | #include <asm/hardware.h> |
diff --git a/arch/arm/mach-sa1100/pleb.c b/arch/arm/mach-sa1100/pleb.c index e17b58fb9c9c..58c18f9e9b7b 100644 --- a/arch/arm/mach-sa1100/pleb.c +++ b/arch/arm/mach-sa1100/pleb.c | |||
@@ -6,7 +6,7 @@ | |||
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
7 | #include <linux/tty.h> | 7 | #include <linux/tty.h> |
8 | #include <linux/ioport.h> | 8 | #include <linux/ioport.h> |
9 | #include <linux/device.h> | 9 | #include <linux/platform_device.h> |
10 | 10 | ||
11 | #include <linux/mtd/partitions.h> | 11 | #include <linux/mtd/partitions.h> |
12 | 12 | ||
diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c index cfb6658e5cdf..439ddc9b06d6 100644 --- a/arch/arm/mach-sa1100/simpad.c +++ b/arch/arm/mach-sa1100/simpad.c | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <linux/proc_fs.h> | 10 | #include <linux/proc_fs.h> |
11 | #include <linux/string.h> | 11 | #include <linux/string.h> |
12 | #include <linux/pm.h> | 12 | #include <linux/pm.h> |
13 | #include <linux/device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/mtd/mtd.h> | 14 | #include <linux/mtd/mtd.h> |
15 | #include <linux/mtd/partitions.h> | 15 | #include <linux/mtd/partitions.h> |
16 | 16 | ||
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c index 7e4bdd07f4af..a1ca46630dda 100644 --- a/arch/arm/mach-versatile/core.c +++ b/arch/arm/mach-versatile/core.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/device.h> | 23 | #include <linux/device.h> |
24 | #include <linux/dma-mapping.h> | 24 | #include <linux/dma-mapping.h> |
25 | #include <linux/platform_device.h> | ||
25 | #include <linux/sysdev.h> | 26 | #include <linux/sysdev.h> |
26 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
27 | 28 | ||
diff --git a/arch/arm/plat-omap/usb.c b/arch/arm/plat-omap/usb.c index 14a836d7ac25..205e2d0b826d 100644 --- a/arch/arm/plat-omap/usb.c +++ b/arch/arm/plat-omap/usb.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/types.h> | 26 | #include <linux/types.h> |
27 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/device.h> | 29 | #include <linux/platform_device.h> |
30 | #include <linux/usb_otg.h> | 30 | #include <linux/usb_otg.h> |
31 | 31 | ||
32 | #include <asm/io.h> | 32 | #include <asm/io.h> |
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig index 5383e5e2d9b7..bac0da731ee3 100644 --- a/arch/i386/Kconfig +++ b/arch/i386/Kconfig | |||
@@ -1042,8 +1042,3 @@ config X86_TRAMPOLINE | |||
1042 | bool | 1042 | bool |
1043 | depends on X86_SMP || (X86_VOYAGER && SMP) | 1043 | depends on X86_SMP || (X86_VOYAGER && SMP) |
1044 | default y | 1044 | default y |
1045 | |||
1046 | config PC | ||
1047 | bool | ||
1048 | depends on X86 && !EMBEDDED | ||
1049 | default y | ||
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c index 9204be6eedb3..7c724ffa08bb 100644 --- a/arch/i386/kernel/apic.c +++ b/arch/i386/kernel/apic.c | |||
@@ -803,7 +803,6 @@ no_apic: | |||
803 | 803 | ||
804 | void __init init_apic_mappings(void) | 804 | void __init init_apic_mappings(void) |
805 | { | 805 | { |
806 | unsigned int orig_apicid; | ||
807 | unsigned long apic_phys; | 806 | unsigned long apic_phys; |
808 | 807 | ||
809 | /* | 808 | /* |
@@ -825,11 +824,8 @@ void __init init_apic_mappings(void) | |||
825 | * Fetch the APIC ID of the BSP in case we have a | 824 | * Fetch the APIC ID of the BSP in case we have a |
826 | * default configuration (or the MP table is broken). | 825 | * default configuration (or the MP table is broken). |
827 | */ | 826 | */ |
828 | orig_apicid = boot_cpu_physical_apicid; | 827 | if (boot_cpu_physical_apicid == -1U) |
829 | boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID)); | 828 | boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID)); |
830 | if ((orig_apicid != -1U) && (orig_apicid != boot_cpu_physical_apicid)) | ||
831 | printk(KERN_WARNING "Boot APIC ID in local APIC unexpected (%d vs %d)", | ||
832 | orig_apicid, boot_cpu_physical_apicid); | ||
833 | 829 | ||
834 | #ifdef CONFIG_X86_IO_APIC | 830 | #ifdef CONFIG_X86_IO_APIC |
835 | { | 831 | { |
@@ -1259,81 +1255,40 @@ fastcall void smp_error_interrupt(struct pt_regs *regs) | |||
1259 | } | 1255 | } |
1260 | 1256 | ||
1261 | /* | 1257 | /* |
1262 | * This initializes the IO-APIC and APIC hardware. | 1258 | * This initializes the IO-APIC and APIC hardware if this is |
1259 | * a UP kernel. | ||
1263 | */ | 1260 | */ |
1264 | int __init APIC_init(void) | 1261 | int __init APIC_init_uniprocessor (void) |
1265 | { | 1262 | { |
1266 | if (enable_local_apic < 0) { | 1263 | if (enable_local_apic < 0) |
1267 | printk(KERN_INFO "APIC disabled\n"); | 1264 | clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability); |
1268 | return -1; | ||
1269 | } | ||
1270 | 1265 | ||
1271 | /* See if we have a SMP configuration or have forced enabled | 1266 | if (!smp_found_config && !cpu_has_apic) |
1272 | * the local apic. | ||
1273 | */ | ||
1274 | if (!smp_found_config && !acpi_lapic && !cpu_has_apic) { | ||
1275 | enable_local_apic = -1; | ||
1276 | return -1; | 1267 | return -1; |
1277 | } | ||
1278 | 1268 | ||
1279 | /* | 1269 | /* |
1280 | * Complain if the BIOS pretends there is an apic. | 1270 | * Complain if the BIOS pretends there is one. |
1281 | * Then get out because we don't have an a local apic. | ||
1282 | */ | 1271 | */ |
1283 | if (!cpu_has_apic && APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { | 1272 | if (!cpu_has_apic && APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { |
1284 | printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n", | 1273 | printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n", |
1285 | boot_cpu_physical_apicid); | 1274 | boot_cpu_physical_apicid); |
1286 | printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n"); | ||
1287 | enable_local_apic = -1; | ||
1288 | return -1; | 1275 | return -1; |
1289 | } | 1276 | } |
1290 | 1277 | ||
1291 | verify_local_APIC(); | 1278 | verify_local_APIC(); |
1292 | 1279 | ||
1293 | /* | ||
1294 | * Should not be necessary because the MP table should list the boot | ||
1295 | * CPU too, but we do it for the sake of robustness anyway. | ||
1296 | * Makes no sense to do this check in clustered apic mode, so skip it | ||
1297 | */ | ||
1298 | if (!check_phys_apicid_present(boot_cpu_physical_apicid)) { | ||
1299 | printk("weird, boot CPU (#%d) not listed by the BIOS.\n", | ||
1300 | boot_cpu_physical_apicid); | ||
1301 | physid_set(boot_cpu_physical_apicid, phys_cpu_present_map); | ||
1302 | } | ||
1303 | |||
1304 | /* | ||
1305 | * Switch from PIC to APIC mode. | ||
1306 | */ | ||
1307 | connect_bsp_APIC(); | 1280 | connect_bsp_APIC(); |
1308 | setup_local_APIC(); | ||
1309 | 1281 | ||
1310 | #ifdef CONFIG_X86_IO_APIC | 1282 | phys_cpu_present_map = physid_mask_of_physid(boot_cpu_physical_apicid); |
1311 | /* | ||
1312 | * Now start the IO-APICs | ||
1313 | */ | ||
1314 | if (smp_found_config && !skip_ioapic_setup && nr_ioapics) | ||
1315 | setup_IO_APIC(); | ||
1316 | #endif | ||
1317 | return 0; | ||
1318 | } | ||
1319 | 1283 | ||
1320 | void __init APIC_late_time_init(void) | 1284 | setup_local_APIC(); |
1321 | { | ||
1322 | /* Improve our loops per jiffy estimate */ | ||
1323 | loops_per_jiffy = ((1000 + HZ - 1)/HZ)*cpu_khz; | ||
1324 | boot_cpu_data.loops_per_jiffy = loops_per_jiffy; | ||
1325 | cpu_data[0].loops_per_jiffy = loops_per_jiffy; | ||
1326 | |||
1327 | /* setup_apic_nmi_watchdog doesn't work properly before cpu_khz is | ||
1328 | * initialized. So redo it here to ensure the boot cpu is setup | ||
1329 | * properly. | ||
1330 | */ | ||
1331 | if (nmi_watchdog == NMI_LOCAL_APIC) | ||
1332 | setup_apic_nmi_watchdog(); | ||
1333 | 1285 | ||
1334 | #ifdef CONFIG_X86_IO_APIC | 1286 | #ifdef CONFIG_X86_IO_APIC |
1335 | if (smp_found_config && !skip_ioapic_setup && nr_ioapics) | 1287 | if (smp_found_config) |
1336 | IO_APIC_late_time_init(); | 1288 | if (!skip_ioapic_setup && nr_ioapics) |
1289 | setup_IO_APIC(); | ||
1337 | #endif | 1290 | #endif |
1338 | setup_boot_APIC_clock(); | 1291 | setup_boot_APIC_clock(); |
1292 | |||
1293 | return 0; | ||
1339 | } | 1294 | } |
diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c index d86f24909284..323ef8ab3244 100644 --- a/arch/i386/kernel/i8259.c +++ b/arch/i386/kernel/i8259.c | |||
@@ -435,8 +435,4 @@ void __init init_IRQ(void) | |||
435 | setup_irq(FPU_IRQ, &fpu_irq); | 435 | setup_irq(FPU_IRQ, &fpu_irq); |
436 | 436 | ||
437 | irq_ctx_init(smp_processor_id()); | 437 | irq_ctx_init(smp_processor_id()); |
438 | |||
439 | #ifdef CONFIG_X86_LOCAL_APIC | ||
440 | APIC_init(); | ||
441 | #endif | ||
442 | } | 438 | } |
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c index 5a77c52b20a9..cc5d7ac5b2e7 100644 --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c | |||
@@ -2387,15 +2387,11 @@ void __init setup_IO_APIC(void) | |||
2387 | sync_Arb_IDs(); | 2387 | sync_Arb_IDs(); |
2388 | setup_IO_APIC_irqs(); | 2388 | setup_IO_APIC_irqs(); |
2389 | init_IO_APIC_traps(); | 2389 | init_IO_APIC_traps(); |
2390 | check_timer(); | ||
2390 | if (!acpi_ioapic) | 2391 | if (!acpi_ioapic) |
2391 | print_IO_APIC(); | 2392 | print_IO_APIC(); |
2392 | } | 2393 | } |
2393 | 2394 | ||
2394 | void __init IO_APIC_late_time_init(void) | ||
2395 | { | ||
2396 | check_timer(); | ||
2397 | } | ||
2398 | |||
2399 | /* | 2395 | /* |
2400 | * Called after all the initialization is done. If we didnt find any | 2396 | * Called after all the initialization is done. If we didnt find any |
2401 | * APIC bugs then we can allow the modify fast path | 2397 | * APIC bugs then we can allow the modify fast path |
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index 5a2bbe0c4fff..01b618e73ecd 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c | |||
@@ -1078,16 +1078,6 @@ void *xquad_portio; | |||
1078 | EXPORT_SYMBOL(xquad_portio); | 1078 | EXPORT_SYMBOL(xquad_portio); |
1079 | #endif | 1079 | #endif |
1080 | 1080 | ||
1081 | /* | ||
1082 | * Fall back to non SMP mode after errors. | ||
1083 | * | ||
1084 | */ | ||
1085 | static __init void disable_smp(void) | ||
1086 | { | ||
1087 | cpu_set(0, cpu_sibling_map[0]); | ||
1088 | cpu_set(0, cpu_core_map[0]); | ||
1089 | } | ||
1090 | |||
1091 | static void __init smp_boot_cpus(unsigned int max_cpus) | 1081 | static void __init smp_boot_cpus(unsigned int max_cpus) |
1092 | { | 1082 | { |
1093 | int apicid, cpu, bit, kicked; | 1083 | int apicid, cpu, bit, kicked; |
@@ -1100,6 +1090,7 @@ static void __init smp_boot_cpus(unsigned int max_cpus) | |||
1100 | printk("CPU%d: ", 0); | 1090 | printk("CPU%d: ", 0); |
1101 | print_cpu_info(&cpu_data[0]); | 1091 | print_cpu_info(&cpu_data[0]); |
1102 | 1092 | ||
1093 | boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID)); | ||
1103 | boot_cpu_logical_apicid = logical_smp_processor_id(); | 1094 | boot_cpu_logical_apicid = logical_smp_processor_id(); |
1104 | x86_cpu_to_apicid[0] = boot_cpu_physical_apicid; | 1095 | x86_cpu_to_apicid[0] = boot_cpu_physical_apicid; |
1105 | 1096 | ||
@@ -1111,27 +1102,68 @@ static void __init smp_boot_cpus(unsigned int max_cpus) | |||
1111 | cpus_clear(cpu_core_map[0]); | 1102 | cpus_clear(cpu_core_map[0]); |
1112 | cpu_set(0, cpu_core_map[0]); | 1103 | cpu_set(0, cpu_core_map[0]); |
1113 | 1104 | ||
1114 | map_cpu_to_logical_apicid(); | ||
1115 | |||
1116 | /* | 1105 | /* |
1117 | * If we couldn't find an SMP configuration at boot time, | 1106 | * If we couldn't find an SMP configuration at boot time, |
1118 | * get out of here now! | 1107 | * get out of here now! |
1119 | */ | 1108 | */ |
1120 | if (!smp_found_config && !acpi_lapic) { | 1109 | if (!smp_found_config && !acpi_lapic) { |
1121 | printk(KERN_NOTICE "SMP motherboard not detected.\n"); | 1110 | printk(KERN_NOTICE "SMP motherboard not detected.\n"); |
1122 | disable_smp(); | 1111 | smpboot_clear_io_apic_irqs(); |
1112 | phys_cpu_present_map = physid_mask_of_physid(0); | ||
1113 | if (APIC_init_uniprocessor()) | ||
1114 | printk(KERN_NOTICE "Local APIC not detected." | ||
1115 | " Using dummy APIC emulation.\n"); | ||
1116 | map_cpu_to_logical_apicid(); | ||
1117 | cpu_set(0, cpu_sibling_map[0]); | ||
1118 | cpu_set(0, cpu_core_map[0]); | ||
1119 | return; | ||
1120 | } | ||
1121 | |||
1122 | /* | ||
1123 | * Should not be necessary because the MP table should list the boot | ||
1124 | * CPU too, but we do it for the sake of robustness anyway. | ||
1125 | * Makes no sense to do this check in clustered apic mode, so skip it | ||
1126 | */ | ||
1127 | if (!check_phys_apicid_present(boot_cpu_physical_apicid)) { | ||
1128 | printk("weird, boot CPU (#%d) not listed by the BIOS.\n", | ||
1129 | boot_cpu_physical_apicid); | ||
1130 | physid_set(hard_smp_processor_id(), phys_cpu_present_map); | ||
1131 | } | ||
1132 | |||
1133 | /* | ||
1134 | * If we couldn't find a local APIC, then get out of here now! | ||
1135 | */ | ||
1136 | if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) && !cpu_has_apic) { | ||
1137 | printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n", | ||
1138 | boot_cpu_physical_apicid); | ||
1139 | printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n"); | ||
1140 | smpboot_clear_io_apic_irqs(); | ||
1141 | phys_cpu_present_map = physid_mask_of_physid(0); | ||
1142 | cpu_set(0, cpu_sibling_map[0]); | ||
1143 | cpu_set(0, cpu_core_map[0]); | ||
1123 | return; | 1144 | return; |
1124 | } | 1145 | } |
1125 | 1146 | ||
1147 | verify_local_APIC(); | ||
1148 | |||
1126 | /* | 1149 | /* |
1127 | * If SMP should be disabled, then really disable it! | 1150 | * If SMP should be disabled, then really disable it! |
1128 | */ | 1151 | */ |
1129 | if (!max_cpus || (enable_local_apic < 0)) { | 1152 | if (!max_cpus) { |
1130 | printk(KERN_INFO "SMP mode deactivated.\n"); | 1153 | smp_found_config = 0; |
1131 | disable_smp(); | 1154 | printk(KERN_INFO "SMP mode deactivated, forcing use of dummy APIC emulation.\n"); |
1155 | smpboot_clear_io_apic_irqs(); | ||
1156 | phys_cpu_present_map = physid_mask_of_physid(0); | ||
1157 | cpu_set(0, cpu_sibling_map[0]); | ||
1158 | cpu_set(0, cpu_core_map[0]); | ||
1132 | return; | 1159 | return; |
1133 | } | 1160 | } |
1134 | 1161 | ||
1162 | connect_bsp_APIC(); | ||
1163 | setup_local_APIC(); | ||
1164 | map_cpu_to_logical_apicid(); | ||
1165 | |||
1166 | |||
1135 | setup_portio_remap(); | 1167 | setup_portio_remap(); |
1136 | 1168 | ||
1137 | /* | 1169 | /* |
@@ -1212,6 +1244,10 @@ static void __init smp_boot_cpus(unsigned int max_cpus) | |||
1212 | cpu_set(0, cpu_sibling_map[0]); | 1244 | cpu_set(0, cpu_sibling_map[0]); |
1213 | cpu_set(0, cpu_core_map[0]); | 1245 | cpu_set(0, cpu_core_map[0]); |
1214 | 1246 | ||
1247 | smpboot_setup_io_apic(); | ||
1248 | |||
1249 | setup_boot_APIC_clock(); | ||
1250 | |||
1215 | /* | 1251 | /* |
1216 | * Synchronize the TSC with the AP | 1252 | * Synchronize the TSC with the AP |
1217 | */ | 1253 | */ |
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c index 07471bba2dc6..41c5b2dc6200 100644 --- a/arch/i386/kernel/time.c +++ b/arch/i386/kernel/time.c | |||
@@ -440,8 +440,8 @@ static int time_init_device(void) | |||
440 | 440 | ||
441 | device_initcall(time_init_device); | 441 | device_initcall(time_init_device); |
442 | 442 | ||
443 | extern void (*late_time_init)(void); | ||
444 | #ifdef CONFIG_HPET_TIMER | 443 | #ifdef CONFIG_HPET_TIMER |
444 | extern void (*late_time_init)(void); | ||
445 | /* Duplicate of time_init() below, with hpet_enable part added */ | 445 | /* Duplicate of time_init() below, with hpet_enable part added */ |
446 | static void __init hpet_time_init(void) | 446 | static void __init hpet_time_init(void) |
447 | { | 447 | { |
@@ -458,11 +458,6 @@ static void __init hpet_time_init(void) | |||
458 | printk(KERN_INFO "Using %s for high-res timesource\n",cur_timer->name); | 458 | printk(KERN_INFO "Using %s for high-res timesource\n",cur_timer->name); |
459 | 459 | ||
460 | time_init_hook(); | 460 | time_init_hook(); |
461 | |||
462 | #ifdef CONFIG_X86_LOCAL_APIC | ||
463 | if (enable_local_apic >= 0) | ||
464 | APIC_late_time_init(); | ||
465 | #endif | ||
466 | } | 461 | } |
467 | #endif | 462 | #endif |
468 | 463 | ||
@@ -487,9 +482,4 @@ void __init time_init(void) | |||
487 | printk(KERN_INFO "Using %s for high-res timesource\n",cur_timer->name); | 482 | printk(KERN_INFO "Using %s for high-res timesource\n",cur_timer->name); |
488 | 483 | ||
489 | time_init_hook(); | 484 | time_init_hook(); |
490 | |||
491 | #ifdef CONFIG_X86_LOCAL_APIC | ||
492 | if (enable_local_apic >= 0) | ||
493 | late_time_init = APIC_late_time_init; | ||
494 | #endif | ||
495 | } | 485 | } |
diff --git a/arch/m32r/kernel/setup_m32700ut.c b/arch/m32r/kernel/setup_m32700ut.c index 708634b685e4..cb76916b014d 100644 --- a/arch/m32r/kernel/setup_m32700ut.c +++ b/arch/m32r/kernel/setup_m32700ut.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/irq.h> | 15 | #include <linux/irq.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/device.h> | 18 | #include <linux/platform_device.h> |
19 | 19 | ||
20 | #include <asm/system.h> | 20 | #include <asm/system.h> |
21 | #include <asm/m32r.h> | 21 | #include <asm/m32r.h> |
diff --git a/arch/m32r/kernel/setup_mappi.c b/arch/m32r/kernel/setup_mappi.c index 4e709809efc5..501d798cf050 100644 --- a/arch/m32r/kernel/setup_mappi.c +++ b/arch/m32r/kernel/setup_mappi.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/irq.h> | 11 | #include <linux/irq.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/device.h> | 14 | #include <linux/platform_device.h> |
15 | 15 | ||
16 | #include <asm/system.h> | 16 | #include <asm/system.h> |
17 | #include <asm/m32r.h> | 17 | #include <asm/m32r.h> |
diff --git a/arch/m32r/kernel/setup_mappi2.c b/arch/m32r/kernel/setup_mappi2.c index a1d801598aa4..7f2db5bfd626 100644 --- a/arch/m32r/kernel/setup_mappi2.c +++ b/arch/m32r/kernel/setup_mappi2.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/irq.h> | 11 | #include <linux/irq.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/device.h> | 14 | #include <linux/platform_device.h> |
15 | 15 | ||
16 | #include <asm/system.h> | 16 | #include <asm/system.h> |
17 | #include <asm/m32r.h> | 17 | #include <asm/m32r.h> |
diff --git a/arch/m32r/kernel/setup_mappi3.c b/arch/m32r/kernel/setup_mappi3.c index a76412e883e8..9c79341a7b45 100644 --- a/arch/m32r/kernel/setup_mappi3.c +++ b/arch/m32r/kernel/setup_mappi3.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/irq.h> | 11 | #include <linux/irq.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/device.h> | 14 | #include <linux/platform_device.h> |
15 | 15 | ||
16 | #include <asm/system.h> | 16 | #include <asm/system.h> |
17 | #include <asm/m32r.h> | 17 | #include <asm/m32r.h> |
diff --git a/arch/m32r/kernel/setup_opsput.c b/arch/m32r/kernel/setup_opsput.c index d7b7ec6d30f8..1fbb140854e7 100644 --- a/arch/m32r/kernel/setup_opsput.c +++ b/arch/m32r/kernel/setup_opsput.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/irq.h> | 16 | #include <linux/irq.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/device.h> | 19 | #include <linux/platform_device.h> |
20 | 20 | ||
21 | #include <asm/system.h> | 21 | #include <asm/system.h> |
22 | #include <asm/m32r.h> | 22 | #include <asm/m32r.h> |
diff --git a/arch/mips/au1000/common/platform.c b/arch/mips/au1000/common/platform.c index 1f7b465c8038..48d3f54f88f8 100644 --- a/arch/mips/au1000/common/platform.c +++ b/arch/mips/au1000/common/platform.c | |||
@@ -9,6 +9,7 @@ | |||
9 | */ | 9 | */ |
10 | #include <linux/config.h> | 10 | #include <linux/config.h> |
11 | #include <linux/device.h> | 11 | #include <linux/device.h> |
12 | #include <linux/platform_device.h> | ||
12 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
13 | #include <linux/init.h> | 14 | #include <linux/init.h> |
14 | #include <linux/resource.h> | 15 | #include <linux/resource.h> |
diff --git a/arch/ppc/platforms/4xx/ibm440ep.c b/arch/ppc/platforms/4xx/ibm440ep.c index 4712de8ff80f..65ac0b9c2d05 100644 --- a/arch/ppc/platforms/4xx/ibm440ep.c +++ b/arch/ppc/platforms/4xx/ibm440ep.c | |||
@@ -14,6 +14,7 @@ | |||
14 | */ | 14 | */ |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/platform_device.h> | ||
17 | #include <platforms/4xx/ibm440ep.h> | 18 | #include <platforms/4xx/ibm440ep.h> |
18 | #include <asm/ocp.h> | 19 | #include <asm/ocp.h> |
19 | #include <asm/ppc4xx_pic.h> | 20 | #include <asm/ppc4xx_pic.h> |
diff --git a/arch/ppc/platforms/4xx/ibmstb4.c b/arch/ppc/platforms/4xx/ibmstb4.c index d90627b68faa..7e33bb635443 100644 --- a/arch/ppc/platforms/4xx/ibmstb4.c +++ b/arch/ppc/platforms/4xx/ibmstb4.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/platform_device.h> | ||
13 | #include <asm/ocp.h> | 14 | #include <asm/ocp.h> |
14 | #include <asm/ppc4xx_pic.h> | 15 | #include <asm/ppc4xx_pic.h> |
15 | #include <platforms/4xx/ibmstb4.h> | 16 | #include <platforms/4xx/ibmstb4.h> |
diff --git a/arch/ppc/platforms/4xx/redwood5.c b/arch/ppc/platforms/4xx/redwood5.c index bee8b4ac8afd..611ac861804d 100644 --- a/arch/ppc/platforms/4xx/redwood5.c +++ b/arch/ppc/platforms/4xx/redwood5.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/config.h> | 14 | #include <linux/config.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/pagemap.h> | 16 | #include <linux/pagemap.h> |
17 | #include <linux/device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/ioport.h> | 18 | #include <linux/ioport.h> |
19 | #include <asm/io.h> | 19 | #include <asm/io.h> |
20 | #include <asm/machdep.h> | 20 | #include <asm/machdep.h> |
diff --git a/arch/ppc/platforms/4xx/redwood6.c b/arch/ppc/platforms/4xx/redwood6.c index 8b1012994dfc..b13116691289 100644 --- a/arch/ppc/platforms/4xx/redwood6.c +++ b/arch/ppc/platforms/4xx/redwood6.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/config.h> | 12 | #include <linux/config.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/pagemap.h> | 14 | #include <linux/pagemap.h> |
15 | #include <linux/device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/ioport.h> | 16 | #include <linux/ioport.h> |
17 | #include <asm/io.h> | 17 | #include <asm/io.h> |
18 | #include <asm/ppc4xx_pic.h> | 18 | #include <asm/ppc4xx_pic.h> |
diff --git a/arch/ppc/platforms/chrp_pegasos_eth.c b/arch/ppc/platforms/chrp_pegasos_eth.c index a9052305c35d..108a6e265185 100644 --- a/arch/ppc/platforms/chrp_pegasos_eth.c +++ b/arch/ppc/platforms/chrp_pegasos_eth.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/types.h> | 13 | #include <linux/types.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/ioport.h> | 15 | #include <linux/ioport.h> |
16 | #include <linux/device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/mv643xx.h> | 17 | #include <linux/mv643xx.h> |
18 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
19 | 19 | ||
diff --git a/arch/ppc/platforms/cpci690.c b/arch/ppc/platforms/cpci690.c index f64ac2acb603..6ca7bcac9474 100644 --- a/arch/ppc/platforms/cpci690.c +++ b/arch/ppc/platforms/cpci690.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/initrd.h> | 21 | #include <linux/initrd.h> |
22 | #include <linux/root_dev.h> | 22 | #include <linux/root_dev.h> |
23 | #include <linux/mv643xx.h> | 23 | #include <linux/mv643xx.h> |
24 | #include <linux/platform_device.h> | ||
24 | #include <asm/bootinfo.h> | 25 | #include <asm/bootinfo.h> |
25 | #include <asm/machdep.h> | 26 | #include <asm/machdep.h> |
26 | #include <asm/todc.h> | 27 | #include <asm/todc.h> |
diff --git a/arch/ppc/platforms/ev64260.c b/arch/ppc/platforms/ev64260.c index aa50637a5cfb..32358b3fb236 100644 --- a/arch/ppc/platforms/ev64260.c +++ b/arch/ppc/platforms/ev64260.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/console.h> | 33 | #include <linux/console.h> |
34 | #include <linux/initrd.h> | 34 | #include <linux/initrd.h> |
35 | #include <linux/root_dev.h> | 35 | #include <linux/root_dev.h> |
36 | #include <linux/platform_device.h> | ||
36 | #if !defined(CONFIG_SERIAL_MPSC_CONSOLE) | 37 | #if !defined(CONFIG_SERIAL_MPSC_CONSOLE) |
37 | #include <linux/serial.h> | 38 | #include <linux/serial.h> |
38 | #include <linux/tty.h> | 39 | #include <linux/tty.h> |
diff --git a/arch/ppc/platforms/ev64360.c b/arch/ppc/platforms/ev64360.c index 53388a1c334f..b1324564456e 100644 --- a/arch/ppc/platforms/ev64360.c +++ b/arch/ppc/platforms/ev64360.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/bootmem.h> | 25 | #include <linux/bootmem.h> |
26 | #include <linux/mtd/physmap.h> | 26 | #include <linux/mtd/physmap.h> |
27 | #include <linux/mv643xx.h> | 27 | #include <linux/mv643xx.h> |
28 | #include <linux/platform_device.h> | ||
28 | #ifdef CONFIG_BOOTIMG | 29 | #ifdef CONFIG_BOOTIMG |
29 | #include <linux/bootimg.h> | 30 | #include <linux/bootimg.h> |
30 | #endif | 31 | #endif |
diff --git a/arch/ppc/platforms/hdpu.c b/arch/ppc/platforms/hdpu.c index b6a66d5e9d83..50039a204c24 100644 --- a/arch/ppc/platforms/hdpu.c +++ b/arch/ppc/platforms/hdpu.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/irq.h> | 22 | #include <linux/irq.h> |
23 | #include <linux/ide.h> | 23 | #include <linux/ide.h> |
24 | #include <linux/seq_file.h> | 24 | #include <linux/seq_file.h> |
25 | #include <linux/platform_device.h> | ||
25 | 26 | ||
26 | #include <linux/initrd.h> | 27 | #include <linux/initrd.h> |
27 | #include <linux/root_dev.h> | 28 | #include <linux/root_dev.h> |
diff --git a/arch/ppc/platforms/katana.c b/arch/ppc/platforms/katana.c index a301c5ac58dd..6e58e30ceed1 100644 --- a/arch/ppc/platforms/katana.c +++ b/arch/ppc/platforms/katana.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/seq_file.h> | 29 | #include <linux/seq_file.h> |
30 | #include <linux/mtd/physmap.h> | 30 | #include <linux/mtd/physmap.h> |
31 | #include <linux/mv643xx.h> | 31 | #include <linux/mv643xx.h> |
32 | #include <linux/platform_device.h> | ||
32 | #ifdef CONFIG_BOOTIMG | 33 | #ifdef CONFIG_BOOTIMG |
33 | #include <linux/bootimg.h> | 34 | #include <linux/bootimg.h> |
34 | #endif | 35 | #endif |
diff --git a/arch/ppc/platforms/radstone_ppc7d.c b/arch/ppc/platforms/radstone_ppc7d.c index 6f97911c330d..708b8739ecdd 100644 --- a/arch/ppc/platforms/radstone_ppc7d.c +++ b/arch/ppc/platforms/radstone_ppc7d.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/serial_core.h> | 40 | #include <linux/serial_core.h> |
41 | #include <linux/mv643xx.h> | 41 | #include <linux/mv643xx.h> |
42 | #include <linux/netdevice.h> | 42 | #include <linux/netdevice.h> |
43 | #include <linux/platform_device.h> | ||
43 | 44 | ||
44 | #include <asm/system.h> | 45 | #include <asm/system.h> |
45 | #include <asm/pgtable.h> | 46 | #include <asm/pgtable.h> |
diff --git a/arch/ppc/syslib/mpc52xx_devices.c b/arch/ppc/syslib/mpc52xx_devices.c index ad5182efca1d..da3c74bfdc92 100644 --- a/arch/ppc/syslib/mpc52xx_devices.c +++ b/arch/ppc/syslib/mpc52xx_devices.c | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/fsl_devices.h> | 16 | #include <linux/fsl_devices.h> |
17 | #include <linux/resource.h> | 17 | #include <linux/resource.h> |
18 | #include <linux/platform_device.h> | ||
18 | #include <asm/mpc52xx.h> | 19 | #include <asm/mpc52xx.h> |
19 | #include <asm/ppc_sys.h> | 20 | #include <asm/ppc_sys.h> |
20 | 21 | ||
diff --git a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c index a781c50d2f4c..94ea346b7b4b 100644 --- a/arch/ppc/syslib/mv64x60.c +++ b/arch/ppc/syslib/mv64x60.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
21 | #include <linux/mv643xx.h> | 21 | #include <linux/mv643xx.h> |
22 | #include <linux/platform_device.h> | ||
22 | 23 | ||
23 | #include <asm/byteorder.h> | 24 | #include <asm/byteorder.h> |
24 | #include <asm/io.h> | 25 | #include <asm/io.h> |
diff --git a/arch/ppc/syslib/pq2_devices.c b/arch/ppc/syslib/pq2_devices.c index 6f88ba93412b..e960fe935325 100644 --- a/arch/ppc/syslib/pq2_devices.c +++ b/arch/ppc/syslib/pq2_devices.c | |||
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/ioport.h> | 17 | #include <linux/ioport.h> |
18 | #include <asm/cpm2.h> | 18 | #include <asm/cpm2.h> |
19 | #include <asm/irq.h> | 19 | #include <asm/irq.h> |
diff --git a/arch/sh/boards/superh/microdev/setup.c b/arch/sh/boards/superh/microdev/setup.c index c18919941ec0..1c1d65fb12df 100644 --- a/arch/sh/boards/superh/microdev/setup.c +++ b/arch/sh/boards/superh/microdev/setup.c | |||
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/config.h> | 14 | #include <linux/config.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/ioport.h> | 17 | #include <linux/ioport.h> |
18 | #include <asm/io.h> | 18 | #include <asm/io.h> |
19 | #include <asm/mach/irq.h> | 19 | #include <asm/mach/irq.h> |
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index 1495007bf6c0..721e2601a75d 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "linux/ctype.h" | 20 | #include "linux/ctype.h" |
21 | #include "linux/bootmem.h" | 21 | #include "linux/bootmem.h" |
22 | #include "linux/ethtool.h" | 22 | #include "linux/ethtool.h" |
23 | #include "linux/platform_device.h" | ||
23 | #include "asm/uaccess.h" | 24 | #include "asm/uaccess.h" |
24 | #include "user_util.h" | 25 | #include "user_util.h" |
25 | #include "kern_util.h" | 26 | #include "kern_util.h" |
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index f73134333f64..b2c86257b0f8 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "linux/blkpg.h" | 35 | #include "linux/blkpg.h" |
36 | #include "linux/genhd.h" | 36 | #include "linux/genhd.h" |
37 | #include "linux/spinlock.h" | 37 | #include "linux/spinlock.h" |
38 | #include "linux/platform_device.h" | ||
38 | #include "asm/segment.h" | 39 | #include "asm/segment.h" |
39 | #include "asm/uaccess.h" | 40 | #include "asm/uaccess.h" |
40 | #include "asm/irq.h" | 41 | #include "asm/irq.h" |
diff --git a/arch/xtensa/platform-iss/network.c b/arch/xtensa/platform-iss/network.c index 498d7dced1f4..0682ffd38175 100644 --- a/arch/xtensa/platform-iss/network.c +++ b/arch/xtensa/platform-iss/network.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/ethtool.h> | 33 | #include <linux/ethtool.h> |
34 | #include <linux/rtnetlink.h> | 34 | #include <linux/rtnetlink.h> |
35 | #include <linux/timer.h> | 35 | #include <linux/timer.h> |
36 | #include <linux/platform_device.h> | ||
36 | 37 | ||
37 | #include <xtensa/simcall.h> | 38 | #include <xtensa/simcall.h> |
38 | 39 | ||
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 08d9cc99c7de..d597c922af11 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * information. | 10 | * information. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/dma-mapping.h> | 16 | #include <linux/dma-mapping.h> |
diff --git a/drivers/block/cfq-iosched.c b/drivers/block/cfq-iosched.c index 5281f8e70510..ecacca9c877e 100644 --- a/drivers/block/cfq-iosched.c +++ b/drivers/block/cfq-iosched.c | |||
@@ -2059,10 +2059,8 @@ static void cfq_put_cfqd(struct cfq_data *cfqd) | |||
2059 | if (!atomic_dec_and_test(&cfqd->ref)) | 2059 | if (!atomic_dec_and_test(&cfqd->ref)) |
2060 | return; | 2060 | return; |
2061 | 2061 | ||
2062 | blk_put_queue(q); | ||
2063 | |||
2064 | cfq_shutdown_timer_wq(cfqd); | 2062 | cfq_shutdown_timer_wq(cfqd); |
2065 | q->elevator->elevator_data = NULL; | 2063 | blk_put_queue(q); |
2066 | 2064 | ||
2067 | mempool_destroy(cfqd->crq_pool); | 2065 | mempool_destroy(cfqd->crq_pool); |
2068 | kfree(cfqd->crq_hash); | 2066 | kfree(cfqd->crq_hash); |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 00895477155e..5eadbb9d4d71 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -177,7 +177,7 @@ static int print_unex = 1; | |||
177 | #include <linux/interrupt.h> | 177 | #include <linux/interrupt.h> |
178 | #include <linux/init.h> | 178 | #include <linux/init.h> |
179 | #include <linux/devfs_fs_kernel.h> | 179 | #include <linux/devfs_fs_kernel.h> |
180 | #include <linux/device.h> | 180 | #include <linux/platform_device.h> |
181 | #include <linux/buffer_head.h> /* for invalidate_buffers() */ | 181 | #include <linux/buffer_head.h> /* for invalidate_buffers() */ |
182 | 182 | ||
183 | /* | 183 | /* |
diff --git a/drivers/block/noop-iosched.c b/drivers/block/noop-iosched.c index f56b8edb06e4..e54f006e7e60 100644 --- a/drivers/block/noop-iosched.c +++ b/drivers/block/noop-iosched.c | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | static void elevator_noop_add_request(request_queue_t *q, struct request *rq) | 10 | static void elevator_noop_add_request(request_queue_t *q, struct request *rq) |
11 | { | 11 | { |
12 | rq->flags |= REQ_NOMERGE; | ||
12 | elv_dispatch_add_tail(q, rq); | 13 | elv_dispatch_add_tail(q, rq); |
13 | } | 14 | } |
14 | 15 | ||
diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c index 887b8b2d7882..d724c0de4f28 100644 --- a/drivers/char/s3c2410-rtc.c +++ b/drivers/char/s3c2410-rtc.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/fs.h> | 20 | #include <linux/fs.h> |
21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/rtc.h> | 25 | #include <linux/rtc.h> |
26 | #include <linux/bcd.h> | 26 | #include <linux/bcd.h> |
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index f86c15587238..d05067dcea01 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/dmi.h> | 48 | #include <linux/dmi.h> |
49 | #include <linux/err.h> | 49 | #include <linux/err.h> |
50 | #include <linux/kfifo.h> | 50 | #include <linux/kfifo.h> |
51 | #include <linux/platform_device.h> | ||
51 | 52 | ||
52 | #include <asm/uaccess.h> | 53 | #include <asm/uaccess.h> |
53 | #include <asm/io.h> | 54 | #include <asm/io.h> |
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c index eb7058cbf015..24355b23b2ca 100644 --- a/drivers/char/tb0219.c +++ b/drivers/char/tb0219.c | |||
@@ -17,7 +17,7 @@ | |||
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ | 19 | */ |
20 | #include <linux/device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c index 683278bc5241..94641085faf8 100644 --- a/drivers/char/vr41xx_giu.c +++ b/drivers/char/vr41xx_giu.c | |||
@@ -19,7 +19,7 @@ | |||
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ | 21 | */ |
22 | #include <linux/device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
24 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
diff --git a/drivers/char/vr41xx_rtc.c b/drivers/char/vr41xx_rtc.c index a6dbe4da030c..5e3292df69d8 100644 --- a/drivers/char/vr41xx_rtc.c +++ b/drivers/char/vr41xx_rtc.c | |||
@@ -17,7 +17,7 @@ | |||
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ | 19 | */ |
20 | #include <linux/device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
diff --git a/drivers/char/watchdog/mpcore_wdt.c b/drivers/char/watchdog/mpcore_wdt.c index 75ca84ed4adf..47a5f6ab4879 100644 --- a/drivers/char/watchdog/mpcore_wdt.c +++ b/drivers/char/watchdog/mpcore_wdt.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/reboot.h> | 29 | #include <linux/reboot.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
32 | #include <linux/device.h> | 32 | #include <linux/platform_device.h> |
33 | 33 | ||
34 | #include <asm/hardware/arm_twd.h> | 34 | #include <asm/hardware/arm_twd.h> |
35 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
diff --git a/drivers/char/watchdog/mv64x60_wdt.c b/drivers/char/watchdog/mv64x60_wdt.c index 6d3ff0836c44..04e0d7e9680d 100644 --- a/drivers/char/watchdog/mv64x60_wdt.c +++ b/drivers/char/watchdog/mv64x60_wdt.c | |||
@@ -22,6 +22,8 @@ | |||
22 | #include <linux/miscdevice.h> | 22 | #include <linux/miscdevice.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/watchdog.h> | 24 | #include <linux/watchdog.h> |
25 | #include <linux/platform_device.h> | ||
26 | |||
25 | #include <asm/mv64x60.h> | 27 | #include <asm/mv64x60.h> |
26 | #include <asm/uaccess.h> | 28 | #include <asm/uaccess.h> |
27 | #include <asm/io.h> | 29 | #include <asm/io.h> |
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index b732020acadb..e7e20a6d64b0 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <linux/watchdog.h> | 44 | #include <linux/watchdog.h> |
45 | #include <linux/fs.h> | 45 | #include <linux/fs.h> |
46 | #include <linux/init.h> | 46 | #include <linux/init.h> |
47 | #include <linux/device.h> | 47 | #include <linux/platform_device.h> |
48 | #include <linux/interrupt.h> | 48 | #include <linux/interrupt.h> |
49 | 49 | ||
50 | #include <asm/uaccess.h> | 50 | #include <asm/uaccess.h> |
diff --git a/drivers/eisa/virtual_root.c b/drivers/eisa/virtual_root.c index 15677f20bd85..0f97a0cb0ff4 100644 --- a/drivers/eisa/virtual_root.c +++ b/drivers/eisa/virtual_root.c | |||
@@ -9,7 +9,7 @@ | |||
9 | 9 | ||
10 | #include <linux/config.h> | 10 | #include <linux/config.h> |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/device.h> | 12 | #include <linux/platform_device.h> |
13 | #include <linux/eisa.h> | 13 | #include <linux/eisa.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/moduleparam.h> | 15 | #include <linux/moduleparam.h> |
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c index 955537fe9958..8ed6ddbb9c5d 100644 --- a/drivers/firmware/dcdbas.c +++ b/drivers/firmware/dcdbas.c | |||
@@ -20,7 +20,7 @@ | |||
20 | * GNU General Public License for more details. | 20 | * GNU General Public License for more details. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/dma-mapping.h> | 24 | #include <linux/dma-mapping.h> |
25 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c index 4f4ba9b6d182..125929c9048f 100644 --- a/drivers/firmware/dell_rbu.c +++ b/drivers/firmware/dell_rbu.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <linux/string.h> | 41 | #include <linux/string.h> |
42 | #include <linux/errno.h> | 42 | #include <linux/errno.h> |
43 | #include <linux/blkdev.h> | 43 | #include <linux/blkdev.h> |
44 | #include <linux/device.h> | 44 | #include <linux/platform_device.h> |
45 | #include <linux/spinlock.h> | 45 | #include <linux/spinlock.h> |
46 | #include <linux/moduleparam.h> | 46 | #include <linux/moduleparam.h> |
47 | #include <linux/firmware.h> | 47 | #include <linux/firmware.h> |
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index 0015da5668a1..1e5dfc7805e2 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c | |||
@@ -27,7 +27,7 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/input.h> | 31 | #include <linux/input.h> |
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index 9888fae1f37a..13752bcb2afd 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
37 | #include <linux/sched.h> | 37 | #include <linux/sched.h> |
38 | #include <linux/device.h> | 38 | #include <linux/platform_device.h> |
39 | #include <linux/i2c.h> | 39 | #include <linux/i2c.h> |
40 | 40 | ||
41 | #include <asm/io.h> | 41 | #include <asm/io.h> |
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 4fdc02411609..03672c9ca409 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/errno.h> | 38 | #include <linux/errno.h> |
39 | #include <linux/i2c.h> | 39 | #include <linux/i2c.h> |
40 | #include <linux/i2c-isa.h> | 40 | #include <linux/i2c-isa.h> |
41 | #include <linux/platform_device.h> | ||
41 | 42 | ||
42 | static u32 isa_func(struct i2c_adapter *adapter); | 43 | static u32 isa_func(struct i2c_adapter *adapter); |
43 | 44 | ||
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c index 42016ee6ef13..64552a376f2d 100644 --- a/drivers/i2c/busses/i2c-ixp2000.c +++ b/drivers/i2c/busses/i2c-ixp2000.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/device.h> | 31 | #include <linux/platform_device.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/i2c-algo-bit.h> | 34 | #include <linux/i2c-algo-bit.h> |
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index 69303ab65e04..cc652c350814 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/device.h> | 31 | #include <linux/platform_device.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/i2c-algo-bit.h> | 34 | #include <linux/i2c-algo-bit.h> |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 8491633005b8..65b939a059e9 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
22 | #include <linux/platform_device.h> | ||
23 | |||
22 | #include <asm/io.h> | 24 | #include <asm/io.h> |
23 | #include <linux/fsl_devices.h> | 25 | #include <linux/fsl_devices.h> |
24 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index d0d2a6f1386e..6b48027b2ee3 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/mv643xx.h> | 19 | #include <linux/mv643xx.h> |
20 | #include <linux/platform_device.h> | ||
21 | |||
20 | #include <asm/io.h> | 22 | #include <asm/io.h> |
21 | 23 | ||
22 | /* Register defines */ | 24 | /* Register defines */ |
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 44b595d90a4a..67ccbea24ba4 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
31 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
32 | #include <linux/i2c-pxa.h> | 32 | #include <linux/i2c-pxa.h> |
33 | #include <linux/platform_device.h> | ||
33 | 34 | ||
34 | #include <asm/hardware.h> | 35 | #include <asm/hardware.h> |
35 | #include <asm/irq.h> | 36 | #include <asm/irq.h> |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 6ced28e90070..1b582262e677 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
35 | #include <linux/err.h> | 35 | #include <linux/err.h> |
36 | #include <linux/device.h> | 36 | #include <linux/platform_device.h> |
37 | 37 | ||
38 | #include <asm/hardware.h> | 38 | #include <asm/hardware.h> |
39 | #include <asm/irq.h> | 39 | #include <asm/irq.h> |
@@ -918,8 +918,11 @@ static int __init i2c_adap_s3c_init(void) | |||
918 | int ret; | 918 | int ret; |
919 | 919 | ||
920 | ret = driver_register(&s3c2410_i2c_driver); | 920 | ret = driver_register(&s3c2410_i2c_driver); |
921 | if (ret == 0) | 921 | if (ret == 0) { |
922 | ret = driver_register(&s3c2440_i2c_driver); | 922 | ret = driver_register(&s3c2440_i2c_driver); |
923 | if (ret) | ||
924 | driver_unregister(&s3c2410_i2c_driver); | ||
925 | } | ||
923 | 926 | ||
924 | return ret; | 927 | return ret; |
925 | } | 928 | } |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index eaa4742e04fa..9dbb72fffbe2 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/usb_ch9.h> | 31 | #include <linux/usb_ch9.h> |
32 | #include <linux/usb_gadget.h> | 32 | #include <linux/usb_gadget.h> |
33 | #include <linux/usb.h> | 33 | #include <linux/usb.h> |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 02e335a04f09..82ea1b7ec914 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/idr.h> | 31 | #include <linux/idr.h> |
32 | #include <linux/seq_file.h> | 32 | #include <linux/seq_file.h> |
33 | #include <linux/platform_device.h> | ||
33 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
34 | 35 | ||
35 | 36 | ||
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index ea14c8f1c82b..8af0bd1424d2 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
36 | #include <linux/i2c-dev.h> | 36 | #include <linux/i2c-dev.h> |
37 | #include <linux/platform_device.h> | ||
37 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
38 | 39 | ||
39 | static struct i2c_client i2cdev_client_template; | 40 | static struct i2c_client i2cdev_client_template; |
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index a4696cd0978c..9f2352bd8348 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -565,6 +565,7 @@ static long evdev_ioctl_compat(struct file *file, unsigned int cmd, unsigned lon | |||
565 | case EV_LED: bits = dev->ledbit; max = LED_MAX; break; | 565 | case EV_LED: bits = dev->ledbit; max = LED_MAX; break; |
566 | case EV_SND: bits = dev->sndbit; max = SND_MAX; break; | 566 | case EV_SND: bits = dev->sndbit; max = SND_MAX; break; |
567 | case EV_FF: bits = dev->ffbit; max = FF_MAX; break; | 567 | case EV_FF: bits = dev->ffbit; max = FF_MAX; break; |
568 | case EV_SW: bits = dev->swbit; max = SW_MAX; break; | ||
568 | default: return -EINVAL; | 569 | default: return -EINVAL; |
569 | } | 570 | } |
570 | bit_to_user(bits, max); | 571 | bit_to_user(bits, max); |
@@ -579,6 +580,9 @@ static long evdev_ioctl_compat(struct file *file, unsigned int cmd, unsigned lon | |||
579 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0))) | 580 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0))) |
580 | bit_to_user(dev->snd, SND_MAX); | 581 | bit_to_user(dev->snd, SND_MAX); |
581 | 582 | ||
583 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSW(0))) | ||
584 | bit_to_user(dev->sw, SW_MAX); | ||
585 | |||
582 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { | 586 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { |
583 | int len; | 587 | int len; |
584 | if (!dev->name) return -ENOENT; | 588 | if (!dev->name) return -ENOENT; |
diff --git a/drivers/input/input.c b/drivers/input/input.c index 3b1685ff9d10..1a1654caedd5 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -730,7 +730,7 @@ static void input_register_classdevice(struct input_dev *dev) | |||
730 | "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1); | 730 | "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1); |
731 | 731 | ||
732 | path = kobject_get_path(&dev->cdev.class->subsys.kset.kobj, GFP_KERNEL); | 732 | path = kobject_get_path(&dev->cdev.class->subsys.kset.kobj, GFP_KERNEL); |
733 | printk(KERN_INFO "input: %s/%s as %s\n", | 733 | printk(KERN_INFO "input: %s as %s/%s\n", |
734 | dev->name ? dev->name : "Unspecified device", | 734 | dev->name ? dev->name : "Unspecified device", |
735 | path ? path : "", dev->cdev.class_id); | 735 | path ? path : "", dev->cdev.class_id); |
736 | kfree(path); | 736 | kfree(path); |
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 571a68691a4a..4a917748fd9f 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -13,11 +13,11 @@ menuconfig INPUT_KEYBOARD | |||
13 | if INPUT_KEYBOARD | 13 | if INPUT_KEYBOARD |
14 | 14 | ||
15 | config KEYBOARD_ATKBD | 15 | config KEYBOARD_ATKBD |
16 | tristate "AT keyboard" if !PC | 16 | tristate "AT keyboard" if !X86_PC |
17 | default y | 17 | default y |
18 | select SERIO | 18 | select SERIO |
19 | select SERIO_LIBPS2 | 19 | select SERIO_LIBPS2 |
20 | select SERIO_I8042 if PC | 20 | select SERIO_I8042 if X86_PC |
21 | select SERIO_GSCPS2 if GSC | 21 | select SERIO_GSCPS2 if GSC |
22 | help | 22 | help |
23 | Say Y here if you want to use a standard AT or PS/2 keyboard. Usually | 23 | Say Y here if you want to use a standard AT or PS/2 keyboard. Usually |
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index 3210d298b3bc..d00d14bb637a 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/input.h> | 17 | #include <linux/input.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 7f06780a437f..9481132532d0 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c | |||
@@ -441,7 +441,7 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags, | |||
441 | input_sync (lk->dev); | 441 | input_sync (lk->dev); |
442 | break; | 442 | break; |
443 | case LK_METRONOME: | 443 | case LK_METRONOME: |
444 | DBG (KERN_INFO "Got %#d and don't " | 444 | DBG (KERN_INFO "Got LK_METRONOME and don't " |
445 | "know how to handle...\n"); | 445 | "know how to handle...\n"); |
446 | break; | 446 | break; |
447 | case LK_OUTPUT_ERROR: | 447 | case LK_OUTPUT_ERROR: |
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c index cee9c734a048..0fa38a559cdf 100644 --- a/drivers/input/keyboard/spitzkbd.c +++ b/drivers/input/keyboard/spitzkbd.c | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/input.h> | 17 | #include <linux/input.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c index e34633c37fdd..68ac97f101b0 100644 --- a/drivers/input/misc/pcspkr.c +++ b/drivers/input/misc/pcspkr.c | |||
@@ -71,7 +71,7 @@ static int __init pcspkr_init(void) | |||
71 | return -ENOMEM; | 71 | return -ENOMEM; |
72 | 72 | ||
73 | pcspkr_dev->name = "PC Speaker"; | 73 | pcspkr_dev->name = "PC Speaker"; |
74 | pcspkr_dev->name = "isa0061/input0"; | 74 | pcspkr_dev->phys = "isa0061/input0"; |
75 | pcspkr_dev->id.bustype = BUS_ISA; | 75 | pcspkr_dev->id.bustype = BUS_ISA; |
76 | pcspkr_dev->id.vendor = 0x001f; | 76 | pcspkr_dev->id.vendor = 0x001f; |
77 | pcspkr_dev->id.product = 0x0001; | 77 | pcspkr_dev->id.product = 0x0001; |
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig index 537154dd7a87..574b18a523af 100644 --- a/drivers/input/mouse/Kconfig +++ b/drivers/input/mouse/Kconfig | |||
@@ -17,7 +17,7 @@ config MOUSE_PS2 | |||
17 | default y | 17 | default y |
18 | select SERIO | 18 | select SERIO |
19 | select SERIO_LIBPS2 | 19 | select SERIO_LIBPS2 |
20 | select SERIO_I8042 if PC | 20 | select SERIO_I8042 if X86_PC |
21 | select SERIO_GSCPS2 if GSC | 21 | select SERIO_GSCPS2 if GSC |
22 | ---help--- | 22 | ---help--- |
23 | Say Y here if you have a PS/2 mouse connected to your system. This | 23 | Say Y here if you have a PS/2 mouse connected to your system. This |
diff --git a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c index dd0f5bd90241..4da6c86b5d76 100644 --- a/drivers/input/serio/ct82c710.c +++ b/drivers/input/serio/ct82c710.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/serio.h> | 37 | #include <linux/serio.h> |
38 | #include <linux/errno.h> | 38 | #include <linux/errno.h> |
39 | #include <linux/err.h> | 39 | #include <linux/err.h> |
40 | #include <linux/platform_device.h> | ||
40 | 41 | ||
41 | #include <asm/io.h> | 42 | #include <asm/io.h> |
42 | 43 | ||
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 4bc40f159996..01e186422021 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/serio.h> | 20 | #include <linux/serio.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/rcupdate.h> | 22 | #include <linux/rcupdate.h> |
23 | #include <linux/platform_device.h> | ||
23 | 24 | ||
24 | #include <asm/io.h> | 25 | #include <asm/io.h> |
25 | 26 | ||
diff --git a/drivers/input/serio/maceps2.c b/drivers/input/serio/maceps2.c index 9880fc145d90..d857f7081adb 100644 --- a/drivers/input/serio/maceps2.c +++ b/drivers/input/serio/maceps2.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
15 | #include <linux/ioport.h> | 15 | #include <linux/ioport.h> |
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/spinlock.h> | 19 | #include <linux/spinlock.h> |
20 | #include <linux/err.h> | 20 | #include <linux/err.h> |
diff --git a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c index 46093c507988..b44d255596c2 100644 --- a/drivers/input/serio/q40kbd.c +++ b/drivers/input/serio/q40kbd.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/interrupt.h> | 37 | #include <linux/interrupt.h> |
38 | #include <linux/err.h> | 38 | #include <linux/err.h> |
39 | #include <linux/bitops.h> | 39 | #include <linux/bitops.h> |
40 | #include <linux/platform_device.h> | ||
40 | 41 | ||
41 | #include <asm/io.h> | 42 | #include <asm/io.h> |
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
diff --git a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c index 106f5eefd89a..52c49258f8a4 100644 --- a/drivers/input/serio/rpckbd.c +++ b/drivers/input/serio/rpckbd.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/serio.h> | 35 | #include <linux/serio.h> |
36 | #include <linux/err.h> | 36 | #include <linux/err.h> |
37 | #include <linux/platform_device.h> | ||
37 | 38 | ||
38 | #include <asm/irq.h> | 39 | #include <asm/irq.h> |
39 | #include <asm/hardware.h> | 40 | #include <asm/hardware.h> |
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index 0ba3e6562bff..15e88eeae8d6 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c | |||
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | 12 | ||
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/input.h> | 16 | #include <linux/input.h> |
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c index cdb6d0283195..8f02c155fdc0 100644 --- a/drivers/macintosh/adbhid.c +++ b/drivers/macintosh/adbhid.c | |||
@@ -723,6 +723,7 @@ adbhid_input_register(int id, int default_id, int original_handler_id, | |||
723 | 723 | ||
724 | sprintf(hid->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id); | 724 | sprintf(hid->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id); |
725 | 725 | ||
726 | hid->input = input_dev; | ||
726 | hid->id = default_id; | 727 | hid->id = default_id; |
727 | hid->original_handler_id = original_handler_id; | 728 | hid->original_handler_id = original_handler_id; |
728 | hid->current_handler_id = current_handler_id; | 729 | hid->current_handler_id = current_handler_id; |
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c index 720e7a326308..7daa0ed7331c 100644 --- a/drivers/mfd/mcp-sa11x0.c +++ b/drivers/mfd/mcp-sa11x0.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/spinlock.h> | 19 | #include <linux/spinlock.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/device.h> | 21 | #include <linux/platform_device.h> |
22 | 22 | ||
23 | #include <asm/dma.h> | 23 | #include <asm/dma.h> |
24 | #include <asm/hardware.h> | 24 | #include <asm/hardware.h> |
diff --git a/drivers/misc/hdpuftrs/hdpu_cpustate.c b/drivers/misc/hdpuftrs/hdpu_cpustate.c index 46de5c940555..9c4dd682ac74 100644 --- a/drivers/misc/hdpuftrs/hdpu_cpustate.c +++ b/drivers/misc/hdpuftrs/hdpu_cpustate.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/miscdevice.h> | 21 | #include <linux/miscdevice.h> |
22 | #include <linux/pci.h> | 22 | #include <linux/pci.h> |
23 | #include <linux/proc_fs.h> | 23 | #include <linux/proc_fs.h> |
24 | #include <linux/device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
26 | #include <linux/hdpu_features.h> | 26 | #include <linux/hdpu_features.h> |
27 | 27 | ||
diff --git a/drivers/misc/hdpuftrs/hdpu_nexus.c b/drivers/misc/hdpuftrs/hdpu_nexus.c index c203b27269ea..165f3405df27 100644 --- a/drivers/misc/hdpuftrs/hdpu_nexus.c +++ b/drivers/misc/hdpuftrs/hdpu_nexus.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/hdpu_features.h> | 21 | #include <linux/hdpu_features.h> |
22 | #include <linux/pci.h> | 22 | #include <linux/pci.h> |
23 | 23 | ||
24 | #include <linux/device.h> | 24 | #include <linux/platform_device.h> |
25 | 25 | ||
26 | static int hdpu_nexus_probe(struct device *ddev); | 26 | static int hdpu_nexus_probe(struct device *ddev); |
27 | static int hdpu_nexus_remove(struct device *ddev); | 27 | static int hdpu_nexus_remove(struct device *ddev); |
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c index d575e3a018bc..f31e247b2cbe 100644 --- a/drivers/mmc/pxamci.c +++ b/drivers/mmc/pxamci.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/ioport.h> | 22 | #include <linux/ioport.h> |
23 | #include <linux/device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/dma-mapping.h> | 26 | #include <linux/dma-mapping.h> |
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c index 3ace875decc4..942668e93a74 100644 --- a/drivers/mmc/wbsd.c +++ b/drivers/mmc/wbsd.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/moduleparam.h> | 26 | #include <linux/moduleparam.h> |
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/ioport.h> | 28 | #include <linux/ioport.h> |
29 | #include <linux/device.h> | 29 | #include <linux/platform_device.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/dma-mapping.h> | 31 | #include <linux/dma-mapping.h> |
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c index 63104c73ca3c..bfe994e59265 100644 --- a/drivers/mtd/maps/bast-flash.c +++ b/drivers/mtd/maps/bast-flash.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/ioport.h> | 34 | #include <linux/ioport.h> |
35 | #include <linux/device.h> | 35 | #include <linux/device.h> |
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | 37 | #include <linux/platform_device.h> | |
38 | #include <linux/mtd/mtd.h> | 38 | #include <linux/mtd/mtd.h> |
39 | #include <linux/mtd/map.h> | 39 | #include <linux/mtd/map.h> |
40 | #include <linux/mtd/partitions.h> | 40 | #include <linux/mtd/partitions.h> |
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c index e39a98a0171c..d14a0185b8f4 100644 --- a/drivers/mtd/maps/integrator-flash.c +++ b/drivers/mtd/maps/integrator-flash.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | #include <linux/ioport.h> | 34 | #include <linux/ioport.h> |
35 | #include <linux/device.h> | 35 | #include <linux/platform_device.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | 37 | ||
38 | #include <linux/mtd/mtd.h> | 38 | #include <linux/mtd/mtd.h> |
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c index 1e5d6e1d05f3..00b9f67580f1 100644 --- a/drivers/mtd/maps/ixp2000.c +++ b/drivers/mtd/maps/ixp2000.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/ioport.h> | 26 | #include <linux/ioport.h> |
27 | #include <linux/device.h> | 27 | #include <linux/device.h> |
28 | #include <linux/platform_device.h> | ||
28 | 29 | ||
29 | #include <linux/mtd/mtd.h> | 30 | #include <linux/mtd/mtd.h> |
30 | #include <linux/mtd/map.h> | 31 | #include <linux/mtd/map.h> |
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c index da316e543237..733a9297a562 100644 --- a/drivers/mtd/maps/ixp4xx.c +++ b/drivers/mtd/maps/ixp4xx.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
25 | #include <linux/device.h> | 25 | #include <linux/device.h> |
26 | #include <linux/platform_device.h> | ||
26 | 27 | ||
27 | #include <linux/mtd/mtd.h> | 28 | #include <linux/mtd/mtd.h> |
28 | #include <linux/mtd/map.h> | 29 | #include <linux/mtd/map.h> |
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c index fa84566245a7..7f370bb794fe 100644 --- a/drivers/mtd/maps/omap_nor.c +++ b/drivers/mtd/maps/omap_nor.c | |||
@@ -30,7 +30,7 @@ | |||
30 | * 675 Mass Ave, Cambridge, MA 02139, USA. | 30 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/types.h> | 35 | #include <linux/types.h> |
36 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c index a0577ea00c3c..104576b5be34 100644 --- a/drivers/mtd/maps/plat-ram.c +++ b/drivers/mtd/maps/plat-ram.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/ioport.h> | 31 | #include <linux/ioport.h> |
32 | #include <linux/device.h> | 32 | #include <linux/device.h> |
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | #include <linux/platform_device.h> | ||
34 | 35 | ||
35 | #include <linux/mtd/mtd.h> | 36 | #include <linux/mtd/mtd.h> |
36 | #include <linux/mtd/map.h> | 37 | #include <linux/mtd/map.h> |
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c index c81bec7b14d5..c8d0da19d897 100644 --- a/drivers/mtd/maps/sa1100-flash.c +++ b/drivers/mtd/maps/sa1100-flash.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
18 | 18 | ||
19 | #include <linux/mtd/mtd.h> | 19 | #include <linux/mtd/mtd.h> |
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index b58ba236a9eb..2df5e47d1f5c 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c | |||
@@ -48,7 +48,7 @@ | |||
48 | #include <linux/kernel.h> | 48 | #include <linux/kernel.h> |
49 | #include <linux/string.h> | 49 | #include <linux/string.h> |
50 | #include <linux/ioport.h> | 50 | #include <linux/ioport.h> |
51 | #include <linux/device.h> | 51 | #include <linux/platform_device.h> |
52 | #include <linux/delay.h> | 52 | #include <linux/delay.h> |
53 | #include <linux/err.h> | 53 | #include <linux/err.h> |
54 | #include <linux/slab.h> | 54 | #include <linux/slab.h> |
diff --git a/drivers/net/depca.c b/drivers/net/depca.c index c4aa5fe2840e..4d26e5e7d18b 100644 --- a/drivers/net/depca.c +++ b/drivers/net/depca.c | |||
@@ -254,7 +254,7 @@ | |||
254 | #include <linux/unistd.h> | 254 | #include <linux/unistd.h> |
255 | #include <linux/ctype.h> | 255 | #include <linux/ctype.h> |
256 | #include <linux/moduleparam.h> | 256 | #include <linux/moduleparam.h> |
257 | #include <linux/device.h> | 257 | #include <linux/platform_device.h> |
258 | #include <linux/bitops.h> | 258 | #include <linux/bitops.h> |
259 | 259 | ||
260 | #include <asm/uaccess.h> | 260 | #include <asm/uaccess.h> |
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index abce1f730d00..c0af6fb1fbba 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c | |||
@@ -66,6 +66,7 @@ | |||
66 | #include <linux/mii.h> | 66 | #include <linux/mii.h> |
67 | #include <linux/dm9000.h> | 67 | #include <linux/dm9000.h> |
68 | #include <linux/delay.h> | 68 | #include <linux/delay.h> |
69 | #include <linux/platform_device.h> | ||
69 | 70 | ||
70 | #include <asm/delay.h> | 71 | #include <asm/delay.h> |
71 | #include <asm/irq.h> | 72 | #include <asm/irq.h> |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index ae5a2ed3b264..962580f2c4ab 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -81,7 +81,7 @@ | |||
81 | #include <linux/if_vlan.h> | 81 | #include <linux/if_vlan.h> |
82 | #include <linux/spinlock.h> | 82 | #include <linux/spinlock.h> |
83 | #include <linux/mm.h> | 83 | #include <linux/mm.h> |
84 | #include <linux/device.h> | 84 | #include <linux/platform_device.h> |
85 | #include <linux/ip.h> | 85 | #include <linux/ip.h> |
86 | #include <linux/tcp.h> | 86 | #include <linux/tcp.h> |
87 | #include <linux/udp.h> | 87 | #include <linux/udp.h> |
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c index 1eca1dbca7f1..5a74d3d3dbe1 100644 --- a/drivers/net/gianfar_mii.c +++ b/drivers/net/gianfar_mii.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/mm.h> | 33 | #include <linux/mm.h> |
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/version.h> | 35 | #include <linux/version.h> |
36 | #include <linux/platform_device.h> | ||
36 | #include <asm/ocp.h> | 37 | #include <asm/ocp.h> |
37 | #include <linux/crc32.h> | 38 | #include <linux/crc32.h> |
38 | #include <linux/mii.h> | 39 | #include <linux/mii.h> |
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c index b886b07412a6..e1aa9910503b 100644 --- a/drivers/net/irda/pxaficp_ir.c +++ b/drivers/net/irda/pxaficp_ir.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/rtnetlink.h> | 22 | #include <linux/rtnetlink.h> |
23 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
24 | #include <linux/dma-mapping.h> | 24 | #include <linux/dma-mapping.h> |
25 | #include <linux/platform_device.h> | ||
25 | #include <linux/pm.h> | 26 | #include <linux/pm.h> |
26 | 27 | ||
27 | #include <net/irda/irda.h> | 28 | #include <net/irda/irda.h> |
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c index 06883309916d..76e0b9fb5e96 100644 --- a/drivers/net/irda/sa1100_ir.c +++ b/drivers/net/irda/sa1100_ir.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/rtnetlink.h> | 29 | #include <linux/rtnetlink.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/device.h> | 32 | #include <linux/platform_device.h> |
33 | #include <linux/dma-mapping.h> | 33 | #include <linux/dma-mapping.h> |
34 | 34 | ||
35 | #include <net/irda/irda.h> | 35 | #include <net/irda/irda.h> |
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c index 140b7cdb1f7e..a1d207f2fa68 100644 --- a/drivers/net/irda/smsc-ircc2.c +++ b/drivers/net/irda/smsc-ircc2.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include <linux/rtnetlink.h> | 53 | #include <linux/rtnetlink.h> |
54 | #include <linux/serial_reg.h> | 54 | #include <linux/serial_reg.h> |
55 | #include <linux/dma-mapping.h> | 55 | #include <linux/dma-mapping.h> |
56 | #include <linux/platform_device.h> | ||
56 | 57 | ||
57 | #include <asm/io.h> | 58 | #include <asm/io.h> |
58 | #include <asm/dma.h> | 59 | #include <asm/dma.h> |
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c index 8423cb6875f0..a74a5cfaf5bc 100644 --- a/drivers/net/jazzsonic.c +++ b/drivers/net/jazzsonic.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/netdevice.h> | 33 | #include <linux/netdevice.h> |
34 | #include <linux/etherdevice.h> | 34 | #include <linux/etherdevice.h> |
35 | #include <linux/skbuff.h> | 35 | #include <linux/skbuff.h> |
36 | #include <linux/device.h> | 36 | #include <linux/platform_device.h> |
37 | #include <linux/dma-mapping.h> | 37 | #include <linux/dma-mapping.h> |
38 | 38 | ||
39 | #include <asm/bootinfo.h> | 39 | #include <asm/bootinfo.h> |
diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c index 405e18365ede..e9c999d7eb39 100644 --- a/drivers/net/macsonic.c +++ b/drivers/net/macsonic.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include <linux/netdevice.h> | 47 | #include <linux/netdevice.h> |
48 | #include <linux/etherdevice.h> | 48 | #include <linux/etherdevice.h> |
49 | #include <linux/skbuff.h> | 49 | #include <linux/skbuff.h> |
50 | #include <linux/device.h> | 50 | #include <linux/platform_device.h> |
51 | #include <linux/dma-mapping.h> | 51 | #include <linux/dma-mapping.h> |
52 | 52 | ||
53 | #include <asm/bootinfo.h> | 53 | #include <asm/bootinfo.h> |
diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c index f79f7ee72ab8..bbffb585b3b3 100644 --- a/drivers/net/mipsnet.c +++ b/drivers/net/mipsnet.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/etherdevice.h> | 14 | #include <linux/etherdevice.h> |
15 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
16 | #include <linux/platform_device.h> | ||
16 | #include <asm/io.h> | 17 | #include <asm/io.h> |
17 | #include <asm/mips-boards/simint.h> | 18 | #include <asm/mips-boards/simint.h> |
18 | 19 | ||
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c index 8fbba21d975b..71f2c6705bc3 100644 --- a/drivers/net/mv643xx_eth.c +++ b/drivers/net/mv643xx_eth.c | |||
@@ -39,6 +39,8 @@ | |||
39 | #include <linux/bitops.h> | 39 | #include <linux/bitops.h> |
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <linux/ethtool.h> | 41 | #include <linux/ethtool.h> |
42 | #include <linux/platform_device.h> | ||
43 | |||
42 | #include <asm/io.h> | 44 | #include <asm/io.h> |
43 | #include <asm/types.h> | 45 | #include <asm/types.h> |
44 | #include <asm/pgtable.h> | 46 | #include <asm/pgtable.h> |
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c index c573bb351d4c..74d5f1a6fdea 100644 --- a/drivers/net/smc91x.c +++ b/drivers/net/smc91x.c | |||
@@ -77,7 +77,7 @@ static const char version[] = | |||
77 | #include <linux/errno.h> | 77 | #include <linux/errno.h> |
78 | #include <linux/ioport.h> | 78 | #include <linux/ioport.h> |
79 | #include <linux/crc32.h> | 79 | #include <linux/crc32.h> |
80 | #include <linux/device.h> | 80 | #include <linux/platform_device.h> |
81 | #include <linux/spinlock.h> | 81 | #include <linux/spinlock.h> |
82 | #include <linux/ethtool.h> | 82 | #include <linux/ethtool.h> |
83 | #include <linux/mii.h> | 83 | #include <linux/mii.h> |
diff --git a/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c index eb1423ede75c..d04c918ebef8 100644 --- a/drivers/net/tokenring/proteon.c +++ b/drivers/net/tokenring/proteon.c | |||
@@ -29,6 +29,7 @@ static const char version[] = "proteon.c: v1.00 02/01/2003 by Jochen Friedrich\n | |||
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/netdevice.h> | 30 | #include <linux/netdevice.h> |
31 | #include <linux/trdevice.h> | 31 | #include <linux/trdevice.h> |
32 | #include <linux/platform_device.h> | ||
32 | 33 | ||
33 | #include <asm/system.h> | 34 | #include <asm/system.h> |
34 | #include <asm/io.h> | 35 | #include <asm/io.h> |
diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c index 3c7c66204f74..72cf708396be 100644 --- a/drivers/net/tokenring/skisa.c +++ b/drivers/net/tokenring/skisa.c | |||
@@ -36,6 +36,7 @@ static const char version[] = "skisa.c: v1.03 09/12/2002 by Jochen Friedrich\n"; | |||
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/netdevice.h> | 37 | #include <linux/netdevice.h> |
38 | #include <linux/trdevice.h> | 38 | #include <linux/trdevice.h> |
39 | #include <linux/platform_device.h> | ||
39 | 40 | ||
40 | #include <asm/system.h> | 41 | #include <asm/system.h> |
41 | #include <asm/io.h> | 42 | #include <asm/io.h> |
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c index ba48cef3a9dc..87302c548c24 100644 --- a/drivers/pcmcia/au1000_generic.c +++ b/drivers/pcmcia/au1000_generic.c | |||
@@ -42,7 +42,7 @@ | |||
42 | #include <linux/notifier.h> | 42 | #include <linux/notifier.h> |
43 | #include <linux/interrupt.h> | 43 | #include <linux/interrupt.h> |
44 | #include <linux/spinlock.h> | 44 | #include <linux/spinlock.h> |
45 | #include <linux/device.h> | 45 | #include <linux/platform_device.h> |
46 | 46 | ||
47 | #include <asm/io.h> | 47 | #include <asm/io.h> |
48 | #include <asm/irq.h> | 48 | #include <asm/irq.h> |
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c index b57a0b98b4d6..561706ba4499 100644 --- a/drivers/pcmcia/hd64465_ss.c +++ b/drivers/pcmcia/hd64465_ss.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <asm/errno.h> | 37 | #include <asm/errno.h> |
38 | #include <linux/irq.h> | 38 | #include <linux/irq.h> |
39 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
40 | #include <linux/device.h> | 40 | #include <linux/platform_device.h> |
41 | 41 | ||
42 | #include <asm/io.h> | 42 | #include <asm/io.h> |
43 | #include <asm/hd64465/hd64465.h> | 43 | #include <asm/hd64465/hd64465.h> |
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 4a41f67d185d..7ce455d01cc9 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include <linux/delay.h> | 47 | #include <linux/delay.h> |
48 | #include <linux/workqueue.h> | 48 | #include <linux/workqueue.h> |
49 | #include <linux/interrupt.h> | 49 | #include <linux/interrupt.h> |
50 | #include <linux/device.h> | 50 | #include <linux/platform_device.h> |
51 | #include <linux/bitops.h> | 51 | #include <linux/bitops.h> |
52 | #include <asm/irq.h> | 52 | #include <asm/irq.h> |
53 | #include <asm/io.h> | 53 | #include <asm/io.h> |
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c index c6ed70ea4812..2c22b4b3619d 100644 --- a/drivers/pcmcia/m32r_cfc.c +++ b/drivers/pcmcia/m32r_cfc.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/bitops.h> | 27 | #include <linux/bitops.h> |
28 | #include <asm/irq.h> | 28 | #include <asm/irq.h> |
29 | #include <asm/io.h> | 29 | #include <asm/io.h> |
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c index 3397ff28de6a..356a6fb416a1 100644 --- a/drivers/pcmcia/m32r_pcc.c +++ b/drivers/pcmcia/m32r_pcc.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <asm/irq.h> | 27 | #include <asm/irq.h> |
28 | #include <asm/io.h> | 28 | #include <asm/io.h> |
29 | #include <asm/bitops.h> | 29 | #include <asm/bitops.h> |
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c index 2558c3cc91ec..47b5ade95bde 100644 --- a/drivers/pcmcia/omap_cf.c +++ b/drivers/pcmcia/omap_cf.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
15 | #include <linux/device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c index c2a12d53f6c7..7fa18fb814bc 100644 --- a/drivers/pcmcia/pxa2xx_base.c +++ b/drivers/pcmcia/pxa2xx_base.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
26 | #include <linux/platform_device.h> | ||
26 | 27 | ||
27 | #include <asm/hardware.h> | 28 | #include <asm/hardware.h> |
28 | #include <asm/io.h> | 29 | #include <asm/io.h> |
diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c index bbe69b07ce50..5209d8c7764f 100644 --- a/drivers/pcmcia/pxa2xx_mainstone.c +++ b/drivers/pcmcia/pxa2xx_mainstone.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/device.h> | 20 | #include <linux/platform_device.h> |
21 | 21 | ||
22 | #include <pcmcia/ss.h> | 22 | #include <pcmcia/ss.h> |
23 | 23 | ||
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c index bd924336a49f..fe5ea36e7de3 100644 --- a/drivers/pcmcia/pxa2xx_sharpsl.c +++ b/drivers/pcmcia/pxa2xx_sharpsl.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/device.h> | 19 | #include <linux/platform_device.h> |
20 | 20 | ||
21 | #include <asm/mach-types.h> | 21 | #include <asm/mach-types.h> |
22 | #include <asm/hardware.h> | 22 | #include <asm/hardware.h> |
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c index acf60ffc8a12..6d441ec75c6a 100644 --- a/drivers/pcmcia/sa1100_generic.c +++ b/drivers/pcmcia/sa1100_generic.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/config.h> | 35 | #include <linux/config.h> |
36 | #include <linux/platform_device.h> | ||
36 | 37 | ||
37 | #include <pcmcia/cs_types.h> | 38 | #include <pcmcia/cs_types.h> |
38 | #include <pcmcia/cs.h> | 39 | #include <pcmcia/cs.h> |
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c index f158b67f6610..e31263864377 100644 --- a/drivers/pcmcia/tcic.c +++ b/drivers/pcmcia/tcic.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <linux/ioport.h> | 44 | #include <linux/ioport.h> |
45 | #include <linux/delay.h> | 45 | #include <linux/delay.h> |
46 | #include <linux/workqueue.h> | 46 | #include <linux/workqueue.h> |
47 | #include <linux/device.h> | 47 | #include <linux/platform_device.h> |
48 | #include <linux/bitops.h> | 48 | #include <linux/bitops.h> |
49 | 49 | ||
50 | #include <asm/io.h> | 50 | #include <asm/io.h> |
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c index 3d2dca675e02..38a028c725d4 100644 --- a/drivers/pcmcia/vrc4171_card.c +++ b/drivers/pcmcia/vrc4171_card.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
26 | #include <linux/types.h> | 26 | #include <linux/types.h> |
27 | #include <linux/platform_device.h> | ||
27 | 28 | ||
28 | #include <asm/io.h> | 29 | #include <asm/io.h> |
29 | 30 | ||
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index f24d84538fd5..71dd1ebbe58f 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/completion.h> | 31 | #include <linux/completion.h> |
32 | #include <linux/transport_class.h> | 32 | #include <linux/transport_class.h> |
33 | #include <linux/platform_device.h> | ||
33 | 34 | ||
34 | #include <scsi/scsi_device.h> | 35 | #include <scsi/scsi_device.h> |
35 | #include <scsi/scsi_host.h> | 36 | #include <scsi/scsi_host.h> |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 00d6a6657ebc..a440ea38efaa 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -180,12 +180,22 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne | |||
180 | return; | 180 | return; |
181 | } | 181 | } |
182 | count = min(pc->sg->length - pc->b_count, bcount); | 182 | count = min(pc->sg->length - pc->b_count, bcount); |
183 | buf = kmap_atomic(pc->sg->page, KM_IRQ0); | 183 | if (PageHighMem(pc->sg->page)) { |
184 | drive->hwif->atapi_input_bytes(drive, | 184 | unsigned long flags; |
185 | buf + pc->b_count + pc->sg->offset, count); | 185 | |
186 | kunmap_atomic(buf, KM_IRQ0); | 186 | local_irq_save(flags); |
187 | bcount -= count; | 187 | buf = kmap_atomic(pc->sg->page, KM_IRQ0) + |
188 | pc->b_count += count; | 188 | pc->sg->offset; |
189 | drive->hwif->atapi_input_bytes(drive, | ||
190 | buf + pc->b_count, count); | ||
191 | kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); | ||
192 | local_irq_restore(flags); | ||
193 | } else { | ||
194 | buf = page_address(pc->sg->page) + pc->sg->offset; | ||
195 | drive->hwif->atapi_input_bytes(drive, | ||
196 | buf + pc->b_count, count); | ||
197 | } | ||
198 | bcount -= count; pc->b_count += count; | ||
189 | if (pc->b_count == pc->sg->length) { | 199 | if (pc->b_count == pc->sg->length) { |
190 | pc->sg++; | 200 | pc->sg++; |
191 | pc->b_count = 0; | 201 | pc->b_count = 0; |
@@ -205,12 +215,22 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign | |||
205 | return; | 215 | return; |
206 | } | 216 | } |
207 | count = min(pc->sg->length - pc->b_count, bcount); | 217 | count = min(pc->sg->length - pc->b_count, bcount); |
208 | buf = kmap_atomic(pc->sg->page, KM_IRQ0); | 218 | if (PageHighMem(pc->sg->page)) { |
209 | drive->hwif->atapi_output_bytes(drive, | 219 | unsigned long flags; |
210 | buf + pc->b_count + pc->sg->offset, count); | 220 | |
211 | kunmap_atomic(buf, KM_IRQ0); | 221 | local_irq_save(flags); |
212 | bcount -= count; | 222 | buf = kmap_atomic(pc->sg->page, KM_IRQ0) + |
213 | pc->b_count += count; | 223 | pc->sg->offset; |
224 | drive->hwif->atapi_output_bytes(drive, | ||
225 | buf + pc->b_count, count); | ||
226 | kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); | ||
227 | local_irq_restore(flags); | ||
228 | } else { | ||
229 | buf = page_address(pc->sg->page) + pc->sg->offset; | ||
230 | drive->hwif->atapi_output_bytes(drive, | ||
231 | buf + pc->b_count, count); | ||
232 | } | ||
233 | bcount -= count; pc->b_count += count; | ||
214 | if (pc->b_count == pc->sg->length) { | 234 | if (pc->b_count == pc->sg->length) { |
215 | pc->sg++; | 235 | pc->sg++; |
216 | pc->b_count = 0; | 236 | pc->b_count = 0; |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 8be7dc0b47b8..ff18fa7044c5 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -295,28 +295,6 @@ void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) | |||
295 | } | 295 | } |
296 | 296 | ||
297 | /** | 297 | /** |
298 | * ata_exec - issue ATA command to host controller | ||
299 | * @ap: port to which command is being issued | ||
300 | * @tf: ATA taskfile register set | ||
301 | * | ||
302 | * Issues PIO/MMIO write to ATA command register, with proper | ||
303 | * synchronization with interrupt handler / other threads. | ||
304 | * | ||
305 | * LOCKING: | ||
306 | * Obtains host_set lock. | ||
307 | */ | ||
308 | |||
309 | static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf) | ||
310 | { | ||
311 | unsigned long flags; | ||
312 | |||
313 | DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); | ||
314 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
315 | ap->ops->exec_command(ap, tf); | ||
316 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * ata_tf_to_host - issue ATA taskfile to host controller | 298 | * ata_tf_to_host - issue ATA taskfile to host controller |
321 | * @ap: port to which command is being issued | 299 | * @ap: port to which command is being issued |
322 | * @tf: ATA taskfile register set | 300 | * @tf: ATA taskfile register set |
@@ -326,30 +304,11 @@ static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf) | |||
326 | * other threads. | 304 | * other threads. |
327 | * | 305 | * |
328 | * LOCKING: | 306 | * LOCKING: |
329 | * Obtains host_set lock. | ||
330 | */ | ||
331 | |||
332 | static void ata_tf_to_host(struct ata_port *ap, const struct ata_taskfile *tf) | ||
333 | { | ||
334 | ap->ops->tf_load(ap, tf); | ||
335 | |||
336 | ata_exec(ap, tf); | ||
337 | } | ||
338 | |||
339 | /** | ||
340 | * ata_tf_to_host_nolock - issue ATA taskfile to host controller | ||
341 | * @ap: port to which command is being issued | ||
342 | * @tf: ATA taskfile register set | ||
343 | * | ||
344 | * Issues ATA taskfile register set to ATA host controller, | ||
345 | * with proper synchronization with interrupt handler and | ||
346 | * other threads. | ||
347 | * | ||
348 | * LOCKING: | ||
349 | * spin_lock_irqsave(host_set lock) | 307 | * spin_lock_irqsave(host_set lock) |
350 | */ | 308 | */ |
351 | 309 | ||
352 | void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf) | 310 | static inline void ata_tf_to_host(struct ata_port *ap, |
311 | const struct ata_taskfile *tf) | ||
353 | { | 312 | { |
354 | ap->ops->tf_load(ap, tf); | 313 | ap->ops->tf_load(ap, tf); |
355 | ap->ops->exec_command(ap, tf); | 314 | ap->ops->exec_command(ap, tf); |
@@ -1912,12 +1871,14 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask) | |||
1912 | * | 1871 | * |
1913 | * LOCKING: | 1872 | * LOCKING: |
1914 | * PCI/etc. bus probe sem. | 1873 | * PCI/etc. bus probe sem. |
1874 | * Obtains host_set lock. | ||
1915 | * | 1875 | * |
1916 | */ | 1876 | */ |
1917 | 1877 | ||
1918 | static unsigned int ata_bus_edd(struct ata_port *ap) | 1878 | static unsigned int ata_bus_edd(struct ata_port *ap) |
1919 | { | 1879 | { |
1920 | struct ata_taskfile tf; | 1880 | struct ata_taskfile tf; |
1881 | unsigned long flags; | ||
1921 | 1882 | ||
1922 | /* set up execute-device-diag (bus reset) taskfile */ | 1883 | /* set up execute-device-diag (bus reset) taskfile */ |
1923 | /* also, take interrupts to a known state (disabled) */ | 1884 | /* also, take interrupts to a known state (disabled) */ |
@@ -1928,7 +1889,9 @@ static unsigned int ata_bus_edd(struct ata_port *ap) | |||
1928 | tf.protocol = ATA_PROT_NODATA; | 1889 | tf.protocol = ATA_PROT_NODATA; |
1929 | 1890 | ||
1930 | /* do bus reset */ | 1891 | /* do bus reset */ |
1892 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
1931 | ata_tf_to_host(ap, &tf); | 1893 | ata_tf_to_host(ap, &tf); |
1894 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1932 | 1895 | ||
1933 | /* spec says at least 2ms. but who knows with those | 1896 | /* spec says at least 2ms. but who knows with those |
1934 | * crazy ATAPI devices... | 1897 | * crazy ATAPI devices... |
@@ -3555,7 +3518,7 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
3555 | 3518 | ||
3556 | switch (qc->tf.protocol) { | 3519 | switch (qc->tf.protocol) { |
3557 | case ATA_PROT_NODATA: | 3520 | case ATA_PROT_NODATA: |
3558 | ata_tf_to_host_nolock(ap, &qc->tf); | 3521 | ata_tf_to_host(ap, &qc->tf); |
3559 | break; | 3522 | break; |
3560 | 3523 | ||
3561 | case ATA_PROT_DMA: | 3524 | case ATA_PROT_DMA: |
@@ -3566,20 +3529,20 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
3566 | 3529 | ||
3567 | case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ | 3530 | case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ |
3568 | ata_qc_set_polling(qc); | 3531 | ata_qc_set_polling(qc); |
3569 | ata_tf_to_host_nolock(ap, &qc->tf); | 3532 | ata_tf_to_host(ap, &qc->tf); |
3570 | ap->hsm_task_state = HSM_ST; | 3533 | ap->hsm_task_state = HSM_ST; |
3571 | queue_work(ata_wq, &ap->pio_task); | 3534 | queue_work(ata_wq, &ap->pio_task); |
3572 | break; | 3535 | break; |
3573 | 3536 | ||
3574 | case ATA_PROT_ATAPI: | 3537 | case ATA_PROT_ATAPI: |
3575 | ata_qc_set_polling(qc); | 3538 | ata_qc_set_polling(qc); |
3576 | ata_tf_to_host_nolock(ap, &qc->tf); | 3539 | ata_tf_to_host(ap, &qc->tf); |
3577 | queue_work(ata_wq, &ap->packet_task); | 3540 | queue_work(ata_wq, &ap->packet_task); |
3578 | break; | 3541 | break; |
3579 | 3542 | ||
3580 | case ATA_PROT_ATAPI_NODATA: | 3543 | case ATA_PROT_ATAPI_NODATA: |
3581 | ap->flags |= ATA_FLAG_NOINTR; | 3544 | ap->flags |= ATA_FLAG_NOINTR; |
3582 | ata_tf_to_host_nolock(ap, &qc->tf); | 3545 | ata_tf_to_host(ap, &qc->tf); |
3583 | queue_work(ata_wq, &ap->packet_task); | 3546 | queue_work(ata_wq, &ap->packet_task); |
3584 | break; | 3547 | break; |
3585 | 3548 | ||
@@ -4126,8 +4089,6 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
4126 | host->unique_id = ata_unique_id++; | 4089 | host->unique_id = ata_unique_id++; |
4127 | host->max_cmd_len = 12; | 4090 | host->max_cmd_len = 12; |
4128 | 4091 | ||
4129 | scsi_assign_lock(host, &host_set->lock); | ||
4130 | |||
4131 | ap->flags = ATA_FLAG_PORT_DISABLED; | 4092 | ap->flags = ATA_FLAG_PORT_DISABLED; |
4132 | ap->id = host->unique_id; | 4093 | ap->id = host->unique_id; |
4133 | ap->host = host; | 4094 | ap->host = host; |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 1e3792f86fcf..248baae96486 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <scsi/scsi.h> | 39 | #include <scsi/scsi.h> |
40 | #include "scsi.h" | 40 | #include "scsi.h" |
41 | #include <scsi/scsi_host.h> | 41 | #include <scsi/scsi_host.h> |
42 | #include <scsi/scsi_device.h> | ||
42 | #include <linux/libata.h> | 43 | #include <linux/libata.h> |
43 | #include <linux/hdreg.h> | 44 | #include <linux/hdreg.h> |
44 | #include <asm/uaccess.h> | 45 | #include <asm/uaccess.h> |
@@ -2405,8 +2406,12 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) | |||
2405 | struct ata_port *ap; | 2406 | struct ata_port *ap; |
2406 | struct ata_device *dev; | 2407 | struct ata_device *dev; |
2407 | struct scsi_device *scsidev = cmd->device; | 2408 | struct scsi_device *scsidev = cmd->device; |
2409 | struct Scsi_Host *shost = scsidev->host; | ||
2408 | 2410 | ||
2409 | ap = (struct ata_port *) &scsidev->host->hostdata[0]; | 2411 | ap = (struct ata_port *) &shost->hostdata[0]; |
2412 | |||
2413 | spin_unlock(shost->host_lock); | ||
2414 | spin_lock(&ap->host_set->lock); | ||
2410 | 2415 | ||
2411 | ata_scsi_dump_cdb(ap, cmd); | 2416 | ata_scsi_dump_cdb(ap, cmd); |
2412 | 2417 | ||
@@ -2429,6 +2434,8 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) | |||
2429 | ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); | 2434 | ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); |
2430 | 2435 | ||
2431 | out_unlock: | 2436 | out_unlock: |
2437 | spin_unlock(&ap->host_set->lock); | ||
2438 | spin_lock(shost->host_lock); | ||
2432 | return 0; | 2439 | return 0; |
2433 | } | 2440 | } |
2434 | 2441 | ||
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 10ecd9e15e4f..fad051ca4672 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -48,7 +48,6 @@ extern int ata_qc_issue(struct ata_queued_cmd *qc); | |||
48 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); | 48 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); |
49 | extern void ata_dev_select(struct ata_port *ap, unsigned int device, | 49 | extern void ata_dev_select(struct ata_port *ap, unsigned int device, |
50 | unsigned int wait, unsigned int can_sleep); | 50 | unsigned int wait, unsigned int can_sleep); |
51 | extern void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf); | ||
52 | extern void swap_buf_le16(u16 *buf, unsigned int buf_words); | 51 | extern void swap_buf_le16(u16 *buf, unsigned int buf_words); |
53 | extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); | 52 | extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); |
54 | extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); | 53 | extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); |
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index afb7ddf200e0..f47d2c454e33 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/sysrq.h> | 33 | #include <linux/sysrq.h> |
34 | #include <linux/mca.h> | 34 | #include <linux/mca.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/device.h> | 36 | #include <linux/platform_device.h> |
37 | #include <linux/tty.h> | 37 | #include <linux/tty.h> |
38 | #include <linux/tty_flip.h> | 38 | #include <linux/tty_flip.h> |
39 | #include <linux/serial_reg.h> | 39 | #include <linux/serial_reg.h> |
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index 5b3933b0c997..4a54ff584700 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/console.h> | 37 | #include <linux/console.h> |
38 | #include <linux/sysrq.h> | 38 | #include <linux/sysrq.h> |
39 | #include <linux/device.h> | 39 | #include <linux/platform_device.h> |
40 | #include <linux/tty.h> | 40 | #include <linux/tty.h> |
41 | #include <linux/tty_flip.h> | 41 | #include <linux/tty_flip.h> |
42 | #include <linux/serial_core.h> | 42 | #include <linux/serial_core.h> |
@@ -995,6 +995,7 @@ static int __init imx_serial_init(void) | |||
995 | static void __exit imx_serial_exit(void) | 995 | static void __exit imx_serial_exit(void) |
996 | { | 996 | { |
997 | uart_unregister_driver(&imx_reg); | 997 | uart_unregister_driver(&imx_reg); |
998 | driver_unregister(&serial_imx_driver); | ||
998 | } | 999 | } |
999 | 1000 | ||
1000 | module_init(imx_serial_init); | 1001 | module_init(imx_serial_init); |
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 8a79968f8ce1..0dd08a09e7e6 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
@@ -45,7 +45,7 @@ | |||
45 | */ | 45 | */ |
46 | 46 | ||
47 | #include <linux/config.h> | 47 | #include <linux/config.h> |
48 | #include <linux/device.h> | 48 | #include <linux/platform_device.h> |
49 | #include <linux/module.h> | 49 | #include <linux/module.h> |
50 | #include <linux/tty.h> | 50 | #include <linux/tty.h> |
51 | #include <linux/serial.h> | 51 | #include <linux/serial.h> |
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c index aec83f577ce6..ba8838b234da 100644 --- a/drivers/serial/mpsc.c +++ b/drivers/serial/mpsc.c | |||
@@ -52,6 +52,8 @@ | |||
52 | * 4) AFAICT, hardware flow control isn't supported by the controller --MAG. | 52 | * 4) AFAICT, hardware flow control isn't supported by the controller --MAG. |
53 | */ | 53 | */ |
54 | 54 | ||
55 | #include <linux/platform_device.h> | ||
56 | |||
55 | #include "mpsc.h" | 57 | #include "mpsc.h" |
56 | 58 | ||
57 | /* | 59 | /* |
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c index 8cc4cedadd99..16b2f9417af9 100644 --- a/drivers/serial/pxa.c +++ b/drivers/serial/pxa.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <linux/circ_buf.h> | 39 | #include <linux/circ_buf.h> |
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
42 | #include <linux/device.h> | 42 | #include <linux/platform_device.h> |
43 | #include <linux/tty.h> | 43 | #include <linux/tty.h> |
44 | #include <linux/tty_flip.h> | 44 | #include <linux/tty_flip.h> |
45 | #include <linux/serial_core.h> | 45 | #include <linux/serial_core.h> |
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index 06a17dff1a73..036792328d49 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c | |||
@@ -63,7 +63,7 @@ | |||
63 | 63 | ||
64 | #include <linux/module.h> | 64 | #include <linux/module.h> |
65 | #include <linux/ioport.h> | 65 | #include <linux/ioport.h> |
66 | #include <linux/device.h> | 66 | #include <linux/platform_device.h> |
67 | #include <linux/init.h> | 67 | #include <linux/init.h> |
68 | #include <linux/sysrq.h> | 68 | #include <linux/sysrq.h> |
69 | #include <linux/console.h> | 69 | #include <linux/console.h> |
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c index c4a789e6af44..ed618cc7ae96 100644 --- a/drivers/serial/sa1100.c +++ b/drivers/serial/sa1100.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/console.h> | 36 | #include <linux/console.h> |
37 | #include <linux/sysrq.h> | 37 | #include <linux/sysrq.h> |
38 | #include <linux/device.h> | 38 | #include <linux/platform_device.h> |
39 | #include <linux/tty.h> | 39 | #include <linux/tty.h> |
40 | #include <linux/tty_flip.h> | 40 | #include <linux/tty_flip.h> |
41 | #include <linux/serial_core.h> | 41 | #include <linux/serial_core.h> |
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c index 2b623ab0e36e..01696b3e3f61 100644 --- a/drivers/serial/vr41xx_siu.c +++ b/drivers/serial/vr41xx_siu.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #include <linux/console.h> | 28 | #include <linux/console.h> |
29 | #include <linux/device.h> | 29 | #include <linux/platform_device.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/ioport.h> | 31 | #include <linux/ioport.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 02106bebd5c1..975ace3f5b1e 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -50,7 +50,7 @@ | |||
50 | #include <linux/list.h> | 50 | #include <linux/list.h> |
51 | #include <linux/interrupt.h> | 51 | #include <linux/interrupt.h> |
52 | #include <linux/version.h> | 52 | #include <linux/version.h> |
53 | 53 | #include <linux/platform_device.h> | |
54 | #include <linux/usb.h> | 54 | #include <linux/usb.h> |
55 | #include <linux/usb_gadget.h> | 55 | #include <linux/usb_gadget.h> |
56 | 56 | ||
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c index 9b3673904daf..bc6269f10cbb 100644 --- a/drivers/usb/gadget/lh7a40x_udc.c +++ b/drivers/usb/gadget/lh7a40x_udc.c | |||
@@ -21,6 +21,8 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/platform_device.h> | ||
25 | |||
24 | #include "lh7a40x_udc.h" | 26 | #include "lh7a40x_udc.h" |
25 | 27 | ||
26 | //#define DEBUG printk | 28 | //#define DEBUG printk |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 41c96b0afbb3..387692a3611e 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
39 | #include <linux/mm.h> | 39 | #include <linux/mm.h> |
40 | #include <linux/moduleparam.h> | 40 | #include <linux/moduleparam.h> |
41 | #include <linux/device.h> | 41 | #include <linux/platform_device.h> |
42 | #include <linux/usb_ch9.h> | 42 | #include <linux/usb_ch9.h> |
43 | #include <linux/usb_gadget.h> | 43 | #include <linux/usb_gadget.h> |
44 | #include <linux/usb_otg.h> | 44 | #include <linux/usb_otg.h> |
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index f83a9262f953..ee9cd7869d92 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include <linux/interrupt.h> | 43 | #include <linux/interrupt.h> |
44 | #include <linux/proc_fs.h> | 44 | #include <linux/proc_fs.h> |
45 | #include <linux/mm.h> | 45 | #include <linux/mm.h> |
46 | #include <linux/device.h> | 46 | #include <linux/platform_device.h> |
47 | #include <linux/dma-mapping.h> | 47 | #include <linux/dma-mapping.h> |
48 | 48 | ||
49 | #include <asm/byteorder.h> | 49 | #include <asm/byteorder.h> |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index ddb8fc591466..f9c3f5b8dd1c 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -70,6 +70,7 @@ | |||
70 | #include <linux/interrupt.h> | 70 | #include <linux/interrupt.h> |
71 | #include <linux/usb.h> | 71 | #include <linux/usb.h> |
72 | #include <linux/usb_isp116x.h> | 72 | #include <linux/usb_isp116x.h> |
73 | #include <linux/platform_device.h> | ||
73 | 74 | ||
74 | #include <asm/io.h> | 75 | #include <asm/io.h> |
75 | #include <asm/irq.h> | 76 | #include <asm/irq.h> |
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c index a277e258eb6c..f0c78cf14b6c 100644 --- a/drivers/usb/host/ohci-au1xxx.c +++ b/drivers/usb/host/ohci-au1xxx.c | |||
@@ -18,6 +18,8 @@ | |||
18 | * This file is licenced under the GPL. | 18 | * This file is licenced under the GPL. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/platform_device.h> | ||
22 | |||
21 | #include <asm/mach-au1x00/au1000.h> | 23 | #include <asm/mach-au1x00/au1000.h> |
22 | 24 | ||
23 | #define USBH_ENABLE_BE (1<<0) | 25 | #define USBH_ENABLE_BE (1<<0) |
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c index 238fa4ade615..336c766c6e29 100644 --- a/drivers/usb/host/ohci-lh7a404.c +++ b/drivers/usb/host/ohci-lh7a404.c | |||
@@ -16,6 +16,8 @@ | |||
16 | * This file is licenced under the GPL. | 16 | * This file is licenced under the GPL. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/platform_device.h> | ||
20 | |||
19 | #include <asm/hardware.h> | 21 | #include <asm/hardware.h> |
20 | 22 | ||
21 | 23 | ||
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 49815ec4b842..e46cc540cf4d 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include <linux/signal.h> /* SA_INTERRUPT */ | 17 | #include <linux/signal.h> /* SA_INTERRUPT */ |
18 | #include <linux/jiffies.h> | 18 | #include <linux/jiffies.h> |
19 | #include <linux/platform_device.h> | ||
19 | 20 | ||
20 | #include <asm/hardware.h> | 21 | #include <asm/hardware.h> |
21 | #include <asm/io.h> | 22 | #include <asm/io.h> |
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c index 4832e57ae579..92cf6f4a1374 100644 --- a/drivers/usb/host/ohci-ppc-soc.c +++ b/drivers/usb/host/ohci-ppc-soc.c | |||
@@ -14,6 +14,8 @@ | |||
14 | * This file is licenced under the GPL. | 14 | * This file is licenced under the GPL. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/platform_device.h> | ||
18 | |||
17 | /* configure so an HC device and id are always provided */ | 19 | /* configure so an HC device and id are always provided */ |
18 | /* always called with process context; sleeping is OK */ | 20 | /* always called with process context; sleeping is OK */ |
19 | 21 | ||
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index f4a4aeda40b7..59e20568e8f9 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -21,6 +21,8 @@ | |||
21 | 21 | ||
22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
23 | #include <linux/signal.h> | 23 | #include <linux/signal.h> |
24 | #include <linux/platform_device.h> | ||
25 | |||
24 | #include <asm/mach-types.h> | 26 | #include <asm/mach-types.h> |
25 | #include <asm/hardware.h> | 27 | #include <asm/hardware.h> |
26 | #include <asm/arch/pxa-regs.h> | 28 | #include <asm/arch/pxa-regs.h> |
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index fab420a2ce71..ee1fc605b402 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c | |||
@@ -19,6 +19,8 @@ | |||
19 | * This file is licenced under the GPL. | 19 | * This file is licenced under the GPL. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/platform_device.h> | ||
23 | |||
22 | #include <asm/hardware.h> | 24 | #include <asm/hardware.h> |
23 | #include <asm/hardware/clock.h> | 25 | #include <asm/hardware/clock.h> |
24 | #include <asm/arch/usb-control.h> | 26 | #include <asm/arch/usb-control.h> |
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index b7fd3f644e1e..b1aa350fd32f 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c | |||
@@ -138,11 +138,23 @@ reset_needed: | |||
138 | } | 138 | } |
139 | EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc); | 139 | EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc); |
140 | 140 | ||
141 | static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask) | ||
142 | { | ||
143 | u16 cmd; | ||
144 | return !pci_read_config_word(pdev, PCI_COMMAND, &cmd) && (cmd & mask); | ||
145 | } | ||
146 | |||
147 | #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO) | ||
148 | #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY) | ||
149 | |||
141 | static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev) | 150 | static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev) |
142 | { | 151 | { |
143 | unsigned long base = 0; | 152 | unsigned long base = 0; |
144 | int i; | 153 | int i; |
145 | 154 | ||
155 | if (!pio_enabled(pdev)) | ||
156 | return; | ||
157 | |||
146 | for (i = 0; i < PCI_ROM_RESOURCE; i++) | 158 | for (i = 0; i < PCI_ROM_RESOURCE; i++) |
147 | if ((pci_resource_flags(pdev, i) & IORESOURCE_IO)) { | 159 | if ((pci_resource_flags(pdev, i) & IORESOURCE_IO)) { |
148 | base = pci_resource_start(pdev, i); | 160 | base = pci_resource_start(pdev, i); |
@@ -153,12 +165,20 @@ static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev) | |||
153 | uhci_check_and_reset_hc(pdev, base); | 165 | uhci_check_and_reset_hc(pdev, base); |
154 | } | 166 | } |
155 | 167 | ||
168 | static int __devinit mmio_resource_enabled(struct pci_dev *pdev, int idx) | ||
169 | { | ||
170 | return pci_resource_start(pdev, idx) && mmio_enabled(pdev); | ||
171 | } | ||
172 | |||
156 | static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) | 173 | static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) |
157 | { | 174 | { |
158 | void __iomem *base; | 175 | void __iomem *base; |
159 | int wait_time; | 176 | int wait_time; |
160 | u32 control; | 177 | u32 control; |
161 | 178 | ||
179 | if (!mmio_resource_enabled(pdev, 0)) | ||
180 | return; | ||
181 | |||
162 | base = ioremap_nocache(pci_resource_start(pdev, 0), | 182 | base = ioremap_nocache(pci_resource_start(pdev, 0), |
163 | pci_resource_len(pdev, 0)); | 183 | pci_resource_len(pdev, 0)); |
164 | if (base == NULL) return; | 184 | if (base == NULL) return; |
@@ -201,6 +221,9 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev) | |||
201 | u32 hcc_params, val, temp; | 221 | u32 hcc_params, val, temp; |
202 | u8 cap_length; | 222 | u8 cap_length; |
203 | 223 | ||
224 | if (!mmio_resource_enabled(pdev, 0)) | ||
225 | return; | ||
226 | |||
204 | base = ioremap_nocache(pci_resource_start(pdev, 0), | 227 | base = ioremap_nocache(pci_resource_start(pdev, 0), |
205 | pci_resource_len(pdev, 0)); | 228 | pci_resource_len(pdev, 0)); |
206 | if (base == NULL) return; | 229 | if (base == NULL) return; |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 40169d9cf2b1..5607c0ae6835 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/interrupt.h> | 54 | #include <linux/interrupt.h> |
55 | #include <linux/usb.h> | 55 | #include <linux/usb.h> |
56 | #include <linux/usb_sl811.h> | 56 | #include <linux/usb_sl811.h> |
57 | #include <linux/platform_device.h> | ||
57 | 58 | ||
58 | #include <asm/io.h> | 59 | #include <asm/io.h> |
59 | #include <asm/irq.h> | 60 | #include <asm/irq.h> |
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 38aebe361ca1..e73faf831b24 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/timer.h> | 20 | #include <linux/timer.h> |
21 | #include <linux/ioport.h> | 21 | #include <linux/ioport.h> |
22 | #include <linux/platform_device.h> | ||
22 | 23 | ||
23 | #include <pcmcia/cs_types.h> | 24 | #include <pcmcia/cs_types.h> |
24 | #include <pcmcia/cs.h> | 25 | #include <pcmcia/cs.h> |
diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c index f02965f39501..9b6a39348f81 100644 --- a/drivers/video/acornfb.c +++ b/drivers/video/acornfb.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/fb.h> | 28 | #include <linux/fb.h> |
29 | #include <linux/device.h> | 29 | #include <linux/platform_device.h> |
30 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
31 | 31 | ||
32 | #include <asm/hardware.h> | 32 | #include <asm/hardware.h> |
diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c index d28457e0c063..126daff1c848 100644 --- a/drivers/video/arcfb.c +++ b/drivers/video/arcfb.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/fb.h> | 47 | #include <linux/fb.h> |
48 | #include <linux/init.h> | 48 | #include <linux/init.h> |
49 | #include <linux/arcfb.h> | 49 | #include <linux/arcfb.h> |
50 | #include <linux/platform_device.h> | ||
50 | 51 | ||
51 | #include <asm/uaccess.h> | 52 | #include <asm/uaccess.h> |
52 | 53 | ||
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c index 1991fdb32dfb..4867498f68e8 100644 --- a/drivers/video/backlight/corgi_bl.c +++ b/drivers/video/backlight/corgi_bl.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
19 | #include <linux/fb.h> | 19 | #include <linux/fb.h> |
20 | #include <linux/backlight.h> | 20 | #include <linux/backlight.h> |
diff --git a/drivers/video/dnfb.c b/drivers/video/dnfb.c index 1dbb82dca40b..1785686a7f11 100644 --- a/drivers/video/dnfb.c +++ b/drivers/video/dnfb.c | |||
@@ -6,6 +6,8 @@ | |||
6 | #include <linux/slab.h> | 6 | #include <linux/slab.h> |
7 | #include <linux/delay.h> | 7 | #include <linux/delay.h> |
8 | #include <linux/interrupt.h> | 8 | #include <linux/interrupt.h> |
9 | #include <linux/platform_device.h> | ||
10 | |||
9 | #include <asm/setup.h> | 11 | #include <asm/setup.h> |
10 | #include <asm/system.h> | 12 | #include <asm/system.h> |
11 | #include <asm/irq.h> | 13 | #include <asm/irq.h> |
diff --git a/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c index 116e808d71cd..7363d0b25fdf 100644 --- a/drivers/video/epson1355fb.c +++ b/drivers/video/epson1355fb.c | |||
@@ -54,6 +54,8 @@ | |||
54 | #include <linux/fb.h> | 54 | #include <linux/fb.h> |
55 | #include <linux/init.h> | 55 | #include <linux/init.h> |
56 | #include <linux/ioport.h> | 56 | #include <linux/ioport.h> |
57 | #include <linux/platform_device.h> | ||
58 | |||
57 | #include <asm/types.h> | 59 | #include <asm/types.h> |
58 | #include <asm/io.h> | 60 | #include <asm/io.h> |
59 | #include <asm/uaccess.h> | 61 | #include <asm/uaccess.h> |
diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c index 485604cd4462..316bfe994811 100644 --- a/drivers/video/gbefb.c +++ b/drivers/video/gbefb.c | |||
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/config.h> | 12 | #include <linux/config.h> |
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/dma-mapping.h> | 15 | #include <linux/dma-mapping.h> |
16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
17 | #include <linux/fb.h> | 17 | #include <linux/fb.h> |
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index 0b9301facbd3..64d9bcc38da3 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/ioport.h> | 32 | #include <linux/ioport.h> |
33 | #include <linux/cpufreq.h> | 33 | #include <linux/cpufreq.h> |
34 | #include <linux/device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
36 | 36 | ||
37 | #include <asm/hardware.h> | 37 | #include <asm/hardware.h> |
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index 6206da9dd5da..efd9333b05c2 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/ioport.h> | 37 | #include <linux/ioport.h> |
38 | #include <linux/cpufreq.h> | 38 | #include <linux/cpufreq.h> |
39 | #include <linux/device.h> | 39 | #include <linux/platform_device.h> |
40 | #include <linux/dma-mapping.h> | 40 | #include <linux/dma-mapping.h> |
41 | 41 | ||
42 | #include <asm/hardware.h> | 42 | #include <asm/hardware.h> |
diff --git a/drivers/video/q40fb.c b/drivers/video/q40fb.c index 162012bb9264..8416b2e2b501 100644 --- a/drivers/video/q40fb.c +++ b/drivers/video/q40fb.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/platform_device.h> | ||
21 | 22 | ||
22 | #include <asm/uaccess.h> | 23 | #include <asm/uaccess.h> |
23 | #include <asm/setup.h> | 24 | #include <asm/setup.h> |
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c index cb2f7a1de947..f4437430dc5f 100644 --- a/drivers/video/s1d13xxxfb.c +++ b/drivers/video/s1d13xxxfb.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | #include <linux/config.h> | 31 | #include <linux/config.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | 35 | ||
36 | #include <linux/types.h> | 36 | #include <linux/types.h> |
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index 3862d3cb1fb2..3cef90456a4b 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c | |||
@@ -86,6 +86,7 @@ | |||
86 | #include <linux/interrupt.h> | 86 | #include <linux/interrupt.h> |
87 | #include <linux/workqueue.h> | 87 | #include <linux/workqueue.h> |
88 | #include <linux/wait.h> | 88 | #include <linux/wait.h> |
89 | #include <linux/platform_device.h> | ||
89 | 90 | ||
90 | #include <asm/io.h> | 91 | #include <asm/io.h> |
91 | #include <asm/uaccess.h> | 92 | #include <asm/uaccess.h> |
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c index 78e5f194b0df..3d35b28aaac7 100644 --- a/drivers/video/sa1100fb.c +++ b/drivers/video/sa1100fb.c | |||
@@ -173,7 +173,7 @@ | |||
173 | #include <linux/init.h> | 173 | #include <linux/init.h> |
174 | #include <linux/ioport.h> | 174 | #include <linux/ioport.h> |
175 | #include <linux/cpufreq.h> | 175 | #include <linux/cpufreq.h> |
176 | #include <linux/device.h> | 176 | #include <linux/platform_device.h> |
177 | #include <linux/dma-mapping.h> | 177 | #include <linux/dma-mapping.h> |
178 | 178 | ||
179 | #include <asm/hardware.h> | 179 | #include <asm/hardware.h> |
diff --git a/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c index 8413907b379a..cf5106eab2d5 100644 --- a/drivers/video/sgivwfb.c +++ b/drivers/video/sgivwfb.c | |||
@@ -18,6 +18,8 @@ | |||
18 | #include <linux/fb.h> | 18 | #include <linux/fb.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/ioport.h> | 20 | #include <linux/ioport.h> |
21 | #include <linux/platform_device.h> | ||
22 | |||
21 | #include <asm/io.h> | 23 | #include <asm/io.h> |
22 | #include <asm/mtrr.h> | 24 | #include <asm/mtrr.h> |
23 | 25 | ||
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c index b1243da55fc5..3cc23106641d 100644 --- a/drivers/video/vesafb.c +++ b/drivers/video/vesafb.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include <linux/fb.h> | 19 | #include <linux/fb.h> |
20 | #include <linux/ioport.h> | 20 | #include <linux/ioport.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/platform_device.h> | ||
23 | |||
22 | #include <video/vga.h> | 24 | #include <video/vga.h> |
23 | #include <asm/io.h> | 25 | #include <asm/io.h> |
24 | #include <asm/mtrr.h> | 26 | #include <asm/mtrr.h> |
diff --git a/drivers/video/vfb.c b/drivers/video/vfb.c index b137a3fe0752..92d46555dd86 100644 --- a/drivers/video/vfb.c +++ b/drivers/video/vfb.c | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <linux/vmalloc.h> | 20 | #include <linux/vmalloc.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
23 | #include <linux/platform_device.h> | ||
24 | |||
23 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
24 | #include <linux/fb.h> | 26 | #include <linux/fb.h> |
25 | #include <linux/init.h> | 27 | #include <linux/init.h> |
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c index 752bf88906a9..cf8cdb108fd9 100644 --- a/drivers/video/w100fb.c +++ b/drivers/video/w100fb.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/mm.h> | 27 | #include <linux/mm.h> |
28 | #include <linux/device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/string.h> | 29 | #include <linux/string.h> |
30 | #include <linux/vmalloc.h> | 30 | #include <linux/vmalloc.h> |
31 | #include <asm/io.h> | 31 | #include <asm/io.h> |
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index ffab4783ac64..c27f8d4098be 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -247,7 +247,7 @@ __writeback_single_inode(struct inode *inode, struct writeback_control *wbc) | |||
247 | wait_queue_head_t *wqh; | 247 | wait_queue_head_t *wqh; |
248 | 248 | ||
249 | if (!atomic_read(&inode->i_count)) | 249 | if (!atomic_read(&inode->i_count)) |
250 | WARN_ON(!(inode->i_state & I_WILL_FREE)); | 250 | WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING))); |
251 | else | 251 | else |
252 | WARN_ON(inode->i_state & I_WILL_FREE); | 252 | WARN_ON(inode->i_state & I_WILL_FREE); |
253 | 253 | ||
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index de58579a1d0e..50a7749cfca1 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog | |||
@@ -1,18 +1,15 @@ | |||
1 | ToDo/Notes: | 1 | ToDo/Notes: |
2 | - Find and fix bugs. | 2 | - Find and fix bugs. |
3 | - In between ntfs_prepare/commit_write, need exclusion between | 3 | - The only places in the kernel where a file is resized are |
4 | simultaneous file extensions. This is given to us by holding i_sem | 4 | ntfs_file_write*() and ntfs_truncate() for both of which i_sem is |
5 | on the inode. The only places in the kernel when a file is resized | 5 | held. Just have to be careful in read-/writepage and other helpers |
6 | are prepare/commit write and truncate for both of which i_sem is | 6 | not running under i_sem that we play nice... Also need to be careful |
7 | held. Just have to be careful in readpage/writepage and all other | 7 | with initialized_size extension in ntfs_file_write*() and writepage. |
8 | helpers not running under i_sem that we play nice... | 8 | UPDATE: The only things that need to be checked are the compressed |
9 | Also need to be careful with initialized_size extention in | 9 | write and the other attribute resize/write cases like index |
10 | ntfs_prepare_write. Basically, just be _very_ careful in this code... | 10 | attributes, etc. For now none of these are implemented so are safe. |
11 | UPDATE: The only things that need to be checked are read/writepage | 11 | - Implement filling in of holes in aops.c::ntfs_writepage() and its |
12 | which do not hold i_sem. Note writepage cannot change i_size but it | 12 | helpers. |
13 | needs to cope with a concurrent i_size change, just like readpage. | ||
14 | Also both need to cope with concurrent changes to the other sizes, | ||
15 | i.e. initialized/allocated/compressed size, as well. | ||
16 | - Implement mft.c::sync_mft_mirror_umount(). We currently will just | 13 | - Implement mft.c::sync_mft_mirror_umount(). We currently will just |
17 | leave the volume dirty on umount if the final iput(vol->mft_ino) | 14 | leave the volume dirty on umount if the final iput(vol->mft_ino) |
18 | causes a write of any mirrored mft records due to the mft mirror | 15 | causes a write of any mirrored mft records due to the mft mirror |
@@ -22,6 +19,68 @@ ToDo/Notes: | |||
22 | - Enable the code for setting the NT4 compatibility flag when we start | 19 | - Enable the code for setting the NT4 compatibility flag when we start |
23 | making NTFS 1.2 specific modifications. | 20 | making NTFS 1.2 specific modifications. |
24 | 21 | ||
22 | 2.1.25 - (Almost) fully implement write(2) and truncate(2). | ||
23 | |||
24 | - Change ntfs_map_runlist_nolock(), ntfs_attr_find_vcn_nolock() and | ||
25 | {__,}ntfs_cluster_free() to also take an optional attribute search | ||
26 | context as argument. This allows calling these functions with the | ||
27 | mft record mapped. Update all callers. | ||
28 | - Fix potential deadlock in ntfs_mft_data_extend_allocation_nolock() | ||
29 | error handling by passing in the active search context when calling | ||
30 | ntfs_cluster_free(). | ||
31 | - Change ntfs_cluster_alloc() to take an extra boolean parameter | ||
32 | specifying whether the cluster are being allocated to extend an | ||
33 | attribute or to fill a hole. | ||
34 | - Change ntfs_attr_make_non_resident() to call ntfs_cluster_alloc() | ||
35 | with @is_extension set to TRUE and remove the runlist terminator | ||
36 | fixup code as this is now done by ntfs_cluster_alloc(). | ||
37 | - Change ntfs_attr_make_non_resident to take the attribute value size | ||
38 | as an extra parameter. This is needed since we need to know the size | ||
39 | before we can map the mft record and our callers always know it. The | ||
40 | reason we cannot simply read the size from the vfs inode i_size is | ||
41 | that this is not necessarily uptodate. This happens when | ||
42 | ntfs_attr_make_non_resident() is called in the ->truncate call path. | ||
43 | - Fix ntfs_attr_make_non_resident() to update the vfs inode i_blocks | ||
44 | which is zero for a resident attribute but should no longer be zero | ||
45 | once the attribute is non-resident as it then has real clusters | ||
46 | allocated. | ||
47 | - Add fs/ntfs/attrib.[hc]::ntfs_attr_extend_allocation(), a function to | ||
48 | extend the allocation of an attributes. Optionally, the data size, | ||
49 | but not the initialized size can be extended, too. | ||
50 | - Implement fs/ntfs/inode.[hc]::ntfs_truncate(). It only supports | ||
51 | uncompressed and unencrypted files and it never creates sparse files | ||
52 | at least for the moment (making a file sparse requires us to modify | ||
53 | its directory entries and we do not support directory operations at | ||
54 | the moment). Also, support for highly fragmented files, i.e. ones | ||
55 | whose data attribute is split across multiple extents, is severly | ||
56 | limited. When such a case is encountered, EOPNOTSUPP is returned. | ||
57 | - Enable ATTR_SIZE attribute changes in ntfs_setattr(). This completes | ||
58 | the initial implementation of file truncation. Now both open(2)ing | ||
59 | a file with the O_TRUNC flag and the {,f}truncate(2) system calls | ||
60 | will resize a file appropriately. The limitations are that only | ||
61 | uncompressed and unencrypted files are supported. Also, there is | ||
62 | only very limited support for highly fragmented files (the ones whose | ||
63 | $DATA attribute is split into multiple attribute extents). | ||
64 | - In attrib.c::ntfs_attr_set() call balance_dirty_pages_ratelimited() | ||
65 | and cond_resched() in the main loop as we could be dirtying a lot of | ||
66 | pages and this ensures we play nice with the VM and the system as a | ||
67 | whole. | ||
68 | - Implement file operations ->write, ->aio_write, ->writev for regular | ||
69 | files. This replaces the old use of generic_file_write(), et al and | ||
70 | the address space operations ->prepare_write and ->commit_write. | ||
71 | This means that both sparse and non-sparse (unencrypted and | ||
72 | uncompressed) files can now be extended using the normal write(2) | ||
73 | code path. There are two limitations at present and these are that | ||
74 | we never create sparse files and that we only have limited support | ||
75 | for highly fragmented files, i.e. ones whose data attribute is split | ||
76 | across multiple extents. When such a case is encountered, | ||
77 | EOPNOTSUPP is returned. | ||
78 | - $EA attributes can be both resident and non-resident. | ||
79 | - Use %z for size_t to fix compilation warnings. (Andrew Morton) | ||
80 | - Fix compilation warnings with gcc-4.0.2 on SUSE 10.0. | ||
81 | - Document extended attribute ($EA) NEED_EA flag. (Based on libntfs | ||
82 | patch by Yura Pakhuchiy.) | ||
83 | |||
25 | 2.1.24 - Lots of bug fixes and support more clean journal states. | 84 | 2.1.24 - Lots of bug fixes and support more clean journal states. |
26 | 85 | ||
27 | - Support journals ($LogFile) which have been modified by chkdsk. This | 86 | - Support journals ($LogFile) which have been modified by chkdsk. This |
diff --git a/fs/ntfs/Makefile b/fs/ntfs/Makefile index 894b2b876d35..d0d45d1c853a 100644 --- a/fs/ntfs/Makefile +++ b/fs/ntfs/Makefile | |||
@@ -6,7 +6,7 @@ ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \ | |||
6 | index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \ | 6 | index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \ |
7 | unistr.o upcase.o | 7 | unistr.o upcase.o |
8 | 8 | ||
9 | EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.24\" | 9 | EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.25\" |
10 | 10 | ||
11 | ifeq ($(CONFIG_NTFS_DEBUG),y) | 11 | ifeq ($(CONFIG_NTFS_DEBUG),y) |
12 | EXTRA_CFLAGS += -DDEBUG | 12 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 5e80c07c6a4d..1c0a4315876a 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c | |||
@@ -1391,8 +1391,7 @@ retry_writepage: | |||
1391 | if (NInoEncrypted(ni)) { | 1391 | if (NInoEncrypted(ni)) { |
1392 | unlock_page(page); | 1392 | unlock_page(page); |
1393 | BUG_ON(ni->type != AT_DATA); | 1393 | BUG_ON(ni->type != AT_DATA); |
1394 | ntfs_debug("Denying write access to encrypted " | 1394 | ntfs_debug("Denying write access to encrypted file."); |
1395 | "file."); | ||
1396 | return -EACCES; | 1395 | return -EACCES; |
1397 | } | 1396 | } |
1398 | /* Compressed data streams are handled in compress.c. */ | 1397 | /* Compressed data streams are handled in compress.c. */ |
@@ -1508,8 +1507,8 @@ retry_writepage: | |||
1508 | /* Zero out of bounds area in the page cache page. */ | 1507 | /* Zero out of bounds area in the page cache page. */ |
1509 | memset(kaddr + attr_len, 0, PAGE_CACHE_SIZE - attr_len); | 1508 | memset(kaddr + attr_len, 0, PAGE_CACHE_SIZE - attr_len); |
1510 | kunmap_atomic(kaddr, KM_USER0); | 1509 | kunmap_atomic(kaddr, KM_USER0); |
1511 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
1512 | flush_dcache_page(page); | 1510 | flush_dcache_page(page); |
1511 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
1513 | /* We are done with the page. */ | 1512 | /* We are done with the page. */ |
1514 | end_page_writeback(page); | 1513 | end_page_writeback(page); |
1515 | /* Finally, mark the mft record dirty, so it gets written back. */ | 1514 | /* Finally, mark the mft record dirty, so it gets written back. */ |
@@ -1542,830 +1541,6 @@ err_out: | |||
1542 | return err; | 1541 | return err; |
1543 | } | 1542 | } |
1544 | 1543 | ||
1545 | /** | ||
1546 | * ntfs_prepare_nonresident_write - | ||
1547 | * | ||
1548 | */ | ||
1549 | static int ntfs_prepare_nonresident_write(struct page *page, | ||
1550 | unsigned from, unsigned to) | ||
1551 | { | ||
1552 | VCN vcn; | ||
1553 | LCN lcn; | ||
1554 | s64 initialized_size; | ||
1555 | loff_t i_size; | ||
1556 | sector_t block, ablock, iblock; | ||
1557 | struct inode *vi; | ||
1558 | ntfs_inode *ni; | ||
1559 | ntfs_volume *vol; | ||
1560 | runlist_element *rl; | ||
1561 | struct buffer_head *bh, *head, *wait[2], **wait_bh = wait; | ||
1562 | unsigned long flags; | ||
1563 | unsigned int vcn_ofs, block_start, block_end, blocksize; | ||
1564 | int err; | ||
1565 | BOOL is_retry; | ||
1566 | unsigned char blocksize_bits; | ||
1567 | |||
1568 | vi = page->mapping->host; | ||
1569 | ni = NTFS_I(vi); | ||
1570 | vol = ni->vol; | ||
1571 | |||
1572 | ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index " | ||
1573 | "0x%lx, from = %u, to = %u.", ni->mft_no, ni->type, | ||
1574 | page->index, from, to); | ||
1575 | |||
1576 | BUG_ON(!NInoNonResident(ni)); | ||
1577 | |||
1578 | blocksize_bits = vi->i_blkbits; | ||
1579 | blocksize = 1 << blocksize_bits; | ||
1580 | |||
1581 | /* | ||
1582 | * create_empty_buffers() will create uptodate/dirty buffers if the | ||
1583 | * page is uptodate/dirty. | ||
1584 | */ | ||
1585 | if (!page_has_buffers(page)) | ||
1586 | create_empty_buffers(page, blocksize, 0); | ||
1587 | bh = head = page_buffers(page); | ||
1588 | if (unlikely(!bh)) | ||
1589 | return -ENOMEM; | ||
1590 | |||
1591 | /* The first block in the page. */ | ||
1592 | block = (s64)page->index << (PAGE_CACHE_SHIFT - blocksize_bits); | ||
1593 | |||
1594 | read_lock_irqsave(&ni->size_lock, flags); | ||
1595 | /* | ||
1596 | * The first out of bounds block for the allocated size. No need to | ||
1597 | * round up as allocated_size is in multiples of cluster size and the | ||
1598 | * minimum cluster size is 512 bytes, which is equal to the smallest | ||
1599 | * blocksize. | ||
1600 | */ | ||
1601 | ablock = ni->allocated_size >> blocksize_bits; | ||
1602 | i_size = i_size_read(vi); | ||
1603 | initialized_size = ni->initialized_size; | ||
1604 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
1605 | |||
1606 | /* The last (fully or partially) initialized block. */ | ||
1607 | iblock = initialized_size >> blocksize_bits; | ||
1608 | |||
1609 | /* Loop through all the buffers in the page. */ | ||
1610 | block_start = 0; | ||
1611 | rl = NULL; | ||
1612 | err = 0; | ||
1613 | do { | ||
1614 | block_end = block_start + blocksize; | ||
1615 | /* | ||
1616 | * If buffer @bh is outside the write, just mark it uptodate | ||
1617 | * if the page is uptodate and continue with the next buffer. | ||
1618 | */ | ||
1619 | if (block_end <= from || block_start >= to) { | ||
1620 | if (PageUptodate(page)) { | ||
1621 | if (!buffer_uptodate(bh)) | ||
1622 | set_buffer_uptodate(bh); | ||
1623 | } | ||
1624 | continue; | ||
1625 | } | ||
1626 | /* | ||
1627 | * @bh is at least partially being written to. | ||
1628 | * Make sure it is not marked as new. | ||
1629 | */ | ||
1630 | //if (buffer_new(bh)) | ||
1631 | // clear_buffer_new(bh); | ||
1632 | |||
1633 | if (block >= ablock) { | ||
1634 | // TODO: block is above allocated_size, need to | ||
1635 | // allocate it. Best done in one go to accommodate not | ||
1636 | // only block but all above blocks up to and including: | ||
1637 | // ((page->index << PAGE_CACHE_SHIFT) + to + blocksize | ||
1638 | // - 1) >> blobksize_bits. Obviously will need to round | ||
1639 | // up to next cluster boundary, too. This should be | ||
1640 | // done with a helper function, so it can be reused. | ||
1641 | ntfs_error(vol->sb, "Writing beyond allocated size " | ||
1642 | "is not supported yet. Sorry."); | ||
1643 | err = -EOPNOTSUPP; | ||
1644 | goto err_out; | ||
1645 | // Need to update ablock. | ||
1646 | // Need to set_buffer_new() on all block bhs that are | ||
1647 | // newly allocated. | ||
1648 | } | ||
1649 | /* | ||
1650 | * Now we have enough allocated size to fulfill the whole | ||
1651 | * request, i.e. block < ablock is true. | ||
1652 | */ | ||
1653 | if (unlikely((block >= iblock) && | ||
1654 | (initialized_size < i_size))) { | ||
1655 | /* | ||
1656 | * If this page is fully outside initialized size, zero | ||
1657 | * out all pages between the current initialized size | ||
1658 | * and the current page. Just use ntfs_readpage() to do | ||
1659 | * the zeroing transparently. | ||
1660 | */ | ||
1661 | if (block > iblock) { | ||
1662 | // TODO: | ||
1663 | // For each page do: | ||
1664 | // - read_cache_page() | ||
1665 | // Again for each page do: | ||
1666 | // - wait_on_page_locked() | ||
1667 | // - Check (PageUptodate(page) && | ||
1668 | // !PageError(page)) | ||
1669 | // Update initialized size in the attribute and | ||
1670 | // in the inode. | ||
1671 | // Again, for each page do: | ||
1672 | // __set_page_dirty_buffers(); | ||
1673 | // page_cache_release() | ||
1674 | // We don't need to wait on the writes. | ||
1675 | // Update iblock. | ||
1676 | } | ||
1677 | /* | ||
1678 | * The current page straddles initialized size. Zero | ||
1679 | * all non-uptodate buffers and set them uptodate (and | ||
1680 | * dirty?). Note, there aren't any non-uptodate buffers | ||
1681 | * if the page is uptodate. | ||
1682 | * FIXME: For an uptodate page, the buffers may need to | ||
1683 | * be written out because they were not initialized on | ||
1684 | * disk before. | ||
1685 | */ | ||
1686 | if (!PageUptodate(page)) { | ||
1687 | // TODO: | ||
1688 | // Zero any non-uptodate buffers up to i_size. | ||
1689 | // Set them uptodate and dirty. | ||
1690 | } | ||
1691 | // TODO: | ||
1692 | // Update initialized size in the attribute and in the | ||
1693 | // inode (up to i_size). | ||
1694 | // Update iblock. | ||
1695 | // FIXME: This is inefficient. Try to batch the two | ||
1696 | // size changes to happen in one go. | ||
1697 | ntfs_error(vol->sb, "Writing beyond initialized size " | ||
1698 | "is not supported yet. Sorry."); | ||
1699 | err = -EOPNOTSUPP; | ||
1700 | goto err_out; | ||
1701 | // Do NOT set_buffer_new() BUT DO clear buffer range | ||
1702 | // outside write request range. | ||
1703 | // set_buffer_uptodate() on complete buffers as well as | ||
1704 | // set_buffer_dirty(). | ||
1705 | } | ||
1706 | |||
1707 | /* Need to map unmapped buffers. */ | ||
1708 | if (!buffer_mapped(bh)) { | ||
1709 | /* Unmapped buffer. Need to map it. */ | ||
1710 | bh->b_bdev = vol->sb->s_bdev; | ||
1711 | |||
1712 | /* Convert block into corresponding vcn and offset. */ | ||
1713 | vcn = (VCN)block << blocksize_bits >> | ||
1714 | vol->cluster_size_bits; | ||
1715 | vcn_ofs = ((VCN)block << blocksize_bits) & | ||
1716 | vol->cluster_size_mask; | ||
1717 | |||
1718 | is_retry = FALSE; | ||
1719 | if (!rl) { | ||
1720 | lock_retry_remap: | ||
1721 | down_read(&ni->runlist.lock); | ||
1722 | rl = ni->runlist.rl; | ||
1723 | } | ||
1724 | if (likely(rl != NULL)) { | ||
1725 | /* Seek to element containing target vcn. */ | ||
1726 | while (rl->length && rl[1].vcn <= vcn) | ||
1727 | rl++; | ||
1728 | lcn = ntfs_rl_vcn_to_lcn(rl, vcn); | ||
1729 | } else | ||
1730 | lcn = LCN_RL_NOT_MAPPED; | ||
1731 | if (unlikely(lcn < 0)) { | ||
1732 | /* | ||
1733 | * We extended the attribute allocation above. | ||
1734 | * If we hit an ENOENT here it means that the | ||
1735 | * allocation was insufficient which is a bug. | ||
1736 | */ | ||
1737 | BUG_ON(lcn == LCN_ENOENT); | ||
1738 | |||
1739 | /* It is a hole, need to instantiate it. */ | ||
1740 | if (lcn == LCN_HOLE) { | ||
1741 | // TODO: Instantiate the hole. | ||
1742 | // clear_buffer_new(bh); | ||
1743 | // unmap_underlying_metadata(bh->b_bdev, | ||
1744 | // bh->b_blocknr); | ||
1745 | // For non-uptodate buffers, need to | ||
1746 | // zero out the region outside the | ||
1747 | // request in this bh or all bhs, | ||
1748 | // depending on what we implemented | ||
1749 | // above. | ||
1750 | // Need to flush_dcache_page(). | ||
1751 | // Or could use set_buffer_new() | ||
1752 | // instead? | ||
1753 | ntfs_error(vol->sb, "Writing into " | ||
1754 | "sparse regions is " | ||
1755 | "not supported yet. " | ||
1756 | "Sorry."); | ||
1757 | err = -EOPNOTSUPP; | ||
1758 | if (!rl) | ||
1759 | up_read(&ni->runlist.lock); | ||
1760 | goto err_out; | ||
1761 | } else if (!is_retry && | ||
1762 | lcn == LCN_RL_NOT_MAPPED) { | ||
1763 | is_retry = TRUE; | ||
1764 | /* | ||
1765 | * Attempt to map runlist, dropping | ||
1766 | * lock for the duration. | ||
1767 | */ | ||
1768 | up_read(&ni->runlist.lock); | ||
1769 | err = ntfs_map_runlist(ni, vcn); | ||
1770 | if (likely(!err)) | ||
1771 | goto lock_retry_remap; | ||
1772 | rl = NULL; | ||
1773 | } else if (!rl) | ||
1774 | up_read(&ni->runlist.lock); | ||
1775 | /* | ||
1776 | * Failed to map the buffer, even after | ||
1777 | * retrying. | ||
1778 | */ | ||
1779 | if (!err) | ||
1780 | err = -EIO; | ||
1781 | bh->b_blocknr = -1; | ||
1782 | ntfs_error(vol->sb, "Failed to write to inode " | ||
1783 | "0x%lx, attribute type 0x%x, " | ||
1784 | "vcn 0x%llx, offset 0x%x " | ||
1785 | "because its location on disk " | ||
1786 | "could not be determined%s " | ||
1787 | "(error code %i).", | ||
1788 | ni->mft_no, ni->type, | ||
1789 | (unsigned long long)vcn, | ||
1790 | vcn_ofs, is_retry ? " even " | ||
1791 | "after retrying" : "", err); | ||
1792 | goto err_out; | ||
1793 | } | ||
1794 | /* We now have a successful remap, i.e. lcn >= 0. */ | ||
1795 | |||
1796 | /* Setup buffer head to correct block. */ | ||
1797 | bh->b_blocknr = ((lcn << vol->cluster_size_bits) | ||
1798 | + vcn_ofs) >> blocksize_bits; | ||
1799 | set_buffer_mapped(bh); | ||
1800 | |||
1801 | // FIXME: Something analogous to this is needed for | ||
1802 | // each newly allocated block, i.e. BH_New. | ||
1803 | // FIXME: Might need to take this out of the | ||
1804 | // if (!buffer_mapped(bh)) {}, depending on how we | ||
1805 | // implement things during the allocated_size and | ||
1806 | // initialized_size extension code above. | ||
1807 | if (buffer_new(bh)) { | ||
1808 | clear_buffer_new(bh); | ||
1809 | unmap_underlying_metadata(bh->b_bdev, | ||
1810 | bh->b_blocknr); | ||
1811 | if (PageUptodate(page)) { | ||
1812 | set_buffer_uptodate(bh); | ||
1813 | continue; | ||
1814 | } | ||
1815 | /* | ||
1816 | * Page is _not_ uptodate, zero surrounding | ||
1817 | * region. NOTE: This is how we decide if to | ||
1818 | * zero or not! | ||
1819 | */ | ||
1820 | if (block_end > to || block_start < from) { | ||
1821 | void *kaddr; | ||
1822 | |||
1823 | kaddr = kmap_atomic(page, KM_USER0); | ||
1824 | if (block_end > to) | ||
1825 | memset(kaddr + to, 0, | ||
1826 | block_end - to); | ||
1827 | if (block_start < from) | ||
1828 | memset(kaddr + block_start, 0, | ||
1829 | from - | ||
1830 | block_start); | ||
1831 | flush_dcache_page(page); | ||
1832 | kunmap_atomic(kaddr, KM_USER0); | ||
1833 | } | ||
1834 | continue; | ||
1835 | } | ||
1836 | } | ||
1837 | /* @bh is mapped, set it uptodate if the page is uptodate. */ | ||
1838 | if (PageUptodate(page)) { | ||
1839 | if (!buffer_uptodate(bh)) | ||
1840 | set_buffer_uptodate(bh); | ||
1841 | continue; | ||
1842 | } | ||
1843 | /* | ||
1844 | * The page is not uptodate. The buffer is mapped. If it is not | ||
1845 | * uptodate, and it is only partially being written to, we need | ||
1846 | * to read the buffer in before the write, i.e. right now. | ||
1847 | */ | ||
1848 | if (!buffer_uptodate(bh) && | ||
1849 | (block_start < from || block_end > to)) { | ||
1850 | ll_rw_block(READ, 1, &bh); | ||
1851 | *wait_bh++ = bh; | ||
1852 | } | ||
1853 | } while (block++, block_start = block_end, | ||
1854 | (bh = bh->b_this_page) != head); | ||
1855 | |||
1856 | /* Release the lock if we took it. */ | ||
1857 | if (rl) { | ||
1858 | up_read(&ni->runlist.lock); | ||
1859 | rl = NULL; | ||
1860 | } | ||
1861 | |||
1862 | /* If we issued read requests, let them complete. */ | ||
1863 | while (wait_bh > wait) { | ||
1864 | wait_on_buffer(*--wait_bh); | ||
1865 | if (!buffer_uptodate(*wait_bh)) | ||
1866 | return -EIO; | ||
1867 | } | ||
1868 | |||
1869 | ntfs_debug("Done."); | ||
1870 | return 0; | ||
1871 | err_out: | ||
1872 | /* | ||
1873 | * Zero out any newly allocated blocks to avoid exposing stale data. | ||
1874 | * If BH_New is set, we know that the block was newly allocated in the | ||
1875 | * above loop. | ||
1876 | * FIXME: What about initialized_size increments? Have we done all the | ||
1877 | * required zeroing above? If not this error handling is broken, and | ||
1878 | * in particular the if (block_end <= from) check is completely bogus. | ||
1879 | */ | ||
1880 | bh = head; | ||
1881 | block_start = 0; | ||
1882 | is_retry = FALSE; | ||
1883 | do { | ||
1884 | block_end = block_start + blocksize; | ||
1885 | if (block_end <= from) | ||
1886 | continue; | ||
1887 | if (block_start >= to) | ||
1888 | break; | ||
1889 | if (buffer_new(bh)) { | ||
1890 | void *kaddr; | ||
1891 | |||
1892 | clear_buffer_new(bh); | ||
1893 | kaddr = kmap_atomic(page, KM_USER0); | ||
1894 | memset(kaddr + block_start, 0, bh->b_size); | ||
1895 | kunmap_atomic(kaddr, KM_USER0); | ||
1896 | set_buffer_uptodate(bh); | ||
1897 | mark_buffer_dirty(bh); | ||
1898 | is_retry = TRUE; | ||
1899 | } | ||
1900 | } while (block_start = block_end, (bh = bh->b_this_page) != head); | ||
1901 | if (is_retry) | ||
1902 | flush_dcache_page(page); | ||
1903 | if (rl) | ||
1904 | up_read(&ni->runlist.lock); | ||
1905 | return err; | ||
1906 | } | ||
1907 | |||
1908 | /** | ||
1909 | * ntfs_prepare_write - prepare a page for receiving data | ||
1910 | * | ||
1911 | * This is called from generic_file_write() with i_sem held on the inode | ||
1912 | * (@page->mapping->host). The @page is locked but not kmap()ped. The source | ||
1913 | * data has not yet been copied into the @page. | ||
1914 | * | ||
1915 | * Need to extend the attribute/fill in holes if necessary, create blocks and | ||
1916 | * make partially overwritten blocks uptodate, | ||
1917 | * | ||
1918 | * i_size is not to be modified yet. | ||
1919 | * | ||
1920 | * Return 0 on success or -errno on error. | ||
1921 | * | ||
1922 | * Should be using block_prepare_write() [support for sparse files] or | ||
1923 | * cont_prepare_write() [no support for sparse files]. Cannot do that due to | ||
1924 | * ntfs specifics but can look at them for implementation guidance. | ||
1925 | * | ||
1926 | * Note: In the range, @from is inclusive and @to is exclusive, i.e. @from is | ||
1927 | * the first byte in the page that will be written to and @to is the first byte | ||
1928 | * after the last byte that will be written to. | ||
1929 | */ | ||
1930 | static int ntfs_prepare_write(struct file *file, struct page *page, | ||
1931 | unsigned from, unsigned to) | ||
1932 | { | ||
1933 | s64 new_size; | ||
1934 | loff_t i_size; | ||
1935 | struct inode *vi = page->mapping->host; | ||
1936 | ntfs_inode *base_ni = NULL, *ni = NTFS_I(vi); | ||
1937 | ntfs_volume *vol = ni->vol; | ||
1938 | ntfs_attr_search_ctx *ctx = NULL; | ||
1939 | MFT_RECORD *m = NULL; | ||
1940 | ATTR_RECORD *a; | ||
1941 | u8 *kaddr; | ||
1942 | u32 attr_len; | ||
1943 | int err; | ||
1944 | |||
1945 | ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index " | ||
1946 | "0x%lx, from = %u, to = %u.", vi->i_ino, ni->type, | ||
1947 | page->index, from, to); | ||
1948 | BUG_ON(!PageLocked(page)); | ||
1949 | BUG_ON(from > PAGE_CACHE_SIZE); | ||
1950 | BUG_ON(to > PAGE_CACHE_SIZE); | ||
1951 | BUG_ON(from > to); | ||
1952 | BUG_ON(NInoMstProtected(ni)); | ||
1953 | /* | ||
1954 | * If a previous ntfs_truncate() failed, repeat it and abort if it | ||
1955 | * fails again. | ||
1956 | */ | ||
1957 | if (unlikely(NInoTruncateFailed(ni))) { | ||
1958 | down_write(&vi->i_alloc_sem); | ||
1959 | err = ntfs_truncate(vi); | ||
1960 | up_write(&vi->i_alloc_sem); | ||
1961 | if (err || NInoTruncateFailed(ni)) { | ||
1962 | if (!err) | ||
1963 | err = -EIO; | ||
1964 | goto err_out; | ||
1965 | } | ||
1966 | } | ||
1967 | /* If the attribute is not resident, deal with it elsewhere. */ | ||
1968 | if (NInoNonResident(ni)) { | ||
1969 | /* | ||
1970 | * Only unnamed $DATA attributes can be compressed, encrypted, | ||
1971 | * and/or sparse. | ||
1972 | */ | ||
1973 | if (ni->type == AT_DATA && !ni->name_len) { | ||
1974 | /* If file is encrypted, deny access, just like NT4. */ | ||
1975 | if (NInoEncrypted(ni)) { | ||
1976 | ntfs_debug("Denying write access to encrypted " | ||
1977 | "file."); | ||
1978 | return -EACCES; | ||
1979 | } | ||
1980 | /* Compressed data streams are handled in compress.c. */ | ||
1981 | if (NInoCompressed(ni)) { | ||
1982 | // TODO: Implement and replace this check with | ||
1983 | // return ntfs_write_compressed_block(page); | ||
1984 | ntfs_error(vi->i_sb, "Writing to compressed " | ||
1985 | "files is not supported yet. " | ||
1986 | "Sorry."); | ||
1987 | return -EOPNOTSUPP; | ||
1988 | } | ||
1989 | // TODO: Implement and remove this check. | ||
1990 | if (NInoSparse(ni)) { | ||
1991 | ntfs_error(vi->i_sb, "Writing to sparse files " | ||
1992 | "is not supported yet. Sorry."); | ||
1993 | return -EOPNOTSUPP; | ||
1994 | } | ||
1995 | } | ||
1996 | /* Normal data stream. */ | ||
1997 | return ntfs_prepare_nonresident_write(page, from, to); | ||
1998 | } | ||
1999 | /* | ||
2000 | * Attribute is resident, implying it is not compressed, encrypted, or | ||
2001 | * sparse. | ||
2002 | */ | ||
2003 | BUG_ON(page_has_buffers(page)); | ||
2004 | new_size = ((s64)page->index << PAGE_CACHE_SHIFT) + to; | ||
2005 | /* If we do not need to resize the attribute allocation we are done. */ | ||
2006 | if (new_size <= i_size_read(vi)) | ||
2007 | goto done; | ||
2008 | /* Map, pin, and lock the (base) mft record. */ | ||
2009 | if (!NInoAttr(ni)) | ||
2010 | base_ni = ni; | ||
2011 | else | ||
2012 | base_ni = ni->ext.base_ntfs_ino; | ||
2013 | m = map_mft_record(base_ni); | ||
2014 | if (IS_ERR(m)) { | ||
2015 | err = PTR_ERR(m); | ||
2016 | m = NULL; | ||
2017 | ctx = NULL; | ||
2018 | goto err_out; | ||
2019 | } | ||
2020 | ctx = ntfs_attr_get_search_ctx(base_ni, m); | ||
2021 | if (unlikely(!ctx)) { | ||
2022 | err = -ENOMEM; | ||
2023 | goto err_out; | ||
2024 | } | ||
2025 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
2026 | CASE_SENSITIVE, 0, NULL, 0, ctx); | ||
2027 | if (unlikely(err)) { | ||
2028 | if (err == -ENOENT) | ||
2029 | err = -EIO; | ||
2030 | goto err_out; | ||
2031 | } | ||
2032 | m = ctx->mrec; | ||
2033 | a = ctx->attr; | ||
2034 | /* The total length of the attribute value. */ | ||
2035 | attr_len = le32_to_cpu(a->data.resident.value_length); | ||
2036 | /* Fix an eventual previous failure of ntfs_commit_write(). */ | ||
2037 | i_size = i_size_read(vi); | ||
2038 | if (unlikely(attr_len > i_size)) { | ||
2039 | attr_len = i_size; | ||
2040 | a->data.resident.value_length = cpu_to_le32(attr_len); | ||
2041 | } | ||
2042 | /* If we do not need to resize the attribute allocation we are done. */ | ||
2043 | if (new_size <= attr_len) | ||
2044 | goto done_unm; | ||
2045 | /* Check if new size is allowed in $AttrDef. */ | ||
2046 | err = ntfs_attr_size_bounds_check(vol, ni->type, new_size); | ||
2047 | if (unlikely(err)) { | ||
2048 | if (err == -ERANGE) { | ||
2049 | ntfs_error(vol->sb, "Write would cause the inode " | ||
2050 | "0x%lx to exceed the maximum size for " | ||
2051 | "its attribute type (0x%x). Aborting " | ||
2052 | "write.", vi->i_ino, | ||
2053 | le32_to_cpu(ni->type)); | ||
2054 | } else { | ||
2055 | ntfs_error(vol->sb, "Inode 0x%lx has unknown " | ||
2056 | "attribute type 0x%x. Aborting " | ||
2057 | "write.", vi->i_ino, | ||
2058 | le32_to_cpu(ni->type)); | ||
2059 | err = -EIO; | ||
2060 | } | ||
2061 | goto err_out2; | ||
2062 | } | ||
2063 | /* | ||
2064 | * Extend the attribute record to be able to store the new attribute | ||
2065 | * size. | ||
2066 | */ | ||
2067 | if (new_size >= vol->mft_record_size || ntfs_attr_record_resize(m, a, | ||
2068 | le16_to_cpu(a->data.resident.value_offset) + | ||
2069 | new_size)) { | ||
2070 | /* Not enough space in the mft record. */ | ||
2071 | ntfs_error(vol->sb, "Not enough space in the mft record for " | ||
2072 | "the resized attribute value. This is not " | ||
2073 | "supported yet. Aborting write."); | ||
2074 | err = -EOPNOTSUPP; | ||
2075 | goto err_out2; | ||
2076 | } | ||
2077 | /* | ||
2078 | * We have enough space in the mft record to fit the write. This | ||
2079 | * implies the attribute is smaller than the mft record and hence the | ||
2080 | * attribute must be in a single page and hence page->index must be 0. | ||
2081 | */ | ||
2082 | BUG_ON(page->index); | ||
2083 | /* | ||
2084 | * If the beginning of the write is past the old size, enlarge the | ||
2085 | * attribute value up to the beginning of the write and fill it with | ||
2086 | * zeroes. | ||
2087 | */ | ||
2088 | if (from > attr_len) { | ||
2089 | memset((u8*)a + le16_to_cpu(a->data.resident.value_offset) + | ||
2090 | attr_len, 0, from - attr_len); | ||
2091 | a->data.resident.value_length = cpu_to_le32(from); | ||
2092 | /* Zero the corresponding area in the page as well. */ | ||
2093 | if (PageUptodate(page)) { | ||
2094 | kaddr = kmap_atomic(page, KM_USER0); | ||
2095 | memset(kaddr + attr_len, 0, from - attr_len); | ||
2096 | kunmap_atomic(kaddr, KM_USER0); | ||
2097 | flush_dcache_page(page); | ||
2098 | } | ||
2099 | } | ||
2100 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
2101 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
2102 | done_unm: | ||
2103 | ntfs_attr_put_search_ctx(ctx); | ||
2104 | unmap_mft_record(base_ni); | ||
2105 | /* | ||
2106 | * Because resident attributes are handled by memcpy() to/from the | ||
2107 | * corresponding MFT record, and because this form of i/o is byte | ||
2108 | * aligned rather than block aligned, there is no need to bring the | ||
2109 | * page uptodate here as in the non-resident case where we need to | ||
2110 | * bring the buffers straddled by the write uptodate before | ||
2111 | * generic_file_write() does the copying from userspace. | ||
2112 | * | ||
2113 | * We thus defer the uptodate bringing of the page region outside the | ||
2114 | * region written to to ntfs_commit_write(), which makes the code | ||
2115 | * simpler and saves one atomic kmap which is good. | ||
2116 | */ | ||
2117 | done: | ||
2118 | ntfs_debug("Done."); | ||
2119 | return 0; | ||
2120 | err_out: | ||
2121 | if (err == -ENOMEM) | ||
2122 | ntfs_warning(vi->i_sb, "Error allocating memory required to " | ||
2123 | "prepare the write."); | ||
2124 | else { | ||
2125 | ntfs_error(vi->i_sb, "Resident attribute prepare write failed " | ||
2126 | "with error %i.", err); | ||
2127 | NVolSetErrors(vol); | ||
2128 | make_bad_inode(vi); | ||
2129 | } | ||
2130 | err_out2: | ||
2131 | if (ctx) | ||
2132 | ntfs_attr_put_search_ctx(ctx); | ||
2133 | if (m) | ||
2134 | unmap_mft_record(base_ni); | ||
2135 | return err; | ||
2136 | } | ||
2137 | |||
2138 | /** | ||
2139 | * ntfs_commit_nonresident_write - | ||
2140 | * | ||
2141 | */ | ||
2142 | static int ntfs_commit_nonresident_write(struct page *page, | ||
2143 | unsigned from, unsigned to) | ||
2144 | { | ||
2145 | s64 pos = ((s64)page->index << PAGE_CACHE_SHIFT) + to; | ||
2146 | struct inode *vi = page->mapping->host; | ||
2147 | struct buffer_head *bh, *head; | ||
2148 | unsigned int block_start, block_end, blocksize; | ||
2149 | BOOL partial; | ||
2150 | |||
2151 | ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index " | ||
2152 | "0x%lx, from = %u, to = %u.", vi->i_ino, | ||
2153 | NTFS_I(vi)->type, page->index, from, to); | ||
2154 | blocksize = 1 << vi->i_blkbits; | ||
2155 | |||
2156 | // FIXME: We need a whole slew of special cases in here for compressed | ||
2157 | // files for example... | ||
2158 | // For now, we know ntfs_prepare_write() would have failed so we can't | ||
2159 | // get here in any of the cases which we have to special case, so we | ||
2160 | // are just a ripped off, unrolled generic_commit_write(). | ||
2161 | |||
2162 | bh = head = page_buffers(page); | ||
2163 | block_start = 0; | ||
2164 | partial = FALSE; | ||
2165 | do { | ||
2166 | block_end = block_start + blocksize; | ||
2167 | if (block_end <= from || block_start >= to) { | ||
2168 | if (!buffer_uptodate(bh)) | ||
2169 | partial = TRUE; | ||
2170 | } else { | ||
2171 | set_buffer_uptodate(bh); | ||
2172 | mark_buffer_dirty(bh); | ||
2173 | } | ||
2174 | } while (block_start = block_end, (bh = bh->b_this_page) != head); | ||
2175 | /* | ||
2176 | * If this is a partial write which happened to make all buffers | ||
2177 | * uptodate then we can optimize away a bogus ->readpage() for the next | ||
2178 | * read(). Here we 'discover' whether the page went uptodate as a | ||
2179 | * result of this (potentially partial) write. | ||
2180 | */ | ||
2181 | if (!partial) | ||
2182 | SetPageUptodate(page); | ||
2183 | /* | ||
2184 | * Not convinced about this at all. See disparity comment above. For | ||
2185 | * now we know ntfs_prepare_write() would have failed in the write | ||
2186 | * exceeds i_size case, so this will never trigger which is fine. | ||
2187 | */ | ||
2188 | if (pos > i_size_read(vi)) { | ||
2189 | ntfs_error(vi->i_sb, "Writing beyond the existing file size is " | ||
2190 | "not supported yet. Sorry."); | ||
2191 | return -EOPNOTSUPP; | ||
2192 | // vi->i_size = pos; | ||
2193 | // mark_inode_dirty(vi); | ||
2194 | } | ||
2195 | ntfs_debug("Done."); | ||
2196 | return 0; | ||
2197 | } | ||
2198 | |||
2199 | /** | ||
2200 | * ntfs_commit_write - commit the received data | ||
2201 | * | ||
2202 | * This is called from generic_file_write() with i_sem held on the inode | ||
2203 | * (@page->mapping->host). The @page is locked but not kmap()ped. The source | ||
2204 | * data has already been copied into the @page. ntfs_prepare_write() has been | ||
2205 | * called before the data copied and it returned success so we can take the | ||
2206 | * results of various BUG checks and some error handling for granted. | ||
2207 | * | ||
2208 | * Need to mark modified blocks dirty so they get written out later when | ||
2209 | * ntfs_writepage() is invoked by the VM. | ||
2210 | * | ||
2211 | * Return 0 on success or -errno on error. | ||
2212 | * | ||
2213 | * Should be using generic_commit_write(). This marks buffers uptodate and | ||
2214 | * dirty, sets the page uptodate if all buffers in the page are uptodate, and | ||
2215 | * updates i_size if the end of io is beyond i_size. In that case, it also | ||
2216 | * marks the inode dirty. | ||
2217 | * | ||
2218 | * Cannot use generic_commit_write() due to ntfs specialities but can look at | ||
2219 | * it for implementation guidance. | ||
2220 | * | ||
2221 | * If things have gone as outlined in ntfs_prepare_write(), then we do not | ||
2222 | * need to do any page content modifications here at all, except in the write | ||
2223 | * to resident attribute case, where we need to do the uptodate bringing here | ||
2224 | * which we combine with the copying into the mft record which means we save | ||
2225 | * one atomic kmap. | ||
2226 | */ | ||
2227 | static int ntfs_commit_write(struct file *file, struct page *page, | ||
2228 | unsigned from, unsigned to) | ||
2229 | { | ||
2230 | struct inode *vi = page->mapping->host; | ||
2231 | ntfs_inode *base_ni, *ni = NTFS_I(vi); | ||
2232 | char *kaddr, *kattr; | ||
2233 | ntfs_attr_search_ctx *ctx; | ||
2234 | MFT_RECORD *m; | ||
2235 | ATTR_RECORD *a; | ||
2236 | u32 attr_len; | ||
2237 | int err; | ||
2238 | |||
2239 | ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index " | ||
2240 | "0x%lx, from = %u, to = %u.", vi->i_ino, ni->type, | ||
2241 | page->index, from, to); | ||
2242 | /* If the attribute is not resident, deal with it elsewhere. */ | ||
2243 | if (NInoNonResident(ni)) { | ||
2244 | /* Only unnamed $DATA attributes can be compressed/encrypted. */ | ||
2245 | if (ni->type == AT_DATA && !ni->name_len) { | ||
2246 | /* Encrypted files need separate handling. */ | ||
2247 | if (NInoEncrypted(ni)) { | ||
2248 | // We never get here at present! | ||
2249 | BUG(); | ||
2250 | } | ||
2251 | /* Compressed data streams are handled in compress.c. */ | ||
2252 | if (NInoCompressed(ni)) { | ||
2253 | // TODO: Implement this! | ||
2254 | // return ntfs_write_compressed_block(page); | ||
2255 | // We never get here at present! | ||
2256 | BUG(); | ||
2257 | } | ||
2258 | } | ||
2259 | /* Normal data stream. */ | ||
2260 | return ntfs_commit_nonresident_write(page, from, to); | ||
2261 | } | ||
2262 | /* | ||
2263 | * Attribute is resident, implying it is not compressed, encrypted, or | ||
2264 | * sparse. | ||
2265 | */ | ||
2266 | if (!NInoAttr(ni)) | ||
2267 | base_ni = ni; | ||
2268 | else | ||
2269 | base_ni = ni->ext.base_ntfs_ino; | ||
2270 | /* Map, pin, and lock the mft record. */ | ||
2271 | m = map_mft_record(base_ni); | ||
2272 | if (IS_ERR(m)) { | ||
2273 | err = PTR_ERR(m); | ||
2274 | m = NULL; | ||
2275 | ctx = NULL; | ||
2276 | goto err_out; | ||
2277 | } | ||
2278 | ctx = ntfs_attr_get_search_ctx(base_ni, m); | ||
2279 | if (unlikely(!ctx)) { | ||
2280 | err = -ENOMEM; | ||
2281 | goto err_out; | ||
2282 | } | ||
2283 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
2284 | CASE_SENSITIVE, 0, NULL, 0, ctx); | ||
2285 | if (unlikely(err)) { | ||
2286 | if (err == -ENOENT) | ||
2287 | err = -EIO; | ||
2288 | goto err_out; | ||
2289 | } | ||
2290 | a = ctx->attr; | ||
2291 | /* The total length of the attribute value. */ | ||
2292 | attr_len = le32_to_cpu(a->data.resident.value_length); | ||
2293 | BUG_ON(from > attr_len); | ||
2294 | kattr = (u8*)a + le16_to_cpu(a->data.resident.value_offset); | ||
2295 | kaddr = kmap_atomic(page, KM_USER0); | ||
2296 | /* Copy the received data from the page to the mft record. */ | ||
2297 | memcpy(kattr + from, kaddr + from, to - from); | ||
2298 | /* Update the attribute length if necessary. */ | ||
2299 | if (to > attr_len) { | ||
2300 | attr_len = to; | ||
2301 | a->data.resident.value_length = cpu_to_le32(attr_len); | ||
2302 | } | ||
2303 | /* | ||
2304 | * If the page is not uptodate, bring the out of bounds area(s) | ||
2305 | * uptodate by copying data from the mft record to the page. | ||
2306 | */ | ||
2307 | if (!PageUptodate(page)) { | ||
2308 | if (from > 0) | ||
2309 | memcpy(kaddr, kattr, from); | ||
2310 | if (to < attr_len) | ||
2311 | memcpy(kaddr + to, kattr + to, attr_len - to); | ||
2312 | /* Zero the region outside the end of the attribute value. */ | ||
2313 | if (attr_len < PAGE_CACHE_SIZE) | ||
2314 | memset(kaddr + attr_len, 0, PAGE_CACHE_SIZE - attr_len); | ||
2315 | /* | ||
2316 | * The probability of not having done any of the above is | ||
2317 | * extremely small, so we just flush unconditionally. | ||
2318 | */ | ||
2319 | flush_dcache_page(page); | ||
2320 | SetPageUptodate(page); | ||
2321 | } | ||
2322 | kunmap_atomic(kaddr, KM_USER0); | ||
2323 | /* Update i_size if necessary. */ | ||
2324 | if (i_size_read(vi) < attr_len) { | ||
2325 | unsigned long flags; | ||
2326 | |||
2327 | write_lock_irqsave(&ni->size_lock, flags); | ||
2328 | ni->allocated_size = ni->initialized_size = attr_len; | ||
2329 | i_size_write(vi, attr_len); | ||
2330 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
2331 | } | ||
2332 | /* Mark the mft record dirty, so it gets written back. */ | ||
2333 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
2334 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
2335 | ntfs_attr_put_search_ctx(ctx); | ||
2336 | unmap_mft_record(base_ni); | ||
2337 | ntfs_debug("Done."); | ||
2338 | return 0; | ||
2339 | err_out: | ||
2340 | if (err == -ENOMEM) { | ||
2341 | ntfs_warning(vi->i_sb, "Error allocating memory required to " | ||
2342 | "commit the write."); | ||
2343 | if (PageUptodate(page)) { | ||
2344 | ntfs_warning(vi->i_sb, "Page is uptodate, setting " | ||
2345 | "dirty so the write will be retried " | ||
2346 | "later on by the VM."); | ||
2347 | /* | ||
2348 | * Put the page on mapping->dirty_pages, but leave its | ||
2349 | * buffers' dirty state as-is. | ||
2350 | */ | ||
2351 | __set_page_dirty_nobuffers(page); | ||
2352 | err = 0; | ||
2353 | } else | ||
2354 | ntfs_error(vi->i_sb, "Page is not uptodate. Written " | ||
2355 | "data has been lost."); | ||
2356 | } else { | ||
2357 | ntfs_error(vi->i_sb, "Resident attribute commit write failed " | ||
2358 | "with error %i.", err); | ||
2359 | NVolSetErrors(ni->vol); | ||
2360 | make_bad_inode(vi); | ||
2361 | } | ||
2362 | if (ctx) | ||
2363 | ntfs_attr_put_search_ctx(ctx); | ||
2364 | if (m) | ||
2365 | unmap_mft_record(base_ni); | ||
2366 | return err; | ||
2367 | } | ||
2368 | |||
2369 | #endif /* NTFS_RW */ | 1544 | #endif /* NTFS_RW */ |
2370 | 1545 | ||
2371 | /** | 1546 | /** |
@@ -2377,9 +1552,6 @@ struct address_space_operations ntfs_aops = { | |||
2377 | disk request queue. */ | 1552 | disk request queue. */ |
2378 | #ifdef NTFS_RW | 1553 | #ifdef NTFS_RW |
2379 | .writepage = ntfs_writepage, /* Write dirty page to disk. */ | 1554 | .writepage = ntfs_writepage, /* Write dirty page to disk. */ |
2380 | .prepare_write = ntfs_prepare_write, /* Prepare page and buffers | ||
2381 | ready to receive data. */ | ||
2382 | .commit_write = ntfs_commit_write, /* Commit received data. */ | ||
2383 | #endif /* NTFS_RW */ | 1555 | #endif /* NTFS_RW */ |
2384 | }; | 1556 | }; |
2385 | 1557 | ||
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 3f9a4ff42ee5..eda056bac256 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c | |||
@@ -21,7 +21,9 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/buffer_head.h> | 23 | #include <linux/buffer_head.h> |
24 | #include <linux/sched.h> | ||
24 | #include <linux/swap.h> | 25 | #include <linux/swap.h> |
26 | #include <linux/writeback.h> | ||
25 | 27 | ||
26 | #include "attrib.h" | 28 | #include "attrib.h" |
27 | #include "debug.h" | 29 | #include "debug.h" |
@@ -36,9 +38,27 @@ | |||
36 | * ntfs_map_runlist_nolock - map (a part of) a runlist of an ntfs inode | 38 | * ntfs_map_runlist_nolock - map (a part of) a runlist of an ntfs inode |
37 | * @ni: ntfs inode for which to map (part of) a runlist | 39 | * @ni: ntfs inode for which to map (part of) a runlist |
38 | * @vcn: map runlist part containing this vcn | 40 | * @vcn: map runlist part containing this vcn |
41 | * @ctx: active attribute search context if present or NULL if not | ||
39 | * | 42 | * |
40 | * Map the part of a runlist containing the @vcn of the ntfs inode @ni. | 43 | * Map the part of a runlist containing the @vcn of the ntfs inode @ni. |
41 | * | 44 | * |
45 | * If @ctx is specified, it is an active search context of @ni and its base mft | ||
46 | * record. This is needed when ntfs_map_runlist_nolock() encounters unmapped | ||
47 | * runlist fragments and allows their mapping. If you do not have the mft | ||
48 | * record mapped, you can specify @ctx as NULL and ntfs_map_runlist_nolock() | ||
49 | * will perform the necessary mapping and unmapping. | ||
50 | * | ||
51 | * Note, ntfs_map_runlist_nolock() saves the state of @ctx on entry and | ||
52 | * restores it before returning. Thus, @ctx will be left pointing to the same | ||
53 | * attribute on return as on entry. However, the actual pointers in @ctx may | ||
54 | * point to different memory locations on return, so you must remember to reset | ||
55 | * any cached pointers from the @ctx, i.e. after the call to | ||
56 | * ntfs_map_runlist_nolock(), you will probably want to do: | ||
57 | * m = ctx->mrec; | ||
58 | * a = ctx->attr; | ||
59 | * Assuming you cache ctx->attr in a variable @a of type ATTR_RECORD * and that | ||
60 | * you cache ctx->mrec in a variable @m of type MFT_RECORD *. | ||
61 | * | ||
42 | * Return 0 on success and -errno on error. There is one special error code | 62 | * Return 0 on success and -errno on error. There is one special error code |
43 | * which is not an error as such. This is -ENOENT. It means that @vcn is out | 63 | * which is not an error as such. This is -ENOENT. It means that @vcn is out |
44 | * of bounds of the runlist. | 64 | * of bounds of the runlist. |
@@ -46,19 +66,32 @@ | |||
46 | * Note the runlist can be NULL after this function returns if @vcn is zero and | 66 | * Note the runlist can be NULL after this function returns if @vcn is zero and |
47 | * the attribute has zero allocated size, i.e. there simply is no runlist. | 67 | * the attribute has zero allocated size, i.e. there simply is no runlist. |
48 | * | 68 | * |
49 | * Locking: - The runlist must be locked for writing. | 69 | * WARNING: If @ctx is supplied, regardless of whether success or failure is |
50 | * - This function modifies the runlist. | 70 | * returned, you need to check IS_ERR(@ctx->mrec) and if TRUE the @ctx |
71 | * is no longer valid, i.e. you need to either call | ||
72 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. | ||
73 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for | ||
74 | * why the mapping of the old inode failed. | ||
75 | * | ||
76 | * Locking: - The runlist described by @ni must be locked for writing on entry | ||
77 | * and is locked on return. Note the runlist will be modified. | ||
78 | * - If @ctx is NULL, the base mft record of @ni must not be mapped on | ||
79 | * entry and it will be left unmapped on return. | ||
80 | * - If @ctx is not NULL, the base mft record must be mapped on entry | ||
81 | * and it will be left mapped on return. | ||
51 | */ | 82 | */ |
52 | int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn) | 83 | int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, ntfs_attr_search_ctx *ctx) |
53 | { | 84 | { |
54 | VCN end_vcn; | 85 | VCN end_vcn; |
86 | unsigned long flags; | ||
55 | ntfs_inode *base_ni; | 87 | ntfs_inode *base_ni; |
56 | MFT_RECORD *m; | 88 | MFT_RECORD *m; |
57 | ATTR_RECORD *a; | 89 | ATTR_RECORD *a; |
58 | ntfs_attr_search_ctx *ctx; | ||
59 | runlist_element *rl; | 90 | runlist_element *rl; |
60 | unsigned long flags; | 91 | struct page *put_this_page = NULL; |
61 | int err = 0; | 92 | int err = 0; |
93 | BOOL ctx_is_temporary, ctx_needs_reset; | ||
94 | ntfs_attr_search_ctx old_ctx = { NULL, }; | ||
62 | 95 | ||
63 | ntfs_debug("Mapping runlist part containing vcn 0x%llx.", | 96 | ntfs_debug("Mapping runlist part containing vcn 0x%llx.", |
64 | (unsigned long long)vcn); | 97 | (unsigned long long)vcn); |
@@ -66,20 +99,77 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn) | |||
66 | base_ni = ni; | 99 | base_ni = ni; |
67 | else | 100 | else |
68 | base_ni = ni->ext.base_ntfs_ino; | 101 | base_ni = ni->ext.base_ntfs_ino; |
69 | m = map_mft_record(base_ni); | 102 | if (!ctx) { |
70 | if (IS_ERR(m)) | 103 | ctx_is_temporary = ctx_needs_reset = TRUE; |
71 | return PTR_ERR(m); | 104 | m = map_mft_record(base_ni); |
72 | ctx = ntfs_attr_get_search_ctx(base_ni, m); | 105 | if (IS_ERR(m)) |
73 | if (unlikely(!ctx)) { | 106 | return PTR_ERR(m); |
74 | err = -ENOMEM; | 107 | ctx = ntfs_attr_get_search_ctx(base_ni, m); |
75 | goto err_out; | 108 | if (unlikely(!ctx)) { |
109 | err = -ENOMEM; | ||
110 | goto err_out; | ||
111 | } | ||
112 | } else { | ||
113 | VCN allocated_size_vcn; | ||
114 | |||
115 | BUG_ON(IS_ERR(ctx->mrec)); | ||
116 | a = ctx->attr; | ||
117 | BUG_ON(!a->non_resident); | ||
118 | ctx_is_temporary = FALSE; | ||
119 | end_vcn = sle64_to_cpu(a->data.non_resident.highest_vcn); | ||
120 | read_lock_irqsave(&ni->size_lock, flags); | ||
121 | allocated_size_vcn = ni->allocated_size >> | ||
122 | ni->vol->cluster_size_bits; | ||
123 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
124 | if (!a->data.non_resident.lowest_vcn && end_vcn <= 0) | ||
125 | end_vcn = allocated_size_vcn - 1; | ||
126 | /* | ||
127 | * If we already have the attribute extent containing @vcn in | ||
128 | * @ctx, no need to look it up again. We slightly cheat in | ||
129 | * that if vcn exceeds the allocated size, we will refuse to | ||
130 | * map the runlist below, so there is definitely no need to get | ||
131 | * the right attribute extent. | ||
132 | */ | ||
133 | if (vcn >= allocated_size_vcn || (a->type == ni->type && | ||
134 | a->name_length == ni->name_len && | ||
135 | !memcmp((u8*)a + le16_to_cpu(a->name_offset), | ||
136 | ni->name, ni->name_len) && | ||
137 | sle64_to_cpu(a->data.non_resident.lowest_vcn) | ||
138 | <= vcn && end_vcn >= vcn)) | ||
139 | ctx_needs_reset = FALSE; | ||
140 | else { | ||
141 | /* Save the old search context. */ | ||
142 | old_ctx = *ctx; | ||
143 | /* | ||
144 | * If the currently mapped (extent) inode is not the | ||
145 | * base inode we will unmap it when we reinitialize the | ||
146 | * search context which means we need to get a | ||
147 | * reference to the page containing the mapped mft | ||
148 | * record so we do not accidentally drop changes to the | ||
149 | * mft record when it has not been marked dirty yet. | ||
150 | */ | ||
151 | if (old_ctx.base_ntfs_ino && old_ctx.ntfs_ino != | ||
152 | old_ctx.base_ntfs_ino) { | ||
153 | put_this_page = old_ctx.ntfs_ino->page; | ||
154 | page_cache_get(put_this_page); | ||
155 | } | ||
156 | /* | ||
157 | * Reinitialize the search context so we can lookup the | ||
158 | * needed attribute extent. | ||
159 | */ | ||
160 | ntfs_attr_reinit_search_ctx(ctx); | ||
161 | ctx_needs_reset = TRUE; | ||
162 | } | ||
76 | } | 163 | } |
77 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | 164 | if (ctx_needs_reset) { |
78 | CASE_SENSITIVE, vcn, NULL, 0, ctx); | 165 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, |
79 | if (unlikely(err)) { | 166 | CASE_SENSITIVE, vcn, NULL, 0, ctx); |
80 | if (err == -ENOENT) | 167 | if (unlikely(err)) { |
81 | err = -EIO; | 168 | if (err == -ENOENT) |
82 | goto err_out; | 169 | err = -EIO; |
170 | goto err_out; | ||
171 | } | ||
172 | BUG_ON(!ctx->attr->non_resident); | ||
83 | } | 173 | } |
84 | a = ctx->attr; | 174 | a = ctx->attr; |
85 | /* | 175 | /* |
@@ -89,11 +179,9 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn) | |||
89 | * ntfs_mapping_pairs_decompress() fails. | 179 | * ntfs_mapping_pairs_decompress() fails. |
90 | */ | 180 | */ |
91 | end_vcn = sle64_to_cpu(a->data.non_resident.highest_vcn) + 1; | 181 | end_vcn = sle64_to_cpu(a->data.non_resident.highest_vcn) + 1; |
92 | if (unlikely(!a->data.non_resident.lowest_vcn && end_vcn <= 1)) { | 182 | if (!a->data.non_resident.lowest_vcn && end_vcn == 1) |
93 | read_lock_irqsave(&ni->size_lock, flags); | 183 | end_vcn = sle64_to_cpu(a->data.non_resident.allocated_size) >> |
94 | end_vcn = ni->allocated_size >> ni->vol->cluster_size_bits; | 184 | ni->vol->cluster_size_bits; |
95 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
96 | } | ||
97 | if (unlikely(vcn >= end_vcn)) { | 185 | if (unlikely(vcn >= end_vcn)) { |
98 | err = -ENOENT; | 186 | err = -ENOENT; |
99 | goto err_out; | 187 | goto err_out; |
@@ -104,9 +192,93 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn) | |||
104 | else | 192 | else |
105 | ni->runlist.rl = rl; | 193 | ni->runlist.rl = rl; |
106 | err_out: | 194 | err_out: |
107 | if (likely(ctx)) | 195 | if (ctx_is_temporary) { |
108 | ntfs_attr_put_search_ctx(ctx); | 196 | if (likely(ctx)) |
109 | unmap_mft_record(base_ni); | 197 | ntfs_attr_put_search_ctx(ctx); |
198 | unmap_mft_record(base_ni); | ||
199 | } else if (ctx_needs_reset) { | ||
200 | /* | ||
201 | * If there is no attribute list, restoring the search context | ||
202 | * is acomplished simply by copying the saved context back over | ||
203 | * the caller supplied context. If there is an attribute list, | ||
204 | * things are more complicated as we need to deal with mapping | ||
205 | * of mft records and resulting potential changes in pointers. | ||
206 | */ | ||
207 | if (NInoAttrList(base_ni)) { | ||
208 | /* | ||
209 | * If the currently mapped (extent) inode is not the | ||
210 | * one we had before, we need to unmap it and map the | ||
211 | * old one. | ||
212 | */ | ||
213 | if (ctx->ntfs_ino != old_ctx.ntfs_ino) { | ||
214 | /* | ||
215 | * If the currently mapped inode is not the | ||
216 | * base inode, unmap it. | ||
217 | */ | ||
218 | if (ctx->base_ntfs_ino && ctx->ntfs_ino != | ||
219 | ctx->base_ntfs_ino) { | ||
220 | unmap_extent_mft_record(ctx->ntfs_ino); | ||
221 | ctx->mrec = ctx->base_mrec; | ||
222 | BUG_ON(!ctx->mrec); | ||
223 | } | ||
224 | /* | ||
225 | * If the old mapped inode is not the base | ||
226 | * inode, map it. | ||
227 | */ | ||
228 | if (old_ctx.base_ntfs_ino && | ||
229 | old_ctx.ntfs_ino != | ||
230 | old_ctx.base_ntfs_ino) { | ||
231 | retry_map: | ||
232 | ctx->mrec = map_mft_record( | ||
233 | old_ctx.ntfs_ino); | ||
234 | /* | ||
235 | * Something bad has happened. If out | ||
236 | * of memory retry till it succeeds. | ||
237 | * Any other errors are fatal and we | ||
238 | * return the error code in ctx->mrec. | ||
239 | * Let the caller deal with it... We | ||
240 | * just need to fudge things so the | ||
241 | * caller can reinit and/or put the | ||
242 | * search context safely. | ||
243 | */ | ||
244 | if (IS_ERR(ctx->mrec)) { | ||
245 | if (PTR_ERR(ctx->mrec) == | ||
246 | -ENOMEM) { | ||
247 | schedule(); | ||
248 | goto retry_map; | ||
249 | } else | ||
250 | old_ctx.ntfs_ino = | ||
251 | old_ctx. | ||
252 | base_ntfs_ino; | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | /* Update the changed pointers in the saved context. */ | ||
257 | if (ctx->mrec != old_ctx.mrec) { | ||
258 | if (!IS_ERR(ctx->mrec)) | ||
259 | old_ctx.attr = (ATTR_RECORD*)( | ||
260 | (u8*)ctx->mrec + | ||
261 | ((u8*)old_ctx.attr - | ||
262 | (u8*)old_ctx.mrec)); | ||
263 | old_ctx.mrec = ctx->mrec; | ||
264 | } | ||
265 | } | ||
266 | /* Restore the search context to the saved one. */ | ||
267 | *ctx = old_ctx; | ||
268 | /* | ||
269 | * We drop the reference on the page we took earlier. In the | ||
270 | * case that IS_ERR(ctx->mrec) is true this means we might lose | ||
271 | * some changes to the mft record that had been made between | ||
272 | * the last time it was marked dirty/written out and now. This | ||
273 | * at this stage is not a problem as the mapping error is fatal | ||
274 | * enough that the mft record cannot be written out anyway and | ||
275 | * the caller is very likely to shutdown the whole inode | ||
276 | * immediately and mark the volume dirty for chkdsk to pick up | ||
277 | * the pieces anyway. | ||
278 | */ | ||
279 | if (put_this_page) | ||
280 | page_cache_release(put_this_page); | ||
281 | } | ||
110 | return err; | 282 | return err; |
111 | } | 283 | } |
112 | 284 | ||
@@ -122,8 +294,8 @@ err_out: | |||
122 | * of bounds of the runlist. | 294 | * of bounds of the runlist. |
123 | * | 295 | * |
124 | * Locking: - The runlist must be unlocked on entry and is unlocked on return. | 296 | * Locking: - The runlist must be unlocked on entry and is unlocked on return. |
125 | * - This function takes the runlist lock for writing and modifies the | 297 | * - This function takes the runlist lock for writing and may modify |
126 | * runlist. | 298 | * the runlist. |
127 | */ | 299 | */ |
128 | int ntfs_map_runlist(ntfs_inode *ni, VCN vcn) | 300 | int ntfs_map_runlist(ntfs_inode *ni, VCN vcn) |
129 | { | 301 | { |
@@ -133,7 +305,7 @@ int ntfs_map_runlist(ntfs_inode *ni, VCN vcn) | |||
133 | /* Make sure someone else didn't do the work while we were sleeping. */ | 305 | /* Make sure someone else didn't do the work while we were sleeping. */ |
134 | if (likely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) <= | 306 | if (likely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) <= |
135 | LCN_RL_NOT_MAPPED)) | 307 | LCN_RL_NOT_MAPPED)) |
136 | err = ntfs_map_runlist_nolock(ni, vcn); | 308 | err = ntfs_map_runlist_nolock(ni, vcn, NULL); |
137 | up_write(&ni->runlist.lock); | 309 | up_write(&ni->runlist.lock); |
138 | return err; | 310 | return err; |
139 | } | 311 | } |
@@ -212,7 +384,7 @@ retry_remap: | |||
212 | goto retry_remap; | 384 | goto retry_remap; |
213 | } | 385 | } |
214 | } | 386 | } |
215 | err = ntfs_map_runlist_nolock(ni, vcn); | 387 | err = ntfs_map_runlist_nolock(ni, vcn, NULL); |
216 | if (!write_locked) { | 388 | if (!write_locked) { |
217 | up_write(&ni->runlist.lock); | 389 | up_write(&ni->runlist.lock); |
218 | down_read(&ni->runlist.lock); | 390 | down_read(&ni->runlist.lock); |
@@ -236,9 +408,9 @@ retry_remap: | |||
236 | 408 | ||
237 | /** | 409 | /** |
238 | * ntfs_attr_find_vcn_nolock - find a vcn in the runlist of an ntfs inode | 410 | * ntfs_attr_find_vcn_nolock - find a vcn in the runlist of an ntfs inode |
239 | * @ni: ntfs inode describing the runlist to search | 411 | * @ni: ntfs inode describing the runlist to search |
240 | * @vcn: vcn to find | 412 | * @vcn: vcn to find |
241 | * @write_locked: true if the runlist is locked for writing | 413 | * @ctx: active attribute search context if present or NULL if not |
242 | * | 414 | * |
243 | * Find the virtual cluster number @vcn in the runlist described by the ntfs | 415 | * Find the virtual cluster number @vcn in the runlist described by the ntfs |
244 | * inode @ni and return the address of the runlist element containing the @vcn. | 416 | * inode @ni and return the address of the runlist element containing the @vcn. |
@@ -246,9 +418,22 @@ retry_remap: | |||
246 | * If the @vcn is not mapped yet, the attempt is made to map the attribute | 418 | * If the @vcn is not mapped yet, the attempt is made to map the attribute |
247 | * extent containing the @vcn and the vcn to lcn conversion is retried. | 419 | * extent containing the @vcn and the vcn to lcn conversion is retried. |
248 | * | 420 | * |
249 | * If @write_locked is true the caller has locked the runlist for writing and | 421 | * If @ctx is specified, it is an active search context of @ni and its base mft |
250 | * if false for reading. | 422 | * record. This is needed when ntfs_attr_find_vcn_nolock() encounters unmapped |
251 | * | 423 | * runlist fragments and allows their mapping. If you do not have the mft |
424 | * record mapped, you can specify @ctx as NULL and ntfs_attr_find_vcn_nolock() | ||
425 | * will perform the necessary mapping and unmapping. | ||
426 | * | ||
427 | * Note, ntfs_attr_find_vcn_nolock() saves the state of @ctx on entry and | ||
428 | * restores it before returning. Thus, @ctx will be left pointing to the same | ||
429 | * attribute on return as on entry. However, the actual pointers in @ctx may | ||
430 | * point to different memory locations on return, so you must remember to reset | ||
431 | * any cached pointers from the @ctx, i.e. after the call to | ||
432 | * ntfs_attr_find_vcn_nolock(), you will probably want to do: | ||
433 | * m = ctx->mrec; | ||
434 | * a = ctx->attr; | ||
435 | * Assuming you cache ctx->attr in a variable @a of type ATTR_RECORD * and that | ||
436 | * you cache ctx->mrec in a variable @m of type MFT_RECORD *. | ||
252 | * Note you need to distinguish between the lcn of the returned runlist element | 437 | * Note you need to distinguish between the lcn of the returned runlist element |
253 | * being >= 0 and LCN_HOLE. In the later case you have to return zeroes on | 438 | * being >= 0 and LCN_HOLE. In the later case you have to return zeroes on |
254 | * read and allocate clusters on write. | 439 | * read and allocate clusters on write. |
@@ -263,22 +448,31 @@ retry_remap: | |||
263 | * -ENOMEM - Not enough memory to map runlist. | 448 | * -ENOMEM - Not enough memory to map runlist. |
264 | * -EIO - Critical error (runlist/file is corrupt, i/o error, etc). | 449 | * -EIO - Critical error (runlist/file is corrupt, i/o error, etc). |
265 | * | 450 | * |
266 | * Locking: - The runlist must be locked on entry and is left locked on return. | 451 | * WARNING: If @ctx is supplied, regardless of whether success or failure is |
267 | * - If @write_locked is FALSE, i.e. the runlist is locked for reading, | 452 | * returned, you need to check IS_ERR(@ctx->mrec) and if TRUE the @ctx |
268 | * the lock may be dropped inside the function so you cannot rely on | 453 | * is no longer valid, i.e. you need to either call |
269 | * the runlist still being the same when this function returns. | 454 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. |
455 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for | ||
456 | * why the mapping of the old inode failed. | ||
457 | * | ||
458 | * Locking: - The runlist described by @ni must be locked for writing on entry | ||
459 | * and is locked on return. Note the runlist may be modified when | ||
460 | * needed runlist fragments need to be mapped. | ||
461 | * - If @ctx is NULL, the base mft record of @ni must not be mapped on | ||
462 | * entry and it will be left unmapped on return. | ||
463 | * - If @ctx is not NULL, the base mft record must be mapped on entry | ||
464 | * and it will be left mapped on return. | ||
270 | */ | 465 | */ |
271 | runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, const VCN vcn, | 466 | runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, const VCN vcn, |
272 | const BOOL write_locked) | 467 | ntfs_attr_search_ctx *ctx) |
273 | { | 468 | { |
274 | unsigned long flags; | 469 | unsigned long flags; |
275 | runlist_element *rl; | 470 | runlist_element *rl; |
276 | int err = 0; | 471 | int err = 0; |
277 | BOOL is_retry = FALSE; | 472 | BOOL is_retry = FALSE; |
278 | 473 | ||
279 | ntfs_debug("Entering for i_ino 0x%lx, vcn 0x%llx, %s_locked.", | 474 | ntfs_debug("Entering for i_ino 0x%lx, vcn 0x%llx, with%s ctx.", |
280 | ni->mft_no, (unsigned long long)vcn, | 475 | ni->mft_no, (unsigned long long)vcn, ctx ? "" : "out"); |
281 | write_locked ? "write" : "read"); | ||
282 | BUG_ON(!ni); | 476 | BUG_ON(!ni); |
283 | BUG_ON(!NInoNonResident(ni)); | 477 | BUG_ON(!NInoNonResident(ni)); |
284 | BUG_ON(vcn < 0); | 478 | BUG_ON(vcn < 0); |
@@ -312,33 +506,22 @@ retry_remap: | |||
312 | } | 506 | } |
313 | if (!err && !is_retry) { | 507 | if (!err && !is_retry) { |
314 | /* | 508 | /* |
315 | * The @vcn is in an unmapped region, map the runlist and | 509 | * If the search context is invalid we cannot map the unmapped |
316 | * retry. | 510 | * region. |
317 | */ | 511 | */ |
318 | if (!write_locked) { | 512 | if (IS_ERR(ctx->mrec)) |
319 | up_read(&ni->runlist.lock); | 513 | err = PTR_ERR(ctx->mrec); |
320 | down_write(&ni->runlist.lock); | 514 | else { |
321 | if (unlikely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) != | 515 | /* |
322 | LCN_RL_NOT_MAPPED)) { | 516 | * The @vcn is in an unmapped region, map the runlist |
323 | up_write(&ni->runlist.lock); | 517 | * and retry. |
324 | down_read(&ni->runlist.lock); | 518 | */ |
519 | err = ntfs_map_runlist_nolock(ni, vcn, ctx); | ||
520 | if (likely(!err)) { | ||
521 | is_retry = TRUE; | ||
325 | goto retry_remap; | 522 | goto retry_remap; |
326 | } | 523 | } |
327 | } | 524 | } |
328 | err = ntfs_map_runlist_nolock(ni, vcn); | ||
329 | if (!write_locked) { | ||
330 | up_write(&ni->runlist.lock); | ||
331 | down_read(&ni->runlist.lock); | ||
332 | } | ||
333 | if (likely(!err)) { | ||
334 | is_retry = TRUE; | ||
335 | goto retry_remap; | ||
336 | } | ||
337 | /* | ||
338 | * -EINVAL coming from a failed mapping attempt is equivalent | ||
339 | * to i/o error for us as it should not happen in our code | ||
340 | * paths. | ||
341 | */ | ||
342 | if (err == -EINVAL) | 525 | if (err == -EINVAL) |
343 | err = -EIO; | 526 | err = -EIO; |
344 | } else if (!err) | 527 | } else if (!err) |
@@ -1011,6 +1194,7 @@ int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name, | |||
1011 | ntfs_inode *base_ni; | 1194 | ntfs_inode *base_ni; |
1012 | 1195 | ||
1013 | ntfs_debug("Entering."); | 1196 | ntfs_debug("Entering."); |
1197 | BUG_ON(IS_ERR(ctx->mrec)); | ||
1014 | if (ctx->base_ntfs_ino) | 1198 | if (ctx->base_ntfs_ino) |
1015 | base_ni = ctx->base_ntfs_ino; | 1199 | base_ni = ctx->base_ntfs_ino; |
1016 | else | 1200 | else |
@@ -1227,7 +1411,7 @@ int ntfs_attr_can_be_non_resident(const ntfs_volume *vol, const ATTR_TYPE type) | |||
1227 | */ | 1411 | */ |
1228 | int ntfs_attr_can_be_resident(const ntfs_volume *vol, const ATTR_TYPE type) | 1412 | int ntfs_attr_can_be_resident(const ntfs_volume *vol, const ATTR_TYPE type) |
1229 | { | 1413 | { |
1230 | if (type == AT_INDEX_ALLOCATION || type == AT_EA) | 1414 | if (type == AT_INDEX_ALLOCATION) |
1231 | return -EPERM; | 1415 | return -EPERM; |
1232 | return 0; | 1416 | return 0; |
1233 | } | 1417 | } |
@@ -1319,10 +1503,17 @@ int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a, | |||
1319 | /** | 1503 | /** |
1320 | * ntfs_attr_make_non_resident - convert a resident to a non-resident attribute | 1504 | * ntfs_attr_make_non_resident - convert a resident to a non-resident attribute |
1321 | * @ni: ntfs inode describing the attribute to convert | 1505 | * @ni: ntfs inode describing the attribute to convert |
1506 | * @data_size: size of the resident data to copy to the non-resident attribute | ||
1322 | * | 1507 | * |
1323 | * Convert the resident ntfs attribute described by the ntfs inode @ni to a | 1508 | * Convert the resident ntfs attribute described by the ntfs inode @ni to a |
1324 | * non-resident one. | 1509 | * non-resident one. |
1325 | * | 1510 | * |
1511 | * @data_size must be equal to the attribute value size. This is needed since | ||
1512 | * we need to know the size before we can map the mft record and our callers | ||
1513 | * always know it. The reason we cannot simply read the size from the vfs | ||
1514 | * inode i_size is that this is not necessarily uptodate. This happens when | ||
1515 | * ntfs_attr_make_non_resident() is called in the ->truncate call path(s). | ||
1516 | * | ||
1326 | * Return 0 on success and -errno on error. The following error return codes | 1517 | * Return 0 on success and -errno on error. The following error return codes |
1327 | * are defined: | 1518 | * are defined: |
1328 | * -EPERM - The attribute is not allowed to be non-resident. | 1519 | * -EPERM - The attribute is not allowed to be non-resident. |
@@ -1343,7 +1534,7 @@ int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a, | |||
1343 | * | 1534 | * |
1344 | * Locking: - The caller must hold i_sem on the inode. | 1535 | * Locking: - The caller must hold i_sem on the inode. |
1345 | */ | 1536 | */ |
1346 | int ntfs_attr_make_non_resident(ntfs_inode *ni) | 1537 | int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size) |
1347 | { | 1538 | { |
1348 | s64 new_size; | 1539 | s64 new_size; |
1349 | struct inode *vi = VFS_I(ni); | 1540 | struct inode *vi = VFS_I(ni); |
@@ -1381,11 +1572,9 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni) | |||
1381 | * The size needs to be aligned to a cluster boundary for allocation | 1572 | * The size needs to be aligned to a cluster boundary for allocation |
1382 | * purposes. | 1573 | * purposes. |
1383 | */ | 1574 | */ |
1384 | new_size = (i_size_read(vi) + vol->cluster_size - 1) & | 1575 | new_size = (data_size + vol->cluster_size - 1) & |
1385 | ~(vol->cluster_size - 1); | 1576 | ~(vol->cluster_size - 1); |
1386 | if (new_size > 0) { | 1577 | if (new_size > 0) { |
1387 | runlist_element *rl2; | ||
1388 | |||
1389 | /* | 1578 | /* |
1390 | * Will need the page later and since the page lock nests | 1579 | * Will need the page later and since the page lock nests |
1391 | * outside all ntfs locks, we need to get the page now. | 1580 | * outside all ntfs locks, we need to get the page now. |
@@ -1396,7 +1585,7 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni) | |||
1396 | return -ENOMEM; | 1585 | return -ENOMEM; |
1397 | /* Start by allocating clusters to hold the attribute value. */ | 1586 | /* Start by allocating clusters to hold the attribute value. */ |
1398 | rl = ntfs_cluster_alloc(vol, 0, new_size >> | 1587 | rl = ntfs_cluster_alloc(vol, 0, new_size >> |
1399 | vol->cluster_size_bits, -1, DATA_ZONE); | 1588 | vol->cluster_size_bits, -1, DATA_ZONE, TRUE); |
1400 | if (IS_ERR(rl)) { | 1589 | if (IS_ERR(rl)) { |
1401 | err = PTR_ERR(rl); | 1590 | err = PTR_ERR(rl); |
1402 | ntfs_debug("Failed to allocate cluster%s, error code " | 1591 | ntfs_debug("Failed to allocate cluster%s, error code " |
@@ -1405,12 +1594,6 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni) | |||
1405 | err); | 1594 | err); |
1406 | goto page_err_out; | 1595 | goto page_err_out; |
1407 | } | 1596 | } |
1408 | /* Change the runlist terminator to LCN_ENOENT. */ | ||
1409 | rl2 = rl; | ||
1410 | while (rl2->length) | ||
1411 | rl2++; | ||
1412 | BUG_ON(rl2->lcn != LCN_RL_NOT_MAPPED); | ||
1413 | rl2->lcn = LCN_ENOENT; | ||
1414 | } else { | 1597 | } else { |
1415 | rl = NULL; | 1598 | rl = NULL; |
1416 | page = NULL; | 1599 | page = NULL; |
@@ -1473,7 +1656,7 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni) | |||
1473 | * attribute value. | 1656 | * attribute value. |
1474 | */ | 1657 | */ |
1475 | attr_size = le32_to_cpu(a->data.resident.value_length); | 1658 | attr_size = le32_to_cpu(a->data.resident.value_length); |
1476 | BUG_ON(attr_size != i_size_read(vi)); | 1659 | BUG_ON(attr_size != data_size); |
1477 | if (page && !PageUptodate(page)) { | 1660 | if (page && !PageUptodate(page)) { |
1478 | kaddr = kmap_atomic(page, KM_USER0); | 1661 | kaddr = kmap_atomic(page, KM_USER0); |
1479 | memcpy(kaddr, (u8*)a + | 1662 | memcpy(kaddr, (u8*)a + |
@@ -1538,7 +1721,9 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni) | |||
1538 | ffs(ni->itype.compressed.block_size) - 1; | 1721 | ffs(ni->itype.compressed.block_size) - 1; |
1539 | ni->itype.compressed.block_clusters = 1U << | 1722 | ni->itype.compressed.block_clusters = 1U << |
1540 | a->data.non_resident.compression_unit; | 1723 | a->data.non_resident.compression_unit; |
1541 | } | 1724 | vi->i_blocks = ni->itype.compressed.size >> 9; |
1725 | } else | ||
1726 | vi->i_blocks = ni->allocated_size >> 9; | ||
1542 | write_unlock_irqrestore(&ni->size_lock, flags); | 1727 | write_unlock_irqrestore(&ni->size_lock, flags); |
1543 | /* | 1728 | /* |
1544 | * This needs to be last since the address space operations ->readpage | 1729 | * This needs to be last since the address space operations ->readpage |
@@ -1652,6 +1837,640 @@ page_err_out: | |||
1652 | } | 1837 | } |
1653 | 1838 | ||
1654 | /** | 1839 | /** |
1840 | * ntfs_attr_extend_allocation - extend the allocated space of an attribute | ||
1841 | * @ni: ntfs inode of the attribute whose allocation to extend | ||
1842 | * @new_alloc_size: new size in bytes to which to extend the allocation to | ||
1843 | * @new_data_size: new size in bytes to which to extend the data to | ||
1844 | * @data_start: beginning of region which is required to be non-sparse | ||
1845 | * | ||
1846 | * Extend the allocated space of an attribute described by the ntfs inode @ni | ||
1847 | * to @new_alloc_size bytes. If @data_start is -1, the whole extension may be | ||
1848 | * implemented as a hole in the file (as long as both the volume and the ntfs | ||
1849 | * inode @ni have sparse support enabled). If @data_start is >= 0, then the | ||
1850 | * region between the old allocated size and @data_start - 1 may be made sparse | ||
1851 | * but the regions between @data_start and @new_alloc_size must be backed by | ||
1852 | * actual clusters. | ||
1853 | * | ||
1854 | * If @new_data_size is -1, it is ignored. If it is >= 0, then the data size | ||
1855 | * of the attribute is extended to @new_data_size. Note that the i_size of the | ||
1856 | * vfs inode is not updated. Only the data size in the base attribute record | ||
1857 | * is updated. The caller has to update i_size separately if this is required. | ||
1858 | * WARNING: It is a BUG() for @new_data_size to be smaller than the old data | ||
1859 | * size as well as for @new_data_size to be greater than @new_alloc_size. | ||
1860 | * | ||
1861 | * For resident attributes this involves resizing the attribute record and if | ||
1862 | * necessary moving it and/or other attributes into extent mft records and/or | ||
1863 | * converting the attribute to a non-resident attribute which in turn involves | ||
1864 | * extending the allocation of a non-resident attribute as described below. | ||
1865 | * | ||
1866 | * For non-resident attributes this involves allocating clusters in the data | ||
1867 | * zone on the volume (except for regions that are being made sparse) and | ||
1868 | * extending the run list to describe the allocated clusters as well as | ||
1869 | * updating the mapping pairs array of the attribute. This in turn involves | ||
1870 | * resizing the attribute record and if necessary moving it and/or other | ||
1871 | * attributes into extent mft records and/or splitting the attribute record | ||
1872 | * into multiple extent attribute records. | ||
1873 | * | ||
1874 | * Also, the attribute list attribute is updated if present and in some of the | ||
1875 | * above cases (the ones where extent mft records/attributes come into play), | ||
1876 | * an attribute list attribute is created if not already present. | ||
1877 | * | ||
1878 | * Return the new allocated size on success and -errno on error. In the case | ||
1879 | * that an error is encountered but a partial extension at least up to | ||
1880 | * @data_start (if present) is possible, the allocation is partially extended | ||
1881 | * and this is returned. This means the caller must check the returned size to | ||
1882 | * determine if the extension was partial. If @data_start is -1 then partial | ||
1883 | * allocations are not performed. | ||
1884 | * | ||
1885 | * WARNING: Do not call ntfs_attr_extend_allocation() for $MFT/$DATA. | ||
1886 | * | ||
1887 | * Locking: This function takes the runlist lock of @ni for writing as well as | ||
1888 | * locking the mft record of the base ntfs inode. These locks are maintained | ||
1889 | * throughout execution of the function. These locks are required so that the | ||
1890 | * attribute can be resized safely and so that it can for example be converted | ||
1891 | * from resident to non-resident safely. | ||
1892 | * | ||
1893 | * TODO: At present attribute list attribute handling is not implemented. | ||
1894 | * | ||
1895 | * TODO: At present it is not safe to call this function for anything other | ||
1896 | * than the $DATA attribute(s) of an uncompressed and unencrypted file. | ||
1897 | */ | ||
1898 | s64 ntfs_attr_extend_allocation(ntfs_inode *ni, s64 new_alloc_size, | ||
1899 | const s64 new_data_size, const s64 data_start) | ||
1900 | { | ||
1901 | VCN vcn; | ||
1902 | s64 ll, allocated_size, start = data_start; | ||
1903 | struct inode *vi = VFS_I(ni); | ||
1904 | ntfs_volume *vol = ni->vol; | ||
1905 | ntfs_inode *base_ni; | ||
1906 | MFT_RECORD *m; | ||
1907 | ATTR_RECORD *a; | ||
1908 | ntfs_attr_search_ctx *ctx; | ||
1909 | runlist_element *rl, *rl2; | ||
1910 | unsigned long flags; | ||
1911 | int err, mp_size; | ||
1912 | u32 attr_len = 0; /* Silence stupid gcc warning. */ | ||
1913 | BOOL mp_rebuilt; | ||
1914 | |||
1915 | #ifdef NTFS_DEBUG | ||
1916 | read_lock_irqsave(&ni->size_lock, flags); | ||
1917 | allocated_size = ni->allocated_size; | ||
1918 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
1919 | ntfs_debug("Entering for i_ino 0x%lx, attribute type 0x%x, " | ||
1920 | "old_allocated_size 0x%llx, " | ||
1921 | "new_allocated_size 0x%llx, new_data_size 0x%llx, " | ||
1922 | "data_start 0x%llx.", vi->i_ino, | ||
1923 | (unsigned)le32_to_cpu(ni->type), | ||
1924 | (unsigned long long)allocated_size, | ||
1925 | (unsigned long long)new_alloc_size, | ||
1926 | (unsigned long long)new_data_size, | ||
1927 | (unsigned long long)start); | ||
1928 | #endif | ||
1929 | retry_extend: | ||
1930 | /* | ||
1931 | * For non-resident attributes, @start and @new_size need to be aligned | ||
1932 | * to cluster boundaries for allocation purposes. | ||
1933 | */ | ||
1934 | if (NInoNonResident(ni)) { | ||
1935 | if (start > 0) | ||
1936 | start &= ~(s64)vol->cluster_size_mask; | ||
1937 | new_alloc_size = (new_alloc_size + vol->cluster_size - 1) & | ||
1938 | ~(s64)vol->cluster_size_mask; | ||
1939 | } | ||
1940 | BUG_ON(new_data_size >= 0 && new_data_size > new_alloc_size); | ||
1941 | /* Check if new size is allowed in $AttrDef. */ | ||
1942 | err = ntfs_attr_size_bounds_check(vol, ni->type, new_alloc_size); | ||
1943 | if (unlikely(err)) { | ||
1944 | /* Only emit errors when the write will fail completely. */ | ||
1945 | read_lock_irqsave(&ni->size_lock, flags); | ||
1946 | allocated_size = ni->allocated_size; | ||
1947 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
1948 | if (start < 0 || start >= allocated_size) { | ||
1949 | if (err == -ERANGE) { | ||
1950 | ntfs_error(vol->sb, "Cannot extend allocation " | ||
1951 | "of inode 0x%lx, attribute " | ||
1952 | "type 0x%x, because the new " | ||
1953 | "allocation would exceed the " | ||
1954 | "maximum allowed size for " | ||
1955 | "this attribute type.", | ||
1956 | vi->i_ino, (unsigned) | ||
1957 | le32_to_cpu(ni->type)); | ||
1958 | } else { | ||
1959 | ntfs_error(vol->sb, "Cannot extend allocation " | ||
1960 | "of inode 0x%lx, attribute " | ||
1961 | "type 0x%x, because this " | ||
1962 | "attribute type is not " | ||
1963 | "defined on the NTFS volume. " | ||
1964 | "Possible corruption! You " | ||
1965 | "should run chkdsk!", | ||
1966 | vi->i_ino, (unsigned) | ||
1967 | le32_to_cpu(ni->type)); | ||
1968 | } | ||
1969 | } | ||
1970 | /* Translate error code to be POSIX conformant for write(2). */ | ||
1971 | if (err == -ERANGE) | ||
1972 | err = -EFBIG; | ||
1973 | else | ||
1974 | err = -EIO; | ||
1975 | return err; | ||
1976 | } | ||
1977 | if (!NInoAttr(ni)) | ||
1978 | base_ni = ni; | ||
1979 | else | ||
1980 | base_ni = ni->ext.base_ntfs_ino; | ||
1981 | /* | ||
1982 | * We will be modifying both the runlist (if non-resident) and the mft | ||
1983 | * record so lock them both down. | ||
1984 | */ | ||
1985 | down_write(&ni->runlist.lock); | ||
1986 | m = map_mft_record(base_ni); | ||
1987 | if (IS_ERR(m)) { | ||
1988 | err = PTR_ERR(m); | ||
1989 | m = NULL; | ||
1990 | ctx = NULL; | ||
1991 | goto err_out; | ||
1992 | } | ||
1993 | ctx = ntfs_attr_get_search_ctx(base_ni, m); | ||
1994 | if (unlikely(!ctx)) { | ||
1995 | err = -ENOMEM; | ||
1996 | goto err_out; | ||
1997 | } | ||
1998 | read_lock_irqsave(&ni->size_lock, flags); | ||
1999 | allocated_size = ni->allocated_size; | ||
2000 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
2001 | /* | ||
2002 | * If non-resident, seek to the last extent. If resident, there is | ||
2003 | * only one extent, so seek to that. | ||
2004 | */ | ||
2005 | vcn = NInoNonResident(ni) ? allocated_size >> vol->cluster_size_bits : | ||
2006 | 0; | ||
2007 | /* | ||
2008 | * Abort if someone did the work whilst we waited for the locks. If we | ||
2009 | * just converted the attribute from resident to non-resident it is | ||
2010 | * likely that exactly this has happened already. We cannot quite | ||
2011 | * abort if we need to update the data size. | ||
2012 | */ | ||
2013 | if (unlikely(new_alloc_size <= allocated_size)) { | ||
2014 | ntfs_debug("Allocated size already exceeds requested size."); | ||
2015 | new_alloc_size = allocated_size; | ||
2016 | if (new_data_size < 0) | ||
2017 | goto done; | ||
2018 | /* | ||
2019 | * We want the first attribute extent so that we can update the | ||
2020 | * data size. | ||
2021 | */ | ||
2022 | vcn = 0; | ||
2023 | } | ||
2024 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
2025 | CASE_SENSITIVE, vcn, NULL, 0, ctx); | ||
2026 | if (unlikely(err)) { | ||
2027 | if (err == -ENOENT) | ||
2028 | err = -EIO; | ||
2029 | goto err_out; | ||
2030 | } | ||
2031 | m = ctx->mrec; | ||
2032 | a = ctx->attr; | ||
2033 | /* Use goto to reduce indentation. */ | ||
2034 | if (a->non_resident) | ||
2035 | goto do_non_resident_extend; | ||
2036 | BUG_ON(NInoNonResident(ni)); | ||
2037 | /* The total length of the attribute value. */ | ||
2038 | attr_len = le32_to_cpu(a->data.resident.value_length); | ||
2039 | /* | ||
2040 | * Extend the attribute record to be able to store the new attribute | ||
2041 | * size. ntfs_attr_record_resize() will not do anything if the size is | ||
2042 | * not changing. | ||
2043 | */ | ||
2044 | if (new_alloc_size < vol->mft_record_size && | ||
2045 | !ntfs_attr_record_resize(m, a, | ||
2046 | le16_to_cpu(a->data.resident.value_offset) + | ||
2047 | new_alloc_size)) { | ||
2048 | /* The resize succeeded! */ | ||
2049 | write_lock_irqsave(&ni->size_lock, flags); | ||
2050 | ni->allocated_size = le32_to_cpu(a->length) - | ||
2051 | le16_to_cpu(a->data.resident.value_offset); | ||
2052 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
2053 | if (new_data_size >= 0) { | ||
2054 | BUG_ON(new_data_size < attr_len); | ||
2055 | a->data.resident.value_length = | ||
2056 | cpu_to_le32((u32)new_data_size); | ||
2057 | } | ||
2058 | goto flush_done; | ||
2059 | } | ||
2060 | /* | ||
2061 | * We have to drop all the locks so we can call | ||
2062 | * ntfs_attr_make_non_resident(). This could be optimised by try- | ||
2063 | * locking the first page cache page and only if that fails dropping | ||
2064 | * the locks, locking the page, and redoing all the locking and | ||
2065 | * lookups. While this would be a huge optimisation, it is not worth | ||
2066 | * it as this is definitely a slow code path. | ||
2067 | */ | ||
2068 | ntfs_attr_put_search_ctx(ctx); | ||
2069 | unmap_mft_record(base_ni); | ||
2070 | up_write(&ni->runlist.lock); | ||
2071 | /* | ||
2072 | * Not enough space in the mft record, try to make the attribute | ||
2073 | * non-resident and if successful restart the extension process. | ||
2074 | */ | ||
2075 | err = ntfs_attr_make_non_resident(ni, attr_len); | ||
2076 | if (likely(!err)) | ||
2077 | goto retry_extend; | ||
2078 | /* | ||
2079 | * Could not make non-resident. If this is due to this not being | ||
2080 | * permitted for this attribute type or there not being enough space, | ||
2081 | * try to make other attributes non-resident. Otherwise fail. | ||
2082 | */ | ||
2083 | if (unlikely(err != -EPERM && err != -ENOSPC)) { | ||
2084 | /* Only emit errors when the write will fail completely. */ | ||
2085 | read_lock_irqsave(&ni->size_lock, flags); | ||
2086 | allocated_size = ni->allocated_size; | ||
2087 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
2088 | if (start < 0 || start >= allocated_size) | ||
2089 | ntfs_error(vol->sb, "Cannot extend allocation of " | ||
2090 | "inode 0x%lx, attribute type 0x%x, " | ||
2091 | "because the conversion from resident " | ||
2092 | "to non-resident attribute failed " | ||
2093 | "with error code %i.", vi->i_ino, | ||
2094 | (unsigned)le32_to_cpu(ni->type), err); | ||
2095 | if (err != -ENOMEM) | ||
2096 | err = -EIO; | ||
2097 | goto conv_err_out; | ||
2098 | } | ||
2099 | /* TODO: Not implemented from here, abort. */ | ||
2100 | read_lock_irqsave(&ni->size_lock, flags); | ||
2101 | allocated_size = ni->allocated_size; | ||
2102 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
2103 | if (start < 0 || start >= allocated_size) { | ||
2104 | if (err == -ENOSPC) | ||
2105 | ntfs_error(vol->sb, "Not enough space in the mft " | ||
2106 | "record/on disk for the non-resident " | ||
2107 | "attribute value. This case is not " | ||
2108 | "implemented yet."); | ||
2109 | else /* if (err == -EPERM) */ | ||
2110 | ntfs_error(vol->sb, "This attribute type may not be " | ||
2111 | "non-resident. This case is not " | ||
2112 | "implemented yet."); | ||
2113 | } | ||
2114 | err = -EOPNOTSUPP; | ||
2115 | goto conv_err_out; | ||
2116 | #if 0 | ||
2117 | // TODO: Attempt to make other attributes non-resident. | ||
2118 | if (!err) | ||
2119 | goto do_resident_extend; | ||
2120 | /* | ||
2121 | * Both the attribute list attribute and the standard information | ||
2122 | * attribute must remain in the base inode. Thus, if this is one of | ||
2123 | * these attributes, we have to try to move other attributes out into | ||
2124 | * extent mft records instead. | ||
2125 | */ | ||
2126 | if (ni->type == AT_ATTRIBUTE_LIST || | ||
2127 | ni->type == AT_STANDARD_INFORMATION) { | ||
2128 | // TODO: Attempt to move other attributes into extent mft | ||
2129 | // records. | ||
2130 | err = -EOPNOTSUPP; | ||
2131 | if (!err) | ||
2132 | goto do_resident_extend; | ||
2133 | goto err_out; | ||
2134 | } | ||
2135 | // TODO: Attempt to move this attribute to an extent mft record, but | ||
2136 | // only if it is not already the only attribute in an mft record in | ||
2137 | // which case there would be nothing to gain. | ||
2138 | err = -EOPNOTSUPP; | ||
2139 | if (!err) | ||
2140 | goto do_resident_extend; | ||
2141 | /* There is nothing we can do to make enough space. )-: */ | ||
2142 | goto err_out; | ||
2143 | #endif | ||
2144 | do_non_resident_extend: | ||
2145 | BUG_ON(!NInoNonResident(ni)); | ||
2146 | if (new_alloc_size == allocated_size) { | ||
2147 | BUG_ON(vcn); | ||
2148 | goto alloc_done; | ||
2149 | } | ||
2150 | /* | ||
2151 | * If the data starts after the end of the old allocation, this is a | ||
2152 | * $DATA attribute and sparse attributes are enabled on the volume and | ||
2153 | * for this inode, then create a sparse region between the old | ||
2154 | * allocated size and the start of the data. Otherwise simply proceed | ||
2155 | * with filling the whole space between the old allocated size and the | ||
2156 | * new allocated size with clusters. | ||
2157 | */ | ||
2158 | if ((start >= 0 && start <= allocated_size) || ni->type != AT_DATA || | ||
2159 | !NVolSparseEnabled(vol) || NInoSparseDisabled(ni)) | ||
2160 | goto skip_sparse; | ||
2161 | // TODO: This is not implemented yet. We just fill in with real | ||
2162 | // clusters for now... | ||
2163 | ntfs_debug("Inserting holes is not-implemented yet. Falling back to " | ||
2164 | "allocating real clusters instead."); | ||
2165 | skip_sparse: | ||
2166 | rl = ni->runlist.rl; | ||
2167 | if (likely(rl)) { | ||
2168 | /* Seek to the end of the runlist. */ | ||
2169 | while (rl->length) | ||
2170 | rl++; | ||
2171 | } | ||
2172 | /* If this attribute extent is not mapped, map it now. */ | ||
2173 | if (unlikely(!rl || rl->lcn == LCN_RL_NOT_MAPPED || | ||
2174 | (rl->lcn == LCN_ENOENT && rl > ni->runlist.rl && | ||
2175 | (rl-1)->lcn == LCN_RL_NOT_MAPPED))) { | ||
2176 | if (!rl && !allocated_size) | ||
2177 | goto first_alloc; | ||
2178 | rl = ntfs_mapping_pairs_decompress(vol, a, ni->runlist.rl); | ||
2179 | if (IS_ERR(rl)) { | ||
2180 | err = PTR_ERR(rl); | ||
2181 | if (start < 0 || start >= allocated_size) | ||
2182 | ntfs_error(vol->sb, "Cannot extend allocation " | ||
2183 | "of inode 0x%lx, attribute " | ||
2184 | "type 0x%x, because the " | ||
2185 | "mapping of a runlist " | ||
2186 | "fragment failed with error " | ||
2187 | "code %i.", vi->i_ino, | ||
2188 | (unsigned)le32_to_cpu(ni->type), | ||
2189 | err); | ||
2190 | if (err != -ENOMEM) | ||
2191 | err = -EIO; | ||
2192 | goto err_out; | ||
2193 | } | ||
2194 | ni->runlist.rl = rl; | ||
2195 | /* Seek to the end of the runlist. */ | ||
2196 | while (rl->length) | ||
2197 | rl++; | ||
2198 | } | ||
2199 | /* | ||
2200 | * We now know the runlist of the last extent is mapped and @rl is at | ||
2201 | * the end of the runlist. We want to begin allocating clusters | ||
2202 | * starting at the last allocated cluster to reduce fragmentation. If | ||
2203 | * there are no valid LCNs in the attribute we let the cluster | ||
2204 | * allocator choose the starting cluster. | ||
2205 | */ | ||
2206 | /* If the last LCN is a hole or simillar seek back to last real LCN. */ | ||
2207 | while (rl->lcn < 0 && rl > ni->runlist.rl) | ||
2208 | rl--; | ||
2209 | first_alloc: | ||
2210 | // FIXME: Need to implement partial allocations so at least part of the | ||
2211 | // write can be performed when start >= 0. (Needed for POSIX write(2) | ||
2212 | // conformance.) | ||
2213 | rl2 = ntfs_cluster_alloc(vol, allocated_size >> vol->cluster_size_bits, | ||
2214 | (new_alloc_size - allocated_size) >> | ||
2215 | vol->cluster_size_bits, (rl && (rl->lcn >= 0)) ? | ||
2216 | rl->lcn + rl->length : -1, DATA_ZONE, TRUE); | ||
2217 | if (IS_ERR(rl2)) { | ||
2218 | err = PTR_ERR(rl2); | ||
2219 | if (start < 0 || start >= allocated_size) | ||
2220 | ntfs_error(vol->sb, "Cannot extend allocation of " | ||
2221 | "inode 0x%lx, attribute type 0x%x, " | ||
2222 | "because the allocation of clusters " | ||
2223 | "failed with error code %i.", vi->i_ino, | ||
2224 | (unsigned)le32_to_cpu(ni->type), err); | ||
2225 | if (err != -ENOMEM && err != -ENOSPC) | ||
2226 | err = -EIO; | ||
2227 | goto err_out; | ||
2228 | } | ||
2229 | rl = ntfs_runlists_merge(ni->runlist.rl, rl2); | ||
2230 | if (IS_ERR(rl)) { | ||
2231 | err = PTR_ERR(rl); | ||
2232 | if (start < 0 || start >= allocated_size) | ||
2233 | ntfs_error(vol->sb, "Cannot extend allocation of " | ||
2234 | "inode 0x%lx, attribute type 0x%x, " | ||
2235 | "because the runlist merge failed " | ||
2236 | "with error code %i.", vi->i_ino, | ||
2237 | (unsigned)le32_to_cpu(ni->type), err); | ||
2238 | if (err != -ENOMEM) | ||
2239 | err = -EIO; | ||
2240 | if (ntfs_cluster_free_from_rl(vol, rl2)) { | ||
2241 | ntfs_error(vol->sb, "Failed to release allocated " | ||
2242 | "cluster(s) in error code path. Run " | ||
2243 | "chkdsk to recover the lost " | ||
2244 | "cluster(s)."); | ||
2245 | NVolSetErrors(vol); | ||
2246 | } | ||
2247 | ntfs_free(rl2); | ||
2248 | goto err_out; | ||
2249 | } | ||
2250 | ni->runlist.rl = rl; | ||
2251 | ntfs_debug("Allocated 0x%llx clusters.", (long long)(new_alloc_size - | ||
2252 | allocated_size) >> vol->cluster_size_bits); | ||
2253 | /* Find the runlist element with which the attribute extent starts. */ | ||
2254 | ll = sle64_to_cpu(a->data.non_resident.lowest_vcn); | ||
2255 | rl2 = ntfs_rl_find_vcn_nolock(rl, ll); | ||
2256 | BUG_ON(!rl2); | ||
2257 | BUG_ON(!rl2->length); | ||
2258 | BUG_ON(rl2->lcn < LCN_HOLE); | ||
2259 | mp_rebuilt = FALSE; | ||
2260 | /* Get the size for the new mapping pairs array for this extent. */ | ||
2261 | mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll, -1); | ||
2262 | if (unlikely(mp_size <= 0)) { | ||
2263 | err = mp_size; | ||
2264 | if (start < 0 || start >= allocated_size) | ||
2265 | ntfs_error(vol->sb, "Cannot extend allocation of " | ||
2266 | "inode 0x%lx, attribute type 0x%x, " | ||
2267 | "because determining the size for the " | ||
2268 | "mapping pairs failed with error code " | ||
2269 | "%i.", vi->i_ino, | ||
2270 | (unsigned)le32_to_cpu(ni->type), err); | ||
2271 | err = -EIO; | ||
2272 | goto undo_alloc; | ||
2273 | } | ||
2274 | /* Extend the attribute record to fit the bigger mapping pairs array. */ | ||
2275 | attr_len = le32_to_cpu(a->length); | ||
2276 | err = ntfs_attr_record_resize(m, a, mp_size + | ||
2277 | le16_to_cpu(a->data.non_resident.mapping_pairs_offset)); | ||
2278 | if (unlikely(err)) { | ||
2279 | BUG_ON(err != -ENOSPC); | ||
2280 | // TODO: Deal with this by moving this extent to a new mft | ||
2281 | // record or by starting a new extent in a new mft record, | ||
2282 | // possibly by extending this extent partially and filling it | ||
2283 | // and creating a new extent for the remainder, or by making | ||
2284 | // other attributes non-resident and/or by moving other | ||
2285 | // attributes out of this mft record. | ||
2286 | if (start < 0 || start >= allocated_size) | ||
2287 | ntfs_error(vol->sb, "Not enough space in the mft " | ||
2288 | "record for the extended attribute " | ||
2289 | "record. This case is not " | ||
2290 | "implemented yet."); | ||
2291 | err = -EOPNOTSUPP; | ||
2292 | goto undo_alloc; | ||
2293 | } | ||
2294 | mp_rebuilt = TRUE; | ||
2295 | /* Generate the mapping pairs array directly into the attr record. */ | ||
2296 | err = ntfs_mapping_pairs_build(vol, (u8*)a + | ||
2297 | le16_to_cpu(a->data.non_resident.mapping_pairs_offset), | ||
2298 | mp_size, rl2, ll, -1, NULL); | ||
2299 | if (unlikely(err)) { | ||
2300 | if (start < 0 || start >= allocated_size) | ||
2301 | ntfs_error(vol->sb, "Cannot extend allocation of " | ||
2302 | "inode 0x%lx, attribute type 0x%x, " | ||
2303 | "because building the mapping pairs " | ||
2304 | "failed with error code %i.", vi->i_ino, | ||
2305 | (unsigned)le32_to_cpu(ni->type), err); | ||
2306 | err = -EIO; | ||
2307 | goto undo_alloc; | ||
2308 | } | ||
2309 | /* Update the highest_vcn. */ | ||
2310 | a->data.non_resident.highest_vcn = cpu_to_sle64((new_alloc_size >> | ||
2311 | vol->cluster_size_bits) - 1); | ||
2312 | /* | ||
2313 | * We now have extended the allocated size of the attribute. Reflect | ||
2314 | * this in the ntfs_inode structure and the attribute record. | ||
2315 | */ | ||
2316 | if (a->data.non_resident.lowest_vcn) { | ||
2317 | /* | ||
2318 | * We are not in the first attribute extent, switch to it, but | ||
2319 | * first ensure the changes will make it to disk later. | ||
2320 | */ | ||
2321 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
2322 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
2323 | ntfs_attr_reinit_search_ctx(ctx); | ||
2324 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
2325 | CASE_SENSITIVE, 0, NULL, 0, ctx); | ||
2326 | if (unlikely(err)) | ||
2327 | goto restore_undo_alloc; | ||
2328 | /* @m is not used any more so no need to set it. */ | ||
2329 | a = ctx->attr; | ||
2330 | } | ||
2331 | write_lock_irqsave(&ni->size_lock, flags); | ||
2332 | ni->allocated_size = new_alloc_size; | ||
2333 | a->data.non_resident.allocated_size = cpu_to_sle64(new_alloc_size); | ||
2334 | /* | ||
2335 | * FIXME: This would fail if @ni is a directory, $MFT, or an index, | ||
2336 | * since those can have sparse/compressed set. For example can be | ||
2337 | * set compressed even though it is not compressed itself and in that | ||
2338 | * case the bit means that files are to be created compressed in the | ||
2339 | * directory... At present this is ok as this code is only called for | ||
2340 | * regular files, and only for their $DATA attribute(s). | ||
2341 | * FIXME: The calculation is wrong if we created a hole above. For now | ||
2342 | * it does not matter as we never create holes. | ||
2343 | */ | ||
2344 | if (NInoSparse(ni) || NInoCompressed(ni)) { | ||
2345 | ni->itype.compressed.size += new_alloc_size - allocated_size; | ||
2346 | a->data.non_resident.compressed_size = | ||
2347 | cpu_to_sle64(ni->itype.compressed.size); | ||
2348 | vi->i_blocks = ni->itype.compressed.size >> 9; | ||
2349 | } else | ||
2350 | vi->i_blocks = new_alloc_size >> 9; | ||
2351 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
2352 | alloc_done: | ||
2353 | if (new_data_size >= 0) { | ||
2354 | BUG_ON(new_data_size < | ||
2355 | sle64_to_cpu(a->data.non_resident.data_size)); | ||
2356 | a->data.non_resident.data_size = cpu_to_sle64(new_data_size); | ||
2357 | } | ||
2358 | flush_done: | ||
2359 | /* Ensure the changes make it to disk. */ | ||
2360 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
2361 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
2362 | done: | ||
2363 | ntfs_attr_put_search_ctx(ctx); | ||
2364 | unmap_mft_record(base_ni); | ||
2365 | up_write(&ni->runlist.lock); | ||
2366 | ntfs_debug("Done, new_allocated_size 0x%llx.", | ||
2367 | (unsigned long long)new_alloc_size); | ||
2368 | return new_alloc_size; | ||
2369 | restore_undo_alloc: | ||
2370 | if (start < 0 || start >= allocated_size) | ||
2371 | ntfs_error(vol->sb, "Cannot complete extension of allocation " | ||
2372 | "of inode 0x%lx, attribute type 0x%x, because " | ||
2373 | "lookup of first attribute extent failed with " | ||
2374 | "error code %i.", vi->i_ino, | ||
2375 | (unsigned)le32_to_cpu(ni->type), err); | ||
2376 | if (err == -ENOENT) | ||
2377 | err = -EIO; | ||
2378 | ntfs_attr_reinit_search_ctx(ctx); | ||
2379 | if (ntfs_attr_lookup(ni->type, ni->name, ni->name_len, CASE_SENSITIVE, | ||
2380 | allocated_size >> vol->cluster_size_bits, NULL, 0, | ||
2381 | ctx)) { | ||
2382 | ntfs_error(vol->sb, "Failed to find last attribute extent of " | ||
2383 | "attribute in error code path. Run chkdsk to " | ||
2384 | "recover."); | ||
2385 | write_lock_irqsave(&ni->size_lock, flags); | ||
2386 | ni->allocated_size = new_alloc_size; | ||
2387 | /* | ||
2388 | * FIXME: This would fail if @ni is a directory... See above. | ||
2389 | * FIXME: The calculation is wrong if we created a hole above. | ||
2390 | * For now it does not matter as we never create holes. | ||
2391 | */ | ||
2392 | if (NInoSparse(ni) || NInoCompressed(ni)) { | ||
2393 | ni->itype.compressed.size += new_alloc_size - | ||
2394 | allocated_size; | ||
2395 | vi->i_blocks = ni->itype.compressed.size >> 9; | ||
2396 | } else | ||
2397 | vi->i_blocks = new_alloc_size >> 9; | ||
2398 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
2399 | ntfs_attr_put_search_ctx(ctx); | ||
2400 | unmap_mft_record(base_ni); | ||
2401 | up_write(&ni->runlist.lock); | ||
2402 | /* | ||
2403 | * The only thing that is now wrong is the allocated size of the | ||
2404 | * base attribute extent which chkdsk should be able to fix. | ||
2405 | */ | ||
2406 | NVolSetErrors(vol); | ||
2407 | return err; | ||
2408 | } | ||
2409 | ctx->attr->data.non_resident.highest_vcn = cpu_to_sle64( | ||
2410 | (allocated_size >> vol->cluster_size_bits) - 1); | ||
2411 | undo_alloc: | ||
2412 | ll = allocated_size >> vol->cluster_size_bits; | ||
2413 | if (ntfs_cluster_free(ni, ll, -1, ctx) < 0) { | ||
2414 | ntfs_error(vol->sb, "Failed to release allocated cluster(s) " | ||
2415 | "in error code path. Run chkdsk to recover " | ||
2416 | "the lost cluster(s)."); | ||
2417 | NVolSetErrors(vol); | ||
2418 | } | ||
2419 | m = ctx->mrec; | ||
2420 | a = ctx->attr; | ||
2421 | /* | ||
2422 | * If the runlist truncation fails and/or the search context is no | ||
2423 | * longer valid, we cannot resize the attribute record or build the | ||
2424 | * mapping pairs array thus we mark the inode bad so that no access to | ||
2425 | * the freed clusters can happen. | ||
2426 | */ | ||
2427 | if (ntfs_rl_truncate_nolock(vol, &ni->runlist, ll) || IS_ERR(m)) { | ||
2428 | ntfs_error(vol->sb, "Failed to %s in error code path. Run " | ||
2429 | "chkdsk to recover.", IS_ERR(m) ? | ||
2430 | "restore attribute search context" : | ||
2431 | "truncate attribute runlist"); | ||
2432 | make_bad_inode(vi); | ||
2433 | make_bad_inode(VFS_I(base_ni)); | ||
2434 | NVolSetErrors(vol); | ||
2435 | } else if (mp_rebuilt) { | ||
2436 | if (ntfs_attr_record_resize(m, a, attr_len)) { | ||
2437 | ntfs_error(vol->sb, "Failed to restore attribute " | ||
2438 | "record in error code path. Run " | ||
2439 | "chkdsk to recover."); | ||
2440 | make_bad_inode(vi); | ||
2441 | make_bad_inode(VFS_I(base_ni)); | ||
2442 | NVolSetErrors(vol); | ||
2443 | } else /* if (success) */ { | ||
2444 | if (ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu( | ||
2445 | a->data.non_resident. | ||
2446 | mapping_pairs_offset), attr_len - | ||
2447 | le16_to_cpu(a->data.non_resident. | ||
2448 | mapping_pairs_offset), rl2, ll, -1, | ||
2449 | NULL)) { | ||
2450 | ntfs_error(vol->sb, "Failed to restore " | ||
2451 | "mapping pairs array in error " | ||
2452 | "code path. Run chkdsk to " | ||
2453 | "recover."); | ||
2454 | make_bad_inode(vi); | ||
2455 | make_bad_inode(VFS_I(base_ni)); | ||
2456 | NVolSetErrors(vol); | ||
2457 | } | ||
2458 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
2459 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
2460 | } | ||
2461 | } | ||
2462 | err_out: | ||
2463 | if (ctx) | ||
2464 | ntfs_attr_put_search_ctx(ctx); | ||
2465 | if (m) | ||
2466 | unmap_mft_record(base_ni); | ||
2467 | up_write(&ni->runlist.lock); | ||
2468 | conv_err_out: | ||
2469 | ntfs_debug("Failed. Returning error code %i.", err); | ||
2470 | return err; | ||
2471 | } | ||
2472 | |||
2473 | /** | ||
1655 | * ntfs_attr_set - fill (a part of) an attribute with a byte | 2474 | * ntfs_attr_set - fill (a part of) an attribute with a byte |
1656 | * @ni: ntfs inode describing the attribute to fill | 2475 | * @ni: ntfs inode describing the attribute to fill |
1657 | * @ofs: offset inside the attribute at which to start to fill | 2476 | * @ofs: offset inside the attribute at which to start to fill |
@@ -1773,6 +2592,8 @@ int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val) | |||
1773 | /* Finally unlock and release the page. */ | 2592 | /* Finally unlock and release the page. */ |
1774 | unlock_page(page); | 2593 | unlock_page(page); |
1775 | page_cache_release(page); | 2594 | page_cache_release(page); |
2595 | balance_dirty_pages_ratelimited(mapping); | ||
2596 | cond_resched(); | ||
1776 | } | 2597 | } |
1777 | /* If there is a last partial page, need to do it the slow way. */ | 2598 | /* If there is a last partial page, need to do it the slow way. */ |
1778 | if (end_ofs) { | 2599 | if (end_ofs) { |
diff --git a/fs/ntfs/attrib.h b/fs/ntfs/attrib.h index 0618ed6fd7b3..9074886b44ba 100644 --- a/fs/ntfs/attrib.h +++ b/fs/ntfs/attrib.h | |||
@@ -60,14 +60,15 @@ typedef struct { | |||
60 | ATTR_RECORD *base_attr; | 60 | ATTR_RECORD *base_attr; |
61 | } ntfs_attr_search_ctx; | 61 | } ntfs_attr_search_ctx; |
62 | 62 | ||
63 | extern int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn); | 63 | extern int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, |
64 | ntfs_attr_search_ctx *ctx); | ||
64 | extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn); | 65 | extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn); |
65 | 66 | ||
66 | extern LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn, | 67 | extern LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn, |
67 | const BOOL write_locked); | 68 | const BOOL write_locked); |
68 | 69 | ||
69 | extern runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, | 70 | extern runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, |
70 | const VCN vcn, const BOOL write_locked); | 71 | const VCN vcn, ntfs_attr_search_ctx *ctx); |
71 | 72 | ||
72 | int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name, | 73 | int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name, |
73 | const u32 name_len, const IGNORE_CASE_BOOL ic, | 74 | const u32 name_len, const IGNORE_CASE_BOOL ic, |
@@ -102,7 +103,10 @@ extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size); | |||
102 | extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a, | 103 | extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a, |
103 | const u32 new_size); | 104 | const u32 new_size); |
104 | 105 | ||
105 | extern int ntfs_attr_make_non_resident(ntfs_inode *ni); | 106 | extern int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size); |
107 | |||
108 | extern s64 ntfs_attr_extend_allocation(ntfs_inode *ni, s64 new_alloc_size, | ||
109 | const s64 new_data_size, const s64 data_start); | ||
106 | 110 | ||
107 | extern int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, | 111 | extern int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, |
108 | const u8 val); | 112 | const u8 val); |
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index be9fd1dd423d..727533891813 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c | |||
@@ -19,11 +19,24 @@ | |||
19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/pagemap.h> | ||
23 | #include <linux/buffer_head.h> | 22 | #include <linux/buffer_head.h> |
23 | #include <linux/pagemap.h> | ||
24 | #include <linux/pagevec.h> | ||
25 | #include <linux/sched.h> | ||
26 | #include <linux/swap.h> | ||
27 | #include <linux/uio.h> | ||
28 | #include <linux/writeback.h> | ||
24 | 29 | ||
30 | #include <asm/page.h> | ||
31 | #include <asm/uaccess.h> | ||
32 | |||
33 | #include "attrib.h" | ||
34 | #include "bitmap.h" | ||
25 | #include "inode.h" | 35 | #include "inode.h" |
26 | #include "debug.h" | 36 | #include "debug.h" |
37 | #include "lcnalloc.h" | ||
38 | #include "malloc.h" | ||
39 | #include "mft.h" | ||
27 | #include "ntfs.h" | 40 | #include "ntfs.h" |
28 | 41 | ||
29 | /** | 42 | /** |
@@ -56,6 +69,2185 @@ static int ntfs_file_open(struct inode *vi, struct file *filp) | |||
56 | #ifdef NTFS_RW | 69 | #ifdef NTFS_RW |
57 | 70 | ||
58 | /** | 71 | /** |
72 | * ntfs_attr_extend_initialized - extend the initialized size of an attribute | ||
73 | * @ni: ntfs inode of the attribute to extend | ||
74 | * @new_init_size: requested new initialized size in bytes | ||
75 | * @cached_page: store any allocated but unused page here | ||
76 | * @lru_pvec: lru-buffering pagevec of the caller | ||
77 | * | ||
78 | * Extend the initialized size of an attribute described by the ntfs inode @ni | ||
79 | * to @new_init_size bytes. This involves zeroing any non-sparse space between | ||
80 | * the old initialized size and @new_init_size both in the page cache and on | ||
81 | * disk (if relevant complete pages are already uptodate in the page cache then | ||
82 | * these are simply marked dirty). | ||
83 | * | ||
84 | * As a side-effect, the file size (vfs inode->i_size) may be incremented as, | ||
85 | * in the resident attribute case, it is tied to the initialized size and, in | ||
86 | * the non-resident attribute case, it may not fall below the initialized size. | ||
87 | * | ||
88 | * Note that if the attribute is resident, we do not need to touch the page | ||
89 | * cache at all. This is because if the page cache page is not uptodate we | ||
90 | * bring it uptodate later, when doing the write to the mft record since we | ||
91 | * then already have the page mapped. And if the page is uptodate, the | ||
92 | * non-initialized region will already have been zeroed when the page was | ||
93 | * brought uptodate and the region may in fact already have been overwritten | ||
94 | * with new data via mmap() based writes, so we cannot just zero it. And since | ||
95 | * POSIX specifies that the behaviour of resizing a file whilst it is mmap()ped | ||
96 | * is unspecified, we choose not to do zeroing and thus we do not need to touch | ||
97 | * the page at all. For a more detailed explanation see ntfs_truncate() in | ||
98 | * fs/ntfs/inode.c. | ||
99 | * | ||
100 | * @cached_page and @lru_pvec are just optimizations for dealing with multiple | ||
101 | * pages. | ||
102 | * | ||
103 | * Return 0 on success and -errno on error. In the case that an error is | ||
104 | * encountered it is possible that the initialized size will already have been | ||
105 | * incremented some way towards @new_init_size but it is guaranteed that if | ||
106 | * this is the case, the necessary zeroing will also have happened and that all | ||
107 | * metadata is self-consistent. | ||
108 | * | ||
109 | * Locking: i_sem on the vfs inode corrseponsind to the ntfs inode @ni must be | ||
110 | * held by the caller. | ||
111 | */ | ||
112 | static int ntfs_attr_extend_initialized(ntfs_inode *ni, const s64 new_init_size, | ||
113 | struct page **cached_page, struct pagevec *lru_pvec) | ||
114 | { | ||
115 | s64 old_init_size; | ||
116 | loff_t old_i_size; | ||
117 | pgoff_t index, end_index; | ||
118 | unsigned long flags; | ||
119 | struct inode *vi = VFS_I(ni); | ||
120 | ntfs_inode *base_ni; | ||
121 | MFT_RECORD *m = NULL; | ||
122 | ATTR_RECORD *a; | ||
123 | ntfs_attr_search_ctx *ctx = NULL; | ||
124 | struct address_space *mapping; | ||
125 | struct page *page = NULL; | ||
126 | u8 *kattr; | ||
127 | int err; | ||
128 | u32 attr_len; | ||
129 | |||
130 | read_lock_irqsave(&ni->size_lock, flags); | ||
131 | old_init_size = ni->initialized_size; | ||
132 | old_i_size = i_size_read(vi); | ||
133 | BUG_ON(new_init_size > ni->allocated_size); | ||
134 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
135 | ntfs_debug("Entering for i_ino 0x%lx, attribute type 0x%x, " | ||
136 | "old_initialized_size 0x%llx, " | ||
137 | "new_initialized_size 0x%llx, i_size 0x%llx.", | ||
138 | vi->i_ino, (unsigned)le32_to_cpu(ni->type), | ||
139 | (unsigned long long)old_init_size, | ||
140 | (unsigned long long)new_init_size, old_i_size); | ||
141 | if (!NInoAttr(ni)) | ||
142 | base_ni = ni; | ||
143 | else | ||
144 | base_ni = ni->ext.base_ntfs_ino; | ||
145 | /* Use goto to reduce indentation and we need the label below anyway. */ | ||
146 | if (NInoNonResident(ni)) | ||
147 | goto do_non_resident_extend; | ||
148 | BUG_ON(old_init_size != old_i_size); | ||
149 | m = map_mft_record(base_ni); | ||
150 | if (IS_ERR(m)) { | ||
151 | err = PTR_ERR(m); | ||
152 | m = NULL; | ||
153 | goto err_out; | ||
154 | } | ||
155 | ctx = ntfs_attr_get_search_ctx(base_ni, m); | ||
156 | if (unlikely(!ctx)) { | ||
157 | err = -ENOMEM; | ||
158 | goto err_out; | ||
159 | } | ||
160 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
161 | CASE_SENSITIVE, 0, NULL, 0, ctx); | ||
162 | if (unlikely(err)) { | ||
163 | if (err == -ENOENT) | ||
164 | err = -EIO; | ||
165 | goto err_out; | ||
166 | } | ||
167 | m = ctx->mrec; | ||
168 | a = ctx->attr; | ||
169 | BUG_ON(a->non_resident); | ||
170 | /* The total length of the attribute value. */ | ||
171 | attr_len = le32_to_cpu(a->data.resident.value_length); | ||
172 | BUG_ON(old_i_size != (loff_t)attr_len); | ||
173 | /* | ||
174 | * Do the zeroing in the mft record and update the attribute size in | ||
175 | * the mft record. | ||
176 | */ | ||
177 | kattr = (u8*)a + le16_to_cpu(a->data.resident.value_offset); | ||
178 | memset(kattr + attr_len, 0, new_init_size - attr_len); | ||
179 | a->data.resident.value_length = cpu_to_le32((u32)new_init_size); | ||
180 | /* Finally, update the sizes in the vfs and ntfs inodes. */ | ||
181 | write_lock_irqsave(&ni->size_lock, flags); | ||
182 | i_size_write(vi, new_init_size); | ||
183 | ni->initialized_size = new_init_size; | ||
184 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
185 | goto done; | ||
186 | do_non_resident_extend: | ||
187 | /* | ||
188 | * If the new initialized size @new_init_size exceeds the current file | ||
189 | * size (vfs inode->i_size), we need to extend the file size to the | ||
190 | * new initialized size. | ||
191 | */ | ||
192 | if (new_init_size > old_i_size) { | ||
193 | m = map_mft_record(base_ni); | ||
194 | if (IS_ERR(m)) { | ||
195 | err = PTR_ERR(m); | ||
196 | m = NULL; | ||
197 | goto err_out; | ||
198 | } | ||
199 | ctx = ntfs_attr_get_search_ctx(base_ni, m); | ||
200 | if (unlikely(!ctx)) { | ||
201 | err = -ENOMEM; | ||
202 | goto err_out; | ||
203 | } | ||
204 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
205 | CASE_SENSITIVE, 0, NULL, 0, ctx); | ||
206 | if (unlikely(err)) { | ||
207 | if (err == -ENOENT) | ||
208 | err = -EIO; | ||
209 | goto err_out; | ||
210 | } | ||
211 | m = ctx->mrec; | ||
212 | a = ctx->attr; | ||
213 | BUG_ON(!a->non_resident); | ||
214 | BUG_ON(old_i_size != (loff_t) | ||
215 | sle64_to_cpu(a->data.non_resident.data_size)); | ||
216 | a->data.non_resident.data_size = cpu_to_sle64(new_init_size); | ||
217 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
218 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
219 | /* Update the file size in the vfs inode. */ | ||
220 | i_size_write(vi, new_init_size); | ||
221 | ntfs_attr_put_search_ctx(ctx); | ||
222 | ctx = NULL; | ||
223 | unmap_mft_record(base_ni); | ||
224 | m = NULL; | ||
225 | } | ||
226 | mapping = vi->i_mapping; | ||
227 | index = old_init_size >> PAGE_CACHE_SHIFT; | ||
228 | end_index = (new_init_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | ||
229 | do { | ||
230 | /* | ||
231 | * Read the page. If the page is not present, this will zero | ||
232 | * the uninitialized regions for us. | ||
233 | */ | ||
234 | page = read_cache_page(mapping, index, | ||
235 | (filler_t*)mapping->a_ops->readpage, NULL); | ||
236 | if (IS_ERR(page)) { | ||
237 | err = PTR_ERR(page); | ||
238 | goto init_err_out; | ||
239 | } | ||
240 | wait_on_page_locked(page); | ||
241 | if (unlikely(!PageUptodate(page) || PageError(page))) { | ||
242 | page_cache_release(page); | ||
243 | err = -EIO; | ||
244 | goto init_err_out; | ||
245 | } | ||
246 | /* | ||
247 | * Update the initialized size in the ntfs inode. This is | ||
248 | * enough to make ntfs_writepage() work. | ||
249 | */ | ||
250 | write_lock_irqsave(&ni->size_lock, flags); | ||
251 | ni->initialized_size = (index + 1) << PAGE_CACHE_SHIFT; | ||
252 | if (ni->initialized_size > new_init_size) | ||
253 | ni->initialized_size = new_init_size; | ||
254 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
255 | /* Set the page dirty so it gets written out. */ | ||
256 | set_page_dirty(page); | ||
257 | page_cache_release(page); | ||
258 | /* | ||
259 | * Play nice with the vm and the rest of the system. This is | ||
260 | * very much needed as we can potentially be modifying the | ||
261 | * initialised size from a very small value to a really huge | ||
262 | * value, e.g. | ||
263 | * f = open(somefile, O_TRUNC); | ||
264 | * truncate(f, 10GiB); | ||
265 | * seek(f, 10GiB); | ||
266 | * write(f, 1); | ||
267 | * And this would mean we would be marking dirty hundreds of | ||
268 | * thousands of pages or as in the above example more than | ||
269 | * two and a half million pages! | ||
270 | * | ||
271 | * TODO: For sparse pages could optimize this workload by using | ||
272 | * the FsMisc / MiscFs page bit as a "PageIsSparse" bit. This | ||
273 | * would be set in readpage for sparse pages and here we would | ||
274 | * not need to mark dirty any pages which have this bit set. | ||
275 | * The only caveat is that we have to clear the bit everywhere | ||
276 | * where we allocate any clusters that lie in the page or that | ||
277 | * contain the page. | ||
278 | * | ||
279 | * TODO: An even greater optimization would be for us to only | ||
280 | * call readpage() on pages which are not in sparse regions as | ||
281 | * determined from the runlist. This would greatly reduce the | ||
282 | * number of pages we read and make dirty in the case of sparse | ||
283 | * files. | ||
284 | */ | ||
285 | balance_dirty_pages_ratelimited(mapping); | ||
286 | cond_resched(); | ||
287 | } while (++index < end_index); | ||
288 | read_lock_irqsave(&ni->size_lock, flags); | ||
289 | BUG_ON(ni->initialized_size != new_init_size); | ||
290 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
291 | /* Now bring in sync the initialized_size in the mft record. */ | ||
292 | m = map_mft_record(base_ni); | ||
293 | if (IS_ERR(m)) { | ||
294 | err = PTR_ERR(m); | ||
295 | m = NULL; | ||
296 | goto init_err_out; | ||
297 | } | ||
298 | ctx = ntfs_attr_get_search_ctx(base_ni, m); | ||
299 | if (unlikely(!ctx)) { | ||
300 | err = -ENOMEM; | ||
301 | goto init_err_out; | ||
302 | } | ||
303 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
304 | CASE_SENSITIVE, 0, NULL, 0, ctx); | ||
305 | if (unlikely(err)) { | ||
306 | if (err == -ENOENT) | ||
307 | err = -EIO; | ||
308 | goto init_err_out; | ||
309 | } | ||
310 | m = ctx->mrec; | ||
311 | a = ctx->attr; | ||
312 | BUG_ON(!a->non_resident); | ||
313 | a->data.non_resident.initialized_size = cpu_to_sle64(new_init_size); | ||
314 | done: | ||
315 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
316 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
317 | if (ctx) | ||
318 | ntfs_attr_put_search_ctx(ctx); | ||
319 | if (m) | ||
320 | unmap_mft_record(base_ni); | ||
321 | ntfs_debug("Done, initialized_size 0x%llx, i_size 0x%llx.", | ||
322 | (unsigned long long)new_init_size, i_size_read(vi)); | ||
323 | return 0; | ||
324 | init_err_out: | ||
325 | write_lock_irqsave(&ni->size_lock, flags); | ||
326 | ni->initialized_size = old_init_size; | ||
327 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
328 | err_out: | ||
329 | if (ctx) | ||
330 | ntfs_attr_put_search_ctx(ctx); | ||
331 | if (m) | ||
332 | unmap_mft_record(base_ni); | ||
333 | ntfs_debug("Failed. Returning error code %i.", err); | ||
334 | return err; | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * ntfs_fault_in_pages_readable - | ||
339 | * | ||
340 | * Fault a number of userspace pages into pagetables. | ||
341 | * | ||
342 | * Unlike include/linux/pagemap.h::fault_in_pages_readable(), this one copes | ||
343 | * with more than two userspace pages as well as handling the single page case | ||
344 | * elegantly. | ||
345 | * | ||
346 | * If you find this difficult to understand, then think of the while loop being | ||
347 | * the following code, except that we do without the integer variable ret: | ||
348 | * | ||
349 | * do { | ||
350 | * ret = __get_user(c, uaddr); | ||
351 | * uaddr += PAGE_SIZE; | ||
352 | * } while (!ret && uaddr < end); | ||
353 | * | ||
354 | * Note, the final __get_user() may well run out-of-bounds of the user buffer, | ||
355 | * but _not_ out-of-bounds of the page the user buffer belongs to, and since | ||
356 | * this is only a read and not a write, and since it is still in the same page, | ||
357 | * it should not matter and this makes the code much simpler. | ||
358 | */ | ||
359 | static inline void ntfs_fault_in_pages_readable(const char __user *uaddr, | ||
360 | int bytes) | ||
361 | { | ||
362 | const char __user *end; | ||
363 | volatile char c; | ||
364 | |||
365 | /* Set @end to the first byte outside the last page we care about. */ | ||
366 | end = (const char __user*)PAGE_ALIGN((ptrdiff_t __user)uaddr + bytes); | ||
367 | |||
368 | while (!__get_user(c, uaddr) && (uaddr += PAGE_SIZE, uaddr < end)) | ||
369 | ; | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * ntfs_fault_in_pages_readable_iovec - | ||
374 | * | ||
375 | * Same as ntfs_fault_in_pages_readable() but operates on an array of iovecs. | ||
376 | */ | ||
377 | static inline void ntfs_fault_in_pages_readable_iovec(const struct iovec *iov, | ||
378 | size_t iov_ofs, int bytes) | ||
379 | { | ||
380 | do { | ||
381 | const char __user *buf; | ||
382 | unsigned len; | ||
383 | |||
384 | buf = iov->iov_base + iov_ofs; | ||
385 | len = iov->iov_len - iov_ofs; | ||
386 | if (len > bytes) | ||
387 | len = bytes; | ||
388 | ntfs_fault_in_pages_readable(buf, len); | ||
389 | bytes -= len; | ||
390 | iov++; | ||
391 | iov_ofs = 0; | ||
392 | } while (bytes); | ||
393 | } | ||
394 | |||
395 | /** | ||
396 | * __ntfs_grab_cache_pages - obtain a number of locked pages | ||
397 | * @mapping: address space mapping from which to obtain page cache pages | ||
398 | * @index: starting index in @mapping at which to begin obtaining pages | ||
399 | * @nr_pages: number of page cache pages to obtain | ||
400 | * @pages: array of pages in which to return the obtained page cache pages | ||
401 | * @cached_page: allocated but as yet unused page | ||
402 | * @lru_pvec: lru-buffering pagevec of caller | ||
403 | * | ||
404 | * Obtain @nr_pages locked page cache pages from the mapping @maping and | ||
405 | * starting at index @index. | ||
406 | * | ||
407 | * If a page is newly created, increment its refcount and add it to the | ||
408 | * caller's lru-buffering pagevec @lru_pvec. | ||
409 | * | ||
410 | * This is the same as mm/filemap.c::__grab_cache_page(), except that @nr_pages | ||
411 | * are obtained at once instead of just one page and that 0 is returned on | ||
412 | * success and -errno on error. | ||
413 | * | ||
414 | * Note, the page locks are obtained in ascending page index order. | ||
415 | */ | ||
416 | static inline int __ntfs_grab_cache_pages(struct address_space *mapping, | ||
417 | pgoff_t index, const unsigned nr_pages, struct page **pages, | ||
418 | struct page **cached_page, struct pagevec *lru_pvec) | ||
419 | { | ||
420 | int err, nr; | ||
421 | |||
422 | BUG_ON(!nr_pages); | ||
423 | err = nr = 0; | ||
424 | do { | ||
425 | pages[nr] = find_lock_page(mapping, index); | ||
426 | if (!pages[nr]) { | ||
427 | if (!*cached_page) { | ||
428 | *cached_page = page_cache_alloc(mapping); | ||
429 | if (unlikely(!*cached_page)) { | ||
430 | err = -ENOMEM; | ||
431 | goto err_out; | ||
432 | } | ||
433 | } | ||
434 | err = add_to_page_cache(*cached_page, mapping, index, | ||
435 | GFP_KERNEL); | ||
436 | if (unlikely(err)) { | ||
437 | if (err == -EEXIST) | ||
438 | continue; | ||
439 | goto err_out; | ||
440 | } | ||
441 | pages[nr] = *cached_page; | ||
442 | page_cache_get(*cached_page); | ||
443 | if (unlikely(!pagevec_add(lru_pvec, *cached_page))) | ||
444 | __pagevec_lru_add(lru_pvec); | ||
445 | *cached_page = NULL; | ||
446 | } | ||
447 | index++; | ||
448 | nr++; | ||
449 | } while (nr < nr_pages); | ||
450 | out: | ||
451 | return err; | ||
452 | err_out: | ||
453 | while (nr > 0) { | ||
454 | unlock_page(pages[--nr]); | ||
455 | page_cache_release(pages[nr]); | ||
456 | } | ||
457 | goto out; | ||
458 | } | ||
459 | |||
460 | static inline int ntfs_submit_bh_for_read(struct buffer_head *bh) | ||
461 | { | ||
462 | lock_buffer(bh); | ||
463 | get_bh(bh); | ||
464 | bh->b_end_io = end_buffer_read_sync; | ||
465 | return submit_bh(READ, bh); | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * ntfs_prepare_pages_for_non_resident_write - prepare pages for receiving data | ||
470 | * @pages: array of destination pages | ||
471 | * @nr_pages: number of pages in @pages | ||
472 | * @pos: byte position in file at which the write begins | ||
473 | * @bytes: number of bytes to be written | ||
474 | * | ||
475 | * This is called for non-resident attributes from ntfs_file_buffered_write() | ||
476 | * with i_sem held on the inode (@pages[0]->mapping->host). There are | ||
477 | * @nr_pages pages in @pages which are locked but not kmap()ped. The source | ||
478 | * data has not yet been copied into the @pages. | ||
479 | * | ||
480 | * Need to fill any holes with actual clusters, allocate buffers if necessary, | ||
481 | * ensure all the buffers are mapped, and bring uptodate any buffers that are | ||
482 | * only partially being written to. | ||
483 | * | ||
484 | * If @nr_pages is greater than one, we are guaranteed that the cluster size is | ||
485 | * greater than PAGE_CACHE_SIZE, that all pages in @pages are entirely inside | ||
486 | * the same cluster and that they are the entirety of that cluster, and that | ||
487 | * the cluster is sparse, i.e. we need to allocate a cluster to fill the hole. | ||
488 | * | ||
489 | * i_size is not to be modified yet. | ||
490 | * | ||
491 | * Return 0 on success or -errno on error. | ||
492 | */ | ||
493 | static int ntfs_prepare_pages_for_non_resident_write(struct page **pages, | ||
494 | unsigned nr_pages, s64 pos, size_t bytes) | ||
495 | { | ||
496 | VCN vcn, highest_vcn = 0, cpos, cend, bh_cpos, bh_cend; | ||
497 | LCN lcn; | ||
498 | s64 bh_pos, vcn_len, end, initialized_size; | ||
499 | sector_t lcn_block; | ||
500 | struct page *page; | ||
501 | struct inode *vi; | ||
502 | ntfs_inode *ni, *base_ni = NULL; | ||
503 | ntfs_volume *vol; | ||
504 | runlist_element *rl, *rl2; | ||
505 | struct buffer_head *bh, *head, *wait[2], **wait_bh = wait; | ||
506 | ntfs_attr_search_ctx *ctx = NULL; | ||
507 | MFT_RECORD *m = NULL; | ||
508 | ATTR_RECORD *a = NULL; | ||
509 | unsigned long flags; | ||
510 | u32 attr_rec_len = 0; | ||
511 | unsigned blocksize, u; | ||
512 | int err, mp_size; | ||
513 | BOOL rl_write_locked, was_hole, is_retry; | ||
514 | unsigned char blocksize_bits; | ||
515 | struct { | ||
516 | u8 runlist_merged:1; | ||
517 | u8 mft_attr_mapped:1; | ||
518 | u8 mp_rebuilt:1; | ||
519 | u8 attr_switched:1; | ||
520 | } status = { 0, 0, 0, 0 }; | ||
521 | |||
522 | BUG_ON(!nr_pages); | ||
523 | BUG_ON(!pages); | ||
524 | BUG_ON(!*pages); | ||
525 | vi = pages[0]->mapping->host; | ||
526 | ni = NTFS_I(vi); | ||
527 | vol = ni->vol; | ||
528 | ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, start page " | ||
529 | "index 0x%lx, nr_pages 0x%x, pos 0x%llx, bytes 0x%zx.", | ||
530 | vi->i_ino, ni->type, pages[0]->index, nr_pages, | ||
531 | (long long)pos, bytes); | ||
532 | blocksize_bits = vi->i_blkbits; | ||
533 | blocksize = 1 << blocksize_bits; | ||
534 | u = 0; | ||
535 | do { | ||
536 | struct page *page = pages[u]; | ||
537 | /* | ||
538 | * create_empty_buffers() will create uptodate/dirty buffers if | ||
539 | * the page is uptodate/dirty. | ||
540 | */ | ||
541 | if (!page_has_buffers(page)) { | ||
542 | create_empty_buffers(page, blocksize, 0); | ||
543 | if (unlikely(!page_has_buffers(page))) | ||
544 | return -ENOMEM; | ||
545 | } | ||
546 | } while (++u < nr_pages); | ||
547 | rl_write_locked = FALSE; | ||
548 | rl = NULL; | ||
549 | err = 0; | ||
550 | vcn = lcn = -1; | ||
551 | vcn_len = 0; | ||
552 | lcn_block = -1; | ||
553 | was_hole = FALSE; | ||
554 | cpos = pos >> vol->cluster_size_bits; | ||
555 | end = pos + bytes; | ||
556 | cend = (end + vol->cluster_size - 1) >> vol->cluster_size_bits; | ||
557 | /* | ||
558 | * Loop over each page and for each page over each buffer. Use goto to | ||
559 | * reduce indentation. | ||
560 | */ | ||
561 | u = 0; | ||
562 | do_next_page: | ||
563 | page = pages[u]; | ||
564 | bh_pos = (s64)page->index << PAGE_CACHE_SHIFT; | ||
565 | bh = head = page_buffers(page); | ||
566 | do { | ||
567 | VCN cdelta; | ||
568 | s64 bh_end; | ||
569 | unsigned bh_cofs; | ||
570 | |||
571 | /* Clear buffer_new on all buffers to reinitialise state. */ | ||
572 | if (buffer_new(bh)) | ||
573 | clear_buffer_new(bh); | ||
574 | bh_end = bh_pos + blocksize; | ||
575 | bh_cpos = bh_pos >> vol->cluster_size_bits; | ||
576 | bh_cofs = bh_pos & vol->cluster_size_mask; | ||
577 | if (buffer_mapped(bh)) { | ||
578 | /* | ||
579 | * The buffer is already mapped. If it is uptodate, | ||
580 | * ignore it. | ||
581 | */ | ||
582 | if (buffer_uptodate(bh)) | ||
583 | continue; | ||
584 | /* | ||
585 | * The buffer is not uptodate. If the page is uptodate | ||
586 | * set the buffer uptodate and otherwise ignore it. | ||
587 | */ | ||
588 | if (PageUptodate(page)) { | ||
589 | set_buffer_uptodate(bh); | ||
590 | continue; | ||
591 | } | ||
592 | /* | ||
593 | * Neither the page nor the buffer are uptodate. If | ||
594 | * the buffer is only partially being written to, we | ||
595 | * need to read it in before the write, i.e. now. | ||
596 | */ | ||
597 | if ((bh_pos < pos && bh_end > pos) || | ||
598 | (bh_pos < end && bh_end > end)) { | ||
599 | /* | ||
600 | * If the buffer is fully or partially within | ||
601 | * the initialized size, do an actual read. | ||
602 | * Otherwise, simply zero the buffer. | ||
603 | */ | ||
604 | read_lock_irqsave(&ni->size_lock, flags); | ||
605 | initialized_size = ni->initialized_size; | ||
606 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
607 | if (bh_pos < initialized_size) { | ||
608 | ntfs_submit_bh_for_read(bh); | ||
609 | *wait_bh++ = bh; | ||
610 | } else { | ||
611 | u8 *kaddr = kmap_atomic(page, KM_USER0); | ||
612 | memset(kaddr + bh_offset(bh), 0, | ||
613 | blocksize); | ||
614 | kunmap_atomic(kaddr, KM_USER0); | ||
615 | flush_dcache_page(page); | ||
616 | set_buffer_uptodate(bh); | ||
617 | } | ||
618 | } | ||
619 | continue; | ||
620 | } | ||
621 | /* Unmapped buffer. Need to map it. */ | ||
622 | bh->b_bdev = vol->sb->s_bdev; | ||
623 | /* | ||
624 | * If the current buffer is in the same clusters as the map | ||
625 | * cache, there is no need to check the runlist again. The | ||
626 | * map cache is made up of @vcn, which is the first cached file | ||
627 | * cluster, @vcn_len which is the number of cached file | ||
628 | * clusters, @lcn is the device cluster corresponding to @vcn, | ||
629 | * and @lcn_block is the block number corresponding to @lcn. | ||
630 | */ | ||
631 | cdelta = bh_cpos - vcn; | ||
632 | if (likely(!cdelta || (cdelta > 0 && cdelta < vcn_len))) { | ||
633 | map_buffer_cached: | ||
634 | BUG_ON(lcn < 0); | ||
635 | bh->b_blocknr = lcn_block + | ||
636 | (cdelta << (vol->cluster_size_bits - | ||
637 | blocksize_bits)) + | ||
638 | (bh_cofs >> blocksize_bits); | ||
639 | set_buffer_mapped(bh); | ||
640 | /* | ||
641 | * If the page is uptodate so is the buffer. If the | ||
642 | * buffer is fully outside the write, we ignore it if | ||
643 | * it was already allocated and we mark it dirty so it | ||
644 | * gets written out if we allocated it. On the other | ||
645 | * hand, if we allocated the buffer but we are not | ||
646 | * marking it dirty we set buffer_new so we can do | ||
647 | * error recovery. | ||
648 | */ | ||
649 | if (PageUptodate(page)) { | ||
650 | if (!buffer_uptodate(bh)) | ||
651 | set_buffer_uptodate(bh); | ||
652 | if (unlikely(was_hole)) { | ||
653 | /* We allocated the buffer. */ | ||
654 | unmap_underlying_metadata(bh->b_bdev, | ||
655 | bh->b_blocknr); | ||
656 | if (bh_end <= pos || bh_pos >= end) | ||
657 | mark_buffer_dirty(bh); | ||
658 | else | ||
659 | set_buffer_new(bh); | ||
660 | } | ||
661 | continue; | ||
662 | } | ||
663 | /* Page is _not_ uptodate. */ | ||
664 | if (likely(!was_hole)) { | ||
665 | /* | ||
666 | * Buffer was already allocated. If it is not | ||
667 | * uptodate and is only partially being written | ||
668 | * to, we need to read it in before the write, | ||
669 | * i.e. now. | ||
670 | */ | ||
671 | if (!buffer_uptodate(bh) && bh_pos < end && | ||
672 | bh_end > pos && | ||
673 | (bh_pos < pos || | ||
674 | bh_end > end)) { | ||
675 | /* | ||
676 | * If the buffer is fully or partially | ||
677 | * within the initialized size, do an | ||
678 | * actual read. Otherwise, simply zero | ||
679 | * the buffer. | ||
680 | */ | ||
681 | read_lock_irqsave(&ni->size_lock, | ||
682 | flags); | ||
683 | initialized_size = ni->initialized_size; | ||
684 | read_unlock_irqrestore(&ni->size_lock, | ||
685 | flags); | ||
686 | if (bh_pos < initialized_size) { | ||
687 | ntfs_submit_bh_for_read(bh); | ||
688 | *wait_bh++ = bh; | ||
689 | } else { | ||
690 | u8 *kaddr = kmap_atomic(page, | ||
691 | KM_USER0); | ||
692 | memset(kaddr + bh_offset(bh), | ||
693 | 0, blocksize); | ||
694 | kunmap_atomic(kaddr, KM_USER0); | ||
695 | flush_dcache_page(page); | ||
696 | set_buffer_uptodate(bh); | ||
697 | } | ||
698 | } | ||
699 | continue; | ||
700 | } | ||
701 | /* We allocated the buffer. */ | ||
702 | unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr); | ||
703 | /* | ||
704 | * If the buffer is fully outside the write, zero it, | ||
705 | * set it uptodate, and mark it dirty so it gets | ||
706 | * written out. If it is partially being written to, | ||
707 | * zero region surrounding the write but leave it to | ||
708 | * commit write to do anything else. Finally, if the | ||
709 | * buffer is fully being overwritten, do nothing. | ||
710 | */ | ||
711 | if (bh_end <= pos || bh_pos >= end) { | ||
712 | if (!buffer_uptodate(bh)) { | ||
713 | u8 *kaddr = kmap_atomic(page, KM_USER0); | ||
714 | memset(kaddr + bh_offset(bh), 0, | ||
715 | blocksize); | ||
716 | kunmap_atomic(kaddr, KM_USER0); | ||
717 | flush_dcache_page(page); | ||
718 | set_buffer_uptodate(bh); | ||
719 | } | ||
720 | mark_buffer_dirty(bh); | ||
721 | continue; | ||
722 | } | ||
723 | set_buffer_new(bh); | ||
724 | if (!buffer_uptodate(bh) && | ||
725 | (bh_pos < pos || bh_end > end)) { | ||
726 | u8 *kaddr; | ||
727 | unsigned pofs; | ||
728 | |||
729 | kaddr = kmap_atomic(page, KM_USER0); | ||
730 | if (bh_pos < pos) { | ||
731 | pofs = bh_pos & ~PAGE_CACHE_MASK; | ||
732 | memset(kaddr + pofs, 0, pos - bh_pos); | ||
733 | } | ||
734 | if (bh_end > end) { | ||
735 | pofs = end & ~PAGE_CACHE_MASK; | ||
736 | memset(kaddr + pofs, 0, bh_end - end); | ||
737 | } | ||
738 | kunmap_atomic(kaddr, KM_USER0); | ||
739 | flush_dcache_page(page); | ||
740 | } | ||
741 | continue; | ||
742 | } | ||
743 | /* | ||
744 | * Slow path: this is the first buffer in the cluster. If it | ||
745 | * is outside allocated size and is not uptodate, zero it and | ||
746 | * set it uptodate. | ||
747 | */ | ||
748 | read_lock_irqsave(&ni->size_lock, flags); | ||
749 | initialized_size = ni->allocated_size; | ||
750 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
751 | if (bh_pos > initialized_size) { | ||
752 | if (PageUptodate(page)) { | ||
753 | if (!buffer_uptodate(bh)) | ||
754 | set_buffer_uptodate(bh); | ||
755 | } else if (!buffer_uptodate(bh)) { | ||
756 | u8 *kaddr = kmap_atomic(page, KM_USER0); | ||
757 | memset(kaddr + bh_offset(bh), 0, blocksize); | ||
758 | kunmap_atomic(kaddr, KM_USER0); | ||
759 | flush_dcache_page(page); | ||
760 | set_buffer_uptodate(bh); | ||
761 | } | ||
762 | continue; | ||
763 | } | ||
764 | is_retry = FALSE; | ||
765 | if (!rl) { | ||
766 | down_read(&ni->runlist.lock); | ||
767 | retry_remap: | ||
768 | rl = ni->runlist.rl; | ||
769 | } | ||
770 | if (likely(rl != NULL)) { | ||
771 | /* Seek to element containing target cluster. */ | ||
772 | while (rl->length && rl[1].vcn <= bh_cpos) | ||
773 | rl++; | ||
774 | lcn = ntfs_rl_vcn_to_lcn(rl, bh_cpos); | ||
775 | if (likely(lcn >= 0)) { | ||
776 | /* | ||
777 | * Successful remap, setup the map cache and | ||
778 | * use that to deal with the buffer. | ||
779 | */ | ||
780 | was_hole = FALSE; | ||
781 | vcn = bh_cpos; | ||
782 | vcn_len = rl[1].vcn - vcn; | ||
783 | lcn_block = lcn << (vol->cluster_size_bits - | ||
784 | blocksize_bits); | ||
785 | cdelta = 0; | ||
786 | /* | ||
787 | * If the number of remaining clusters touched | ||
788 | * by the write is smaller or equal to the | ||
789 | * number of cached clusters, unlock the | ||
790 | * runlist as the map cache will be used from | ||
791 | * now on. | ||
792 | */ | ||
793 | if (likely(vcn + vcn_len >= cend)) { | ||
794 | if (rl_write_locked) { | ||
795 | up_write(&ni->runlist.lock); | ||
796 | rl_write_locked = FALSE; | ||
797 | } else | ||
798 | up_read(&ni->runlist.lock); | ||
799 | rl = NULL; | ||
800 | } | ||
801 | goto map_buffer_cached; | ||
802 | } | ||
803 | } else | ||
804 | lcn = LCN_RL_NOT_MAPPED; | ||
805 | /* | ||
806 | * If it is not a hole and not out of bounds, the runlist is | ||
807 | * probably unmapped so try to map it now. | ||
808 | */ | ||
809 | if (unlikely(lcn != LCN_HOLE && lcn != LCN_ENOENT)) { | ||
810 | if (likely(!is_retry && lcn == LCN_RL_NOT_MAPPED)) { | ||
811 | /* Attempt to map runlist. */ | ||
812 | if (!rl_write_locked) { | ||
813 | /* | ||
814 | * We need the runlist locked for | ||
815 | * writing, so if it is locked for | ||
816 | * reading relock it now and retry in | ||
817 | * case it changed whilst we dropped | ||
818 | * the lock. | ||
819 | */ | ||
820 | up_read(&ni->runlist.lock); | ||
821 | down_write(&ni->runlist.lock); | ||
822 | rl_write_locked = TRUE; | ||
823 | goto retry_remap; | ||
824 | } | ||
825 | err = ntfs_map_runlist_nolock(ni, bh_cpos, | ||
826 | NULL); | ||
827 | if (likely(!err)) { | ||
828 | is_retry = TRUE; | ||
829 | goto retry_remap; | ||
830 | } | ||
831 | /* | ||
832 | * If @vcn is out of bounds, pretend @lcn is | ||
833 | * LCN_ENOENT. As long as the buffer is out | ||
834 | * of bounds this will work fine. | ||
835 | */ | ||
836 | if (err == -ENOENT) { | ||
837 | lcn = LCN_ENOENT; | ||
838 | err = 0; | ||
839 | goto rl_not_mapped_enoent; | ||
840 | } | ||
841 | } else | ||
842 | err = -EIO; | ||
843 | /* Failed to map the buffer, even after retrying. */ | ||
844 | bh->b_blocknr = -1; | ||
845 | ntfs_error(vol->sb, "Failed to write to inode 0x%lx, " | ||
846 | "attribute type 0x%x, vcn 0x%llx, " | ||
847 | "vcn offset 0x%x, because its " | ||
848 | "location on disk could not be " | ||
849 | "determined%s (error code %i).", | ||
850 | ni->mft_no, ni->type, | ||
851 | (unsigned long long)bh_cpos, | ||
852 | (unsigned)bh_pos & | ||
853 | vol->cluster_size_mask, | ||
854 | is_retry ? " even after retrying" : "", | ||
855 | err); | ||
856 | break; | ||
857 | } | ||
858 | rl_not_mapped_enoent: | ||
859 | /* | ||
860 | * The buffer is in a hole or out of bounds. We need to fill | ||
861 | * the hole, unless the buffer is in a cluster which is not | ||
862 | * touched by the write, in which case we just leave the buffer | ||
863 | * unmapped. This can only happen when the cluster size is | ||
864 | * less than the page cache size. | ||
865 | */ | ||
866 | if (unlikely(vol->cluster_size < PAGE_CACHE_SIZE)) { | ||
867 | bh_cend = (bh_end + vol->cluster_size - 1) >> | ||
868 | vol->cluster_size_bits; | ||
869 | if ((bh_cend <= cpos || bh_cpos >= cend)) { | ||
870 | bh->b_blocknr = -1; | ||
871 | /* | ||
872 | * If the buffer is uptodate we skip it. If it | ||
873 | * is not but the page is uptodate, we can set | ||
874 | * the buffer uptodate. If the page is not | ||
875 | * uptodate, we can clear the buffer and set it | ||
876 | * uptodate. Whether this is worthwhile is | ||
877 | * debatable and this could be removed. | ||
878 | */ | ||
879 | if (PageUptodate(page)) { | ||
880 | if (!buffer_uptodate(bh)) | ||
881 | set_buffer_uptodate(bh); | ||
882 | } else if (!buffer_uptodate(bh)) { | ||
883 | u8 *kaddr = kmap_atomic(page, KM_USER0); | ||
884 | memset(kaddr + bh_offset(bh), 0, | ||
885 | blocksize); | ||
886 | kunmap_atomic(kaddr, KM_USER0); | ||
887 | flush_dcache_page(page); | ||
888 | set_buffer_uptodate(bh); | ||
889 | } | ||
890 | continue; | ||
891 | } | ||
892 | } | ||
893 | /* | ||
894 | * Out of bounds buffer is invalid if it was not really out of | ||
895 | * bounds. | ||
896 | */ | ||
897 | BUG_ON(lcn != LCN_HOLE); | ||
898 | /* | ||
899 | * We need the runlist locked for writing, so if it is locked | ||
900 | * for reading relock it now and retry in case it changed | ||
901 | * whilst we dropped the lock. | ||
902 | */ | ||
903 | BUG_ON(!rl); | ||
904 | if (!rl_write_locked) { | ||
905 | up_read(&ni->runlist.lock); | ||
906 | down_write(&ni->runlist.lock); | ||
907 | rl_write_locked = TRUE; | ||
908 | goto retry_remap; | ||
909 | } | ||
910 | /* Find the previous last allocated cluster. */ | ||
911 | BUG_ON(rl->lcn != LCN_HOLE); | ||
912 | lcn = -1; | ||
913 | rl2 = rl; | ||
914 | while (--rl2 >= ni->runlist.rl) { | ||
915 | if (rl2->lcn >= 0) { | ||
916 | lcn = rl2->lcn + rl2->length; | ||
917 | break; | ||
918 | } | ||
919 | } | ||
920 | rl2 = ntfs_cluster_alloc(vol, bh_cpos, 1, lcn, DATA_ZONE, | ||
921 | FALSE); | ||
922 | if (IS_ERR(rl2)) { | ||
923 | err = PTR_ERR(rl2); | ||
924 | ntfs_debug("Failed to allocate cluster, error code %i.", | ||
925 | err); | ||
926 | break; | ||
927 | } | ||
928 | lcn = rl2->lcn; | ||
929 | rl = ntfs_runlists_merge(ni->runlist.rl, rl2); | ||
930 | if (IS_ERR(rl)) { | ||
931 | err = PTR_ERR(rl); | ||
932 | if (err != -ENOMEM) | ||
933 | err = -EIO; | ||
934 | if (ntfs_cluster_free_from_rl(vol, rl2)) { | ||
935 | ntfs_error(vol->sb, "Failed to release " | ||
936 | "allocated cluster in error " | ||
937 | "code path. Run chkdsk to " | ||
938 | "recover the lost cluster."); | ||
939 | NVolSetErrors(vol); | ||
940 | } | ||
941 | ntfs_free(rl2); | ||
942 | break; | ||
943 | } | ||
944 | ni->runlist.rl = rl; | ||
945 | status.runlist_merged = 1; | ||
946 | ntfs_debug("Allocated cluster, lcn 0x%llx.", lcn); | ||
947 | /* Map and lock the mft record and get the attribute record. */ | ||
948 | if (!NInoAttr(ni)) | ||
949 | base_ni = ni; | ||
950 | else | ||
951 | base_ni = ni->ext.base_ntfs_ino; | ||
952 | m = map_mft_record(base_ni); | ||
953 | if (IS_ERR(m)) { | ||
954 | err = PTR_ERR(m); | ||
955 | break; | ||
956 | } | ||
957 | ctx = ntfs_attr_get_search_ctx(base_ni, m); | ||
958 | if (unlikely(!ctx)) { | ||
959 | err = -ENOMEM; | ||
960 | unmap_mft_record(base_ni); | ||
961 | break; | ||
962 | } | ||
963 | status.mft_attr_mapped = 1; | ||
964 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
965 | CASE_SENSITIVE, bh_cpos, NULL, 0, ctx); | ||
966 | if (unlikely(err)) { | ||
967 | if (err == -ENOENT) | ||
968 | err = -EIO; | ||
969 | break; | ||
970 | } | ||
971 | m = ctx->mrec; | ||
972 | a = ctx->attr; | ||
973 | /* | ||
974 | * Find the runlist element with which the attribute extent | ||
975 | * starts. Note, we cannot use the _attr_ version because we | ||
976 | * have mapped the mft record. That is ok because we know the | ||
977 | * runlist fragment must be mapped already to have ever gotten | ||
978 | * here, so we can just use the _rl_ version. | ||
979 | */ | ||
980 | vcn = sle64_to_cpu(a->data.non_resident.lowest_vcn); | ||
981 | rl2 = ntfs_rl_find_vcn_nolock(rl, vcn); | ||
982 | BUG_ON(!rl2); | ||
983 | BUG_ON(!rl2->length); | ||
984 | BUG_ON(rl2->lcn < LCN_HOLE); | ||
985 | highest_vcn = sle64_to_cpu(a->data.non_resident.highest_vcn); | ||
986 | /* | ||
987 | * If @highest_vcn is zero, calculate the real highest_vcn | ||
988 | * (which can really be zero). | ||
989 | */ | ||
990 | if (!highest_vcn) | ||
991 | highest_vcn = (sle64_to_cpu( | ||
992 | a->data.non_resident.allocated_size) >> | ||
993 | vol->cluster_size_bits) - 1; | ||
994 | /* | ||
995 | * Determine the size of the mapping pairs array for the new | ||
996 | * extent, i.e. the old extent with the hole filled. | ||
997 | */ | ||
998 | mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, vcn, | ||
999 | highest_vcn); | ||
1000 | if (unlikely(mp_size <= 0)) { | ||
1001 | if (!(err = mp_size)) | ||
1002 | err = -EIO; | ||
1003 | ntfs_debug("Failed to get size for mapping pairs " | ||
1004 | "array, error code %i.", err); | ||
1005 | break; | ||
1006 | } | ||
1007 | /* | ||
1008 | * Resize the attribute record to fit the new mapping pairs | ||
1009 | * array. | ||
1010 | */ | ||
1011 | attr_rec_len = le32_to_cpu(a->length); | ||
1012 | err = ntfs_attr_record_resize(m, a, mp_size + le16_to_cpu( | ||
1013 | a->data.non_resident.mapping_pairs_offset)); | ||
1014 | if (unlikely(err)) { | ||
1015 | BUG_ON(err != -ENOSPC); | ||
1016 | // TODO: Deal with this by using the current attribute | ||
1017 | // and fill it with as much of the mapping pairs | ||
1018 | // array as possible. Then loop over each attribute | ||
1019 | // extent rewriting the mapping pairs arrays as we go | ||
1020 | // along and if when we reach the end we have not | ||
1021 | // enough space, try to resize the last attribute | ||
1022 | // extent and if even that fails, add a new attribute | ||
1023 | // extent. | ||
1024 | // We could also try to resize at each step in the hope | ||
1025 | // that we will not need to rewrite every single extent. | ||
1026 | // Note, we may need to decompress some extents to fill | ||
1027 | // the runlist as we are walking the extents... | ||
1028 | ntfs_error(vol->sb, "Not enough space in the mft " | ||
1029 | "record for the extended attribute " | ||
1030 | "record. This case is not " | ||
1031 | "implemented yet."); | ||
1032 | err = -EOPNOTSUPP; | ||
1033 | break ; | ||
1034 | } | ||
1035 | status.mp_rebuilt = 1; | ||
1036 | /* | ||
1037 | * Generate the mapping pairs array directly into the attribute | ||
1038 | * record. | ||
1039 | */ | ||
1040 | err = ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu( | ||
1041 | a->data.non_resident.mapping_pairs_offset), | ||
1042 | mp_size, rl2, vcn, highest_vcn, NULL); | ||
1043 | if (unlikely(err)) { | ||
1044 | ntfs_error(vol->sb, "Cannot fill hole in inode 0x%lx, " | ||
1045 | "attribute type 0x%x, because building " | ||
1046 | "the mapping pairs failed with error " | ||
1047 | "code %i.", vi->i_ino, | ||
1048 | (unsigned)le32_to_cpu(ni->type), err); | ||
1049 | err = -EIO; | ||
1050 | break; | ||
1051 | } | ||
1052 | /* Update the highest_vcn but only if it was not set. */ | ||
1053 | if (unlikely(!a->data.non_resident.highest_vcn)) | ||
1054 | a->data.non_resident.highest_vcn = | ||
1055 | cpu_to_sle64(highest_vcn); | ||
1056 | /* | ||
1057 | * If the attribute is sparse/compressed, update the compressed | ||
1058 | * size in the ntfs_inode structure and the attribute record. | ||
1059 | */ | ||
1060 | if (likely(NInoSparse(ni) || NInoCompressed(ni))) { | ||
1061 | /* | ||
1062 | * If we are not in the first attribute extent, switch | ||
1063 | * to it, but first ensure the changes will make it to | ||
1064 | * disk later. | ||
1065 | */ | ||
1066 | if (a->data.non_resident.lowest_vcn) { | ||
1067 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
1068 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
1069 | ntfs_attr_reinit_search_ctx(ctx); | ||
1070 | err = ntfs_attr_lookup(ni->type, ni->name, | ||
1071 | ni->name_len, CASE_SENSITIVE, | ||
1072 | 0, NULL, 0, ctx); | ||
1073 | if (unlikely(err)) { | ||
1074 | status.attr_switched = 1; | ||
1075 | break; | ||
1076 | } | ||
1077 | /* @m is not used any more so do not set it. */ | ||
1078 | a = ctx->attr; | ||
1079 | } | ||
1080 | write_lock_irqsave(&ni->size_lock, flags); | ||
1081 | ni->itype.compressed.size += vol->cluster_size; | ||
1082 | a->data.non_resident.compressed_size = | ||
1083 | cpu_to_sle64(ni->itype.compressed.size); | ||
1084 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
1085 | } | ||
1086 | /* Ensure the changes make it to disk. */ | ||
1087 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
1088 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
1089 | ntfs_attr_put_search_ctx(ctx); | ||
1090 | unmap_mft_record(base_ni); | ||
1091 | /* Successfully filled the hole. */ | ||
1092 | status.runlist_merged = 0; | ||
1093 | status.mft_attr_mapped = 0; | ||
1094 | status.mp_rebuilt = 0; | ||
1095 | /* Setup the map cache and use that to deal with the buffer. */ | ||
1096 | was_hole = TRUE; | ||
1097 | vcn = bh_cpos; | ||
1098 | vcn_len = 1; | ||
1099 | lcn_block = lcn << (vol->cluster_size_bits - blocksize_bits); | ||
1100 | cdelta = 0; | ||
1101 | /* | ||
1102 | * If the number of remaining clusters in the @pages is smaller | ||
1103 | * or equal to the number of cached clusters, unlock the | ||
1104 | * runlist as the map cache will be used from now on. | ||
1105 | */ | ||
1106 | if (likely(vcn + vcn_len >= cend)) { | ||
1107 | up_write(&ni->runlist.lock); | ||
1108 | rl_write_locked = FALSE; | ||
1109 | rl = NULL; | ||
1110 | } | ||
1111 | goto map_buffer_cached; | ||
1112 | } while (bh_pos += blocksize, (bh = bh->b_this_page) != head); | ||
1113 | /* If there are no errors, do the next page. */ | ||
1114 | if (likely(!err && ++u < nr_pages)) | ||
1115 | goto do_next_page; | ||
1116 | /* If there are no errors, release the runlist lock if we took it. */ | ||
1117 | if (likely(!err)) { | ||
1118 | if (unlikely(rl_write_locked)) { | ||
1119 | up_write(&ni->runlist.lock); | ||
1120 | rl_write_locked = FALSE; | ||
1121 | } else if (unlikely(rl)) | ||
1122 | up_read(&ni->runlist.lock); | ||
1123 | rl = NULL; | ||
1124 | } | ||
1125 | /* If we issued read requests, let them complete. */ | ||
1126 | read_lock_irqsave(&ni->size_lock, flags); | ||
1127 | initialized_size = ni->initialized_size; | ||
1128 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
1129 | while (wait_bh > wait) { | ||
1130 | bh = *--wait_bh; | ||
1131 | wait_on_buffer(bh); | ||
1132 | if (likely(buffer_uptodate(bh))) { | ||
1133 | page = bh->b_page; | ||
1134 | bh_pos = ((s64)page->index << PAGE_CACHE_SHIFT) + | ||
1135 | bh_offset(bh); | ||
1136 | /* | ||
1137 | * If the buffer overflows the initialized size, need | ||
1138 | * to zero the overflowing region. | ||
1139 | */ | ||
1140 | if (unlikely(bh_pos + blocksize > initialized_size)) { | ||
1141 | u8 *kaddr; | ||
1142 | int ofs = 0; | ||
1143 | |||
1144 | if (likely(bh_pos < initialized_size)) | ||
1145 | ofs = initialized_size - bh_pos; | ||
1146 | kaddr = kmap_atomic(page, KM_USER0); | ||
1147 | memset(kaddr + bh_offset(bh) + ofs, 0, | ||
1148 | blocksize - ofs); | ||
1149 | kunmap_atomic(kaddr, KM_USER0); | ||
1150 | flush_dcache_page(page); | ||
1151 | } | ||
1152 | } else /* if (unlikely(!buffer_uptodate(bh))) */ | ||
1153 | err = -EIO; | ||
1154 | } | ||
1155 | if (likely(!err)) { | ||
1156 | /* Clear buffer_new on all buffers. */ | ||
1157 | u = 0; | ||
1158 | do { | ||
1159 | bh = head = page_buffers(pages[u]); | ||
1160 | do { | ||
1161 | if (buffer_new(bh)) | ||
1162 | clear_buffer_new(bh); | ||
1163 | } while ((bh = bh->b_this_page) != head); | ||
1164 | } while (++u < nr_pages); | ||
1165 | ntfs_debug("Done."); | ||
1166 | return err; | ||
1167 | } | ||
1168 | if (status.attr_switched) { | ||
1169 | /* Get back to the attribute extent we modified. */ | ||
1170 | ntfs_attr_reinit_search_ctx(ctx); | ||
1171 | if (ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
1172 | CASE_SENSITIVE, bh_cpos, NULL, 0, ctx)) { | ||
1173 | ntfs_error(vol->sb, "Failed to find required " | ||
1174 | "attribute extent of attribute in " | ||
1175 | "error code path. Run chkdsk to " | ||
1176 | "recover."); | ||
1177 | write_lock_irqsave(&ni->size_lock, flags); | ||
1178 | ni->itype.compressed.size += vol->cluster_size; | ||
1179 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
1180 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
1181 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
1182 | /* | ||
1183 | * The only thing that is now wrong is the compressed | ||
1184 | * size of the base attribute extent which chkdsk | ||
1185 | * should be able to fix. | ||
1186 | */ | ||
1187 | NVolSetErrors(vol); | ||
1188 | } else { | ||
1189 | m = ctx->mrec; | ||
1190 | a = ctx->attr; | ||
1191 | status.attr_switched = 0; | ||
1192 | } | ||
1193 | } | ||
1194 | /* | ||
1195 | * If the runlist has been modified, need to restore it by punching a | ||
1196 | * hole into it and we then need to deallocate the on-disk cluster as | ||
1197 | * well. Note, we only modify the runlist if we are able to generate a | ||
1198 | * new mapping pairs array, i.e. only when the mapped attribute extent | ||
1199 | * is not switched. | ||
1200 | */ | ||
1201 | if (status.runlist_merged && !status.attr_switched) { | ||
1202 | BUG_ON(!rl_write_locked); | ||
1203 | /* Make the file cluster we allocated sparse in the runlist. */ | ||
1204 | if (ntfs_rl_punch_nolock(vol, &ni->runlist, bh_cpos, 1)) { | ||
1205 | ntfs_error(vol->sb, "Failed to punch hole into " | ||
1206 | "attribute runlist in error code " | ||
1207 | "path. Run chkdsk to recover the " | ||
1208 | "lost cluster."); | ||
1209 | make_bad_inode(vi); | ||
1210 | make_bad_inode(VFS_I(base_ni)); | ||
1211 | NVolSetErrors(vol); | ||
1212 | } else /* if (success) */ { | ||
1213 | status.runlist_merged = 0; | ||
1214 | /* | ||
1215 | * Deallocate the on-disk cluster we allocated but only | ||
1216 | * if we succeeded in punching its vcn out of the | ||
1217 | * runlist. | ||
1218 | */ | ||
1219 | down_write(&vol->lcnbmp_lock); | ||
1220 | if (ntfs_bitmap_clear_bit(vol->lcnbmp_ino, lcn)) { | ||
1221 | ntfs_error(vol->sb, "Failed to release " | ||
1222 | "allocated cluster in error " | ||
1223 | "code path. Run chkdsk to " | ||
1224 | "recover the lost cluster."); | ||
1225 | NVolSetErrors(vol); | ||
1226 | } | ||
1227 | up_write(&vol->lcnbmp_lock); | ||
1228 | } | ||
1229 | } | ||
1230 | /* | ||
1231 | * Resize the attribute record to its old size and rebuild the mapping | ||
1232 | * pairs array. Note, we only can do this if the runlist has been | ||
1233 | * restored to its old state which also implies that the mapped | ||
1234 | * attribute extent is not switched. | ||
1235 | */ | ||
1236 | if (status.mp_rebuilt && !status.runlist_merged) { | ||
1237 | if (ntfs_attr_record_resize(m, a, attr_rec_len)) { | ||
1238 | ntfs_error(vol->sb, "Failed to restore attribute " | ||
1239 | "record in error code path. Run " | ||
1240 | "chkdsk to recover."); | ||
1241 | make_bad_inode(vi); | ||
1242 | make_bad_inode(VFS_I(base_ni)); | ||
1243 | NVolSetErrors(vol); | ||
1244 | } else /* if (success) */ { | ||
1245 | if (ntfs_mapping_pairs_build(vol, (u8*)a + | ||
1246 | le16_to_cpu(a->data.non_resident. | ||
1247 | mapping_pairs_offset), attr_rec_len - | ||
1248 | le16_to_cpu(a->data.non_resident. | ||
1249 | mapping_pairs_offset), ni->runlist.rl, | ||
1250 | vcn, highest_vcn, NULL)) { | ||
1251 | ntfs_error(vol->sb, "Failed to restore " | ||
1252 | "mapping pairs array in error " | ||
1253 | "code path. Run chkdsk to " | ||
1254 | "recover."); | ||
1255 | make_bad_inode(vi); | ||
1256 | make_bad_inode(VFS_I(base_ni)); | ||
1257 | NVolSetErrors(vol); | ||
1258 | } | ||
1259 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
1260 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
1261 | } | ||
1262 | } | ||
1263 | /* Release the mft record and the attribute. */ | ||
1264 | if (status.mft_attr_mapped) { | ||
1265 | ntfs_attr_put_search_ctx(ctx); | ||
1266 | unmap_mft_record(base_ni); | ||
1267 | } | ||
1268 | /* Release the runlist lock. */ | ||
1269 | if (rl_write_locked) | ||
1270 | up_write(&ni->runlist.lock); | ||
1271 | else if (rl) | ||
1272 | up_read(&ni->runlist.lock); | ||
1273 | /* | ||
1274 | * Zero out any newly allocated blocks to avoid exposing stale data. | ||
1275 | * If BH_New is set, we know that the block was newly allocated above | ||
1276 | * and that it has not been fully zeroed and marked dirty yet. | ||
1277 | */ | ||
1278 | nr_pages = u; | ||
1279 | u = 0; | ||
1280 | end = bh_cpos << vol->cluster_size_bits; | ||
1281 | do { | ||
1282 | page = pages[u]; | ||
1283 | bh = head = page_buffers(page); | ||
1284 | do { | ||
1285 | if (u == nr_pages && | ||
1286 | ((s64)page->index << PAGE_CACHE_SHIFT) + | ||
1287 | bh_offset(bh) >= end) | ||
1288 | break; | ||
1289 | if (!buffer_new(bh)) | ||
1290 | continue; | ||
1291 | clear_buffer_new(bh); | ||
1292 | if (!buffer_uptodate(bh)) { | ||
1293 | if (PageUptodate(page)) | ||
1294 | set_buffer_uptodate(bh); | ||
1295 | else { | ||
1296 | u8 *kaddr = kmap_atomic(page, KM_USER0); | ||
1297 | memset(kaddr + bh_offset(bh), 0, | ||
1298 | blocksize); | ||
1299 | kunmap_atomic(kaddr, KM_USER0); | ||
1300 | flush_dcache_page(page); | ||
1301 | set_buffer_uptodate(bh); | ||
1302 | } | ||
1303 | } | ||
1304 | mark_buffer_dirty(bh); | ||
1305 | } while ((bh = bh->b_this_page) != head); | ||
1306 | } while (++u <= nr_pages); | ||
1307 | ntfs_error(vol->sb, "Failed. Returning error code %i.", err); | ||
1308 | return err; | ||
1309 | } | ||
1310 | |||
1311 | /* | ||
1312 | * Copy as much as we can into the pages and return the number of bytes which | ||
1313 | * were sucessfully copied. If a fault is encountered then clear the pages | ||
1314 | * out to (ofs + bytes) and return the number of bytes which were copied. | ||
1315 | */ | ||
1316 | static inline size_t ntfs_copy_from_user(struct page **pages, | ||
1317 | unsigned nr_pages, unsigned ofs, const char __user *buf, | ||
1318 | size_t bytes) | ||
1319 | { | ||
1320 | struct page **last_page = pages + nr_pages; | ||
1321 | char *kaddr; | ||
1322 | size_t total = 0; | ||
1323 | unsigned len; | ||
1324 | int left; | ||
1325 | |||
1326 | do { | ||
1327 | len = PAGE_CACHE_SIZE - ofs; | ||
1328 | if (len > bytes) | ||
1329 | len = bytes; | ||
1330 | kaddr = kmap_atomic(*pages, KM_USER0); | ||
1331 | left = __copy_from_user_inatomic(kaddr + ofs, buf, len); | ||
1332 | kunmap_atomic(kaddr, KM_USER0); | ||
1333 | if (unlikely(left)) { | ||
1334 | /* Do it the slow way. */ | ||
1335 | kaddr = kmap(*pages); | ||
1336 | left = __copy_from_user(kaddr + ofs, buf, len); | ||
1337 | kunmap(*pages); | ||
1338 | if (unlikely(left)) | ||
1339 | goto err_out; | ||
1340 | } | ||
1341 | total += len; | ||
1342 | bytes -= len; | ||
1343 | if (!bytes) | ||
1344 | break; | ||
1345 | buf += len; | ||
1346 | ofs = 0; | ||
1347 | } while (++pages < last_page); | ||
1348 | out: | ||
1349 | return total; | ||
1350 | err_out: | ||
1351 | total += len - left; | ||
1352 | /* Zero the rest of the target like __copy_from_user(). */ | ||
1353 | while (++pages < last_page) { | ||
1354 | bytes -= len; | ||
1355 | if (!bytes) | ||
1356 | break; | ||
1357 | len = PAGE_CACHE_SIZE; | ||
1358 | if (len > bytes) | ||
1359 | len = bytes; | ||
1360 | kaddr = kmap_atomic(*pages, KM_USER0); | ||
1361 | memset(kaddr, 0, len); | ||
1362 | kunmap_atomic(kaddr, KM_USER0); | ||
1363 | } | ||
1364 | goto out; | ||
1365 | } | ||
1366 | |||
1367 | static size_t __ntfs_copy_from_user_iovec(char *vaddr, | ||
1368 | const struct iovec *iov, size_t iov_ofs, size_t bytes) | ||
1369 | { | ||
1370 | size_t total = 0; | ||
1371 | |||
1372 | while (1) { | ||
1373 | const char __user *buf = iov->iov_base + iov_ofs; | ||
1374 | unsigned len; | ||
1375 | size_t left; | ||
1376 | |||
1377 | len = iov->iov_len - iov_ofs; | ||
1378 | if (len > bytes) | ||
1379 | len = bytes; | ||
1380 | left = __copy_from_user_inatomic(vaddr, buf, len); | ||
1381 | total += len; | ||
1382 | bytes -= len; | ||
1383 | vaddr += len; | ||
1384 | if (unlikely(left)) { | ||
1385 | /* | ||
1386 | * Zero the rest of the target like __copy_from_user(). | ||
1387 | */ | ||
1388 | memset(vaddr, 0, bytes); | ||
1389 | total -= left; | ||
1390 | break; | ||
1391 | } | ||
1392 | if (!bytes) | ||
1393 | break; | ||
1394 | iov++; | ||
1395 | iov_ofs = 0; | ||
1396 | } | ||
1397 | return total; | ||
1398 | } | ||
1399 | |||
1400 | static inline void ntfs_set_next_iovec(const struct iovec **iovp, | ||
1401 | size_t *iov_ofsp, size_t bytes) | ||
1402 | { | ||
1403 | const struct iovec *iov = *iovp; | ||
1404 | size_t iov_ofs = *iov_ofsp; | ||
1405 | |||
1406 | while (bytes) { | ||
1407 | unsigned len; | ||
1408 | |||
1409 | len = iov->iov_len - iov_ofs; | ||
1410 | if (len > bytes) | ||
1411 | len = bytes; | ||
1412 | bytes -= len; | ||
1413 | iov_ofs += len; | ||
1414 | if (iov->iov_len == iov_ofs) { | ||
1415 | iov++; | ||
1416 | iov_ofs = 0; | ||
1417 | } | ||
1418 | } | ||
1419 | *iovp = iov; | ||
1420 | *iov_ofsp = iov_ofs; | ||
1421 | } | ||
1422 | |||
1423 | /* | ||
1424 | * This has the same side-effects and return value as ntfs_copy_from_user(). | ||
1425 | * The difference is that on a fault we need to memset the remainder of the | ||
1426 | * pages (out to offset + bytes), to emulate ntfs_copy_from_user()'s | ||
1427 | * single-segment behaviour. | ||
1428 | * | ||
1429 | * We call the same helper (__ntfs_copy_from_user_iovec()) both when atomic and | ||
1430 | * when not atomic. This is ok because __ntfs_copy_from_user_iovec() calls | ||
1431 | * __copy_from_user_inatomic() and it is ok to call this when non-atomic. In | ||
1432 | * fact, the only difference between __copy_from_user_inatomic() and | ||
1433 | * __copy_from_user() is that the latter calls might_sleep(). And on many | ||
1434 | * architectures __copy_from_user_inatomic() is just defined to | ||
1435 | * __copy_from_user() so it makes no difference at all on those architectures. | ||
1436 | */ | ||
1437 | static inline size_t ntfs_copy_from_user_iovec(struct page **pages, | ||
1438 | unsigned nr_pages, unsigned ofs, const struct iovec **iov, | ||
1439 | size_t *iov_ofs, size_t bytes) | ||
1440 | { | ||
1441 | struct page **last_page = pages + nr_pages; | ||
1442 | char *kaddr; | ||
1443 | size_t copied, len, total = 0; | ||
1444 | |||
1445 | do { | ||
1446 | len = PAGE_CACHE_SIZE - ofs; | ||
1447 | if (len > bytes) | ||
1448 | len = bytes; | ||
1449 | kaddr = kmap_atomic(*pages, KM_USER0); | ||
1450 | copied = __ntfs_copy_from_user_iovec(kaddr + ofs, | ||
1451 | *iov, *iov_ofs, len); | ||
1452 | kunmap_atomic(kaddr, KM_USER0); | ||
1453 | if (unlikely(copied != len)) { | ||
1454 | /* Do it the slow way. */ | ||
1455 | kaddr = kmap(*pages); | ||
1456 | copied = __ntfs_copy_from_user_iovec(kaddr + ofs, | ||
1457 | *iov, *iov_ofs, len); | ||
1458 | kunmap(*pages); | ||
1459 | if (unlikely(copied != len)) | ||
1460 | goto err_out; | ||
1461 | } | ||
1462 | total += len; | ||
1463 | bytes -= len; | ||
1464 | if (!bytes) | ||
1465 | break; | ||
1466 | ntfs_set_next_iovec(iov, iov_ofs, len); | ||
1467 | ofs = 0; | ||
1468 | } while (++pages < last_page); | ||
1469 | out: | ||
1470 | return total; | ||
1471 | err_out: | ||
1472 | total += copied; | ||
1473 | /* Zero the rest of the target like __copy_from_user(). */ | ||
1474 | while (++pages < last_page) { | ||
1475 | bytes -= len; | ||
1476 | if (!bytes) | ||
1477 | break; | ||
1478 | len = PAGE_CACHE_SIZE; | ||
1479 | if (len > bytes) | ||
1480 | len = bytes; | ||
1481 | kaddr = kmap_atomic(*pages, KM_USER0); | ||
1482 | memset(kaddr, 0, len); | ||
1483 | kunmap_atomic(kaddr, KM_USER0); | ||
1484 | } | ||
1485 | goto out; | ||
1486 | } | ||
1487 | |||
1488 | static inline void ntfs_flush_dcache_pages(struct page **pages, | ||
1489 | unsigned nr_pages) | ||
1490 | { | ||
1491 | BUG_ON(!nr_pages); | ||
1492 | do { | ||
1493 | /* | ||
1494 | * Warning: Do not do the decrement at the same time as the | ||
1495 | * call because flush_dcache_page() is a NULL macro on i386 | ||
1496 | * and hence the decrement never happens. | ||
1497 | */ | ||
1498 | flush_dcache_page(pages[nr_pages]); | ||
1499 | } while (--nr_pages > 0); | ||
1500 | } | ||
1501 | |||
1502 | /** | ||
1503 | * ntfs_commit_pages_after_non_resident_write - commit the received data | ||
1504 | * @pages: array of destination pages | ||
1505 | * @nr_pages: number of pages in @pages | ||
1506 | * @pos: byte position in file at which the write begins | ||
1507 | * @bytes: number of bytes to be written | ||
1508 | * | ||
1509 | * See description of ntfs_commit_pages_after_write(), below. | ||
1510 | */ | ||
1511 | static inline int ntfs_commit_pages_after_non_resident_write( | ||
1512 | struct page **pages, const unsigned nr_pages, | ||
1513 | s64 pos, size_t bytes) | ||
1514 | { | ||
1515 | s64 end, initialized_size; | ||
1516 | struct inode *vi; | ||
1517 | ntfs_inode *ni, *base_ni; | ||
1518 | struct buffer_head *bh, *head; | ||
1519 | ntfs_attr_search_ctx *ctx; | ||
1520 | MFT_RECORD *m; | ||
1521 | ATTR_RECORD *a; | ||
1522 | unsigned long flags; | ||
1523 | unsigned blocksize, u; | ||
1524 | int err; | ||
1525 | |||
1526 | vi = pages[0]->mapping->host; | ||
1527 | ni = NTFS_I(vi); | ||
1528 | blocksize = 1 << vi->i_blkbits; | ||
1529 | end = pos + bytes; | ||
1530 | u = 0; | ||
1531 | do { | ||
1532 | s64 bh_pos; | ||
1533 | struct page *page; | ||
1534 | BOOL partial; | ||
1535 | |||
1536 | page = pages[u]; | ||
1537 | bh_pos = (s64)page->index << PAGE_CACHE_SHIFT; | ||
1538 | bh = head = page_buffers(page); | ||
1539 | partial = FALSE; | ||
1540 | do { | ||
1541 | s64 bh_end; | ||
1542 | |||
1543 | bh_end = bh_pos + blocksize; | ||
1544 | if (bh_end <= pos || bh_pos >= end) { | ||
1545 | if (!buffer_uptodate(bh)) | ||
1546 | partial = TRUE; | ||
1547 | } else { | ||
1548 | set_buffer_uptodate(bh); | ||
1549 | mark_buffer_dirty(bh); | ||
1550 | } | ||
1551 | } while (bh_pos += blocksize, (bh = bh->b_this_page) != head); | ||
1552 | /* | ||
1553 | * If all buffers are now uptodate but the page is not, set the | ||
1554 | * page uptodate. | ||
1555 | */ | ||
1556 | if (!partial && !PageUptodate(page)) | ||
1557 | SetPageUptodate(page); | ||
1558 | } while (++u < nr_pages); | ||
1559 | /* | ||
1560 | * Finally, if we do not need to update initialized_size or i_size we | ||
1561 | * are finished. | ||
1562 | */ | ||
1563 | read_lock_irqsave(&ni->size_lock, flags); | ||
1564 | initialized_size = ni->initialized_size; | ||
1565 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
1566 | if (end <= initialized_size) { | ||
1567 | ntfs_debug("Done."); | ||
1568 | return 0; | ||
1569 | } | ||
1570 | /* | ||
1571 | * Update initialized_size/i_size as appropriate, both in the inode and | ||
1572 | * the mft record. | ||
1573 | */ | ||
1574 | if (!NInoAttr(ni)) | ||
1575 | base_ni = ni; | ||
1576 | else | ||
1577 | base_ni = ni->ext.base_ntfs_ino; | ||
1578 | /* Map, pin, and lock the mft record. */ | ||
1579 | m = map_mft_record(base_ni); | ||
1580 | if (IS_ERR(m)) { | ||
1581 | err = PTR_ERR(m); | ||
1582 | m = NULL; | ||
1583 | ctx = NULL; | ||
1584 | goto err_out; | ||
1585 | } | ||
1586 | BUG_ON(!NInoNonResident(ni)); | ||
1587 | ctx = ntfs_attr_get_search_ctx(base_ni, m); | ||
1588 | if (unlikely(!ctx)) { | ||
1589 | err = -ENOMEM; | ||
1590 | goto err_out; | ||
1591 | } | ||
1592 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
1593 | CASE_SENSITIVE, 0, NULL, 0, ctx); | ||
1594 | if (unlikely(err)) { | ||
1595 | if (err == -ENOENT) | ||
1596 | err = -EIO; | ||
1597 | goto err_out; | ||
1598 | } | ||
1599 | a = ctx->attr; | ||
1600 | BUG_ON(!a->non_resident); | ||
1601 | write_lock_irqsave(&ni->size_lock, flags); | ||
1602 | BUG_ON(end > ni->allocated_size); | ||
1603 | ni->initialized_size = end; | ||
1604 | a->data.non_resident.initialized_size = cpu_to_sle64(end); | ||
1605 | if (end > i_size_read(vi)) { | ||
1606 | i_size_write(vi, end); | ||
1607 | a->data.non_resident.data_size = | ||
1608 | a->data.non_resident.initialized_size; | ||
1609 | } | ||
1610 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
1611 | /* Mark the mft record dirty, so it gets written back. */ | ||
1612 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
1613 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
1614 | ntfs_attr_put_search_ctx(ctx); | ||
1615 | unmap_mft_record(base_ni); | ||
1616 | ntfs_debug("Done."); | ||
1617 | return 0; | ||
1618 | err_out: | ||
1619 | if (ctx) | ||
1620 | ntfs_attr_put_search_ctx(ctx); | ||
1621 | if (m) | ||
1622 | unmap_mft_record(base_ni); | ||
1623 | ntfs_error(vi->i_sb, "Failed to update initialized_size/i_size (error " | ||
1624 | "code %i).", err); | ||
1625 | if (err != -ENOMEM) { | ||
1626 | NVolSetErrors(ni->vol); | ||
1627 | make_bad_inode(VFS_I(base_ni)); | ||
1628 | make_bad_inode(vi); | ||
1629 | } | ||
1630 | return err; | ||
1631 | } | ||
1632 | |||
1633 | /** | ||
1634 | * ntfs_commit_pages_after_write - commit the received data | ||
1635 | * @pages: array of destination pages | ||
1636 | * @nr_pages: number of pages in @pages | ||
1637 | * @pos: byte position in file at which the write begins | ||
1638 | * @bytes: number of bytes to be written | ||
1639 | * | ||
1640 | * This is called from ntfs_file_buffered_write() with i_sem held on the inode | ||
1641 | * (@pages[0]->mapping->host). There are @nr_pages pages in @pages which are | ||
1642 | * locked but not kmap()ped. The source data has already been copied into the | ||
1643 | * @page. ntfs_prepare_pages_for_non_resident_write() has been called before | ||
1644 | * the data was copied (for non-resident attributes only) and it returned | ||
1645 | * success. | ||
1646 | * | ||
1647 | * Need to set uptodate and mark dirty all buffers within the boundary of the | ||
1648 | * write. If all buffers in a page are uptodate we set the page uptodate, too. | ||
1649 | * | ||
1650 | * Setting the buffers dirty ensures that they get written out later when | ||
1651 | * ntfs_writepage() is invoked by the VM. | ||
1652 | * | ||
1653 | * Finally, we need to update i_size and initialized_size as appropriate both | ||
1654 | * in the inode and the mft record. | ||
1655 | * | ||
1656 | * This is modelled after fs/buffer.c::generic_commit_write(), which marks | ||
1657 | * buffers uptodate and dirty, sets the page uptodate if all buffers in the | ||
1658 | * page are uptodate, and updates i_size if the end of io is beyond i_size. In | ||
1659 | * that case, it also marks the inode dirty. | ||
1660 | * | ||
1661 | * If things have gone as outlined in | ||
1662 | * ntfs_prepare_pages_for_non_resident_write(), we do not need to do any page | ||
1663 | * content modifications here for non-resident attributes. For resident | ||
1664 | * attributes we need to do the uptodate bringing here which we combine with | ||
1665 | * the copying into the mft record which means we save one atomic kmap. | ||
1666 | * | ||
1667 | * Return 0 on success or -errno on error. | ||
1668 | */ | ||
1669 | static int ntfs_commit_pages_after_write(struct page **pages, | ||
1670 | const unsigned nr_pages, s64 pos, size_t bytes) | ||
1671 | { | ||
1672 | s64 end, initialized_size; | ||
1673 | loff_t i_size; | ||
1674 | struct inode *vi; | ||
1675 | ntfs_inode *ni, *base_ni; | ||
1676 | struct page *page; | ||
1677 | ntfs_attr_search_ctx *ctx; | ||
1678 | MFT_RECORD *m; | ||
1679 | ATTR_RECORD *a; | ||
1680 | char *kattr, *kaddr; | ||
1681 | unsigned long flags; | ||
1682 | u32 attr_len; | ||
1683 | int err; | ||
1684 | |||
1685 | BUG_ON(!nr_pages); | ||
1686 | BUG_ON(!pages); | ||
1687 | page = pages[0]; | ||
1688 | BUG_ON(!page); | ||
1689 | vi = page->mapping->host; | ||
1690 | ni = NTFS_I(vi); | ||
1691 | ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, start page " | ||
1692 | "index 0x%lx, nr_pages 0x%x, pos 0x%llx, bytes 0x%zx.", | ||
1693 | vi->i_ino, ni->type, page->index, nr_pages, | ||
1694 | (long long)pos, bytes); | ||
1695 | if (NInoNonResident(ni)) | ||
1696 | return ntfs_commit_pages_after_non_resident_write(pages, | ||
1697 | nr_pages, pos, bytes); | ||
1698 | BUG_ON(nr_pages > 1); | ||
1699 | /* | ||
1700 | * Attribute is resident, implying it is not compressed, encrypted, or | ||
1701 | * sparse. | ||
1702 | */ | ||
1703 | if (!NInoAttr(ni)) | ||
1704 | base_ni = ni; | ||
1705 | else | ||
1706 | base_ni = ni->ext.base_ntfs_ino; | ||
1707 | BUG_ON(NInoNonResident(ni)); | ||
1708 | /* Map, pin, and lock the mft record. */ | ||
1709 | m = map_mft_record(base_ni); | ||
1710 | if (IS_ERR(m)) { | ||
1711 | err = PTR_ERR(m); | ||
1712 | m = NULL; | ||
1713 | ctx = NULL; | ||
1714 | goto err_out; | ||
1715 | } | ||
1716 | ctx = ntfs_attr_get_search_ctx(base_ni, m); | ||
1717 | if (unlikely(!ctx)) { | ||
1718 | err = -ENOMEM; | ||
1719 | goto err_out; | ||
1720 | } | ||
1721 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | ||
1722 | CASE_SENSITIVE, 0, NULL, 0, ctx); | ||
1723 | if (unlikely(err)) { | ||
1724 | if (err == -ENOENT) | ||
1725 | err = -EIO; | ||
1726 | goto err_out; | ||
1727 | } | ||
1728 | a = ctx->attr; | ||
1729 | BUG_ON(a->non_resident); | ||
1730 | /* The total length of the attribute value. */ | ||
1731 | attr_len = le32_to_cpu(a->data.resident.value_length); | ||
1732 | i_size = i_size_read(vi); | ||
1733 | BUG_ON(attr_len != i_size); | ||
1734 | BUG_ON(pos > attr_len); | ||
1735 | end = pos + bytes; | ||
1736 | BUG_ON(end > le32_to_cpu(a->length) - | ||
1737 | le16_to_cpu(a->data.resident.value_offset)); | ||
1738 | kattr = (u8*)a + le16_to_cpu(a->data.resident.value_offset); | ||
1739 | kaddr = kmap_atomic(page, KM_USER0); | ||
1740 | /* Copy the received data from the page to the mft record. */ | ||
1741 | memcpy(kattr + pos, kaddr + pos, bytes); | ||
1742 | /* Update the attribute length if necessary. */ | ||
1743 | if (end > attr_len) { | ||
1744 | attr_len = end; | ||
1745 | a->data.resident.value_length = cpu_to_le32(attr_len); | ||
1746 | } | ||
1747 | /* | ||
1748 | * If the page is not uptodate, bring the out of bounds area(s) | ||
1749 | * uptodate by copying data from the mft record to the page. | ||
1750 | */ | ||
1751 | if (!PageUptodate(page)) { | ||
1752 | if (pos > 0) | ||
1753 | memcpy(kaddr, kattr, pos); | ||
1754 | if (end < attr_len) | ||
1755 | memcpy(kaddr + end, kattr + end, attr_len - end); | ||
1756 | /* Zero the region outside the end of the attribute value. */ | ||
1757 | memset(kaddr + attr_len, 0, PAGE_CACHE_SIZE - attr_len); | ||
1758 | flush_dcache_page(page); | ||
1759 | SetPageUptodate(page); | ||
1760 | } | ||
1761 | kunmap_atomic(kaddr, KM_USER0); | ||
1762 | /* Update initialized_size/i_size if necessary. */ | ||
1763 | read_lock_irqsave(&ni->size_lock, flags); | ||
1764 | initialized_size = ni->initialized_size; | ||
1765 | BUG_ON(end > ni->allocated_size); | ||
1766 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
1767 | BUG_ON(initialized_size != i_size); | ||
1768 | if (end > initialized_size) { | ||
1769 | unsigned long flags; | ||
1770 | |||
1771 | write_lock_irqsave(&ni->size_lock, flags); | ||
1772 | ni->initialized_size = end; | ||
1773 | i_size_write(vi, end); | ||
1774 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
1775 | } | ||
1776 | /* Mark the mft record dirty, so it gets written back. */ | ||
1777 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
1778 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
1779 | ntfs_attr_put_search_ctx(ctx); | ||
1780 | unmap_mft_record(base_ni); | ||
1781 | ntfs_debug("Done."); | ||
1782 | return 0; | ||
1783 | err_out: | ||
1784 | if (err == -ENOMEM) { | ||
1785 | ntfs_warning(vi->i_sb, "Error allocating memory required to " | ||
1786 | "commit the write."); | ||
1787 | if (PageUptodate(page)) { | ||
1788 | ntfs_warning(vi->i_sb, "Page is uptodate, setting " | ||
1789 | "dirty so the write will be retried " | ||
1790 | "later on by the VM."); | ||
1791 | /* | ||
1792 | * Put the page on mapping->dirty_pages, but leave its | ||
1793 | * buffers' dirty state as-is. | ||
1794 | */ | ||
1795 | __set_page_dirty_nobuffers(page); | ||
1796 | err = 0; | ||
1797 | } else | ||
1798 | ntfs_error(vi->i_sb, "Page is not uptodate. Written " | ||
1799 | "data has been lost."); | ||
1800 | } else { | ||
1801 | ntfs_error(vi->i_sb, "Resident attribute commit write failed " | ||
1802 | "with error %i.", err); | ||
1803 | NVolSetErrors(ni->vol); | ||
1804 | make_bad_inode(VFS_I(base_ni)); | ||
1805 | make_bad_inode(vi); | ||
1806 | } | ||
1807 | if (ctx) | ||
1808 | ntfs_attr_put_search_ctx(ctx); | ||
1809 | if (m) | ||
1810 | unmap_mft_record(base_ni); | ||
1811 | return err; | ||
1812 | } | ||
1813 | |||
1814 | /** | ||
1815 | * ntfs_file_buffered_write - | ||
1816 | * | ||
1817 | * Locking: The vfs is holding ->i_sem on the inode. | ||
1818 | */ | ||
1819 | static ssize_t ntfs_file_buffered_write(struct kiocb *iocb, | ||
1820 | const struct iovec *iov, unsigned long nr_segs, | ||
1821 | loff_t pos, loff_t *ppos, size_t count) | ||
1822 | { | ||
1823 | struct file *file = iocb->ki_filp; | ||
1824 | struct address_space *mapping = file->f_mapping; | ||
1825 | struct inode *vi = mapping->host; | ||
1826 | ntfs_inode *ni = NTFS_I(vi); | ||
1827 | ntfs_volume *vol = ni->vol; | ||
1828 | struct page *pages[NTFS_MAX_PAGES_PER_CLUSTER]; | ||
1829 | struct page *cached_page = NULL; | ||
1830 | char __user *buf = NULL; | ||
1831 | s64 end, ll; | ||
1832 | VCN last_vcn; | ||
1833 | LCN lcn; | ||
1834 | unsigned long flags; | ||
1835 | size_t bytes, iov_ofs = 0; /* Offset in the current iovec. */ | ||
1836 | ssize_t status, written; | ||
1837 | unsigned nr_pages; | ||
1838 | int err; | ||
1839 | struct pagevec lru_pvec; | ||
1840 | |||
1841 | ntfs_debug("Entering for i_ino 0x%lx, attribute type 0x%x, " | ||
1842 | "pos 0x%llx, count 0x%lx.", | ||
1843 | vi->i_ino, (unsigned)le32_to_cpu(ni->type), | ||
1844 | (unsigned long long)pos, (unsigned long)count); | ||
1845 | if (unlikely(!count)) | ||
1846 | return 0; | ||
1847 | BUG_ON(NInoMstProtected(ni)); | ||
1848 | /* | ||
1849 | * If the attribute is not an index root and it is encrypted or | ||
1850 | * compressed, we cannot write to it yet. Note we need to check for | ||
1851 | * AT_INDEX_ALLOCATION since this is the type of both directory and | ||
1852 | * index inodes. | ||
1853 | */ | ||
1854 | if (ni->type != AT_INDEX_ALLOCATION) { | ||
1855 | /* If file is encrypted, deny access, just like NT4. */ | ||
1856 | if (NInoEncrypted(ni)) { | ||
1857 | /* | ||
1858 | * Reminder for later: Encrypted files are _always_ | ||
1859 | * non-resident so that the content can always be | ||
1860 | * encrypted. | ||
1861 | */ | ||
1862 | ntfs_debug("Denying write access to encrypted file."); | ||
1863 | return -EACCES; | ||
1864 | } | ||
1865 | if (NInoCompressed(ni)) { | ||
1866 | /* Only unnamed $DATA attribute can be compressed. */ | ||
1867 | BUG_ON(ni->type != AT_DATA); | ||
1868 | BUG_ON(ni->name_len); | ||
1869 | /* | ||
1870 | * Reminder for later: If resident, the data is not | ||
1871 | * actually compressed. Only on the switch to non- | ||
1872 | * resident does compression kick in. This is in | ||
1873 | * contrast to encrypted files (see above). | ||
1874 | */ | ||
1875 | ntfs_error(vi->i_sb, "Writing to compressed files is " | ||
1876 | "not implemented yet. Sorry."); | ||
1877 | return -EOPNOTSUPP; | ||
1878 | } | ||
1879 | } | ||
1880 | /* | ||
1881 | * If a previous ntfs_truncate() failed, repeat it and abort if it | ||
1882 | * fails again. | ||
1883 | */ | ||
1884 | if (unlikely(NInoTruncateFailed(ni))) { | ||
1885 | down_write(&vi->i_alloc_sem); | ||
1886 | err = ntfs_truncate(vi); | ||
1887 | up_write(&vi->i_alloc_sem); | ||
1888 | if (err || NInoTruncateFailed(ni)) { | ||
1889 | if (!err) | ||
1890 | err = -EIO; | ||
1891 | ntfs_error(vol->sb, "Cannot perform write to inode " | ||
1892 | "0x%lx, attribute type 0x%x, because " | ||
1893 | "ntfs_truncate() failed (error code " | ||
1894 | "%i).", vi->i_ino, | ||
1895 | (unsigned)le32_to_cpu(ni->type), err); | ||
1896 | return err; | ||
1897 | } | ||
1898 | } | ||
1899 | /* The first byte after the write. */ | ||
1900 | end = pos + count; | ||
1901 | /* | ||
1902 | * If the write goes beyond the allocated size, extend the allocation | ||
1903 | * to cover the whole of the write, rounded up to the nearest cluster. | ||
1904 | */ | ||
1905 | read_lock_irqsave(&ni->size_lock, flags); | ||
1906 | ll = ni->allocated_size; | ||
1907 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
1908 | if (end > ll) { | ||
1909 | /* Extend the allocation without changing the data size. */ | ||
1910 | ll = ntfs_attr_extend_allocation(ni, end, -1, pos); | ||
1911 | if (likely(ll >= 0)) { | ||
1912 | BUG_ON(pos >= ll); | ||
1913 | /* If the extension was partial truncate the write. */ | ||
1914 | if (end > ll) { | ||
1915 | ntfs_debug("Truncating write to inode 0x%lx, " | ||
1916 | "attribute type 0x%x, because " | ||
1917 | "the allocation was only " | ||
1918 | "partially extended.", | ||
1919 | vi->i_ino, (unsigned) | ||
1920 | le32_to_cpu(ni->type)); | ||
1921 | end = ll; | ||
1922 | count = ll - pos; | ||
1923 | } | ||
1924 | } else { | ||
1925 | err = ll; | ||
1926 | read_lock_irqsave(&ni->size_lock, flags); | ||
1927 | ll = ni->allocated_size; | ||
1928 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
1929 | /* Perform a partial write if possible or fail. */ | ||
1930 | if (pos < ll) { | ||
1931 | ntfs_debug("Truncating write to inode 0x%lx, " | ||
1932 | "attribute type 0x%x, because " | ||
1933 | "extending the allocation " | ||
1934 | "failed (error code %i).", | ||
1935 | vi->i_ino, (unsigned) | ||
1936 | le32_to_cpu(ni->type), err); | ||
1937 | end = ll; | ||
1938 | count = ll - pos; | ||
1939 | } else { | ||
1940 | ntfs_error(vol->sb, "Cannot perform write to " | ||
1941 | "inode 0x%lx, attribute type " | ||
1942 | "0x%x, because extending the " | ||
1943 | "allocation failed (error " | ||
1944 | "code %i).", vi->i_ino, | ||
1945 | (unsigned) | ||
1946 | le32_to_cpu(ni->type), err); | ||
1947 | return err; | ||
1948 | } | ||
1949 | } | ||
1950 | } | ||
1951 | pagevec_init(&lru_pvec, 0); | ||
1952 | written = 0; | ||
1953 | /* | ||
1954 | * If the write starts beyond the initialized size, extend it up to the | ||
1955 | * beginning of the write and initialize all non-sparse space between | ||
1956 | * the old initialized size and the new one. This automatically also | ||
1957 | * increments the vfs inode->i_size to keep it above or equal to the | ||
1958 | * initialized_size. | ||
1959 | */ | ||
1960 | read_lock_irqsave(&ni->size_lock, flags); | ||
1961 | ll = ni->initialized_size; | ||
1962 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
1963 | if (pos > ll) { | ||
1964 | err = ntfs_attr_extend_initialized(ni, pos, &cached_page, | ||
1965 | &lru_pvec); | ||
1966 | if (err < 0) { | ||
1967 | ntfs_error(vol->sb, "Cannot perform write to inode " | ||
1968 | "0x%lx, attribute type 0x%x, because " | ||
1969 | "extending the initialized size " | ||
1970 | "failed (error code %i).", vi->i_ino, | ||
1971 | (unsigned)le32_to_cpu(ni->type), err); | ||
1972 | status = err; | ||
1973 | goto err_out; | ||
1974 | } | ||
1975 | } | ||
1976 | /* | ||
1977 | * Determine the number of pages per cluster for non-resident | ||
1978 | * attributes. | ||
1979 | */ | ||
1980 | nr_pages = 1; | ||
1981 | if (vol->cluster_size > PAGE_CACHE_SIZE && NInoNonResident(ni)) | ||
1982 | nr_pages = vol->cluster_size >> PAGE_CACHE_SHIFT; | ||
1983 | /* Finally, perform the actual write. */ | ||
1984 | last_vcn = -1; | ||
1985 | if (likely(nr_segs == 1)) | ||
1986 | buf = iov->iov_base; | ||
1987 | do { | ||
1988 | VCN vcn; | ||
1989 | pgoff_t idx, start_idx; | ||
1990 | unsigned ofs, do_pages, u; | ||
1991 | size_t copied; | ||
1992 | |||
1993 | start_idx = idx = pos >> PAGE_CACHE_SHIFT; | ||
1994 | ofs = pos & ~PAGE_CACHE_MASK; | ||
1995 | bytes = PAGE_CACHE_SIZE - ofs; | ||
1996 | do_pages = 1; | ||
1997 | if (nr_pages > 1) { | ||
1998 | vcn = pos >> vol->cluster_size_bits; | ||
1999 | if (vcn != last_vcn) { | ||
2000 | last_vcn = vcn; | ||
2001 | /* | ||
2002 | * Get the lcn of the vcn the write is in. If | ||
2003 | * it is a hole, need to lock down all pages in | ||
2004 | * the cluster. | ||
2005 | */ | ||
2006 | down_read(&ni->runlist.lock); | ||
2007 | lcn = ntfs_attr_vcn_to_lcn_nolock(ni, pos >> | ||
2008 | vol->cluster_size_bits, FALSE); | ||
2009 | up_read(&ni->runlist.lock); | ||
2010 | if (unlikely(lcn < LCN_HOLE)) { | ||
2011 | status = -EIO; | ||
2012 | if (lcn == LCN_ENOMEM) | ||
2013 | status = -ENOMEM; | ||
2014 | else | ||
2015 | ntfs_error(vol->sb, "Cannot " | ||
2016 | "perform write to " | ||
2017 | "inode 0x%lx, " | ||
2018 | "attribute type 0x%x, " | ||
2019 | "because the attribute " | ||
2020 | "is corrupt.", | ||
2021 | vi->i_ino, (unsigned) | ||
2022 | le32_to_cpu(ni->type)); | ||
2023 | break; | ||
2024 | } | ||
2025 | if (lcn == LCN_HOLE) { | ||
2026 | start_idx = (pos & ~(s64) | ||
2027 | vol->cluster_size_mask) | ||
2028 | >> PAGE_CACHE_SHIFT; | ||
2029 | bytes = vol->cluster_size - (pos & | ||
2030 | vol->cluster_size_mask); | ||
2031 | do_pages = nr_pages; | ||
2032 | } | ||
2033 | } | ||
2034 | } | ||
2035 | if (bytes > count) | ||
2036 | bytes = count; | ||
2037 | /* | ||
2038 | * Bring in the user page(s) that we will copy from _first_. | ||
2039 | * Otherwise there is a nasty deadlock on copying from the same | ||
2040 | * page(s) as we are writing to, without it/them being marked | ||
2041 | * up-to-date. Note, at present there is nothing to stop the | ||
2042 | * pages being swapped out between us bringing them into memory | ||
2043 | * and doing the actual copying. | ||
2044 | */ | ||
2045 | if (likely(nr_segs == 1)) | ||
2046 | ntfs_fault_in_pages_readable(buf, bytes); | ||
2047 | else | ||
2048 | ntfs_fault_in_pages_readable_iovec(iov, iov_ofs, bytes); | ||
2049 | /* Get and lock @do_pages starting at index @start_idx. */ | ||
2050 | status = __ntfs_grab_cache_pages(mapping, start_idx, do_pages, | ||
2051 | pages, &cached_page, &lru_pvec); | ||
2052 | if (unlikely(status)) | ||
2053 | break; | ||
2054 | /* | ||
2055 | * For non-resident attributes, we need to fill any holes with | ||
2056 | * actual clusters and ensure all bufferes are mapped. We also | ||
2057 | * need to bring uptodate any buffers that are only partially | ||
2058 | * being written to. | ||
2059 | */ | ||
2060 | if (NInoNonResident(ni)) { | ||
2061 | status = ntfs_prepare_pages_for_non_resident_write( | ||
2062 | pages, do_pages, pos, bytes); | ||
2063 | if (unlikely(status)) { | ||
2064 | loff_t i_size; | ||
2065 | |||
2066 | do { | ||
2067 | unlock_page(pages[--do_pages]); | ||
2068 | page_cache_release(pages[do_pages]); | ||
2069 | } while (do_pages); | ||
2070 | /* | ||
2071 | * The write preparation may have instantiated | ||
2072 | * allocated space outside i_size. Trim this | ||
2073 | * off again. We can ignore any errors in this | ||
2074 | * case as we will just be waisting a bit of | ||
2075 | * allocated space, which is not a disaster. | ||
2076 | */ | ||
2077 | i_size = i_size_read(vi); | ||
2078 | if (pos + bytes > i_size) | ||
2079 | vmtruncate(vi, i_size); | ||
2080 | break; | ||
2081 | } | ||
2082 | } | ||
2083 | u = (pos >> PAGE_CACHE_SHIFT) - pages[0]->index; | ||
2084 | if (likely(nr_segs == 1)) { | ||
2085 | copied = ntfs_copy_from_user(pages + u, do_pages - u, | ||
2086 | ofs, buf, bytes); | ||
2087 | buf += copied; | ||
2088 | } else | ||
2089 | copied = ntfs_copy_from_user_iovec(pages + u, | ||
2090 | do_pages - u, ofs, &iov, &iov_ofs, | ||
2091 | bytes); | ||
2092 | ntfs_flush_dcache_pages(pages + u, do_pages - u); | ||
2093 | status = ntfs_commit_pages_after_write(pages, do_pages, pos, | ||
2094 | bytes); | ||
2095 | if (likely(!status)) { | ||
2096 | written += copied; | ||
2097 | count -= copied; | ||
2098 | pos += copied; | ||
2099 | if (unlikely(copied != bytes)) | ||
2100 | status = -EFAULT; | ||
2101 | } | ||
2102 | do { | ||
2103 | unlock_page(pages[--do_pages]); | ||
2104 | mark_page_accessed(pages[do_pages]); | ||
2105 | page_cache_release(pages[do_pages]); | ||
2106 | } while (do_pages); | ||
2107 | if (unlikely(status)) | ||
2108 | break; | ||
2109 | balance_dirty_pages_ratelimited(mapping); | ||
2110 | cond_resched(); | ||
2111 | } while (count); | ||
2112 | err_out: | ||
2113 | *ppos = pos; | ||
2114 | if (cached_page) | ||
2115 | page_cache_release(cached_page); | ||
2116 | /* For now, when the user asks for O_SYNC, we actually give O_DSYNC. */ | ||
2117 | if (likely(!status)) { | ||
2118 | if (unlikely((file->f_flags & O_SYNC) || IS_SYNC(vi))) { | ||
2119 | if (!mapping->a_ops->writepage || !is_sync_kiocb(iocb)) | ||
2120 | status = generic_osync_inode(vi, mapping, | ||
2121 | OSYNC_METADATA|OSYNC_DATA); | ||
2122 | } | ||
2123 | } | ||
2124 | pagevec_lru_add(&lru_pvec); | ||
2125 | ntfs_debug("Done. Returning %s (written 0x%lx, status %li).", | ||
2126 | written ? "written" : "status", (unsigned long)written, | ||
2127 | (long)status); | ||
2128 | return written ? written : status; | ||
2129 | } | ||
2130 | |||
2131 | /** | ||
2132 | * ntfs_file_aio_write_nolock - | ||
2133 | */ | ||
2134 | static ssize_t ntfs_file_aio_write_nolock(struct kiocb *iocb, | ||
2135 | const struct iovec *iov, unsigned long nr_segs, loff_t *ppos) | ||
2136 | { | ||
2137 | struct file *file = iocb->ki_filp; | ||
2138 | struct address_space *mapping = file->f_mapping; | ||
2139 | struct inode *inode = mapping->host; | ||
2140 | loff_t pos; | ||
2141 | unsigned long seg; | ||
2142 | size_t count; /* after file limit checks */ | ||
2143 | ssize_t written, err; | ||
2144 | |||
2145 | count = 0; | ||
2146 | for (seg = 0; seg < nr_segs; seg++) { | ||
2147 | const struct iovec *iv = &iov[seg]; | ||
2148 | /* | ||
2149 | * If any segment has a negative length, or the cumulative | ||
2150 | * length ever wraps negative then return -EINVAL. | ||
2151 | */ | ||
2152 | count += iv->iov_len; | ||
2153 | if (unlikely((ssize_t)(count|iv->iov_len) < 0)) | ||
2154 | return -EINVAL; | ||
2155 | if (access_ok(VERIFY_READ, iv->iov_base, iv->iov_len)) | ||
2156 | continue; | ||
2157 | if (!seg) | ||
2158 | return -EFAULT; | ||
2159 | nr_segs = seg; | ||
2160 | count -= iv->iov_len; /* This segment is no good */ | ||
2161 | break; | ||
2162 | } | ||
2163 | pos = *ppos; | ||
2164 | vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE); | ||
2165 | /* We can write back this queue in page reclaim. */ | ||
2166 | current->backing_dev_info = mapping->backing_dev_info; | ||
2167 | written = 0; | ||
2168 | err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); | ||
2169 | if (err) | ||
2170 | goto out; | ||
2171 | if (!count) | ||
2172 | goto out; | ||
2173 | err = remove_suid(file->f_dentry); | ||
2174 | if (err) | ||
2175 | goto out; | ||
2176 | inode_update_time(inode, 1); | ||
2177 | written = ntfs_file_buffered_write(iocb, iov, nr_segs, pos, ppos, | ||
2178 | count); | ||
2179 | out: | ||
2180 | current->backing_dev_info = NULL; | ||
2181 | return written ? written : err; | ||
2182 | } | ||
2183 | |||
2184 | /** | ||
2185 | * ntfs_file_aio_write - | ||
2186 | */ | ||
2187 | static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const char __user *buf, | ||
2188 | size_t count, loff_t pos) | ||
2189 | { | ||
2190 | struct file *file = iocb->ki_filp; | ||
2191 | struct address_space *mapping = file->f_mapping; | ||
2192 | struct inode *inode = mapping->host; | ||
2193 | ssize_t ret; | ||
2194 | struct iovec local_iov = { .iov_base = (void __user *)buf, | ||
2195 | .iov_len = count }; | ||
2196 | |||
2197 | BUG_ON(iocb->ki_pos != pos); | ||
2198 | |||
2199 | down(&inode->i_sem); | ||
2200 | ret = ntfs_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos); | ||
2201 | up(&inode->i_sem); | ||
2202 | if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { | ||
2203 | int err = sync_page_range(inode, mapping, pos, ret); | ||
2204 | if (err < 0) | ||
2205 | ret = err; | ||
2206 | } | ||
2207 | return ret; | ||
2208 | } | ||
2209 | |||
2210 | /** | ||
2211 | * ntfs_file_writev - | ||
2212 | * | ||
2213 | * Basically the same as generic_file_writev() except that it ends up calling | ||
2214 | * ntfs_file_aio_write_nolock() instead of __generic_file_aio_write_nolock(). | ||
2215 | */ | ||
2216 | static ssize_t ntfs_file_writev(struct file *file, const struct iovec *iov, | ||
2217 | unsigned long nr_segs, loff_t *ppos) | ||
2218 | { | ||
2219 | struct address_space *mapping = file->f_mapping; | ||
2220 | struct inode *inode = mapping->host; | ||
2221 | struct kiocb kiocb; | ||
2222 | ssize_t ret; | ||
2223 | |||
2224 | down(&inode->i_sem); | ||
2225 | init_sync_kiocb(&kiocb, file); | ||
2226 | ret = ntfs_file_aio_write_nolock(&kiocb, iov, nr_segs, ppos); | ||
2227 | if (ret == -EIOCBQUEUED) | ||
2228 | ret = wait_on_sync_kiocb(&kiocb); | ||
2229 | up(&inode->i_sem); | ||
2230 | if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { | ||
2231 | int err = sync_page_range(inode, mapping, *ppos - ret, ret); | ||
2232 | if (err < 0) | ||
2233 | ret = err; | ||
2234 | } | ||
2235 | return ret; | ||
2236 | } | ||
2237 | |||
2238 | /** | ||
2239 | * ntfs_file_write - simple wrapper for ntfs_file_writev() | ||
2240 | */ | ||
2241 | static ssize_t ntfs_file_write(struct file *file, const char __user *buf, | ||
2242 | size_t count, loff_t *ppos) | ||
2243 | { | ||
2244 | struct iovec local_iov = { .iov_base = (void __user *)buf, | ||
2245 | .iov_len = count }; | ||
2246 | |||
2247 | return ntfs_file_writev(file, &local_iov, 1, ppos); | ||
2248 | } | ||
2249 | |||
2250 | /** | ||
59 | * ntfs_file_fsync - sync a file to disk | 2251 | * ntfs_file_fsync - sync a file to disk |
60 | * @filp: file to be synced | 2252 | * @filp: file to be synced |
61 | * @dentry: dentry describing the file to sync | 2253 | * @dentry: dentry describing the file to sync |
@@ -113,39 +2305,39 @@ static int ntfs_file_fsync(struct file *filp, struct dentry *dentry, | |||
113 | #endif /* NTFS_RW */ | 2305 | #endif /* NTFS_RW */ |
114 | 2306 | ||
115 | struct file_operations ntfs_file_ops = { | 2307 | struct file_operations ntfs_file_ops = { |
116 | .llseek = generic_file_llseek, /* Seek inside file. */ | 2308 | .llseek = generic_file_llseek, /* Seek inside file. */ |
117 | .read = generic_file_read, /* Read from file. */ | 2309 | .read = generic_file_read, /* Read from file. */ |
118 | .aio_read = generic_file_aio_read, /* Async read from file. */ | 2310 | .aio_read = generic_file_aio_read, /* Async read from file. */ |
119 | .readv = generic_file_readv, /* Read from file. */ | 2311 | .readv = generic_file_readv, /* Read from file. */ |
120 | #ifdef NTFS_RW | 2312 | #ifdef NTFS_RW |
121 | .write = generic_file_write, /* Write to file. */ | 2313 | .write = ntfs_file_write, /* Write to file. */ |
122 | .aio_write = generic_file_aio_write, /* Async write to file. */ | 2314 | .aio_write = ntfs_file_aio_write, /* Async write to file. */ |
123 | .writev = generic_file_writev, /* Write to file. */ | 2315 | .writev = ntfs_file_writev, /* Write to file. */ |
124 | /*.release = ,*/ /* Last file is closed. See | 2316 | /*.release = ,*/ /* Last file is closed. See |
125 | fs/ext2/file.c:: | 2317 | fs/ext2/file.c:: |
126 | ext2_release_file() for | 2318 | ext2_release_file() for |
127 | how to use this to discard | 2319 | how to use this to discard |
128 | preallocated space for | 2320 | preallocated space for |
129 | write opened files. */ | 2321 | write opened files. */ |
130 | .fsync = ntfs_file_fsync, /* Sync a file to disk. */ | 2322 | .fsync = ntfs_file_fsync, /* Sync a file to disk. */ |
131 | /*.aio_fsync = ,*/ /* Sync all outstanding async | 2323 | /*.aio_fsync = ,*/ /* Sync all outstanding async |
132 | i/o operations on a | 2324 | i/o operations on a |
133 | kiocb. */ | 2325 | kiocb. */ |
134 | #endif /* NTFS_RW */ | 2326 | #endif /* NTFS_RW */ |
135 | /*.ioctl = ,*/ /* Perform function on the | 2327 | /*.ioctl = ,*/ /* Perform function on the |
136 | mounted filesystem. */ | 2328 | mounted filesystem. */ |
137 | .mmap = generic_file_mmap, /* Mmap file. */ | 2329 | .mmap = generic_file_mmap, /* Mmap file. */ |
138 | .open = ntfs_file_open, /* Open file. */ | 2330 | .open = ntfs_file_open, /* Open file. */ |
139 | .sendfile = generic_file_sendfile, /* Zero-copy data send with | 2331 | .sendfile = generic_file_sendfile, /* Zero-copy data send with |
140 | the data source being on | 2332 | the data source being on |
141 | the ntfs partition. We | 2333 | the ntfs partition. We do |
142 | do not need to care about | 2334 | not need to care about the |
143 | the data destination. */ | 2335 | data destination. */ |
144 | /*.sendpage = ,*/ /* Zero-copy data send with | 2336 | /*.sendpage = ,*/ /* Zero-copy data send with |
145 | the data destination being | 2337 | the data destination being |
146 | on the ntfs partition. We | 2338 | on the ntfs partition. We |
147 | do not need to care about | 2339 | do not need to care about |
148 | the data source. */ | 2340 | the data source. */ |
149 | }; | 2341 | }; |
150 | 2342 | ||
151 | struct inode_operations ntfs_file_inode_ops = { | 2343 | struct inode_operations ntfs_file_inode_ops = { |
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 7ec045131808..b24f4c4b2c5c 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "debug.h" | 30 | #include "debug.h" |
31 | #include "inode.h" | 31 | #include "inode.h" |
32 | #include "attrib.h" | 32 | #include "attrib.h" |
33 | #include "lcnalloc.h" | ||
33 | #include "malloc.h" | 34 | #include "malloc.h" |
34 | #include "mft.h" | 35 | #include "mft.h" |
35 | #include "time.h" | 36 | #include "time.h" |
@@ -2291,11 +2292,16 @@ int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt) | |||
2291 | 2292 | ||
2292 | #ifdef NTFS_RW | 2293 | #ifdef NTFS_RW |
2293 | 2294 | ||
2295 | static const char *es = " Leaving inconsistent metadata. Unmount and run " | ||
2296 | "chkdsk."; | ||
2297 | |||
2294 | /** | 2298 | /** |
2295 | * ntfs_truncate - called when the i_size of an ntfs inode is changed | 2299 | * ntfs_truncate - called when the i_size of an ntfs inode is changed |
2296 | * @vi: inode for which the i_size was changed | 2300 | * @vi: inode for which the i_size was changed |
2297 | * | 2301 | * |
2298 | * We do not support i_size changes yet. | 2302 | * We only support i_size changes for normal files at present, i.e. not |
2303 | * compressed and not encrypted. This is enforced in ntfs_setattr(), see | ||
2304 | * below. | ||
2299 | * | 2305 | * |
2300 | * The kernel guarantees that @vi is a regular file (S_ISREG() is true) and | 2306 | * The kernel guarantees that @vi is a regular file (S_ISREG() is true) and |
2301 | * that the change is allowed. | 2307 | * that the change is allowed. |
@@ -2306,80 +2312,499 @@ int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt) | |||
2306 | * Returns 0 on success or -errno on error. | 2312 | * Returns 0 on success or -errno on error. |
2307 | * | 2313 | * |
2308 | * Called with ->i_sem held. In all but one case ->i_alloc_sem is held for | 2314 | * Called with ->i_sem held. In all but one case ->i_alloc_sem is held for |
2309 | * writing. The only case where ->i_alloc_sem is not held is | 2315 | * writing. The only case in the kernel where ->i_alloc_sem is not held is |
2310 | * mm/filemap.c::generic_file_buffered_write() where vmtruncate() is called | 2316 | * mm/filemap.c::generic_file_buffered_write() where vmtruncate() is called |
2311 | * with the current i_size as the offset which means that it is a noop as far | 2317 | * with the current i_size as the offset. The analogous place in NTFS is in |
2312 | * as ntfs_truncate() is concerned. | 2318 | * fs/ntfs/file.c::ntfs_file_buffered_write() where we call vmtruncate() again |
2319 | * without holding ->i_alloc_sem. | ||
2313 | */ | 2320 | */ |
2314 | int ntfs_truncate(struct inode *vi) | 2321 | int ntfs_truncate(struct inode *vi) |
2315 | { | 2322 | { |
2316 | ntfs_inode *ni = NTFS_I(vi); | 2323 | s64 new_size, old_size, nr_freed, new_alloc_size, old_alloc_size; |
2324 | VCN highest_vcn; | ||
2325 | unsigned long flags; | ||
2326 | ntfs_inode *base_ni, *ni = NTFS_I(vi); | ||
2317 | ntfs_volume *vol = ni->vol; | 2327 | ntfs_volume *vol = ni->vol; |
2318 | ntfs_attr_search_ctx *ctx; | 2328 | ntfs_attr_search_ctx *ctx; |
2319 | MFT_RECORD *m; | 2329 | MFT_RECORD *m; |
2320 | ATTR_RECORD *a; | 2330 | ATTR_RECORD *a; |
2321 | const char *te = " Leaving file length out of sync with i_size."; | 2331 | const char *te = " Leaving file length out of sync with i_size."; |
2322 | int err; | 2332 | int err, mp_size, size_change, alloc_change; |
2333 | u32 attr_len; | ||
2323 | 2334 | ||
2324 | ntfs_debug("Entering for inode 0x%lx.", vi->i_ino); | 2335 | ntfs_debug("Entering for inode 0x%lx.", vi->i_ino); |
2325 | BUG_ON(NInoAttr(ni)); | 2336 | BUG_ON(NInoAttr(ni)); |
2337 | BUG_ON(S_ISDIR(vi->i_mode)); | ||
2338 | BUG_ON(NInoMstProtected(ni)); | ||
2326 | BUG_ON(ni->nr_extents < 0); | 2339 | BUG_ON(ni->nr_extents < 0); |
2327 | m = map_mft_record(ni); | 2340 | retry_truncate: |
2341 | /* | ||
2342 | * Lock the runlist for writing and map the mft record to ensure it is | ||
2343 | * safe to mess with the attribute runlist and sizes. | ||
2344 | */ | ||
2345 | down_write(&ni->runlist.lock); | ||
2346 | if (!NInoAttr(ni)) | ||
2347 | base_ni = ni; | ||
2348 | else | ||
2349 | base_ni = ni->ext.base_ntfs_ino; | ||
2350 | m = map_mft_record(base_ni); | ||
2328 | if (IS_ERR(m)) { | 2351 | if (IS_ERR(m)) { |
2329 | err = PTR_ERR(m); | 2352 | err = PTR_ERR(m); |
2330 | ntfs_error(vi->i_sb, "Failed to map mft record for inode 0x%lx " | 2353 | ntfs_error(vi->i_sb, "Failed to map mft record for inode 0x%lx " |
2331 | "(error code %d).%s", vi->i_ino, err, te); | 2354 | "(error code %d).%s", vi->i_ino, err, te); |
2332 | ctx = NULL; | 2355 | ctx = NULL; |
2333 | m = NULL; | 2356 | m = NULL; |
2334 | goto err_out; | 2357 | goto old_bad_out; |
2335 | } | 2358 | } |
2336 | ctx = ntfs_attr_get_search_ctx(ni, m); | 2359 | ctx = ntfs_attr_get_search_ctx(base_ni, m); |
2337 | if (unlikely(!ctx)) { | 2360 | if (unlikely(!ctx)) { |
2338 | ntfs_error(vi->i_sb, "Failed to allocate a search context for " | 2361 | ntfs_error(vi->i_sb, "Failed to allocate a search context for " |
2339 | "inode 0x%lx (not enough memory).%s", | 2362 | "inode 0x%lx (not enough memory).%s", |
2340 | vi->i_ino, te); | 2363 | vi->i_ino, te); |
2341 | err = -ENOMEM; | 2364 | err = -ENOMEM; |
2342 | goto err_out; | 2365 | goto old_bad_out; |
2343 | } | 2366 | } |
2344 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, | 2367 | err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, |
2345 | CASE_SENSITIVE, 0, NULL, 0, ctx); | 2368 | CASE_SENSITIVE, 0, NULL, 0, ctx); |
2346 | if (unlikely(err)) { | 2369 | if (unlikely(err)) { |
2347 | if (err == -ENOENT) | 2370 | if (err == -ENOENT) { |
2348 | ntfs_error(vi->i_sb, "Open attribute is missing from " | 2371 | ntfs_error(vi->i_sb, "Open attribute is missing from " |
2349 | "mft record. Inode 0x%lx is corrupt. " | 2372 | "mft record. Inode 0x%lx is corrupt. " |
2350 | "Run chkdsk.", vi->i_ino); | 2373 | "Run chkdsk.%s", vi->i_ino, te); |
2351 | else | 2374 | err = -EIO; |
2375 | } else | ||
2352 | ntfs_error(vi->i_sb, "Failed to lookup attribute in " | 2376 | ntfs_error(vi->i_sb, "Failed to lookup attribute in " |
2353 | "inode 0x%lx (error code %d).", | 2377 | "inode 0x%lx (error code %d).%s", |
2354 | vi->i_ino, err); | 2378 | vi->i_ino, err, te); |
2355 | goto err_out; | 2379 | goto old_bad_out; |
2356 | } | 2380 | } |
2381 | m = ctx->mrec; | ||
2357 | a = ctx->attr; | 2382 | a = ctx->attr; |
2358 | /* If the size has not changed there is nothing to do. */ | 2383 | /* |
2359 | if (ntfs_attr_size(a) == i_size_read(vi)) | 2384 | * The i_size of the vfs inode is the new size for the attribute value. |
2360 | goto done; | 2385 | */ |
2361 | // TODO: Implement the truncate... | 2386 | new_size = i_size_read(vi); |
2362 | ntfs_error(vi->i_sb, "Inode size has changed but this is not " | 2387 | /* The current size of the attribute value is the old size. */ |
2363 | "implemented yet. Resetting inode size to old value. " | 2388 | old_size = ntfs_attr_size(a); |
2364 | " This is most likely a bug in the ntfs driver!"); | 2389 | /* Calculate the new allocated size. */ |
2365 | i_size_write(vi, ntfs_attr_size(a)); | 2390 | if (NInoNonResident(ni)) |
2366 | done: | 2391 | new_alloc_size = (new_size + vol->cluster_size - 1) & |
2392 | ~(s64)vol->cluster_size_mask; | ||
2393 | else | ||
2394 | new_alloc_size = (new_size + 7) & ~7; | ||
2395 | /* The current allocated size is the old allocated size. */ | ||
2396 | read_lock_irqsave(&ni->size_lock, flags); | ||
2397 | old_alloc_size = ni->allocated_size; | ||
2398 | read_unlock_irqrestore(&ni->size_lock, flags); | ||
2399 | /* | ||
2400 | * The change in the file size. This will be 0 if no change, >0 if the | ||
2401 | * size is growing, and <0 if the size is shrinking. | ||
2402 | */ | ||
2403 | size_change = -1; | ||
2404 | if (new_size - old_size >= 0) { | ||
2405 | size_change = 1; | ||
2406 | if (new_size == old_size) | ||
2407 | size_change = 0; | ||
2408 | } | ||
2409 | /* As above for the allocated size. */ | ||
2410 | alloc_change = -1; | ||
2411 | if (new_alloc_size - old_alloc_size >= 0) { | ||
2412 | alloc_change = 1; | ||
2413 | if (new_alloc_size == old_alloc_size) | ||
2414 | alloc_change = 0; | ||
2415 | } | ||
2416 | /* | ||
2417 | * If neither the size nor the allocation are being changed there is | ||
2418 | * nothing to do. | ||
2419 | */ | ||
2420 | if (!size_change && !alloc_change) | ||
2421 | goto unm_done; | ||
2422 | /* If the size is changing, check if new size is allowed in $AttrDef. */ | ||
2423 | if (size_change) { | ||
2424 | err = ntfs_attr_size_bounds_check(vol, ni->type, new_size); | ||
2425 | if (unlikely(err)) { | ||
2426 | if (err == -ERANGE) { | ||
2427 | ntfs_error(vol->sb, "Truncate would cause the " | ||
2428 | "inode 0x%lx to %simum size " | ||
2429 | "for its attribute type " | ||
2430 | "(0x%x). Aborting truncate.", | ||
2431 | vi->i_ino, | ||
2432 | new_size > old_size ? "exceed " | ||
2433 | "the max" : "go under the min", | ||
2434 | le32_to_cpu(ni->type)); | ||
2435 | err = -EFBIG; | ||
2436 | } else { | ||
2437 | ntfs_error(vol->sb, "Inode 0x%lx has unknown " | ||
2438 | "attribute type 0x%x. " | ||
2439 | "Aborting truncate.", | ||
2440 | vi->i_ino, | ||
2441 | le32_to_cpu(ni->type)); | ||
2442 | err = -EIO; | ||
2443 | } | ||
2444 | /* Reset the vfs inode size to the old size. */ | ||
2445 | i_size_write(vi, old_size); | ||
2446 | goto err_out; | ||
2447 | } | ||
2448 | } | ||
2449 | if (NInoCompressed(ni) || NInoEncrypted(ni)) { | ||
2450 | ntfs_warning(vi->i_sb, "Changes in inode size are not " | ||
2451 | "supported yet for %s files, ignoring.", | ||
2452 | NInoCompressed(ni) ? "compressed" : | ||
2453 | "encrypted"); | ||
2454 | err = -EOPNOTSUPP; | ||
2455 | goto bad_out; | ||
2456 | } | ||
2457 | if (a->non_resident) | ||
2458 | goto do_non_resident_truncate; | ||
2459 | BUG_ON(NInoNonResident(ni)); | ||
2460 | /* Resize the attribute record to best fit the new attribute size. */ | ||
2461 | if (new_size < vol->mft_record_size && | ||
2462 | !ntfs_resident_attr_value_resize(m, a, new_size)) { | ||
2463 | unsigned long flags; | ||
2464 | |||
2465 | /* The resize succeeded! */ | ||
2466 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
2467 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
2468 | write_lock_irqsave(&ni->size_lock, flags); | ||
2469 | /* Update the sizes in the ntfs inode and all is done. */ | ||
2470 | ni->allocated_size = le32_to_cpu(a->length) - | ||
2471 | le16_to_cpu(a->data.resident.value_offset); | ||
2472 | /* | ||
2473 | * Note ntfs_resident_attr_value_resize() has already done any | ||
2474 | * necessary data clearing in the attribute record. When the | ||
2475 | * file is being shrunk vmtruncate() will already have cleared | ||
2476 | * the top part of the last partial page, i.e. since this is | ||
2477 | * the resident case this is the page with index 0. However, | ||
2478 | * when the file is being expanded, the page cache page data | ||
2479 | * between the old data_size, i.e. old_size, and the new_size | ||
2480 | * has not been zeroed. Fortunately, we do not need to zero it | ||
2481 | * either since on one hand it will either already be zero due | ||
2482 | * to both readpage and writepage clearing partial page data | ||
2483 | * beyond i_size in which case there is nothing to do or in the | ||
2484 | * case of the file being mmap()ped at the same time, POSIX | ||
2485 | * specifies that the behaviour is unspecified thus we do not | ||
2486 | * have to do anything. This means that in our implementation | ||
2487 | * in the rare case that the file is mmap()ped and a write | ||
2488 | * occured into the mmap()ped region just beyond the file size | ||
2489 | * and writepage has not yet been called to write out the page | ||
2490 | * (which would clear the area beyond the file size) and we now | ||
2491 | * extend the file size to incorporate this dirty region | ||
2492 | * outside the file size, a write of the page would result in | ||
2493 | * this data being written to disk instead of being cleared. | ||
2494 | * Given both POSIX and the Linux mmap(2) man page specify that | ||
2495 | * this corner case is undefined, we choose to leave it like | ||
2496 | * that as this is much simpler for us as we cannot lock the | ||
2497 | * relevant page now since we are holding too many ntfs locks | ||
2498 | * which would result in a lock reversal deadlock. | ||
2499 | */ | ||
2500 | ni->initialized_size = new_size; | ||
2501 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
2502 | goto unm_done; | ||
2503 | } | ||
2504 | /* If the above resize failed, this must be an attribute extension. */ | ||
2505 | BUG_ON(size_change < 0); | ||
2506 | /* | ||
2507 | * We have to drop all the locks so we can call | ||
2508 | * ntfs_attr_make_non_resident(). This could be optimised by try- | ||
2509 | * locking the first page cache page and only if that fails dropping | ||
2510 | * the locks, locking the page, and redoing all the locking and | ||
2511 | * lookups. While this would be a huge optimisation, it is not worth | ||
2512 | * it as this is definitely a slow code path as it only ever can happen | ||
2513 | * once for any given file. | ||
2514 | */ | ||
2367 | ntfs_attr_put_search_ctx(ctx); | 2515 | ntfs_attr_put_search_ctx(ctx); |
2368 | unmap_mft_record(ni); | 2516 | unmap_mft_record(base_ni); |
2369 | NInoClearTruncateFailed(ni); | 2517 | up_write(&ni->runlist.lock); |
2370 | ntfs_debug("Done."); | 2518 | /* |
2371 | return 0; | 2519 | * Not enough space in the mft record, try to make the attribute |
2372 | err_out: | 2520 | * non-resident and if successful restart the truncation process. |
2373 | if (err != -ENOMEM) { | 2521 | */ |
2522 | err = ntfs_attr_make_non_resident(ni, old_size); | ||
2523 | if (likely(!err)) | ||
2524 | goto retry_truncate; | ||
2525 | /* | ||
2526 | * Could not make non-resident. If this is due to this not being | ||
2527 | * permitted for this attribute type or there not being enough space, | ||
2528 | * try to make other attributes non-resident. Otherwise fail. | ||
2529 | */ | ||
2530 | if (unlikely(err != -EPERM && err != -ENOSPC)) { | ||
2531 | ntfs_error(vol->sb, "Cannot truncate inode 0x%lx, attribute " | ||
2532 | "type 0x%x, because the conversion from " | ||
2533 | "resident to non-resident attribute failed " | ||
2534 | "with error code %i.", vi->i_ino, | ||
2535 | (unsigned)le32_to_cpu(ni->type), err); | ||
2536 | if (err != -ENOMEM) | ||
2537 | err = -EIO; | ||
2538 | goto conv_err_out; | ||
2539 | } | ||
2540 | /* TODO: Not implemented from here, abort. */ | ||
2541 | if (err == -ENOSPC) | ||
2542 | ntfs_error(vol->sb, "Not enough space in the mft record/on " | ||
2543 | "disk for the non-resident attribute value. " | ||
2544 | "This case is not implemented yet."); | ||
2545 | else /* if (err == -EPERM) */ | ||
2546 | ntfs_error(vol->sb, "This attribute type may not be " | ||
2547 | "non-resident. This case is not implemented " | ||
2548 | "yet."); | ||
2549 | err = -EOPNOTSUPP; | ||
2550 | goto conv_err_out; | ||
2551 | #if 0 | ||
2552 | // TODO: Attempt to make other attributes non-resident. | ||
2553 | if (!err) | ||
2554 | goto do_resident_extend; | ||
2555 | /* | ||
2556 | * Both the attribute list attribute and the standard information | ||
2557 | * attribute must remain in the base inode. Thus, if this is one of | ||
2558 | * these attributes, we have to try to move other attributes out into | ||
2559 | * extent mft records instead. | ||
2560 | */ | ||
2561 | if (ni->type == AT_ATTRIBUTE_LIST || | ||
2562 | ni->type == AT_STANDARD_INFORMATION) { | ||
2563 | // TODO: Attempt to move other attributes into extent mft | ||
2564 | // records. | ||
2565 | err = -EOPNOTSUPP; | ||
2566 | if (!err) | ||
2567 | goto do_resident_extend; | ||
2568 | goto err_out; | ||
2569 | } | ||
2570 | // TODO: Attempt to move this attribute to an extent mft record, but | ||
2571 | // only if it is not already the only attribute in an mft record in | ||
2572 | // which case there would be nothing to gain. | ||
2573 | err = -EOPNOTSUPP; | ||
2574 | if (!err) | ||
2575 | goto do_resident_extend; | ||
2576 | /* There is nothing we can do to make enough space. )-: */ | ||
2577 | goto err_out; | ||
2578 | #endif | ||
2579 | do_non_resident_truncate: | ||
2580 | BUG_ON(!NInoNonResident(ni)); | ||
2581 | if (alloc_change < 0) { | ||
2582 | highest_vcn = sle64_to_cpu(a->data.non_resident.highest_vcn); | ||
2583 | if (highest_vcn > 0 && | ||
2584 | old_alloc_size >> vol->cluster_size_bits > | ||
2585 | highest_vcn + 1) { | ||
2586 | /* | ||
2587 | * This attribute has multiple extents. Not yet | ||
2588 | * supported. | ||
2589 | */ | ||
2590 | ntfs_error(vol->sb, "Cannot truncate inode 0x%lx, " | ||
2591 | "attribute type 0x%x, because the " | ||
2592 | "attribute is highly fragmented (it " | ||
2593 | "consists of multiple extents) and " | ||
2594 | "this case is not implemented yet.", | ||
2595 | vi->i_ino, | ||
2596 | (unsigned)le32_to_cpu(ni->type)); | ||
2597 | err = -EOPNOTSUPP; | ||
2598 | goto bad_out; | ||
2599 | } | ||
2600 | } | ||
2601 | /* | ||
2602 | * If the size is shrinking, need to reduce the initialized_size and | ||
2603 | * the data_size before reducing the allocation. | ||
2604 | */ | ||
2605 | if (size_change < 0) { | ||
2606 | /* | ||
2607 | * Make the valid size smaller (i_size is already up-to-date). | ||
2608 | */ | ||
2609 | write_lock_irqsave(&ni->size_lock, flags); | ||
2610 | if (new_size < ni->initialized_size) { | ||
2611 | ni->initialized_size = new_size; | ||
2612 | a->data.non_resident.initialized_size = | ||
2613 | cpu_to_sle64(new_size); | ||
2614 | } | ||
2615 | a->data.non_resident.data_size = cpu_to_sle64(new_size); | ||
2616 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
2617 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
2618 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
2619 | /* If the allocated size is not changing, we are done. */ | ||
2620 | if (!alloc_change) | ||
2621 | goto unm_done; | ||
2622 | /* | ||
2623 | * If the size is shrinking it makes no sense for the | ||
2624 | * allocation to be growing. | ||
2625 | */ | ||
2626 | BUG_ON(alloc_change > 0); | ||
2627 | } else /* if (size_change >= 0) */ { | ||
2628 | /* | ||
2629 | * The file size is growing or staying the same but the | ||
2630 | * allocation can be shrinking, growing or staying the same. | ||
2631 | */ | ||
2632 | if (alloc_change > 0) { | ||
2633 | /* | ||
2634 | * We need to extend the allocation and possibly update | ||
2635 | * the data size. If we are updating the data size, | ||
2636 | * since we are not touching the initialized_size we do | ||
2637 | * not need to worry about the actual data on disk. | ||
2638 | * And as far as the page cache is concerned, there | ||
2639 | * will be no pages beyond the old data size and any | ||
2640 | * partial region in the last page between the old and | ||
2641 | * new data size (or the end of the page if the new | ||
2642 | * data size is outside the page) does not need to be | ||
2643 | * modified as explained above for the resident | ||
2644 | * attribute truncate case. To do this, we simply drop | ||
2645 | * the locks we hold and leave all the work to our | ||
2646 | * friendly helper ntfs_attr_extend_allocation(). | ||
2647 | */ | ||
2648 | ntfs_attr_put_search_ctx(ctx); | ||
2649 | unmap_mft_record(base_ni); | ||
2650 | up_write(&ni->runlist.lock); | ||
2651 | err = ntfs_attr_extend_allocation(ni, new_size, | ||
2652 | size_change > 0 ? new_size : -1, -1); | ||
2653 | /* | ||
2654 | * ntfs_attr_extend_allocation() will have done error | ||
2655 | * output already. | ||
2656 | */ | ||
2657 | goto done; | ||
2658 | } | ||
2659 | if (!alloc_change) | ||
2660 | goto alloc_done; | ||
2661 | } | ||
2662 | /* alloc_change < 0 */ | ||
2663 | /* Free the clusters. */ | ||
2664 | nr_freed = ntfs_cluster_free(ni, new_alloc_size >> | ||
2665 | vol->cluster_size_bits, -1, ctx); | ||
2666 | m = ctx->mrec; | ||
2667 | a = ctx->attr; | ||
2668 | if (unlikely(nr_freed < 0)) { | ||
2669 | ntfs_error(vol->sb, "Failed to release cluster(s) (error code " | ||
2670 | "%lli). Unmount and run chkdsk to recover " | ||
2671 | "the lost cluster(s).", (long long)nr_freed); | ||
2374 | NVolSetErrors(vol); | 2672 | NVolSetErrors(vol); |
2673 | nr_freed = 0; | ||
2674 | } | ||
2675 | /* Truncate the runlist. */ | ||
2676 | err = ntfs_rl_truncate_nolock(vol, &ni->runlist, | ||
2677 | new_alloc_size >> vol->cluster_size_bits); | ||
2678 | /* | ||
2679 | * If the runlist truncation failed and/or the search context is no | ||
2680 | * longer valid, we cannot resize the attribute record or build the | ||
2681 | * mapping pairs array thus we mark the inode bad so that no access to | ||
2682 | * the freed clusters can happen. | ||
2683 | */ | ||
2684 | if (unlikely(err || IS_ERR(m))) { | ||
2685 | ntfs_error(vol->sb, "Failed to %s (error code %li).%s", | ||
2686 | IS_ERR(m) ? | ||
2687 | "restore attribute search context" : | ||
2688 | "truncate attribute runlist", | ||
2689 | IS_ERR(m) ? PTR_ERR(m) : err, es); | ||
2690 | err = -EIO; | ||
2691 | goto bad_out; | ||
2692 | } | ||
2693 | /* Get the size for the shrunk mapping pairs array for the runlist. */ | ||
2694 | mp_size = ntfs_get_size_for_mapping_pairs(vol, ni->runlist.rl, 0, -1); | ||
2695 | if (unlikely(mp_size <= 0)) { | ||
2696 | ntfs_error(vol->sb, "Cannot shrink allocation of inode 0x%lx, " | ||
2697 | "attribute type 0x%x, because determining the " | ||
2698 | "size for the mapping pairs failed with error " | ||
2699 | "code %i.%s", vi->i_ino, | ||
2700 | (unsigned)le32_to_cpu(ni->type), mp_size, es); | ||
2701 | err = -EIO; | ||
2702 | goto bad_out; | ||
2703 | } | ||
2704 | /* | ||
2705 | * Shrink the attribute record for the new mapping pairs array. Note, | ||
2706 | * this cannot fail since we are making the attribute smaller thus by | ||
2707 | * definition there is enough space to do so. | ||
2708 | */ | ||
2709 | attr_len = le32_to_cpu(a->length); | ||
2710 | err = ntfs_attr_record_resize(m, a, mp_size + | ||
2711 | le16_to_cpu(a->data.non_resident.mapping_pairs_offset)); | ||
2712 | BUG_ON(err); | ||
2713 | /* | ||
2714 | * Generate the mapping pairs array directly into the attribute record. | ||
2715 | */ | ||
2716 | err = ntfs_mapping_pairs_build(vol, (u8*)a + | ||
2717 | le16_to_cpu(a->data.non_resident.mapping_pairs_offset), | ||
2718 | mp_size, ni->runlist.rl, 0, -1, NULL); | ||
2719 | if (unlikely(err)) { | ||
2720 | ntfs_error(vol->sb, "Cannot shrink allocation of inode 0x%lx, " | ||
2721 | "attribute type 0x%x, because building the " | ||
2722 | "mapping pairs failed with error code %i.%s", | ||
2723 | vi->i_ino, (unsigned)le32_to_cpu(ni->type), | ||
2724 | err, es); | ||
2725 | err = -EIO; | ||
2726 | goto bad_out; | ||
2727 | } | ||
2728 | /* Update the allocated/compressed size as well as the highest vcn. */ | ||
2729 | a->data.non_resident.highest_vcn = cpu_to_sle64((new_alloc_size >> | ||
2730 | vol->cluster_size_bits) - 1); | ||
2731 | write_lock_irqsave(&ni->size_lock, flags); | ||
2732 | ni->allocated_size = new_alloc_size; | ||
2733 | a->data.non_resident.allocated_size = cpu_to_sle64(new_alloc_size); | ||
2734 | if (NInoSparse(ni) || NInoCompressed(ni)) { | ||
2735 | if (nr_freed) { | ||
2736 | ni->itype.compressed.size -= nr_freed << | ||
2737 | vol->cluster_size_bits; | ||
2738 | BUG_ON(ni->itype.compressed.size < 0); | ||
2739 | a->data.non_resident.compressed_size = cpu_to_sle64( | ||
2740 | ni->itype.compressed.size); | ||
2741 | vi->i_blocks = ni->itype.compressed.size >> 9; | ||
2742 | } | ||
2743 | } else | ||
2744 | vi->i_blocks = new_alloc_size >> 9; | ||
2745 | write_unlock_irqrestore(&ni->size_lock, flags); | ||
2746 | /* | ||
2747 | * We have shrunk the allocation. If this is a shrinking truncate we | ||
2748 | * have already dealt with the initialized_size and the data_size above | ||
2749 | * and we are done. If the truncate is only changing the allocation | ||
2750 | * and not the data_size, we are also done. If this is an extending | ||
2751 | * truncate, need to extend the data_size now which is ensured by the | ||
2752 | * fact that @size_change is positive. | ||
2753 | */ | ||
2754 | alloc_done: | ||
2755 | /* | ||
2756 | * If the size is growing, need to update it now. If it is shrinking, | ||
2757 | * we have already updated it above (before the allocation change). | ||
2758 | */ | ||
2759 | if (size_change > 0) | ||
2760 | a->data.non_resident.data_size = cpu_to_sle64(new_size); | ||
2761 | /* Ensure the modified mft record is written out. */ | ||
2762 | flush_dcache_mft_record_page(ctx->ntfs_ino); | ||
2763 | mark_mft_record_dirty(ctx->ntfs_ino); | ||
2764 | unm_done: | ||
2765 | ntfs_attr_put_search_ctx(ctx); | ||
2766 | unmap_mft_record(base_ni); | ||
2767 | up_write(&ni->runlist.lock); | ||
2768 | done: | ||
2769 | /* Update the mtime and ctime on the base inode. */ | ||
2770 | inode_update_time(VFS_I(base_ni), 1); | ||
2771 | if (likely(!err)) { | ||
2772 | NInoClearTruncateFailed(ni); | ||
2773 | ntfs_debug("Done."); | ||
2774 | } | ||
2775 | return err; | ||
2776 | old_bad_out: | ||
2777 | old_size = -1; | ||
2778 | bad_out: | ||
2779 | if (err != -ENOMEM && err != -EOPNOTSUPP) { | ||
2375 | make_bad_inode(vi); | 2780 | make_bad_inode(vi); |
2781 | make_bad_inode(VFS_I(base_ni)); | ||
2782 | NVolSetErrors(vol); | ||
2376 | } | 2783 | } |
2784 | if (err != -EOPNOTSUPP) | ||
2785 | NInoSetTruncateFailed(ni); | ||
2786 | else if (old_size >= 0) | ||
2787 | i_size_write(vi, old_size); | ||
2788 | err_out: | ||
2377 | if (ctx) | 2789 | if (ctx) |
2378 | ntfs_attr_put_search_ctx(ctx); | 2790 | ntfs_attr_put_search_ctx(ctx); |
2379 | if (m) | 2791 | if (m) |
2380 | unmap_mft_record(ni); | 2792 | unmap_mft_record(base_ni); |
2381 | NInoSetTruncateFailed(ni); | 2793 | up_write(&ni->runlist.lock); |
2794 | out: | ||
2795 | ntfs_debug("Failed. Returning error code %i.", err); | ||
2382 | return err; | 2796 | return err; |
2797 | conv_err_out: | ||
2798 | if (err != -ENOMEM && err != -EOPNOTSUPP) { | ||
2799 | make_bad_inode(vi); | ||
2800 | make_bad_inode(VFS_I(base_ni)); | ||
2801 | NVolSetErrors(vol); | ||
2802 | } | ||
2803 | if (err != -EOPNOTSUPP) | ||
2804 | NInoSetTruncateFailed(ni); | ||
2805 | else | ||
2806 | i_size_write(vi, old_size); | ||
2807 | goto out; | ||
2383 | } | 2808 | } |
2384 | 2809 | ||
2385 | /** | 2810 | /** |
@@ -2420,8 +2845,7 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
2420 | 2845 | ||
2421 | err = inode_change_ok(vi, attr); | 2846 | err = inode_change_ok(vi, attr); |
2422 | if (err) | 2847 | if (err) |
2423 | return err; | 2848 | goto out; |
2424 | |||
2425 | /* We do not support NTFS ACLs yet. */ | 2849 | /* We do not support NTFS ACLs yet. */ |
2426 | if (ia_valid & (ATTR_UID | ATTR_GID | ATTR_MODE)) { | 2850 | if (ia_valid & (ATTR_UID | ATTR_GID | ATTR_MODE)) { |
2427 | ntfs_warning(vi->i_sb, "Changes in user/group/mode are not " | 2851 | ntfs_warning(vi->i_sb, "Changes in user/group/mode are not " |
@@ -2429,14 +2853,22 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
2429 | err = -EOPNOTSUPP; | 2853 | err = -EOPNOTSUPP; |
2430 | goto out; | 2854 | goto out; |
2431 | } | 2855 | } |
2432 | |||
2433 | if (ia_valid & ATTR_SIZE) { | 2856 | if (ia_valid & ATTR_SIZE) { |
2434 | if (attr->ia_size != i_size_read(vi)) { | 2857 | if (attr->ia_size != i_size_read(vi)) { |
2435 | ntfs_warning(vi->i_sb, "Changes in inode size are not " | 2858 | ntfs_inode *ni = NTFS_I(vi); |
2436 | "supported yet, ignoring."); | 2859 | /* |
2437 | err = -EOPNOTSUPP; | 2860 | * FIXME: For now we do not support resizing of |
2438 | // TODO: Implement... | 2861 | * compressed or encrypted files yet. |
2439 | // err = vmtruncate(vi, attr->ia_size); | 2862 | */ |
2863 | if (NInoCompressed(ni) || NInoEncrypted(ni)) { | ||
2864 | ntfs_warning(vi->i_sb, "Changes in inode size " | ||
2865 | "are not supported yet for " | ||
2866 | "%s files, ignoring.", | ||
2867 | NInoCompressed(ni) ? | ||
2868 | "compressed" : "encrypted"); | ||
2869 | err = -EOPNOTSUPP; | ||
2870 | } else | ||
2871 | err = vmtruncate(vi, attr->ia_size); | ||
2440 | if (err || ia_valid == ATTR_SIZE) | 2872 | if (err || ia_valid == ATTR_SIZE) |
2441 | goto out; | 2873 | goto out; |
2442 | } else { | 2874 | } else { |
diff --git a/fs/ntfs/layout.h b/fs/ntfs/layout.h index 5c248d404f05..f5678d5d7919 100644 --- a/fs/ntfs/layout.h +++ b/fs/ntfs/layout.h | |||
@@ -1021,10 +1021,17 @@ enum { | |||
1021 | FILE_NAME_POSIX = 0x00, | 1021 | FILE_NAME_POSIX = 0x00, |
1022 | /* This is the largest namespace. It is case sensitive and allows all | 1022 | /* This is the largest namespace. It is case sensitive and allows all |
1023 | Unicode characters except for: '\0' and '/'. Beware that in | 1023 | Unicode characters except for: '\0' and '/'. Beware that in |
1024 | WinNT/2k files which eg have the same name except for their case | 1024 | WinNT/2k/2003 by default files which eg have the same name except |
1025 | will not be distinguished by the standard utilities and thus a "del | 1025 | for their case will not be distinguished by the standard utilities |
1026 | filename" will delete both "filename" and "fileName" without | 1026 | and thus a "del filename" will delete both "filename" and "fileName" |
1027 | warning. */ | 1027 | without warning. However if for example Services For Unix (SFU) are |
1028 | installed and the case sensitive option was enabled at installation | ||
1029 | time, then you can create/access/delete such files. | ||
1030 | Note that even SFU places restrictions on the filenames beyond the | ||
1031 | '\0' and '/' and in particular the following set of characters is | ||
1032 | not allowed: '"', '/', '<', '>', '\'. All other characters, | ||
1033 | including the ones no allowed in WIN32 namespace are allowed. | ||
1034 | Tested with SFU 3.5 (this is now free) running on Windows XP. */ | ||
1028 | FILE_NAME_WIN32 = 0x01, | 1035 | FILE_NAME_WIN32 = 0x01, |
1029 | /* The standard WinNT/2k NTFS long filenames. Case insensitive. All | 1036 | /* The standard WinNT/2k NTFS long filenames. Case insensitive. All |
1030 | Unicode chars except: '\0', '"', '*', '/', ':', '<', '>', '?', '\', | 1037 | Unicode chars except: '\0', '"', '*', '/', ':', '<', '>', '?', '\', |
@@ -2367,7 +2374,9 @@ typedef struct { | |||
2367 | * Extended attribute flags (8-bit). | 2374 | * Extended attribute flags (8-bit). |
2368 | */ | 2375 | */ |
2369 | enum { | 2376 | enum { |
2370 | NEED_EA = 0x80 | 2377 | NEED_EA = 0x80 /* If set the file to which the EA belongs |
2378 | cannot be interpreted without understanding | ||
2379 | the associates extended attributes. */ | ||
2371 | } __attribute__ ((__packed__)); | 2380 | } __attribute__ ((__packed__)); |
2372 | 2381 | ||
2373 | typedef u8 EA_FLAGS; | 2382 | typedef u8 EA_FLAGS; |
@@ -2375,20 +2384,20 @@ typedef u8 EA_FLAGS; | |||
2375 | /* | 2384 | /* |
2376 | * Attribute: Extended attribute (EA) (0xe0). | 2385 | * Attribute: Extended attribute (EA) (0xe0). |
2377 | * | 2386 | * |
2378 | * NOTE: Always non-resident. (Is this true?) | 2387 | * NOTE: Can be resident or non-resident. |
2379 | * | 2388 | * |
2380 | * Like the attribute list and the index buffer list, the EA attribute value is | 2389 | * Like the attribute list and the index buffer list, the EA attribute value is |
2381 | * a sequence of EA_ATTR variable length records. | 2390 | * a sequence of EA_ATTR variable length records. |
2382 | * | ||
2383 | * FIXME: It appears weird that the EA name is not unicode. Is it true? | ||
2384 | */ | 2391 | */ |
2385 | typedef struct { | 2392 | typedef struct { |
2386 | le32 next_entry_offset; /* Offset to the next EA_ATTR. */ | 2393 | le32 next_entry_offset; /* Offset to the next EA_ATTR. */ |
2387 | EA_FLAGS flags; /* Flags describing the EA. */ | 2394 | EA_FLAGS flags; /* Flags describing the EA. */ |
2388 | u8 ea_name_length; /* Length of the name of the EA in bytes. */ | 2395 | u8 ea_name_length; /* Length of the name of the EA in bytes |
2396 | excluding the '\0' byte terminator. */ | ||
2389 | le16 ea_value_length; /* Byte size of the EA's value. */ | 2397 | le16 ea_value_length; /* Byte size of the EA's value. */ |
2390 | u8 ea_name[0]; /* Name of the EA. */ | 2398 | u8 ea_name[0]; /* Name of the EA. Note this is ASCII, not |
2391 | u8 ea_value[0]; /* The value of the EA. Immediately follows | 2399 | Unicode and it is zero terminated. */ |
2400 | u8 ea_value[0]; /* The value of the EA. Immediately follows | ||
2392 | the name. */ | 2401 | the name. */ |
2393 | } __attribute__ ((__packed__)) EA_ATTR; | 2402 | } __attribute__ ((__packed__)) EA_ATTR; |
2394 | 2403 | ||
diff --git a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c index 5af3bf0b7eee..29cabf93d2d2 100644 --- a/fs/ntfs/lcnalloc.c +++ b/fs/ntfs/lcnalloc.c | |||
@@ -76,6 +76,7 @@ int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, | |||
76 | * @count: number of clusters to allocate | 76 | * @count: number of clusters to allocate |
77 | * @start_lcn: starting lcn at which to allocate the clusters (or -1 if none) | 77 | * @start_lcn: starting lcn at which to allocate the clusters (or -1 if none) |
78 | * @zone: zone from which to allocate the clusters | 78 | * @zone: zone from which to allocate the clusters |
79 | * @is_extension: if TRUE, this is an attribute extension | ||
79 | * | 80 | * |
80 | * Allocate @count clusters preferably starting at cluster @start_lcn or at the | 81 | * Allocate @count clusters preferably starting at cluster @start_lcn or at the |
81 | * current allocator position if @start_lcn is -1, on the mounted ntfs volume | 82 | * current allocator position if @start_lcn is -1, on the mounted ntfs volume |
@@ -86,6 +87,13 @@ int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, | |||
86 | * @start_vcn specifies the vcn of the first allocated cluster. This makes | 87 | * @start_vcn specifies the vcn of the first allocated cluster. This makes |
87 | * merging the resulting runlist with the old runlist easier. | 88 | * merging the resulting runlist with the old runlist easier. |
88 | * | 89 | * |
90 | * If @is_extension is TRUE, the caller is allocating clusters to extend an | ||
91 | * attribute and if it is FALSE, the caller is allocating clusters to fill a | ||
92 | * hole in an attribute. Practically the difference is that if @is_extension | ||
93 | * is TRUE the returned runlist will be terminated with LCN_ENOENT and if | ||
94 | * @is_extension is FALSE the runlist will be terminated with | ||
95 | * LCN_RL_NOT_MAPPED. | ||
96 | * | ||
89 | * You need to check the return value with IS_ERR(). If this is false, the | 97 | * You need to check the return value with IS_ERR(). If this is false, the |
90 | * function was successful and the return value is a runlist describing the | 98 | * function was successful and the return value is a runlist describing the |
91 | * allocated cluster(s). If IS_ERR() is true, the function failed and | 99 | * allocated cluster(s). If IS_ERR() is true, the function failed and |
@@ -137,7 +145,8 @@ int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, | |||
137 | */ | 145 | */ |
138 | runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn, | 146 | runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn, |
139 | const s64 count, const LCN start_lcn, | 147 | const s64 count, const LCN start_lcn, |
140 | const NTFS_CLUSTER_ALLOCATION_ZONES zone) | 148 | const NTFS_CLUSTER_ALLOCATION_ZONES zone, |
149 | const BOOL is_extension) | ||
141 | { | 150 | { |
142 | LCN zone_start, zone_end, bmp_pos, bmp_initial_pos, last_read_pos, lcn; | 151 | LCN zone_start, zone_end, bmp_pos, bmp_initial_pos, last_read_pos, lcn; |
143 | LCN prev_lcn = 0, prev_run_len = 0, mft_zone_size; | 152 | LCN prev_lcn = 0, prev_run_len = 0, mft_zone_size; |
@@ -310,7 +319,7 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn, | |||
310 | continue; | 319 | continue; |
311 | } | 320 | } |
312 | bit = 1 << (lcn & 7); | 321 | bit = 1 << (lcn & 7); |
313 | ntfs_debug("bit %i.", bit); | 322 | ntfs_debug("bit 0x%x.", bit); |
314 | /* If the bit is already set, go onto the next one. */ | 323 | /* If the bit is already set, go onto the next one. */ |
315 | if (*byte & bit) { | 324 | if (*byte & bit) { |
316 | lcn++; | 325 | lcn++; |
@@ -729,7 +738,7 @@ out: | |||
729 | /* Add runlist terminator element. */ | 738 | /* Add runlist terminator element. */ |
730 | if (likely(rl)) { | 739 | if (likely(rl)) { |
731 | rl[rlpos].vcn = rl[rlpos - 1].vcn + rl[rlpos - 1].length; | 740 | rl[rlpos].vcn = rl[rlpos - 1].vcn + rl[rlpos - 1].length; |
732 | rl[rlpos].lcn = LCN_RL_NOT_MAPPED; | 741 | rl[rlpos].lcn = is_extension ? LCN_ENOENT : LCN_RL_NOT_MAPPED; |
733 | rl[rlpos].length = 0; | 742 | rl[rlpos].length = 0; |
734 | } | 743 | } |
735 | if (likely(page && !IS_ERR(page))) { | 744 | if (likely(page && !IS_ERR(page))) { |
@@ -782,6 +791,7 @@ out: | |||
782 | * @ni: ntfs inode whose runlist describes the clusters to free | 791 | * @ni: ntfs inode whose runlist describes the clusters to free |
783 | * @start_vcn: vcn in the runlist of @ni at which to start freeing clusters | 792 | * @start_vcn: vcn in the runlist of @ni at which to start freeing clusters |
784 | * @count: number of clusters to free or -1 for all clusters | 793 | * @count: number of clusters to free or -1 for all clusters |
794 | * @ctx: active attribute search context if present or NULL if not | ||
785 | * @is_rollback: true if this is a rollback operation | 795 | * @is_rollback: true if this is a rollback operation |
786 | * | 796 | * |
787 | * Free @count clusters starting at the cluster @start_vcn in the runlist | 797 | * Free @count clusters starting at the cluster @start_vcn in the runlist |
@@ -791,15 +801,39 @@ out: | |||
791 | * deallocated. Thus, to completely free all clusters in a runlist, use | 801 | * deallocated. Thus, to completely free all clusters in a runlist, use |
792 | * @start_vcn = 0 and @count = -1. | 802 | * @start_vcn = 0 and @count = -1. |
793 | * | 803 | * |
804 | * If @ctx is specified, it is an active search context of @ni and its base mft | ||
805 | * record. This is needed when __ntfs_cluster_free() encounters unmapped | ||
806 | * runlist fragments and allows their mapping. If you do not have the mft | ||
807 | * record mapped, you can specify @ctx as NULL and __ntfs_cluster_free() will | ||
808 | * perform the necessary mapping and unmapping. | ||
809 | * | ||
810 | * Note, __ntfs_cluster_free() saves the state of @ctx on entry and restores it | ||
811 | * before returning. Thus, @ctx will be left pointing to the same attribute on | ||
812 | * return as on entry. However, the actual pointers in @ctx may point to | ||
813 | * different memory locations on return, so you must remember to reset any | ||
814 | * cached pointers from the @ctx, i.e. after the call to __ntfs_cluster_free(), | ||
815 | * you will probably want to do: | ||
816 | * m = ctx->mrec; | ||
817 | * a = ctx->attr; | ||
818 | * Assuming you cache ctx->attr in a variable @a of type ATTR_RECORD * and that | ||
819 | * you cache ctx->mrec in a variable @m of type MFT_RECORD *. | ||
820 | * | ||
794 | * @is_rollback should always be FALSE, it is for internal use to rollback | 821 | * @is_rollback should always be FALSE, it is for internal use to rollback |
795 | * errors. You probably want to use ntfs_cluster_free() instead. | 822 | * errors. You probably want to use ntfs_cluster_free() instead. |
796 | * | 823 | * |
797 | * Note, ntfs_cluster_free() does not modify the runlist at all, so the caller | 824 | * Note, __ntfs_cluster_free() does not modify the runlist, so you have to |
798 | * has to deal with it later. | 825 | * remove from the runlist or mark sparse the freed runs later. |
799 | * | 826 | * |
800 | * Return the number of deallocated clusters (not counting sparse ones) on | 827 | * Return the number of deallocated clusters (not counting sparse ones) on |
801 | * success and -errno on error. | 828 | * success and -errno on error. |
802 | * | 829 | * |
830 | * WARNING: If @ctx is supplied, regardless of whether success or failure is | ||
831 | * returned, you need to check IS_ERR(@ctx->mrec) and if TRUE the @ctx | ||
832 | * is no longer valid, i.e. you need to either call | ||
833 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. | ||
834 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for | ||
835 | * why the mapping of the old inode failed. | ||
836 | * | ||
803 | * Locking: - The runlist described by @ni must be locked for writing on entry | 837 | * Locking: - The runlist described by @ni must be locked for writing on entry |
804 | * and is locked on return. Note the runlist may be modified when | 838 | * and is locked on return. Note the runlist may be modified when |
805 | * needed runlist fragments need to be mapped. | 839 | * needed runlist fragments need to be mapped. |
@@ -807,9 +841,13 @@ out: | |||
807 | * on return. | 841 | * on return. |
808 | * - This function takes the volume lcn bitmap lock for writing and | 842 | * - This function takes the volume lcn bitmap lock for writing and |
809 | * modifies the bitmap contents. | 843 | * modifies the bitmap contents. |
844 | * - If @ctx is NULL, the base mft record of @ni must not be mapped on | ||
845 | * entry and it will be left unmapped on return. | ||
846 | * - If @ctx is not NULL, the base mft record must be mapped on entry | ||
847 | * and it will be left mapped on return. | ||
810 | */ | 848 | */ |
811 | s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, s64 count, | 849 | s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, s64 count, |
812 | const BOOL is_rollback) | 850 | ntfs_attr_search_ctx *ctx, const BOOL is_rollback) |
813 | { | 851 | { |
814 | s64 delta, to_free, total_freed, real_freed; | 852 | s64 delta, to_free, total_freed, real_freed; |
815 | ntfs_volume *vol; | 853 | ntfs_volume *vol; |
@@ -839,7 +877,7 @@ s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, s64 count, | |||
839 | 877 | ||
840 | total_freed = real_freed = 0; | 878 | total_freed = real_freed = 0; |
841 | 879 | ||
842 | rl = ntfs_attr_find_vcn_nolock(ni, start_vcn, TRUE); | 880 | rl = ntfs_attr_find_vcn_nolock(ni, start_vcn, ctx); |
843 | if (IS_ERR(rl)) { | 881 | if (IS_ERR(rl)) { |
844 | if (!is_rollback) | 882 | if (!is_rollback) |
845 | ntfs_error(vol->sb, "Failed to find first runlist " | 883 | ntfs_error(vol->sb, "Failed to find first runlist " |
@@ -893,7 +931,7 @@ s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, s64 count, | |||
893 | 931 | ||
894 | /* Attempt to map runlist. */ | 932 | /* Attempt to map runlist. */ |
895 | vcn = rl->vcn; | 933 | vcn = rl->vcn; |
896 | rl = ntfs_attr_find_vcn_nolock(ni, vcn, TRUE); | 934 | rl = ntfs_attr_find_vcn_nolock(ni, vcn, ctx); |
897 | if (IS_ERR(rl)) { | 935 | if (IS_ERR(rl)) { |
898 | err = PTR_ERR(rl); | 936 | err = PTR_ERR(rl); |
899 | if (!is_rollback) | 937 | if (!is_rollback) |
@@ -961,7 +999,7 @@ err_out: | |||
961 | * If rollback fails, set the volume errors flag, emit an error | 999 | * If rollback fails, set the volume errors flag, emit an error |
962 | * message, and return the error code. | 1000 | * message, and return the error code. |
963 | */ | 1001 | */ |
964 | delta = __ntfs_cluster_free(ni, start_vcn, total_freed, TRUE); | 1002 | delta = __ntfs_cluster_free(ni, start_vcn, total_freed, ctx, TRUE); |
965 | if (delta < 0) { | 1003 | if (delta < 0) { |
966 | ntfs_error(vol->sb, "Failed to rollback (error %i). Leaving " | 1004 | ntfs_error(vol->sb, "Failed to rollback (error %i). Leaving " |
967 | "inconsistent metadata! Unmount and run " | 1005 | "inconsistent metadata! Unmount and run " |
diff --git a/fs/ntfs/lcnalloc.h b/fs/ntfs/lcnalloc.h index a6a8827882e7..72cbca7003b2 100644 --- a/fs/ntfs/lcnalloc.h +++ b/fs/ntfs/lcnalloc.h | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include <linux/fs.h> | 28 | #include <linux/fs.h> |
29 | 29 | ||
30 | #include "attrib.h" | ||
30 | #include "types.h" | 31 | #include "types.h" |
31 | #include "inode.h" | 32 | #include "inode.h" |
32 | #include "runlist.h" | 33 | #include "runlist.h" |
@@ -41,16 +42,18 @@ typedef enum { | |||
41 | 42 | ||
42 | extern runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, | 43 | extern runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, |
43 | const VCN start_vcn, const s64 count, const LCN start_lcn, | 44 | const VCN start_vcn, const s64 count, const LCN start_lcn, |
44 | const NTFS_CLUSTER_ALLOCATION_ZONES zone); | 45 | const NTFS_CLUSTER_ALLOCATION_ZONES zone, |
46 | const BOOL is_extension); | ||
45 | 47 | ||
46 | extern s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, | 48 | extern s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, |
47 | s64 count, const BOOL is_rollback); | 49 | s64 count, ntfs_attr_search_ctx *ctx, const BOOL is_rollback); |
48 | 50 | ||
49 | /** | 51 | /** |
50 | * ntfs_cluster_free - free clusters on an ntfs volume | 52 | * ntfs_cluster_free - free clusters on an ntfs volume |
51 | * @ni: ntfs inode whose runlist describes the clusters to free | 53 | * @ni: ntfs inode whose runlist describes the clusters to free |
52 | * @start_vcn: vcn in the runlist of @ni at which to start freeing clusters | 54 | * @start_vcn: vcn in the runlist of @ni at which to start freeing clusters |
53 | * @count: number of clusters to free or -1 for all clusters | 55 | * @count: number of clusters to free or -1 for all clusters |
56 | * @ctx: active attribute search context if present or NULL if not | ||
54 | * | 57 | * |
55 | * Free @count clusters starting at the cluster @start_vcn in the runlist | 58 | * Free @count clusters starting at the cluster @start_vcn in the runlist |
56 | * described by the ntfs inode @ni. | 59 | * described by the ntfs inode @ni. |
@@ -59,12 +62,36 @@ extern s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, | |||
59 | * deallocated. Thus, to completely free all clusters in a runlist, use | 62 | * deallocated. Thus, to completely free all clusters in a runlist, use |
60 | * @start_vcn = 0 and @count = -1. | 63 | * @start_vcn = 0 and @count = -1. |
61 | * | 64 | * |
62 | * Note, ntfs_cluster_free() does not modify the runlist at all, so the caller | 65 | * If @ctx is specified, it is an active search context of @ni and its base mft |
63 | * has to deal with it later. | 66 | * record. This is needed when ntfs_cluster_free() encounters unmapped runlist |
67 | * fragments and allows their mapping. If you do not have the mft record | ||
68 | * mapped, you can specify @ctx as NULL and ntfs_cluster_free() will perform | ||
69 | * the necessary mapping and unmapping. | ||
70 | * | ||
71 | * Note, ntfs_cluster_free() saves the state of @ctx on entry and restores it | ||
72 | * before returning. Thus, @ctx will be left pointing to the same attribute on | ||
73 | * return as on entry. However, the actual pointers in @ctx may point to | ||
74 | * different memory locations on return, so you must remember to reset any | ||
75 | * cached pointers from the @ctx, i.e. after the call to ntfs_cluster_free(), | ||
76 | * you will probably want to do: | ||
77 | * m = ctx->mrec; | ||
78 | * a = ctx->attr; | ||
79 | * Assuming you cache ctx->attr in a variable @a of type ATTR_RECORD * and that | ||
80 | * you cache ctx->mrec in a variable @m of type MFT_RECORD *. | ||
81 | * | ||
82 | * Note, ntfs_cluster_free() does not modify the runlist, so you have to remove | ||
83 | * from the runlist or mark sparse the freed runs later. | ||
64 | * | 84 | * |
65 | * Return the number of deallocated clusters (not counting sparse ones) on | 85 | * Return the number of deallocated clusters (not counting sparse ones) on |
66 | * success and -errno on error. | 86 | * success and -errno on error. |
67 | * | 87 | * |
88 | * WARNING: If @ctx is supplied, regardless of whether success or failure is | ||
89 | * returned, you need to check IS_ERR(@ctx->mrec) and if TRUE the @ctx | ||
90 | * is no longer valid, i.e. you need to either call | ||
91 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. | ||
92 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for | ||
93 | * why the mapping of the old inode failed. | ||
94 | * | ||
68 | * Locking: - The runlist described by @ni must be locked for writing on entry | 95 | * Locking: - The runlist described by @ni must be locked for writing on entry |
69 | * and is locked on return. Note the runlist may be modified when | 96 | * and is locked on return. Note the runlist may be modified when |
70 | * needed runlist fragments need to be mapped. | 97 | * needed runlist fragments need to be mapped. |
@@ -72,11 +99,15 @@ extern s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, | |||
72 | * on return. | 99 | * on return. |
73 | * - This function takes the volume lcn bitmap lock for writing and | 100 | * - This function takes the volume lcn bitmap lock for writing and |
74 | * modifies the bitmap contents. | 101 | * modifies the bitmap contents. |
102 | * - If @ctx is NULL, the base mft record of @ni must not be mapped on | ||
103 | * entry and it will be left unmapped on return. | ||
104 | * - If @ctx is not NULL, the base mft record must be mapped on entry | ||
105 | * and it will be left mapped on return. | ||
75 | */ | 106 | */ |
76 | static inline s64 ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, | 107 | static inline s64 ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, |
77 | s64 count) | 108 | s64 count, ntfs_attr_search_ctx *ctx) |
78 | { | 109 | { |
79 | return __ntfs_cluster_free(ni, start_vcn, count, FALSE); | 110 | return __ntfs_cluster_free(ni, start_vcn, count, ctx, FALSE); |
80 | } | 111 | } |
81 | 112 | ||
82 | extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, | 113 | extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, |
diff --git a/fs/ntfs/malloc.h b/fs/ntfs/malloc.h index 590887b943f5..e38e402e4103 100644 --- a/fs/ntfs/malloc.h +++ b/fs/ntfs/malloc.h | |||
@@ -39,8 +39,7 @@ | |||
39 | * If there was insufficient memory to complete the request, return NULL. | 39 | * If there was insufficient memory to complete the request, return NULL. |
40 | * Depending on @gfp_mask the allocation may be guaranteed to succeed. | 40 | * Depending on @gfp_mask the allocation may be guaranteed to succeed. |
41 | */ | 41 | */ |
42 | static inline void *__ntfs_malloc(unsigned long size, | 42 | static inline void *__ntfs_malloc(unsigned long size, gfp_t gfp_mask) |
43 | gfp_t gfp_mask) | ||
44 | { | 43 | { |
45 | if (likely(size <= PAGE_SIZE)) { | 44 | if (likely(size <= PAGE_SIZE)) { |
46 | BUG_ON(!size); | 45 | BUG_ON(!size); |
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index b011369b5956..0c65cbb8c5cf 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c | |||
@@ -49,7 +49,8 @@ static inline MFT_RECORD *map_mft_record_page(ntfs_inode *ni) | |||
49 | ntfs_volume *vol = ni->vol; | 49 | ntfs_volume *vol = ni->vol; |
50 | struct inode *mft_vi = vol->mft_ino; | 50 | struct inode *mft_vi = vol->mft_ino; |
51 | struct page *page; | 51 | struct page *page; |
52 | unsigned long index, ofs, end_index; | 52 | unsigned long index, end_index; |
53 | unsigned ofs; | ||
53 | 54 | ||
54 | BUG_ON(ni->page); | 55 | BUG_ON(ni->page); |
55 | /* | 56 | /* |
@@ -1308,7 +1309,7 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(ntfs_volume *vol) | |||
1308 | ll = mftbmp_ni->allocated_size; | 1309 | ll = mftbmp_ni->allocated_size; |
1309 | read_unlock_irqrestore(&mftbmp_ni->size_lock, flags); | 1310 | read_unlock_irqrestore(&mftbmp_ni->size_lock, flags); |
1310 | rl = ntfs_attr_find_vcn_nolock(mftbmp_ni, | 1311 | rl = ntfs_attr_find_vcn_nolock(mftbmp_ni, |
1311 | (ll - 1) >> vol->cluster_size_bits, TRUE); | 1312 | (ll - 1) >> vol->cluster_size_bits, NULL); |
1312 | if (unlikely(IS_ERR(rl) || !rl->length || rl->lcn < 0)) { | 1313 | if (unlikely(IS_ERR(rl) || !rl->length || rl->lcn < 0)) { |
1313 | up_write(&mftbmp_ni->runlist.lock); | 1314 | up_write(&mftbmp_ni->runlist.lock); |
1314 | ntfs_error(vol->sb, "Failed to determine last allocated " | 1315 | ntfs_error(vol->sb, "Failed to determine last allocated " |
@@ -1354,7 +1355,8 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(ntfs_volume *vol) | |||
1354 | up_write(&vol->lcnbmp_lock); | 1355 | up_write(&vol->lcnbmp_lock); |
1355 | ntfs_unmap_page(page); | 1356 | ntfs_unmap_page(page); |
1356 | /* Allocate a cluster from the DATA_ZONE. */ | 1357 | /* Allocate a cluster from the DATA_ZONE. */ |
1357 | rl2 = ntfs_cluster_alloc(vol, rl[1].vcn, 1, lcn, DATA_ZONE); | 1358 | rl2 = ntfs_cluster_alloc(vol, rl[1].vcn, 1, lcn, DATA_ZONE, |
1359 | TRUE); | ||
1358 | if (IS_ERR(rl2)) { | 1360 | if (IS_ERR(rl2)) { |
1359 | up_write(&mftbmp_ni->runlist.lock); | 1361 | up_write(&mftbmp_ni->runlist.lock); |
1360 | ntfs_error(vol->sb, "Failed to allocate a cluster for " | 1362 | ntfs_error(vol->sb, "Failed to allocate a cluster for " |
@@ -1738,7 +1740,7 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol) | |||
1738 | ll = mft_ni->allocated_size; | 1740 | ll = mft_ni->allocated_size; |
1739 | read_unlock_irqrestore(&mft_ni->size_lock, flags); | 1741 | read_unlock_irqrestore(&mft_ni->size_lock, flags); |
1740 | rl = ntfs_attr_find_vcn_nolock(mft_ni, | 1742 | rl = ntfs_attr_find_vcn_nolock(mft_ni, |
1741 | (ll - 1) >> vol->cluster_size_bits, TRUE); | 1743 | (ll - 1) >> vol->cluster_size_bits, NULL); |
1742 | if (unlikely(IS_ERR(rl) || !rl->length || rl->lcn < 0)) { | 1744 | if (unlikely(IS_ERR(rl) || !rl->length || rl->lcn < 0)) { |
1743 | up_write(&mft_ni->runlist.lock); | 1745 | up_write(&mft_ni->runlist.lock); |
1744 | ntfs_error(vol->sb, "Failed to determine last allocated " | 1746 | ntfs_error(vol->sb, "Failed to determine last allocated " |
@@ -1779,7 +1781,8 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol) | |||
1779 | nr > min_nr ? "default" : "minimal", (long long)nr); | 1781 | nr > min_nr ? "default" : "minimal", (long long)nr); |
1780 | old_last_vcn = rl[1].vcn; | 1782 | old_last_vcn = rl[1].vcn; |
1781 | do { | 1783 | do { |
1782 | rl2 = ntfs_cluster_alloc(vol, old_last_vcn, nr, lcn, MFT_ZONE); | 1784 | rl2 = ntfs_cluster_alloc(vol, old_last_vcn, nr, lcn, MFT_ZONE, |
1785 | TRUE); | ||
1783 | if (likely(!IS_ERR(rl2))) | 1786 | if (likely(!IS_ERR(rl2))) |
1784 | break; | 1787 | break; |
1785 | if (PTR_ERR(rl2) != -ENOSPC || nr == min_nr) { | 1788 | if (PTR_ERR(rl2) != -ENOSPC || nr == min_nr) { |
@@ -1951,20 +1954,21 @@ restore_undo_alloc: | |||
1951 | NVolSetErrors(vol); | 1954 | NVolSetErrors(vol); |
1952 | return ret; | 1955 | return ret; |
1953 | } | 1956 | } |
1954 | a = ctx->attr; | 1957 | ctx->attr->data.non_resident.highest_vcn = |
1955 | a->data.non_resident.highest_vcn = cpu_to_sle64(old_last_vcn - 1); | 1958 | cpu_to_sle64(old_last_vcn - 1); |
1956 | undo_alloc: | 1959 | undo_alloc: |
1957 | if (ntfs_cluster_free(mft_ni, old_last_vcn, -1) < 0) { | 1960 | if (ntfs_cluster_free(mft_ni, old_last_vcn, -1, ctx) < 0) { |
1958 | ntfs_error(vol->sb, "Failed to free clusters from mft data " | 1961 | ntfs_error(vol->sb, "Failed to free clusters from mft data " |
1959 | "attribute.%s", es); | 1962 | "attribute.%s", es); |
1960 | NVolSetErrors(vol); | 1963 | NVolSetErrors(vol); |
1961 | } | 1964 | } |
1965 | a = ctx->attr; | ||
1962 | if (ntfs_rl_truncate_nolock(vol, &mft_ni->runlist, old_last_vcn)) { | 1966 | if (ntfs_rl_truncate_nolock(vol, &mft_ni->runlist, old_last_vcn)) { |
1963 | ntfs_error(vol->sb, "Failed to truncate mft data attribute " | 1967 | ntfs_error(vol->sb, "Failed to truncate mft data attribute " |
1964 | "runlist.%s", es); | 1968 | "runlist.%s", es); |
1965 | NVolSetErrors(vol); | 1969 | NVolSetErrors(vol); |
1966 | } | 1970 | } |
1967 | if (mp_rebuilt) { | 1971 | if (mp_rebuilt && !IS_ERR(ctx->mrec)) { |
1968 | if (ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu( | 1972 | if (ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu( |
1969 | a->data.non_resident.mapping_pairs_offset), | 1973 | a->data.non_resident.mapping_pairs_offset), |
1970 | old_alen - le16_to_cpu( | 1974 | old_alen - le16_to_cpu( |
@@ -1981,6 +1985,10 @@ undo_alloc: | |||
1981 | } | 1985 | } |
1982 | flush_dcache_mft_record_page(ctx->ntfs_ino); | 1986 | flush_dcache_mft_record_page(ctx->ntfs_ino); |
1983 | mark_mft_record_dirty(ctx->ntfs_ino); | 1987 | mark_mft_record_dirty(ctx->ntfs_ino); |
1988 | } else if (IS_ERR(ctx->mrec)) { | ||
1989 | ntfs_error(vol->sb, "Failed to restore attribute search " | ||
1990 | "context.%s", es); | ||
1991 | NVolSetErrors(vol); | ||
1984 | } | 1992 | } |
1985 | if (ctx) | 1993 | if (ctx) |
1986 | ntfs_attr_put_search_ctx(ctx); | 1994 | ntfs_attr_put_search_ctx(ctx); |
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 453d0d51ea4b..6c16db9e1a8a 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
@@ -1447,7 +1447,7 @@ not_enabled: | |||
1447 | if (unlikely(i_size_read(tmp_ino) < sizeof(USN_HEADER))) { | 1447 | if (unlikely(i_size_read(tmp_ino) < sizeof(USN_HEADER))) { |
1448 | ntfs_error(vol->sb, "Found corrupt $UsnJrnl/$DATA/$Max " | 1448 | ntfs_error(vol->sb, "Found corrupt $UsnJrnl/$DATA/$Max " |
1449 | "attribute (size is 0x%llx but should be at " | 1449 | "attribute (size is 0x%llx but should be at " |
1450 | "least 0x%x bytes).", i_size_read(tmp_ino), | 1450 | "least 0x%zx bytes).", i_size_read(tmp_ino), |
1451 | sizeof(USN_HEADER)); | 1451 | sizeof(USN_HEADER)); |
1452 | return FALSE; | 1452 | return FALSE; |
1453 | } | 1453 | } |
diff --git a/include/asm-i386/apic.h b/include/asm-i386/apic.h index a515e2aed829..8c454aa58ac6 100644 --- a/include/asm-i386/apic.h +++ b/include/asm-i386/apic.h | |||
@@ -118,8 +118,7 @@ extern void release_lapic_nmi(void); | |||
118 | extern void disable_timer_nmi_watchdog(void); | 118 | extern void disable_timer_nmi_watchdog(void); |
119 | extern void enable_timer_nmi_watchdog(void); | 119 | extern void enable_timer_nmi_watchdog(void); |
120 | extern void nmi_watchdog_tick (struct pt_regs * regs); | 120 | extern void nmi_watchdog_tick (struct pt_regs * regs); |
121 | extern int APIC_init(void); | 121 | extern int APIC_init_uniprocessor (void); |
122 | extern void APIC_late_time_init(void); | ||
123 | extern void disable_APIC_timer(void); | 122 | extern void disable_APIC_timer(void); |
124 | extern void enable_APIC_timer(void); | 123 | extern void enable_APIC_timer(void); |
125 | 124 | ||
diff --git a/include/asm-i386/hw_irq.h b/include/asm-i386/hw_irq.h index 9139b89497a1..622815bf3243 100644 --- a/include/asm-i386/hw_irq.h +++ b/include/asm-i386/hw_irq.h | |||
@@ -55,7 +55,6 @@ void init_8259A(int aeoi); | |||
55 | void FASTCALL(send_IPI_self(int vector)); | 55 | void FASTCALL(send_IPI_self(int vector)); |
56 | void init_VISWS_APIC_irqs(void); | 56 | void init_VISWS_APIC_irqs(void); |
57 | void setup_IO_APIC(void); | 57 | void setup_IO_APIC(void); |
58 | void IO_APIC_late_time_init(void); | ||
59 | void disable_IO_APIC(void); | 58 | void disable_IO_APIC(void); |
60 | void print_IO_APIC(void); | 59 | void print_IO_APIC(void); |
61 | int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn); | 60 | int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn); |
diff --git a/include/asm-i386/mach-default/smpboot_hooks.h b/include/asm-i386/mach-default/smpboot_hooks.h index d7c70c144f9f..7f45f6311059 100644 --- a/include/asm-i386/mach-default/smpboot_hooks.h +++ b/include/asm-i386/mach-default/smpboot_hooks.h | |||
@@ -1,6 +1,11 @@ | |||
1 | /* two abstractions specific to kernel/smpboot.c, mainly to cater to visws | 1 | /* two abstractions specific to kernel/smpboot.c, mainly to cater to visws |
2 | * which needs to alter them. */ | 2 | * which needs to alter them. */ |
3 | 3 | ||
4 | static inline void smpboot_clear_io_apic_irqs(void) | ||
5 | { | ||
6 | io_apic_irqs = 0; | ||
7 | } | ||
8 | |||
4 | static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip) | 9 | static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip) |
5 | { | 10 | { |
6 | CMOS_WRITE(0xa, 0xf); | 11 | CMOS_WRITE(0xa, 0xf); |
@@ -27,3 +32,13 @@ static inline void smpboot_restore_warm_reset_vector(void) | |||
27 | 32 | ||
28 | *((volatile long *) phys_to_virt(0x467)) = 0; | 33 | *((volatile long *) phys_to_virt(0x467)) = 0; |
29 | } | 34 | } |
35 | |||
36 | static inline void smpboot_setup_io_apic(void) | ||
37 | { | ||
38 | /* | ||
39 | * Here we can be sure that there is an IO-APIC in the system. Let's | ||
40 | * go and set it up: | ||
41 | */ | ||
42 | if (!skip_ioapic_setup && nr_ioapics) | ||
43 | setup_IO_APIC(); | ||
44 | } | ||
diff --git a/include/asm-i386/mach-visws/smpboot_hooks.h b/include/asm-i386/mach-visws/smpboot_hooks.h index 14d8e0375f7a..d926471fa359 100644 --- a/include/asm-i386/mach-visws/smpboot_hooks.h +++ b/include/asm-i386/mach-visws/smpboot_hooks.h | |||
@@ -11,7 +11,14 @@ static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip) | |||
11 | 11 | ||
12 | /* for visws do nothing for any of these */ | 12 | /* for visws do nothing for any of these */ |
13 | 13 | ||
14 | static inline void smpboot_clear_io_apic_irqs(void) | ||
15 | { | ||
16 | } | ||
17 | |||
14 | static inline void smpboot_restore_warm_reset_vector(void) | 18 | static inline void smpboot_restore_warm_reset_vector(void) |
15 | { | 19 | { |
16 | } | 20 | } |
17 | 21 | ||
22 | static inline void smpboot_setup_io_apic(void) | ||
23 | { | ||
24 | } | ||
diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h index 549f44843c5e..bba5305c29ed 100644 --- a/include/asm-ppc/ppc_sys.h +++ b/include/asm-ppc/ppc_sys.h | |||
@@ -18,7 +18,7 @@ | |||
18 | #define __ASM_PPC_SYS_H | 18 | #define __ASM_PPC_SYS_H |
19 | 19 | ||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | 23 | ||
24 | #if defined(CONFIG_8260) | 24 | #if defined(CONFIG_8260) |
diff --git a/include/linux/device.h b/include/linux/device.h index a9e72ac3fb9f..17cbc6db67b4 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -396,32 +396,6 @@ extern struct device * get_device(struct device * dev); | |||
396 | extern void put_device(struct device * dev); | 396 | extern void put_device(struct device * dev); |
397 | 397 | ||
398 | 398 | ||
399 | /* drivers/base/platform.c */ | ||
400 | |||
401 | struct platform_device { | ||
402 | const char * name; | ||
403 | u32 id; | ||
404 | struct device dev; | ||
405 | u32 num_resources; | ||
406 | struct resource * resource; | ||
407 | }; | ||
408 | |||
409 | #define to_platform_device(x) container_of((x), struct platform_device, dev) | ||
410 | |||
411 | extern int platform_device_register(struct platform_device *); | ||
412 | extern void platform_device_unregister(struct platform_device *); | ||
413 | |||
414 | extern struct bus_type platform_bus_type; | ||
415 | extern struct device platform_bus; | ||
416 | |||
417 | extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); | ||
418 | extern int platform_get_irq(struct platform_device *, unsigned int); | ||
419 | extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, char *); | ||
420 | extern int platform_get_irq_byname(struct platform_device *, char *); | ||
421 | extern int platform_add_devices(struct platform_device **, int); | ||
422 | |||
423 | extern struct platform_device *platform_device_register_simple(char *, unsigned int, struct resource *, unsigned int); | ||
424 | |||
425 | /* drivers/base/power.c */ | 399 | /* drivers/base/power.c */ |
426 | extern void device_shutdown(void); | 400 | extern void device_shutdown(void); |
427 | 401 | ||
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h new file mode 100644 index 000000000000..a726225e0afe --- /dev/null +++ b/include/linux/platform_device.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | * platform_device.h - generic, centralized driver model | ||
3 | * | ||
4 | * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org> | ||
5 | * | ||
6 | * This file is released under the GPLv2 | ||
7 | * | ||
8 | * See Documentation/driver-model/ for more information. | ||
9 | */ | ||
10 | |||
11 | #ifndef _PLATFORM_DEVICE_H_ | ||
12 | #define _PLATFORM_DEVICE_H_ | ||
13 | |||
14 | #include <linux/device.h> | ||
15 | |||
16 | struct platform_device { | ||
17 | const char * name; | ||
18 | u32 id; | ||
19 | struct device dev; | ||
20 | u32 num_resources; | ||
21 | struct resource * resource; | ||
22 | }; | ||
23 | |||
24 | #define to_platform_device(x) container_of((x), struct platform_device, dev) | ||
25 | |||
26 | extern int platform_device_register(struct platform_device *); | ||
27 | extern void platform_device_unregister(struct platform_device *); | ||
28 | |||
29 | extern struct bus_type platform_bus_type; | ||
30 | extern struct device platform_bus; | ||
31 | |||
32 | extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); | ||
33 | extern int platform_get_irq(struct platform_device *, unsigned int); | ||
34 | extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, char *); | ||
35 | extern int platform_get_irq_byname(struct platform_device *, char *); | ||
36 | extern int platform_add_devices(struct platform_device **, int); | ||
37 | |||
38 | extern struct platform_device *platform_device_register_simple(char *, unsigned int, struct resource *, unsigned int); | ||
39 | |||
40 | #endif /* _PLATFORM_DEVICE_H_ */ | ||
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index 317a979b24de..2b799d40d669 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h | |||
@@ -12,7 +12,7 @@ | |||
12 | #define _LINUX_SERIAL_8250_H | 12 | #define _LINUX_SERIAL_8250_H |
13 | 13 | ||
14 | #include <linux/serial_core.h> | 14 | #include <linux/serial_core.h> |
15 | #include <linux/device.h> | 15 | #include <linux/platform_device.h> |
16 | 16 | ||
17 | /* | 17 | /* |
18 | * This is the platform device platform_data structure | 18 | * This is the platform device platform_data structure |
diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 14cb2718cb77..46e3c0bf3c94 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h | |||
@@ -1055,6 +1055,7 @@ typedef struct { | |||
1055 | unsigned char emu10k2_chip; /* Audigy 1 or Audigy 2. */ | 1055 | unsigned char emu10k2_chip; /* Audigy 1 or Audigy 2. */ |
1056 | unsigned char ca0102_chip; /* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */ | 1056 | unsigned char ca0102_chip; /* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */ |
1057 | unsigned char ca0108_chip; /* Audigy 2 Value */ | 1057 | unsigned char ca0108_chip; /* Audigy 2 Value */ |
1058 | unsigned char ca_cardbus_chip; /* Audigy 2 ZS Notebook */ | ||
1058 | unsigned char ca0151_chip; /* P16V */ | 1059 | unsigned char ca0151_chip; /* P16V */ |
1059 | unsigned char spk71; /* Has 7.1 speakers */ | 1060 | unsigned char spk71; /* Has 7.1 speakers */ |
1060 | unsigned char sblive51; /* SBLive! 5.1 - extout 0x11 -> center, 0x12 -> lfe */ | 1061 | unsigned char sblive51; /* SBLive! 5.1 - extout 0x11 -> center, 0x12 -> lfe */ |
diff --git a/init/main.c b/init/main.c index 4075d97e94b1..f142d4035341 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -64,6 +64,10 @@ | |||
64 | #endif | 64 | #endif |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #ifdef CONFIG_X86_LOCAL_APIC | ||
68 | #include <asm/smp.h> | ||
69 | #endif | ||
70 | |||
67 | /* | 71 | /* |
68 | * Versions of gcc older than that listed below may actually compile | 72 | * Versions of gcc older than that listed below may actually compile |
69 | * and link okay, but the end product can have subtle run time bugs. | 73 | * and link okay, but the end product can have subtle run time bugs. |
@@ -310,7 +314,14 @@ extern void setup_arch(char **); | |||
310 | 314 | ||
311 | #ifndef CONFIG_SMP | 315 | #ifndef CONFIG_SMP |
312 | 316 | ||
317 | #ifdef CONFIG_X86_LOCAL_APIC | ||
318 | static void __init smp_init(void) | ||
319 | { | ||
320 | APIC_init_uniprocessor(); | ||
321 | } | ||
322 | #else | ||
313 | #define smp_init() do { } while (0) | 323 | #define smp_init() do { } while (0) |
324 | #endif | ||
314 | 325 | ||
315 | static inline void setup_per_cpu_areas(void) { } | 326 | static inline void setup_per_cpu_areas(void) { } |
316 | static inline void smp_prepare_cpus(unsigned int maxcpus) { } | 327 | static inline void smp_prepare_cpus(unsigned int maxcpus) { } |
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index 877bb00d3295..d1f9da498729 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/wait.h> | 18 | #include <linux/wait.h> |
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
diff --git a/sound/core/init.c b/sound/core/init.c index 59202de1d2ce..41e224986f35 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <linux/ctype.h> | 28 | #include <linux/ctype.h> |
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/pm.h> | 30 | #include <linux/pm.h> |
31 | #include <linux/platform_device.h> | ||
32 | |||
31 | #include <sound/core.h> | 33 | #include <sound/core.h> |
32 | #include <sound/control.h> | 34 | #include <sound/control.h> |
33 | #include <sound/info.h> | 35 | #include <sound/info.h> |
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index e9cd8e054f25..53aeff0b783a 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c | |||
@@ -579,6 +579,30 @@ static int __devinit snd_emu10k1_ecard_init(emu10k1_t * emu) | |||
579 | return 0; | 579 | return 0; |
580 | } | 580 | } |
581 | 581 | ||
582 | static int __devinit snd_emu10k1_cardbus_init(emu10k1_t * emu) | ||
583 | { | ||
584 | unsigned long special_port; | ||
585 | unsigned int value; | ||
586 | |||
587 | /* Special initialisation routine | ||
588 | * before the rest of the IO-Ports become active. | ||
589 | */ | ||
590 | special_port = emu->port + 0x38; | ||
591 | value = inl(special_port); | ||
592 | outl(0x00d00000, special_port); | ||
593 | value = inl(special_port); | ||
594 | outl(0x00d00001, special_port); | ||
595 | value = inl(special_port); | ||
596 | outl(0x00d0005f, special_port); | ||
597 | value = inl(special_port); | ||
598 | outl(0x00d0007f, special_port); | ||
599 | value = inl(special_port); | ||
600 | outl(0x0090007f, special_port); | ||
601 | value = inl(special_port); | ||
602 | |||
603 | return 0; | ||
604 | } | ||
605 | |||
582 | /* | 606 | /* |
583 | * Create the EMU10K1 instance | 607 | * Create the EMU10K1 instance |
584 | */ | 608 | */ |
@@ -624,6 +648,16 @@ static emu_chip_details_t emu_chip_details[] = { | |||
624 | .ca0108_chip = 1, | 648 | .ca0108_chip = 1, |
625 | .spk71 = 1, | 649 | .spk71 = 1, |
626 | .ac97_chip = 1} , | 650 | .ac97_chip = 1} , |
651 | /* Audigy 2 ZS Notebook Cardbus card.*/ | ||
652 | /* Tested by James@superbug.co.uk 30th October 2005 */ | ||
653 | /* Not working yet, but progressing. */ | ||
654 | {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, | ||
655 | .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", | ||
656 | .id = "Audigy2", | ||
657 | .emu10k2_chip = 1, | ||
658 | .ca0108_chip = 1, | ||
659 | .ca_cardbus_chip = 1, | ||
660 | .spk71 = 1} , | ||
627 | {.vendor = 0x1102, .device = 0x0008, | 661 | {.vendor = 0x1102, .device = 0x0008, |
628 | .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", | 662 | .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", |
629 | .id = "Audigy2", | 663 | .id = "Audigy2", |
@@ -1011,6 +1045,11 @@ int __devinit snd_emu10k1_create(snd_card_t * card, | |||
1011 | snd_emu10k1_free(emu); | 1045 | snd_emu10k1_free(emu); |
1012 | return err; | 1046 | return err; |
1013 | } | 1047 | } |
1048 | } else if (emu->card_capabilities->ca_cardbus_chip) { | ||
1049 | if ((err = snd_emu10k1_cardbus_init(emu)) < 0) { | ||
1050 | snd_emu10k1_free(emu); | ||
1051 | return err; | ||
1052 | } | ||
1014 | } else { | 1053 | } else { |
1015 | /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version | 1054 | /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version |
1016 | does not support this, it shouldn't do any harm */ | 1055 | does not support this, it shouldn't do any harm */ |